git_sitools_idoc / Module_DatasetExplorerOchart_sitools2v3 / DatasetExplorerOchartController.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 |
|
19 |
/*global Ext, sitools, i18n, projectGlobal, alertFailure, showResponse*/
|
20 |
|
21 |
/**
|
22 |
* DatasetExplorerOchart Module Controller
|
23 |
* @class sitools.user.controller.modules.datasetExplorerOchart.DatasetExplorerOchartController
|
24 |
* @extends Ext.app.Controller
|
25 |
*/
|
26 |
Ext.define('sitools.user.controller.modules.datasetExplorerOchart.DatasetExplorerOchartController', {
|
27 |
extend : 'Ext.app.Controller', |
28 |
|
29 |
views : ['modules.datasetExplorerOchart.DatasetExplorerOchartView'], |
30 |
|
31 |
init : function () { |
32 |
this.control({
|
33 |
"DatasetExplorerOchart" : {
|
34 |
render : function (ochart) { |
35 |
var project = Ext.getStore('ProjectStore').getProject(); |
36 |
var projectAttachment = project.get("sitoolsAttachementForUsers"); |
37 |
|
38 |
Ext.Ajax.request({ |
39 |
method : 'GET', |
40 |
url : projectAttachment + "/graph", |
41 |
scope : this, |
42 |
success : function (ret) { |
43 |
var Json = Ext.decode(ret.responseText);
|
44 |
if (!Json.success) {
|
45 |
Ext.Msg.alert(i18n.get('label.warning'), Json.message);
|
46 |
return;
|
47 |
} |
48 |
if (Json.graph && Json.graph.nodeList) {
|
49 |
ochart.store.getRootNode().appendChild(Json.graph.nodeList); |
50 |
ochart.store.getRootNode().collapseChildren(); |
51 |
//ochart.store.setRootNode(Json.graph.nodeList);
|
52 |
console.log(ochart.store.getRootNode()); |
53 |
var root=ochart.store.getRootNode();
|
54 |
for(var i=0; i<root.childNodes.length; i++){ |
55 |
this.collapseRecursive(root.childNodes[i]);
|
56 |
} |
57 |
} |
58 |
} |
59 |
}); |
60 |
|
61 |
|
62 |
} |
63 |
} |
64 |
}); |
65 |
|
66 |
this.listen({
|
67 |
store : {
|
68 |
"#datasetExplorerOchartTreeStore" : {
|
69 |
append : function (store, record) { |
70 |
//record.set("id", Ext.id());
|
71 |
if (record.get("type") === "dataset") { |
72 |
var icon = record.get("authorized") === "true" ? loadUrl.get('APP_URL') + "/common/res/images/icons/tree_datasets.png" : loadUrl.get('APP_URL') + "/common/res/images/icons/cadenas.png"; |
73 |
record.set('icon', icon);
|
74 |
//record.set("leaf", true);
|
75 |
|
76 |
} |
77 |
if (record.get("type") === "node") { |
78 |
if(!Ext.isEmpty(record.get("image"))) { |
79 |
record.set("icon", record.get("image").url); |
80 |
} |
81 |
//record.set('iconCls', "graphNodeType");
|
82 |
//record.set("readme", record.get("description"));
|
83 |
//record.set("expanded", false);
|
84 |
//record.set("leaf", false);
|
85 |
//console.log(record);
|
86 |
//record.collapseChildren();
|
87 |
} |
88 |
} |
89 |
|
90 |
} |
91 |
} |
92 |
}); |
93 |
}, |
94 |
collapseRecursive: function(node){ |
95 |
if(node.childNodes != []) {
|
96 |
for(var i=0; i<node.childNodes.length; i++){ |
97 |
this.collapseRecursive(node.childNodes[i]);
|
98 |
node.childNodes[i].collapse(); |
99 |
} |
100 |
|
101 |
} |
102 |
} |
103 |
|
104 |
}); |