git_sitools_idoc / Module_DatasetExplorerOchart_sitools2 / dataSetExplorerDataViewOchart.js @ 20ff13ec
| 1 |
/***************************************
|
|---|---|
| 2 |
* Copyright 2010-2013 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
|
| 7 |
* it under the terms of the GNU General Public License as published by
|
| 8 |
* the Free Software Foundation, either version 3 of the License, or
|
| 9 |
* (at your option) any later version.
|
| 10 |
*
|
| 11 |
* SITools2 is distributed in the hope that it will be useful,
|
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 14 |
* GNU General Public License for more details.
|
| 15 |
*
|
| 16 |
* You should have received a copy of the GNU General Public License
|
| 17 |
* along with SITools2. If not, see <http://www.gnu.org/licenses/>.
|
| 18 |
***************************************/
|
| 19 |
/*global Ext, sitools, projectGlobal, commonTreeUtils, showResponse, document, i18n, loadUrl, SITOOLS_DEFAULT_PROJECT_IMAGE_URL, SitoolsDesk*/
|
| 20 |
/*
|
| 21 |
* @include "../../env.js"
|
| 22 |
*/
|
| 23 |
Ext.namespace('sitools.user.modules');
|
| 24 |
|
| 25 |
/**
|
| 26 |
* Dataset Explorer Module.
|
| 27 |
* Displays each dataset of the Project.
|
| 28 |
* @class sitools.user.modules.datasetExplorerDataView
|
| 29 |
* @extends Ext.tree.TreePanel
|
| 30 |
*/
|
| 31 |
sitools.user.modules.dataSetExplorerDataviewOchart = Ext.extend(Ext.Panel, {
|
| 32 |
layout : "border", |
| 33 |
|
| 34 |
initComponent : function () { |
| 35 |
/**
|
| 36 |
* INDEX JPB var projectId = Ext.util.Cookies.get('projectId'); if
|
| 37 |
* (Ext.isEmpty(projectId)){ Ext.Msg.alert(i18n.get ('warning.noProject'));
|
| 38 |
* return; }
|
| 39 |
*/
|
| 40 |
|
| 41 |
//me.chartConfig = me.chartConfig || {};
|
| 42 |
//console.log(me.store);
|
| 43 |
var myDataView = new Ext.DataView({ |
| 44 |
id : "chart", |
| 45 |
region : 'center', |
| 46 |
singleSelect : true, |
| 47 |
autoScroll : true, |
| 48 |
}); |
| 49 |
this.items = [myDataView];
|
| 50 |
var projectAttachment = projectGlobal.sitoolsAttachementForUsers;
|
| 51 |
//alert(projectAttachment);
|
| 52 |
Ext.Ajax.request( {
|
| 53 |
url : projectAttachment + '/graph?media=json', |
| 54 |
//url: 'http://localhost:8182/sitools/client-user/js/modules/dataSetExplorerDataView/ochart/response_sitemap.json',
|
| 55 |
method : "GET", |
| 56 |
//root : 'graph.nodeList',
|
| 57 |
success : function(response, opts) { |
| 58 |
function getChild(n,node) { |
| 59 |
//nodeList.push(node);
|
| 60 |
//rootNodeList.push(node);
|
| 61 |
if(!n.leaf){
|
| 62 |
for(var i=0;i<n.children.length;i++){ |
| 63 |
var child=new sitools.user.modules.ExtJSOrgChart.createNode(n.children[i]); |
| 64 |
node.addChild(child); |
| 65 |
getChild(n.children[i],child); |
| 66 |
} |
| 67 |
} |
| 68 |
} |
| 69 |
var rootNodeList=new Array(); |
| 70 |
//var nodeList = new Array();
|
| 71 |
var data= Ext.decode(response.responseText);
|
| 72 |
for(var n=0;n<data.graph.nodeList.length;n++){ |
| 73 |
var rootNode = new sitools.user.modules.ExtJSOrgChart.createNode(data.graph.nodeList[n]); |
| 74 |
//nodeList.push(rootNode);
|
| 75 |
rootNodeList.push(rootNode); |
| 76 |
getChild(data.graph.nodeList[n],rootNode); |
| 77 |
} |
| 78 |
for(var i=0;i<rootNodeList.length;i++){ |
| 79 |
sitools.user.modules.ExtJSOrgChart.prepareTree({
|
| 80 |
chartElement: 'chart', |
| 81 |
rootObject: rootNodeList[i],
|
| 82 |
depth: -1 |
| 83 |
}); |
| 84 |
} |
| 85 |
} , |
| 86 |
failure : function(response, opts) { |
| 87 |
alert("Error while loading data : "+response.responseText);
|
| 88 |
} |
| 89 |
}); |
| 90 |
|
| 91 |
sitools.user.modules.dataSetExplorerDataviewOchart.superclass.initComponent.call(this);
|
| 92 |
|
| 93 |
}, |
| 94 |
afterRender : function () { |
| 95 |
sitools.user.modules.dataSetExplorerDataviewOchart.superclass.afterRender.apply(this, arguments); |
| 96 |
console.log(this);
|
| 97 |
}, |
| 98 |
/**
|
| 99 |
* method called when trying to save preference
|
| 100 |
* @returns
|
| 101 |
*/
|
| 102 |
_getSettings : function () { |
| 103 |
return {
|
| 104 |
preferencesPath : "/modules", |
| 105 |
preferencesFileName : this.id |
| 106 |
}; |
| 107 |
|
| 108 |
} |
| 109 |
|
| 110 |
}); |
| 111 |
|
| 112 |
Ext.reg('sitools.user.modules.dataSetExplorerDataviewOchart', sitools.user.modules.dataSetExplorerDataviewOchart);
|