git_sitools_idoc / Asynchronous_Download_userInterface_sitools2 / goToTaskPanel.js @ 20ff13ec
| 1 |
/*******************************************************************************
|
|---|---|
| 2 |
* Copyright 2010-2014 CNES - CENTRE NATIONAL d'ETUDES SPATIALES
|
| 3 |
*
|
| 4 |
* This file is part of SITools2.
|
| 5 |
*
|
| 6 |
* SITools2 is free software: you can redistribute it and/or modify it under the
|
| 7 |
* terms of the GNU General Public License as published by the Free Software
|
| 8 |
* Foundation, either version 3 of the License, or (at your option) any later
|
| 9 |
* version.
|
| 10 |
*
|
| 11 |
* SITools2 is distributed in the hope that it will be useful, but WITHOUT ANY
|
| 12 |
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
| 13 |
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
| 14 |
*
|
| 15 |
* You should have received a copy of the GNU General Public License along with
|
| 16 |
* SITools2. If not, see <http://www.gnu.org/licenses/>.
|
| 17 |
******************************************************************************/
|
| 18 |
/*global Ext, sitools, i18n, SitoolsDesk, alertFailure, window, loadUrl */
|
| 19 |
|
| 20 |
Ext.namespace('sitools.user.component.dataviews');
|
| 21 |
|
| 22 |
/**
|
| 23 |
* A simple window that displays result of Resource Tasks.
|
| 24 |
* @class sitools.user.component.dataviews.goToTaskPanel
|
| 25 |
* @extends Ext.Panel
|
| 26 |
*/
|
| 27 |
sitools.user.component.dataviews.goToTaskPanel = Ext.extend(Ext.Panel, {
|
| 28 |
//sitools.user.component.livegrid.goToTaskPanel = Ext.extend(Ext.Window, {
|
| 29 |
// modal : true,
|
| 30 |
width : "500", |
| 31 |
buttonAlign : 'left', |
| 32 |
layout : 'fit', |
| 33 |
initComponent : function () { |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
this.mainPanel = this.createNewFormComponent(this.task); |
| 38 |
|
| 39 |
this.buttons = ["->",/* { |
| 40 |
text : i18n.get('label.goToTask'),
|
| 41 |
scope : this,
|
| 42 |
handler : this.goToTask
|
| 43 |
},*/ {
|
| 44 |
text : i18n.get('label.close'), |
| 45 |
scope : this, |
| 46 |
handler : function () { |
| 47 |
this.ownerCt.close();
|
| 48 |
} |
| 49 |
} ]; |
| 50 |
|
| 51 |
|
| 52 |
this.items = [this.mainPanel]; |
| 53 |
|
| 54 |
sitools.user.component.dataviews.goToTaskPanel.superclass.initComponent.call(this);
|
| 55 |
|
| 56 |
}, |
| 57 |
|
| 58 |
refreshTask : function () { |
| 59 |
// var form = this.mainPanel;
|
| 60 |
var url = this.task.statusUrl; |
| 61 |
Ext.Ajax.request({
|
| 62 |
url : url,
|
| 63 |
method : "GET", |
| 64 |
scope : this, |
| 65 |
success : function (ret) { |
| 66 |
var data = Ext.decode(ret.responseText);
|
| 67 |
if (!data.success) {
|
| 68 |
Ext.Msg.alert(i18n.get('label.warning'), data.message);
|
| 69 |
return false; |
| 70 |
} |
| 71 |
this.task = data.TaskModel;
|
| 72 |
this.mainPanel = this.createNewFormComponent(this.task); |
| 73 |
this.removeAll();
|
| 74 |
this.add(this.mainPanel); |
| 75 |
this.doLayout();
|
| 76 |
}, |
| 77 |
failure : alertFailure
|
| 78 |
}); |
| 79 |
}, |
| 80 |
|
| 81 |
createNewFormComponent : function (task) { |
| 82 |
var html = String.format("<p>Hi, your download task is being processed, we will inform you by email when it is done.</p>"); |
| 83 |
html += String.format("<p>For public users, we will send you a link for download in the email.</p>");
|
| 84 |
//html += String.format("<p>You can check the progress by clicking the button <b>Go to the task</b> below.</p>");
|
| 85 |
html += String.format("<p>For registered users, you can find and manage(delete or download) all your historical download tasks by clicking the <b>Tasks</b> button which located in your user menu.</p>");
|
| 86 |
|
| 87 |
/* var html = String.format(i18n.get("label.taskLaunched"), task.status);
|
| 88 |
html += String.format("<a href='#'>{0}</a><br>", i18n.get("label.detail"));
|
| 89 |
|
| 90 |
if (!Ext.isEmpty(task.urlResult)) {
|
| 91 |
html += "<br>" + String.format(i18n.get("label.taskResult"), task.urlResult);
|
| 92 |
html += String.format("<a href='#'>{0}</a><br>", i18n.get("label.result"));
|
| 93 |
}
|
| 94 |
else {
|
| 95 |
html += "<br>" + i18n.get("label.refreshTaskWindow");
|
| 96 |
html += String.format("<a href='#'>{0}</a><br>", i18n.get("label.refresh"));
|
| 97 |
}*/
|
| 98 |
|
| 99 |
var panel = new Ext.Panel({ |
| 100 |
padding: 5, |
| 101 |
layout : "fit", |
| 102 |
html : html,
|
| 103 |
listeners : {
|
| 104 |
scope : this, |
| 105 |
afterrender : function (panel) { |
| 106 |
/*panel.getEl().child('a').on("click", function () {
|
| 107 |
this.showTaskDetail(task);
|
| 108 |
}, this);
|
| 109 |
var resultOrRefreshLink = panel.getEl().child('a').next('a');
|
| 110 |
if (!Ext.isEmpty(task.urlResult)) {
|
| 111 |
resultOrRefreshLink.on("click", function () {
|
| 112 |
this.showTaskResults(task);
|
| 113 |
}, this);
|
| 114 |
}
|
| 115 |
else {
|
| 116 |
resultOrRefreshLink.on("click", function () {
|
| 117 |
this.refreshTask();
|
| 118 |
}, this);
|
| 119 |
}*/
|
| 120 |
} |
| 121 |
} |
| 122 |
}); |
| 123 |
return panel;
|
| 124 |
|
| 125 |
// var formPanel = new Ext.form.FormPanel({
|
| 126 |
// title : i18n.get("label.taskDetails"),
|
| 127 |
// padding: 5,
|
| 128 |
// items : [ {
|
| 129 |
// name : 'statusUrl',
|
| 130 |
// xtype : 'textfield',
|
| 131 |
// value : task.statusUrl,
|
| 132 |
// hidden : true
|
| 133 |
// }, {
|
| 134 |
// name : 'status',
|
| 135 |
// fieldLabel : i18n.get('label.status'),
|
| 136 |
// anchor : "100%",
|
| 137 |
// xtype : 'textfield',
|
| 138 |
// value : task.status
|
| 139 |
// }, {
|
| 140 |
// name : 'id',
|
| 141 |
// fieldLabel : i18n.get('label.id'),
|
| 142 |
// anchor : "100%",
|
| 143 |
// xtype : 'textfield',
|
| 144 |
// value : task.id
|
| 145 |
// }, {
|
| 146 |
// itemValue : task.statusUrl,
|
| 147 |
// fieldLabel : i18n.get('label.url'),
|
| 148 |
// xtype : 'box',
|
| 149 |
// html : "<a href='#'> " + task.statusUrl + "</a>"
|
| 150 |
// ,
|
| 151 |
// listeners : {
|
| 152 |
// scope : this,
|
| 153 |
// render : function (cmp) {
|
| 154 |
// cmp.getEl().on('click', function () {
|
| 155 |
// var jsObj = sitools.user.modules.userSpaceDependencies.svaTasksDetails;
|
| 156 |
// var componentCfg = {
|
| 157 |
// sva : task
|
| 158 |
// };
|
| 159 |
// var windowConfig = {
|
| 160 |
// id : "taskStatusDetails",
|
| 161 |
// title : i18n.get("label.taskDetails") + ":" + task.id
|
| 162 |
// };
|
| 163 |
// SitoolsDesk.addDesktopWindow(windowConfig, componentCfg, jsObj);
|
| 164 |
// });
|
| 165 |
// }
|
| 166 |
// }
|
| 167 |
// }
|
| 168 |
// ]
|
| 169 |
// });
|
| 170 |
//
|
| 171 |
// if (!Ext.isEmpty(task.urlResult)) {
|
| 172 |
// var item = new Ext.BoxComponent({
|
| 173 |
// itemValue : task.urlResult,
|
| 174 |
// fieldLabel : i18n.get('label.result'),
|
| 175 |
// html : "<a href='#'> " + task.urlResult + "</a>",
|
| 176 |
// listeners : {
|
| 177 |
// scope : this,
|
| 178 |
// render : function (cmp) {
|
| 179 |
// cmp.getEl().on('click', function () {
|
| 180 |
// var orderUrl = loadUrl.get('APP_URL') + loadUrl.get('APP_ORDERS_USER_URL');
|
| 181 |
// if (cmp.itemValue.indexOf(orderUrl) != -1) {
|
| 182 |
// this._showOrderDetails(cmp.itemValue);
|
| 183 |
// } else if (cmp.itemValue.indexOf("/records") != -1) {
|
| 184 |
// this._showDatasetDetails(cmp.itemValue);
|
| 185 |
// }
|
| 186 |
// else {
|
| 187 |
// window.open(cmp.itemValue);
|
| 188 |
// }
|
| 189 |
// }, this);
|
| 190 |
// }
|
| 191 |
// }
|
| 192 |
// });
|
| 193 |
// formPanel.add(item);
|
| 194 |
// }
|
| 195 |
//
|
| 196 |
// return formPanel;
|
| 197 |
|
| 198 |
}, |
| 199 |
|
| 200 |
/**
|
| 201 |
* Handler of the button goToTask.
|
| 202 |
* Open the home Module Window with the taskPanel opened.
|
| 203 |
*/
|
| 204 |
goToTask : function () { |
| 205 |
this.ownerCt.close();
|
| 206 |
var jsObj = sitools.user.component.entete.userProfile.tasks;
|
| 207 |
var windowConfig = {
|
| 208 |
title : i18n.get('label.Tasks'), |
| 209 |
saveToolbar : false, |
| 210 |
iconCls : "tasks" |
| 211 |
}; |
| 212 |
SitoolsDesk.addDesktopWindow(windowConfig, {}, jsObj, true);
|
| 213 |
|
| 214 |
}, |
| 215 |
/**
|
| 216 |
* Open a sitools.user.component.entete.userProfile.orderProp window.
|
| 217 |
* @param {String} url the Url to request the task.
|
| 218 |
*/
|
| 219 |
_showOrderDetails : function (url) { |
| 220 |
Ext.Ajax.request({
|
| 221 |
url : url,
|
| 222 |
method : 'GET', |
| 223 |
scope : this, |
| 224 |
success : function (ret) { |
| 225 |
var data = Ext.decode(ret.responseText);
|
| 226 |
if (!data.success) {
|
| 227 |
Ext.Msg.alert(i18n.get('label.warning'), data.message);
|
| 228 |
return false; |
| 229 |
} |
| 230 |
var rec = new Ext.data.Record(data.order); |
| 231 |
var jsObj = sitools.user.component.entete.userProfile.orderProp;
|
| 232 |
var componentCfg = {
|
| 233 |
action : 'detail', |
| 234 |
orderRec : rec
|
| 235 |
}; |
| 236 |
var title = i18n.get('label.details') + " : "; |
| 237 |
title += rec.data.userId; |
| 238 |
title += " " + i18n.get('label.the'); |
| 239 |
title += " " + rec.data.dateOrder;
|
| 240 |
|
| 241 |
var windowConfig = {
|
| 242 |
id : "showDataDetailId", |
| 243 |
title : title,
|
| 244 |
specificType : "dataDetail", |
| 245 |
iconCls : "dataDetail" |
| 246 |
}; |
| 247 |
SitoolsDesk.addDesktopWindow(windowConfig, componentCfg, jsObj); |
| 248 |
}, |
| 249 |
failure : alertFailure
|
| 250 |
}); |
| 251 |
|
| 252 |
}, |
| 253 |
/**
|
| 254 |
* Only in NoSql, open a dataset view
|
| 255 |
* @param {} url
|
| 256 |
*/
|
| 257 |
_showDatasetDetails : function (url) { |
| 258 |
var urlDataset = url.substring(0, url.indexOf("/records")); |
| 259 |
Ext.Ajax.request({
|
| 260 |
url : urlDataset,
|
| 261 |
method : 'GET', |
| 262 |
scope : this, |
| 263 |
success : function (ret) { |
| 264 |
var data = Ext.decode(ret.responseText);
|
| 265 |
if (!data.success) {
|
| 266 |
Ext.Msg.alert(i18n.get('label.warning'), data.message);
|
| 267 |
return false; |
| 268 |
} |
| 269 |
var dataset = new Ext.data.Record(data.dataset).data; |
| 270 |
|
| 271 |
var windowConfig = {
|
| 272 |
title : i18n.get('label.dataTitle') + " : " + dataset.name, |
| 273 |
datasetName : dataset.name,
|
| 274 |
datasetDescription : dataset.description,
|
| 275 |
type : "data", |
| 276 |
saveToolbar : true, |
| 277 |
toolbarItems : [],
|
| 278 |
iconCls : "dataDetail" |
| 279 |
}; |
| 280 |
|
| 281 |
//open the dataView according to the dataset Configuration.
|
| 282 |
var javascriptObject = eval(dataset.datasetView.jsObject);
|
| 283 |
//add the toolbarItems configuration
|
| 284 |
Ext.apply(windowConfig, {
|
| 285 |
id : "data" + dataset.datasetId |
| 286 |
}); |
| 287 |
var componentCfg = {
|
| 288 |
dataUrl : dataset.sitoolsAttachementForUsers,
|
| 289 |
datasetId : dataset.id,
|
| 290 |
datasetCm : dataset.columnModel,
|
| 291 |
datasetName : dataset.name,
|
| 292 |
dictionaryMappings : dataset.dictionaryMappings,
|
| 293 |
datasetViewConfig : dataset.datasetViewConfig,
|
| 294 |
preferencesPath : "/" + dataset.name, |
| 295 |
preferencesFileName : "datasetView" |
| 296 |
}; |
| 297 |
|
| 298 |
SitoolsDesk.addDesktopWindow(windowConfig, componentCfg, javascriptObject); |
| 299 |
|
| 300 |
}, |
| 301 |
failure : alertFailure
|
| 302 |
}); |
| 303 |
|
| 304 |
}, |
| 305 |
/**
|
| 306 |
* Opens a sitools.user.modules.userSpaceDependencies.svaTasksDetails window to see the task Details.
|
| 307 |
* @param {} task
|
| 308 |
*/
|
| 309 |
showTaskDetail : function (task) { |
| 310 |
var jsObj = sitools.user.component.entete.userProfile.tasksDetails;
|
| 311 |
var componentCfg = {
|
| 312 |
sva : task
|
| 313 |
}; |
| 314 |
var windowConfig = {
|
| 315 |
id : "taskStatusDetails", |
| 316 |
title : i18n.get("label.taskDetails") + ":" + task.id, |
| 317 |
iconCls : "dataDetail" |
| 318 |
}; |
| 319 |
SitoolsDesk.addDesktopWindow(windowConfig, componentCfg, jsObj); |
| 320 |
}, |
| 321 |
/**
|
| 322 |
* parse the task.urlResult to see if this is an Specialized resource (noSQl or Order).
|
| 323 |
* If not, open a new Window to get the result of the resource.
|
| 324 |
* @param {} task
|
| 325 |
*/
|
| 326 |
showTaskResults : function (task) { |
| 327 |
var orderUrl = loadUrl.get('APP_URL') + loadUrl.get('APP_ORDERS_USER_URL'); |
| 328 |
if (task.urlResult.indexOf(orderUrl) != -1) { |
| 329 |
this._showOrderDetails(task.urlResult);
|
| 330 |
} else if (task.urlResult.indexOf("/records") != -1) { |
| 331 |
this._showDatasetDetails(task.urlResult);
|
| 332 |
} |
| 333 |
else {
|
| 334 |
window.open(task.urlResult); |
| 335 |
} |
| 336 |
}, |
| 337 |
/**
|
| 338 |
* Method called when trying to show this component with fixed navigation
|
| 339 |
*
|
| 340 |
* @param {sitools.user.component.viewDataDetail} me the dataDetail view
|
| 341 |
* @param {} config config options
|
| 342 |
* @returns
|
| 343 |
*/
|
| 344 |
showMeInFixedNav : function (me, config) { |
| 345 |
Ext.apply(config.windowSettings, {
|
| 346 |
width : config.windowSettings.winWidth || DEFAULT_WIN_WIDTH,
|
| 347 |
height : config.windowSettings.winHeight || DEFAULT_WIN_HEIGHT
|
| 348 |
}); |
| 349 |
SitoolsDesk.openModalWindow(me, config); |
| 350 |
}, |
| 351 |
/**
|
| 352 |
* Method called when trying to show this component with Desktop navigation
|
| 353 |
*
|
| 354 |
* @param {sitools.user.component.viewDataDetail} me the dataDetail view
|
| 355 |
* @param {} config config options
|
| 356 |
* @returns
|
| 357 |
*/
|
| 358 |
showMeInDesktopNav : function (me, config) { |
| 359 |
Ext.apply(config.windowSettings, {
|
| 360 |
width : config.windowSettings.winWidth || DEFAULT_WIN_WIDTH,
|
| 361 |
height : config.windowSettings.winHeight || DEFAULT_WIN_HEIGHT
|
| 362 |
}); |
| 363 |
SitoolsDesk.openModalWindow(me, config); |
| 364 |
} |
| 365 |
|
| 366 |
|
| 367 |
}); |
| 368 |
|