From 29847577db93dd8ea3e7a0d384a893de210af36b Mon Sep 17 00:00:00 2001
From: zhaowei8188127 <18810460332@163.com>
Date: Fri, 6 Dec 2013 13:28:57 +0800
Subject: [PATCH] merge
---
src/main/webapp/script/haflow.main.js | 585 ++++++++++---------
src/main/webapp/script/haflow.report_list.js | 496 ++++++++--------
2 files changed, 544 insertions(+), 537 deletions(-)
diff --git a/src/main/webapp/script/haflow.main.js b/src/main/webapp/script/haflow.main.js
index f0a4c7e..a044a95 100644
--- a/src/main/webapp/script/haflow.main.js
+++ b/src/main/webapp/script/haflow.main.js
@@ -1,293 +1,294 @@
-dojo.require("dojo.dom");
-dojo.require("dojo.aspect");
-dojo.require("dojo.on");
-dojo.require("dojo.json");
-dojo.require("dojo.parser");
-dojo.require("dojo.mouse");
-dojo.require("dojo.store.Memory");
-dojo.require("dojo.store.Observable");
-dojo.require("dojo.io.iframe");
-dojo.require("dijit.form.Button");
-dojo.require("dijit.form.CheckBox");
-dojo.require("dijit.form.TextBox");
-dojo.require("dijit.layout.BorderContainer");
-dojo.require("dijit.layout.TabContainer");
-dojo.require("dijit.layout.ContentPane");
-dojo.require("dijit.tree.ObjectStoreModel");
-dojo.require("dijit.Menu");
-dojo.require("dijit.MenuItem");
-dojo.require("dijit.MenuBar");
-dojo.require("dijit.MenuBarItem");
-dojo.require("dijit.PopupMenuBarItem");
-dojo.require("dijit.TitlePane");
-dojo.require("dijit.Toolbar");
-dojo.require("dijit.Tree");
-dojo.require("dijit.tree.dndSource");
-dojo.require("dijit.registry");
-dojo.require("dijit.form.Form");
-dojo.require("dojo._base.lang");
-dojo.require("dojox.grid.EnhancedGrid");
-dojo.require("dojo.data.ItemFileWriteStore");
-dojo.require("dojox.grid.cells.dijit");
-dojo.require("dojox.layout.ContentPane");
-
-var flow;
-var watchHandle;
-
-dojo.ready(function() {
- flow = new HAFlow.Main(new HAFlow.UI());
- flow.init();
-});
-
-HAFlow.Main = function(ui) {
- this.basePath = dojo.byId("basePath").value;
- this.ui = ui;
- this.rootPath = "hdfs://133.133.2.150:9000/user/root/" + username;
- this.userId = userid;
- this.userName = username;
- this.hdfspath = null;
-};
-
-// Initialize
-HAFlow.Main.prototype.init = function() {
- this.flows = {};
- this.jsPlumb = {};
- this.reports = {};
- this.initUserInterface();
- this.initData();
-};
-
-HAFlow.Main.prototype.initUserInterface = function() {
- this.ui.init();
- this.initUserInterfaceId();
- this.initMainMenu();
- this.initToolbar();
- this.initBottomTabs();
- this.initFlowList();
- this.initFlowContainer();
- this.initHdfsFileList();
- this.initReportList();
- this.ui.refresh();
-};
-
-HAFlow.Main.prototype.initUserInterfaceId = function() {
- this.flowListContainerId = "flowListTreeContainer";
- this.flowListTreeId = "flowListTree";
- this.hdfsFileListContainerId = "hdfsFileListContainer";
- this.hdfsFileListTreeId = "hdfsFileListTree";
- this.moduleListContainerId = "moduleListContainer";
- this.reportListContainerId = "reportListContainer";
- this.reportListTreeId = "reportListTree";
- this.flowContainerId = "flowContainer";
- this.informationContainerId = "informationContainer";
- this.consoleContainerId = "consoleContainer";
- this.logContainerId = "logContainer";
- this.configurationContainerId = "configurationContainer";
-};
-
-HAFlow.Main.prototype.initMainMenu = function() {
- this.menu = {};
- this.initFlowMenu();
-};
-
-// initFlowMenu --> haflow.toolbar.js
-// initToolbar --> haflow.toolbar.js
-
-HAFlow.Main.prototype.initBottomTabs = function() {
- this.initInformationTab();
- this.initConsoleTab();
-};
-
-HAFlow.Main.prototype.initConsoleTab = function() {
- var consoleContentPane = (new dijit.layout.ContentPane({
- id : this.consoleContainerId,
- title : "Console"
- }));
- this.ui.bottomContainer.addChild(consoleContentPane);
-};
-
-HAFlow.Main.prototype.initInformationTab = function() {
- var informationContentPane = (new dijit.layout.ContentPane({
- id : this.informationContainerId,
- title : "Information"
- }));
- this.ui.bottomContainer.addChild(informationContentPane);
-};
-
-// initFlowList --> haflow.flow_list.js
-
-HAFlow.Main.prototype.initFlowContainer = function() {
- var _currentInstance = this;
- watchHandle=this.ui.centerContainer.watch("selectedChildWidget", function(name, from,
- to) {
- var targetContainerPaneId = to.domNode.id;
- var flowContainerPaneString = "flowContainerPane_";
- var reportContainerPaneString = "reportContainerPane_";
- var hdfsContainerPaneString = "hdfsContainerPane_";
-
- if(targetContainerPaneId.substring(0, reportContainerPaneString.length)
- === reportContainerPaneString){//report opened
- _currentInstance.afterFlowUnSelected();
- _currentInstance.afterReportSelected();
-
- var reportId = targetContainerPaneId.replace(reportContainerPaneString, "");
- _currentInstance.setupReportDroppable(reportId);
-// _currentInstance.paintReport(reportId);
- }else if(targetContainerPaneId.substring(0, flowContainerPaneString.length)
- === flowContainerPaneString){ //flow opened
-
- _currentInstance.afterReportUnSelected();
- _currentInstance.afterFlowSelected();
-
- var flowId = targetContainerPaneId.replace(flowContainerPaneString, "");
- _currentInstance.currentFlowId = flowId;
- _currentInstance.setupDroppable(flowId);
- _currentInstance.paintFlow(flowId);
- }else{
- _currentInstance.afterFlowUnSelected();
- _currentInstance.afterReportUnSelected();
-
-// var hdfsreg = new RegExp("^hdfs://");hdfsreg.test(targetContainerPaneId)
- if(targetContainerPaneId.substring(0, hdfsContainerPaneString.length)
- === hdfsContainerPaneString){ //hdfs opened
-
- }else if( targetContainerPaneId == "oozie"
- || targetContainerPaneId == "hive"){//oozie or hive opened
-
- }else {
- alert("not known target container!");
- }
- }
-
- });
-
- dojo.connect(this.ui.centerContainer, "closeChild", function(child){
- if( !_currentInstance.ui.centerContainer.hasChildren()){
- _currentInstance.ui.centerRightContainer.removeChild(_currentInstance.ui.trailingContainer);
- }
- });
-};
-
-HAFlow.Main.prototype.afterReportSelected = function(){
- var _currentInstance = this;
- _currentInstance.ui.centerRightContainer.addChild(_currentInstance.ui.secondTrailingContainer);
- if(_currentInstance.ui.secondTrailingContainerLoaded == false){
- _currentInstance.paintReportList();
- _currentInstance.ui.secondTrailingContainerLoaded = true;
- }
-};
-
-HAFlow.Main.prototype.afterReportUnSelected = function(){
- var _currentInstance = this;
- _currentInstance.ui.centerRightContainer.removeChild(_currentInstance.ui.secondTrailingContainer);
-};
-
-HAFlow.Main.prototype.afterFlowSelected = function(){
- var _currentInstance = this;
-
- //toolbar
- _currentInstance.toolbar.removeFlowButton.set("disabled", false);
- _currentInstance.toolbar.saveFlowButton.set("disabled", false);
- _currentInstance.toolbar.runFlowButton.set("disabled", false);
- //menu item
- _currentInstance.menu.flowMenu.deleteFlowMenuItem.set("disabled", false);
- _currentInstance.menu.flowMenu.saveFlowMenuItem.set("disabled", false);
- _currentInstance.menu.runMenu.runFlowMenuItem.set("disabled", false);
- _currentInstance.menu.runMenu.runFlowHistoryMenuItem.set("disabled", false);
-
- _currentInstance.ui.centerRightContainer.addChild(_currentInstance.ui.trailingContainer);
- if(_currentInstance.ui.trailingContainerLoaded == false){
- _currentInstance.paintModuleList();
- _currentInstance.ui.trailingContainerLoaded = true;
- }
-};
-
-HAFlow.Main.prototype.afterFlowUnSelected = function() {
- var _currentInstance = this;
-
- //toolbar
- _currentInstance.toolbar.removeFlowButton.set("disabled", true);
- _currentInstance.toolbar.saveFlowButton.set("disabled", true);
- _currentInstance.toolbar.runFlowButton.set("disabled", true);
- //menu item
- _currentInstance.menu.flowMenu.deleteFlowMenuItem.set("disabled", true);
- _currentInstance.menu.flowMenu.saveFlowMenuItem.set("disabled", true);
- _currentInstance.menu.runMenu.runFlowMenuItem.set("disabled", true);
- _currentInstance.menu.runMenu.runFlowHistoryMenuItem.set("disabled", true);
-
- _currentInstance.ui.centerRightContainer.removeChild(_currentInstance.ui.trailingContainer);
-};
-// initHdfsFileList --> halow.hdfs.js
-// initReportList --> haflow.report_list.js
-// end initUserInterface
-
-HAFlow.Main.prototype.initData = function() {
-/* this.initFlowListData();*/
- this.initModuleListData();
-};
-
-HAFlow.Main.prototype.initModuleListData = function() {
- var _currentInstance = this;
- $.ajax({
-
- url : _currentInstance.basePath + "module",
- type : "GET",
- cache : false,
- dataType : "json",
- success : function(data, status) {
- _currentInstance.moduleList = data;
- _currentInstance.drawLists(_currentInstance);
- },
- error : function(request, status, error) {
- _currentInsance.addToConsole("An error occurred while loading module list: " + error, true);
- }
- });
-};
-
-HAFlow.Main.prototype.drawLists = function(instance) {
- instance.paintModuleList();
-/* instance.buildFlowListTree();*/
-};
-
-HAFlow.Main.prototype.paintModuleList = function() {
- var i;
- for (i = 0; i < this.moduleList.modules.length; i++) {
- if (dijit.byId(this.moduleListContainerId + "_"
- + this.moduleList.modules[i].category) == null) {
- var moduleListPane = new dijit.layout.ContentPane({
- id : this.moduleListContainerId + "_"
- + this.moduleList.modules[i].category,
- title : this.moduleList.modules[i].category
- });
- this.ui.trailingContainer.addChild(moduleListPane);
- }
- text = "
"
- + this.moduleList.modules[i].name + "
";
- $("#" + this.moduleListContainerId + "_"
- + this.moduleList.modules[i].category).append(text);
- }
- this.ui.refresh();
-
-};
-
-HAFlow.Main.prototype.addToConsole = function(message, isError) {
- var consoleContainer = dijit.registry
- .byId(_currentInstance.consoleContainerId);
-
- var text = " >>> ";
- if( isError){
- text += "" + message + "
";
- }else{
- text += "" + message + "
";
- }
- var randomId = HAFlow.generateUUID();
- text += "" + "" + "
";
- $("#" + _currentInstance.consoleContainerId).append(text);
- dojo.window.scrollIntoView(randomId);
- _currentInstance.ui.bottomContainer.selectChild(consoleContainer);
-};
-
-//paintReportList --> haflow.report.js
-
+dojo.require("dojo.dom");
+dojo.require("dojo.aspect");
+dojo.require("dojo.on");
+dojo.require("dojo.json");
+dojo.require("dojo.parser");
+dojo.require("dojo.mouse");
+dojo.require("dojo.store.Memory");
+dojo.require("dojo.store.Observable");
+dojo.require("dojo.io.iframe");
+dojo.require("dijit.form.Button");
+dojo.require("dijit.form.CheckBox");
+dojo.require("dijit.form.TextBox");
+dojo.require("dijit.layout.BorderContainer");
+dojo.require("dijit.layout.TabContainer");
+dojo.require("dijit.layout.ContentPane");
+dojo.require("dijit.tree.ObjectStoreModel");
+dojo.require("dijit.Menu");
+dojo.require("dijit.MenuItem");
+dojo.require("dijit.MenuBar");
+dojo.require("dijit.MenuBarItem");
+dojo.require("dijit.PopupMenuBarItem");
+dojo.require("dijit.TitlePane");
+dojo.require("dijit.Toolbar");
+dojo.require("dijit.Tree");
+dojo.require("dijit.tree.dndSource");
+dojo.require("dijit.registry");
+dojo.require("dijit.form.Form");
+dojo.require("dojo._base.lang");
+dojo.require("dojox.grid.EnhancedGrid");
+dojo.require("dojo.data.ItemFileWriteStore");
+dojo.require("dojox.grid.cells.dijit");
+dojo.require("dojox.layout.ContentPane");
+
+var flow;
+var watchHandle;
+
+dojo.ready(function() {
+ flow = new HAFlow.Main(new HAFlow.UI());
+ flow.init();
+});
+
+HAFlow.Main = function(ui) {
+ this.basePath = dojo.byId("basePath").value;
+ this.ui = ui;
+ this.rootPath = "hdfs://133.133.2.150:9000/user/root/" + username;
+ this.userId = userid;
+ this.userName = username;
+ this.hdfspath = null;
+};
+
+// Initialize
+HAFlow.Main.prototype.init = function() {
+ this.flows = {};
+ this.jsPlumb = {};
+ this.reports = {};
+ this.initUserInterface();
+ this.initData();
+};
+
+HAFlow.Main.prototype.initUserInterface = function() {
+ this.ui.init();
+ this.initUserInterfaceId();
+ this.initMainMenu();
+ this.initToolbar();
+ this.initBottomTabs();
+ this.initFlowList();
+ this.initFlowContainer();
+ this.initHdfsFileList();
+ this.initReportList();
+ this.ui.refresh();
+};
+
+HAFlow.Main.prototype.initUserInterfaceId = function() {
+ this.flowListContainerId = "flowListTreeContainer";
+ this.flowListTreeId = "flowListTree";
+ this.hdfsFileListContainerId = "hdfsFileListContainer";
+ this.hdfsFileListTreeId = "hdfsFileListTree";
+ this.moduleListContainerId = "moduleListContainer";
+ this.reportListContainerId = "reportListContainer";
+ this.reportListTreeId = "reportListTree";
+ this.flowContainerId = "flowContainer";
+ this.informationContainerId = "informationContainer";
+ this.consoleContainerId = "consoleContainer";
+ this.logContainerId = "logContainer";
+ this.configurationContainerId = "configurationContainer";
+};
+
+HAFlow.Main.prototype.initMainMenu = function() {
+ this.menu = {};
+ this.initFlowMenu();
+};
+
+// initFlowMenu --> haflow.toolbar.js
+// initToolbar --> haflow.toolbar.js
+
+HAFlow.Main.prototype.initBottomTabs = function() {
+ this.initInformationTab();
+ this.initConsoleTab();
+};
+
+HAFlow.Main.prototype.initConsoleTab = function() {
+ var consoleContentPane = (new dijit.layout.ContentPane({
+ id : this.consoleContainerId,
+ title : myfile.console
+ }));
+ this.ui.bottomContainer.addChild(consoleContentPane);
+};
+
+HAFlow.Main.prototype.initInformationTab = function() {
+ var informationContentPane = (new dijit.layout.ContentPane({
+ id : this.informationContainerId,
+ title : myfile.information
+ }));
+ this.ui.bottomContainer.addChild(informationContentPane);
+};
+
+// initFlowList --> haflow.flow_list.js
+
+HAFlow.Main.prototype.initFlowContainer = function() {
+ var _currentInstance = this;
+ watchHandle=this.ui.centerContainer.watch("selectedChildWidget", function(name, from,
+ to) {
+ var targetContainerPaneId = to.domNode.id;
+ var flowContainerPaneString = "flowContainerPane_";
+ var reportContainerPaneString = "reportContainerPane_";
+ var hdfsContainerPaneString = "hdfsContainerPane_";
+
+ if(targetContainerPaneId.substring(0, reportContainerPaneString.length)
+ === reportContainerPaneString){//report opened
+ _currentInstance.afterFlowUnSelected();
+ _currentInstance.afterReportSelected();
+
+ var reportId = targetContainerPaneId.replace(reportContainerPaneString, "");
+ _currentInstance.currentReportId = reportId;
+ _currentInstance.setupReportDroppable(reportId);
+// _currentInstance.paintReport(reportId);
+ }else if(targetContainerPaneId.substring(0, flowContainerPaneString.length)
+ === flowContainerPaneString){ //flow opened
+
+ _currentInstance.afterReportUnSelected();
+ _currentInstance.afterFlowSelected();
+
+ var flowId = targetContainerPaneId.replace(flowContainerPaneString, "");
+ _currentInstance.currentFlowId = flowId;
+ _currentInstance.setupDroppable(flowId);
+ _currentInstance.paintFlow(flowId);
+ }else{
+ _currentInstance.afterFlowUnSelected();
+ _currentInstance.afterReportUnSelected();
+
+// var hdfsreg = new RegExp("^hdfs://");hdfsreg.test(targetContainerPaneId)
+ if(targetContainerPaneId.substring(0, hdfsContainerPaneString.length)
+ === hdfsContainerPaneString){ //hdfs opened
+
+ }else if( targetContainerPaneId == "oozie"
+ || targetContainerPaneId == "hive"){//oozie or hive opened
+
+ }else {
+ alert("not known target container!");
+ }
+ }
+
+ });
+
+ dojo.connect(this.ui.centerContainer, "closeChild", function(child){
+ if( !_currentInstance.ui.centerContainer.hasChildren()){
+ _currentInstance.ui.centerRightContainer.removeChild(_currentInstance.ui.trailingContainer);
+ }
+ });
+};
+
+HAFlow.Main.prototype.afterReportSelected = function(){
+ var _currentInstance = this;
+ _currentInstance.ui.centerRightContainer.addChild(_currentInstance.ui.secondTrailingContainer);
+ if(_currentInstance.ui.secondTrailingContainerLoaded == false){
+ _currentInstance.paintReportList();
+ _currentInstance.ui.secondTrailingContainerLoaded = true;
+ }
+};
+
+HAFlow.Main.prototype.afterReportUnSelected = function(){
+ var _currentInstance = this;
+ _currentInstance.ui.centerRightContainer.removeChild(_currentInstance.ui.secondTrailingContainer);
+};
+
+HAFlow.Main.prototype.afterFlowSelected = function(){
+ var _currentInstance = this;
+
+ //toolbar
+ _currentInstance.toolbar.removeFlowButton.set("disabled", false);
+ _currentInstance.toolbar.saveFlowButton.set("disabled", false);
+ _currentInstance.toolbar.runFlowButton.set("disabled", false);
+ //menu item
+ _currentInstance.menu.flowMenu.deleteFlowMenuItem.set("disabled", false);
+ _currentInstance.menu.flowMenu.saveFlowMenuItem.set("disabled", false);
+ _currentInstance.menu.runMenu.runFlowMenuItem.set("disabled", false);
+ _currentInstance.menu.runMenu.runFlowHistoryMenuItem.set("disabled", false);
+
+ _currentInstance.ui.centerRightContainer.addChild(_currentInstance.ui.trailingContainer);
+ if(_currentInstance.ui.trailingContainerLoaded == false){
+ _currentInstance.paintModuleList();
+ _currentInstance.ui.trailingContainerLoaded = true;
+ }
+};
+
+HAFlow.Main.prototype.afterFlowUnSelected = function() {
+ var _currentInstance = this;
+
+ //toolbar
+ _currentInstance.toolbar.removeFlowButton.set("disabled", true);
+ _currentInstance.toolbar.saveFlowButton.set("disabled", true);
+ _currentInstance.toolbar.runFlowButton.set("disabled", true);
+ //menu item
+ _currentInstance.menu.flowMenu.deleteFlowMenuItem.set("disabled", true);
+ _currentInstance.menu.flowMenu.saveFlowMenuItem.set("disabled", true);
+ _currentInstance.menu.runMenu.runFlowMenuItem.set("disabled", true);
+ _currentInstance.menu.runMenu.runFlowHistoryMenuItem.set("disabled", true);
+
+ _currentInstance.ui.centerRightContainer.removeChild(_currentInstance.ui.trailingContainer);
+};
+// initHdfsFileList --> halow.hdfs.js
+// initReportList --> haflow.report_list.js
+// end initUserInterface
+
+HAFlow.Main.prototype.initData = function() {
+/* this.initFlowListData();*/
+ this.initModuleListData();
+};
+
+HAFlow.Main.prototype.initModuleListData = function() {
+ var _currentInstance = this;
+ $.ajax({
+
+ url : _currentInstance.basePath + "module",
+ type : "GET",
+ cache : false,
+ dataType : "json",
+ success : function(data, status) {
+ _currentInstance.moduleList = data;
+ _currentInstance.drawLists(_currentInstance);
+ },
+ error : function(request, status, error) {
+ _currentInsance.addToConsole("An error occurred while loading module list: " + error, true);
+ }
+ });
+};
+
+HAFlow.Main.prototype.drawLists = function(instance) {
+ instance.paintModuleList();
+/* instance.buildFlowListTree();*/
+};
+
+HAFlow.Main.prototype.paintModuleList = function() {
+ var i;
+ for (i = 0; i < this.moduleList.modules.length; i++) {
+ if (dijit.byId(this.moduleListContainerId + "_"
+ + this.moduleList.modules[i].category) == null) {
+ var moduleListPane = new dijit.layout.ContentPane({
+ id : this.moduleListContainerId + "_"
+ + this.moduleList.modules[i].category,
+ title : this.moduleList.modules[i].category
+ });
+ this.ui.trailingContainer.addChild(moduleListPane);
+ }
+ text = ""
+ + this.moduleList.modules[i].name + "
";
+ $("#" + this.moduleListContainerId + "_"
+ + this.moduleList.modules[i].category).append(text);
+ }
+ this.ui.refresh();
+
+};
+
+HAFlow.Main.prototype.addToConsole = function(message, isError) {
+ var consoleContainer = dijit.registry
+ .byId(_currentInstance.consoleContainerId);
+
+ var text = " >>> ";
+ if( isError){
+ text += "" + message + "
";
+ }else{
+ text += "" + message + "
";
+ }
+ var randomId = HAFlow.generateUUID();
+ text += "" + "" + "
";
+ $("#" + _currentInstance.consoleContainerId).append(text);
+ dojo.window.scrollIntoView(randomId);
+ _currentInstance.ui.bottomContainer.selectChild(consoleContainer);
+};
+
+//paintReportList --> haflow.report.js
+
//end initData
\ No newline at end of file
diff --git a/src/main/webapp/script/haflow.report_list.js b/src/main/webapp/script/haflow.report_list.js
index f6f9411..240a081 100644
--- a/src/main/webapp/script/haflow.report_list.js
+++ b/src/main/webapp/script/haflow.report_list.js
@@ -1,246 +1,252 @@
-// public
-HAFlow.Main.prototype.initReportList = function() {
- var reportListContentPane = new dijit.layout.ContentPane({
- id: this.reportListContainerId,
- title: "Reports"
- });
- this.ui.leadingContainer.addChild(reportListContentPane);
-
- var _currentInstance = this;
- $.ajax({
- url: this.basePath + "report",
- type: "GET",
- dataType: "json",
- data: {},
- success: function(data, status) {
- _currentInstance.initReportListStore();
- _currentInstance.fillReportListStore(data);
- _currentInstance.fillReportsData(data);
- _currentInstance.initReportListTree();
- },
- error: function(request, status, error) {
- _currentInstance.addToConsole("An error occurred while loading flow list: " + error, true);
- }
- });
-};
-
-//private
-HAFlow.Main.prototype.initReportListStore = function() {
- this.reportListStore = new dojo.store.Observable(new dojo.store.Memory({
- data: [],
- getChildren: function(object) {
- return this.query({
- parent: object.id
- });
- }
- }));
-};
-
-HAFlow.Main.prototype.fillReportListStore = function(data) {
- for (var i = 0; i < data.reports.length; i++) {
- var dataItem = data.reports[i];
- this.reportListStore.put({
- id: dataItem.id,
- name: dataItem.name,
- isdirectory: dataItem.isdirectory,
- parent: dataItem.parentid,
- });
- }
-};
-
-HAFlow.Main.prototype.fillReportsData = function(data) {
- for (var i = 0; i < data.reports.length; i++) {
- var reportItem = data.reports[i];
- var reportItemId = reportItem.id;
- this.reports[reportItemId] = {};
- this.reports[reportItemId].id = reportItemId;
- this.reports[reportItemId].name = reportItem.name;
- this.reports[reportItemId].isdirectory = reportItem.isdirectory;
- this.reports[reportItemId].parentid = reportItem.parentid;
- this.reports[reportItemId].portlets = new Array();
- var portlets = reportItem.portlets;
- for( var j = 0; j < portlets.length; j++){
- var currentPortlet = {
- id: portlets[j].id,
- title: portlets[j].title,
- type: portlets[j].type,
- position: portlets[j].position,
-
- reportId: portlets[j].reportId,
- };
- this.reports[reportItemId].portlets.push(currentPortlet);
- }
- }
-};
-
-HAFlow.Main.prototype.checkReportItem = function(isDirectory, needsDirectory){
- if( needsDirectory ){
- if( isDirectory){
- return true;
- }else{
- _currentInstance.addToConsole("It's not a flow directory!", true);
- return false;
- }
- }else{
- if( isDirectory){
- _currentInstance.addToConsole("It's not a flow! ", true);
- return false;
- }else{
- return true;
- }
- }
-};
-
-HAFlow.Main.prototype.initReportListTree = function() {
- var rootId;
- for(var i = 0; i < this.reportListStore.data.length; i++ ){
- if( this.reportListStore.data[i].parent == null){
- rootId = this.reportListStore.data[i].id;
- break;
- }
- }
- var treeModel = new dijit.tree.ObjectStoreModel({
- store: this.reportListStore,
- query: {
- id: rootId,
- },
- mayHaveChildren: function(item) {
- return item.isdirectory;
- }
- });
-
- var tree = new dijit.Tree({
- model: treeModel,
- dndController: dijit.tree.dndSource
- },
- dojo.create("div", {
- id: this.reportListTreeId,
- },
- this.reportListContainerId));
- var _currentInstance = this;
- //TODO put
-
- this.menu.reportTreeMenu = new dijit.Menu({
- id: "reportTreeMenu",
- targetNodeIds: [_currentInstance.reportListTreeId],
- selector: ".dijitTreeNode"
- });
- this.menu.reportTreeMenu.newReportMenuItem = new dijit.MenuItem({
- id: "newReportMenuItem",
- label: "New Report"
- });
- this.menu.reportTreeMenu.newReportDirectoryMenuItem = new dijit.MenuItem({
- id: "newReportDirectoryMenuItem",
- label: "New Report Directory"
- });
- this.menu.reportTreeMenu.deleteReportMenuItem = new dijit.MenuItem({
- id: "deleteReportMenuItem",
- label: "Delete"
- });
- this.menu.reportTreeMenu.renameReportMenuItem = new dijit.MenuItem({
- id: "renameReportMenuItem",
- label: "Rename"
- });
- this.menu.reportTreeMenu.saveReportMenuItem = new dijit.MenuItem({
- id: "saveReportMenuItem",
- label: "Save"
- });
-
- this.menu.reportTreeMenu.addChild(this.menu.reportTreeMenu.newReportMenuItem);
- this.menu.reportTreeMenu.addChild(this.menu.reportTreeMenu.newReportDirectoryMenuItem);
- this.menu.reportTreeMenu.addChild(this.menu.reportTreeMenu.deleteReportMenuItem);
- this.menu.reportTreeMenu.addChild(this.menu.reportTreeMenu.renameReportMenuItem);
- this.menu.reportTreeMenu.addChild(this.menu.reportTreeMenu.saveReportMenuItem);
-
- dojo.connect(this.menu.reportTreeMenu.newReportMenuItem, "onClick",
- function() {
- var tn = dijit.byNode(this.getParent().currentTarget);
- var checkResult = _currentInstance.checkReportItem(tn.item.isdirectory, true);
- if( checkResult ){
- _currentInstance.newReport(tn.item.id);
- }
- });
- dojo.connect(this.menu.reportTreeMenu.newReportDirectoryMenuItem, "onClick",
- function() {
- var tn = dijit.byNode(this.getParent().currentTarget);
- var checkResult = _currentInstance.checkReportItem(tn.item.isdirectory, true);
- if( checkResult ){
- _currentInstance.newReportDirectory(tn.item.id);
- }
- });
- dojo.connect(this.menu.reportTreeMenu.deleteReportMenuItem, "onClick",
- function() {
- var tn = dijit.byNode(this.getParent().currentTarget);
- _currentInstance.deleteReport(tn.item.id);
- });
- dojo.connect(this.menu.reportTreeMenu.renameReportMenuItem, "onClick",
- function() {
-
- });
- dojo.connect(this.menu.reportTreeMenu.saveReportMenuItem, "onClick",
- function() {
- var tn = dijit.byNode(this.getParent().currentTarget);
- var checkResult = _currentInstance.checkReportItem(tn.item.isdirectory, false);
- if( checkResult ){
- _currentInstance.saveReport(tn.item.id);
- }
- });
-
- this.menu.reportTreeMenu.startup();
- tree.on("click", function(item) {
- _currentInstance.onReportClicked(_currentInstance, item.id);
- }, true);
- var picture = new RegExp("^[A-Za-z0-9_]*\.jpg$");
- var text = new RegExp("^[A-Za-z0-9_]*\.(txt|ini)$");
- var csv = new RegExp("^[A-Za-z0-9_-]*\.csv$");
-
- tree.on("dblclick",
- function(reportItem) {
- if (!reportItem.isdirectory) {
- _currentInstance.openReport(reportItem.id);
- }
- },
- true);
-
- tree.startup();
-};
-
-HAFlow.Main.prototype.onReportClicked = function(instance, reportId) {
- var reportInfo = instance.reports[reportId];
- var text = "";
- text += "";
- text += "Flow Info | " + "" + reportInfo.id + " |
";
- text += "IsDirectory | " + reportInfo.isdirectory + " |
";
- text += "ParentId | " + reportInfo.parentid + " |
";
- text += "Name | |
";
- text += " |
";
- text += "
";
- $("#" + instance.informationContainerId).html(text);
-
- var reportNameTextBoxId = "report_" + reportInfo.id + "_name";
- if (dijit.byId(reportNameTextBoxId) != null) {
- dijit.registry.remove(reportNameTextBoxId);
- }
- var flowNameTextBox = new dijit.form.TextBox({
- id : reportNameTextBoxId,
- value : reportInfo.name,
- style : "width:300px;"
- });
- flowNameTextBox.placeAt(dojo.byId("report_name_text_box"));
- flowNameTextBox.startup();
- var button = new dijit.form.Button({
- label : "Save",
- onClick : function() {
- instance.saveReportName(instance, reportInfo.id);
- }
- });
- button.placeAt(dojo.byId("save_report_name_button"));
- button.startup();
- var informationPane = dijit.byId(instance.informationContainerId);
- _currentInstance.ui.bottomContainer.selectChild(informationPane);
-};
-
-// TODO for now not used
-HAFlow.Main.prototype.onCloseTab_hdfs = function(instance) {
-
+// public
+HAFlow.Main.prototype.initReportList = function() {
+ var reportListContentPane = new dijit.layout.ContentPane({
+ id: this.reportListContainerId,
+ title: myfile.reports
+ });
+ this.ui.leadingContainer.addChild(reportListContentPane);
+
+ var _currentInstance = this;
+ $.ajax({
+ url: this.basePath + "report",
+ type: "GET",
+ dataType: "json",
+ data: {},
+ success: function(data, status) {
+ _currentInstance.initReportListStore();
+ _currentInstance.fillReportListStore(data);
+ _currentInstance.fillReportsData(data);
+ _currentInstance.initReportListTree();
+ },
+ error: function(request, status, error) {
+ _currentInstance.addToConsole("An error occurred while loading flow list: " + error, true);
+ }
+ });
+};
+
+//private
+HAFlow.Main.prototype.initReportListStore = function() {
+ this.reportListStore = new dojo.store.Observable(new dojo.store.Memory({
+ data: [],
+ getChildren: function(object) {
+ return this.query({
+ parent: object.id
+ });
+ }
+ }));
+};
+
+HAFlow.Main.prototype.fillReportListStore = function(data) {
+ for (var i = 0; i < data.reports.length; i++) {
+ var dataItem = data.reports[i];
+ this.reportListStore.put({
+ id: dataItem.id,
+ name: dataItem.name,
+ isdirectory: dataItem.isdirectory,
+ parent: dataItem.parentid,
+ });
+ }
+};
+
+HAFlow.Main.prototype.fillReportsData = function(data) {
+ for (var i = 0; i < data.reports.length; i++) {
+ var reportItem = data.reports[i];
+ var reportItemId = reportItem.id;
+ this.reports[reportItemId] = {};
+ this.reports[reportItemId].id = reportItemId;
+ this.reports[reportItemId].name = reportItem.name;
+ this.reports[reportItemId].isdirectory = reportItem.isdirectory;
+ this.reports[reportItemId].parentid = reportItem.parentid;
+ this.reports[reportItemId].portlets = new Array();
+ var portlets = reportItem.portlets;
+ for( var j = 0; j < portlets.length; j++){
+ var currentPortlet = {
+ id: portlets[j].id,
+ title: portlets[j].title,
+ type: portlets[j].type,
+ position: portlets[j].position,
+
+ reportId: portlets[j].reportId,
+ configurations:[]
+ };
+ var configurations = portlets[j].configurations;
+ for( var x = 0; x < configurations.length; x++){
+ var configuration = configurations[x];
+ currentPortlet.configurations.push(configuration);
+ }
+ this.reports[reportItemId].portlets.push(currentPortlet);
+ }
+ }
+};
+
+HAFlow.Main.prototype.checkReportItem = function(isDirectory, needsDirectory){
+ if( needsDirectory ){
+ if( isDirectory){
+ return true;
+ }else{
+ _currentInstance.addToConsole("It's not a flow directory!", true);
+ return false;
+ }
+ }else{
+ if( isDirectory){
+ _currentInstance.addToConsole("It's not a flow! ", true);
+ return false;
+ }else{
+ return true;
+ }
+ }
+};
+
+HAFlow.Main.prototype.initReportListTree = function() {
+ var rootId;
+ for(var i = 0; i < this.reportListStore.data.length; i++ ){
+ if( this.reportListStore.data[i].parent == null){
+ rootId = this.reportListStore.data[i].id;
+ break;
+ }
+ }
+ var treeModel = new dijit.tree.ObjectStoreModel({
+ store: this.reportListStore,
+ query: {
+ id: rootId,
+ },
+ mayHaveChildren: function(item) {
+ return item.isdirectory;
+ }
+ });
+
+ var tree = new dijit.Tree({
+ model: treeModel,
+ dndController: dijit.tree.dndSource
+ },
+ dojo.create("div", {
+ id: this.reportListTreeId,
+ },
+ this.reportListContainerId));
+ var _currentInstance = this;
+ //TODO put
+
+ this.menu.reportTreeMenu = new dijit.Menu({
+ id: "reportTreeMenu",
+ targetNodeIds: [_currentInstance.reportListTreeId],
+ selector: ".dijitTreeNode"
+ });
+ this.menu.reportTreeMenu.newReportMenuItem = new dijit.MenuItem({
+ id: "newReportMenuItem",
+ label: myfile.newReport
+ });
+ this.menu.reportTreeMenu.newReportDirectoryMenuItem = new dijit.MenuItem({
+ id: "newReportDirectoryMenuItem",
+ label: myfile.newReportDirectory
+ });
+ this.menu.reportTreeMenu.deleteReportMenuItem = new dijit.MenuItem({
+ id: "deleteReportMenuItem",
+ label: myfile.delete_
+ });
+ this.menu.reportTreeMenu.renameReportMenuItem = new dijit.MenuItem({
+ id: "renameReportMenuItem",
+ label: myfile.rename
+ });
+ this.menu.reportTreeMenu.saveReportMenuItem = new dijit.MenuItem({
+ id: "saveReportMenuItem",
+ label: myfile.save
+ });
+
+ this.menu.reportTreeMenu.addChild(this.menu.reportTreeMenu.newReportMenuItem);
+ this.menu.reportTreeMenu.addChild(this.menu.reportTreeMenu.newReportDirectoryMenuItem);
+ this.menu.reportTreeMenu.addChild(this.menu.reportTreeMenu.deleteReportMenuItem);
+ this.menu.reportTreeMenu.addChild(this.menu.reportTreeMenu.renameReportMenuItem);
+ this.menu.reportTreeMenu.addChild(this.menu.reportTreeMenu.saveReportMenuItem);
+
+ dojo.connect(this.menu.reportTreeMenu.newReportMenuItem, "onClick",
+ function() {
+ var tn = dijit.byNode(this.getParent().currentTarget);
+ var checkResult = _currentInstance.checkReportItem(tn.item.isdirectory, true);
+ if( checkResult ){
+ _currentInstance.newReport(tn.item.id);
+ }
+ });
+ dojo.connect(this.menu.reportTreeMenu.newReportDirectoryMenuItem, "onClick",
+ function() {
+ var tn = dijit.byNode(this.getParent().currentTarget);
+ var checkResult = _currentInstance.checkReportItem(tn.item.isdirectory, true);
+ if( checkResult ){
+ _currentInstance.newReportDirectory(tn.item.id);
+ }
+ });
+ dojo.connect(this.menu.reportTreeMenu.deleteReportMenuItem, "onClick",
+ function() {
+ var tn = dijit.byNode(this.getParent().currentTarget);
+ _currentInstance.deleteReport(tn.item.id);
+ });
+ dojo.connect(this.menu.reportTreeMenu.renameReportMenuItem, "onClick",
+ function() {
+
+ });
+ dojo.connect(this.menu.reportTreeMenu.saveReportMenuItem, "onClick",
+ function() {
+ var tn = dijit.byNode(this.getParent().currentTarget);
+ var checkResult = _currentInstance.checkReportItem(tn.item.isdirectory, false);
+ if( checkResult ){
+ _currentInstance.saveReport(tn.item.id);
+ }
+ });
+
+ this.menu.reportTreeMenu.startup();
+ tree.on("click", function(item) {
+ _currentInstance.onReportClicked(_currentInstance, item.id);
+ }, true);
+ var picture = new RegExp("^[A-Za-z0-9_]*\.jpg$");
+ var text = new RegExp("^[A-Za-z0-9_]*\.(txt|ini)$");
+ var csv = new RegExp("^[A-Za-z0-9_-]*\.csv$");
+
+ tree.on("dblclick",
+ function(reportItem) {
+ if (!reportItem.isdirectory) {
+ _currentInstance.openReport(reportItem.id);
+ }
+ },
+ true);
+
+ tree.startup();
+};
+
+HAFlow.Main.prototype.onReportClicked = function(instance, reportId) {
+ var reportInfo = instance.reports[reportId];
+ var text = "";
+ text += "";
+ text += "Flow Info | " + "" + reportInfo.id + " |
";
+ text += "IsDirectory | " + reportInfo.isdirectory + " |
";
+ text += "ParentId | " + reportInfo.parentid + " |
";
+ text += "Name | |
";
+ text += " |
";
+ text += "
";
+ $("#" + instance.informationContainerId).html(text);
+
+ var reportNameTextBoxId = "report_" + reportInfo.id + "_name";
+ if (dijit.byId(reportNameTextBoxId) != null) {
+ dijit.registry.remove(reportNameTextBoxId);
+ }
+ var flowNameTextBox = new dijit.form.TextBox({
+ id : reportNameTextBoxId,
+ value : reportInfo.name,
+ style : "width:300px;"
+ });
+ flowNameTextBox.placeAt(dojo.byId("report_name_text_box"));
+ flowNameTextBox.startup();
+ var button = new dijit.form.Button({
+ label : "Save",
+ onClick : function() {
+ instance.saveReportName(instance, reportInfo.id);
+ }
+ });
+ button.placeAt(dojo.byId("save_report_name_button"));
+ button.startup();
+ var informationPane = dijit.byId(instance.informationContainerId);
+ _currentInstance.ui.bottomContainer.selectChild(informationPane);
+};
+
+// TODO for now not used
+HAFlow.Main.prototype.onCloseTab_hdfs = function(instance) {
+
};
\ No newline at end of file