fix bugs in xml generator.
add report configuration. Merge branch 'master' of https://github.com/justinliucs/haflow.git Conflicts: src/main/webapp/script/haflow.main.js src/main/webapp/script/haflow.report_list.js
This commit is contained in:
commit
2318e3cc77
|
@ -1,13 +1,17 @@
|
|||
package haflow.dto.entity;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table( name="portlet")
|
||||
|
@ -19,6 +23,7 @@
|
|||
private int position;
|
||||
|
||||
private Report report;
|
||||
private Set<PortletConfiguration> configurations;
|
||||
|
||||
@Id
|
||||
@Column(name="id", length = 16)
|
||||
|
@ -67,4 +72,13 @@
|
|||
this.report = report;
|
||||
}
|
||||
|
||||
@OneToMany(mappedBy = "portlet", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
|
||||
public Set<PortletConfiguration> getConfigurations() {
|
||||
return configurations;
|
||||
}
|
||||
|
||||
public void setConfigurations(Set<PortletConfiguration> configurations) {
|
||||
this.configurations = configurations;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package haflow.dto.entity;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table( name = "portletconfiguration")
|
||||
public class PortletConfiguration {
|
||||
|
||||
private UUID id;
|
||||
private String key;
|
||||
private String value;
|
||||
private Portlet portlet;
|
||||
|
||||
@Id
|
||||
@Column( name="id", length=16)
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Column( name="configurationKey")
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
@Column( name="configurationValue")
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn( name="portletid", referencedColumnName="id")
|
||||
public Portlet getPortlet() {
|
||||
return portlet;
|
||||
}
|
||||
public void setPortlet(Portlet portlet) {
|
||||
this.portlet = portlet;
|
||||
}
|
||||
}
|
|
@ -74,13 +74,15 @@ public class GraphTransformer {
|
|||
nodeConfiguration.put(v.getPath().getSourceEndpoint(), v.getValue());//source end point
|
||||
inputConfiguration.put(v.getPath().getTargetEndpoint(), v.getValue());//target end point
|
||||
if( moduleType != ModuleType.SOURCE && moduleType != ModuleType.DEST ){
|
||||
newGraphNodes.add(node);
|
||||
if( targetModuleType != ModuleType.SOURCE && targetModuleType != ModuleType.DEST ){
|
||||
newGraphEdges.add(v.getPath());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if( moduleType != ModuleType.SOURCE && moduleType != ModuleType.DEST ){
|
||||
newGraphNodes.add(node);
|
||||
}
|
||||
}
|
||||
|
||||
return new DirectedGraph(newGraphNodes, newGraphEdges);
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
package haflow.ui.helper;
|
||||
|
||||
import haflow.dto.entity.Portlet;
|
||||
import haflow.dto.entity.PortletConfiguration;
|
||||
import haflow.dto.entity.Report;
|
||||
import haflow.service.ReportService;
|
||||
import haflow.ui.model.PortletConfigurationItemModel;
|
||||
import haflow.ui.model.PortletModel;
|
||||
import haflow.ui.model.ReportListModel;
|
||||
import haflow.ui.model.SaveReportModel;
|
||||
import haflow.ui.model.ReportResultModel;
|
||||
import haflow.ui.model.SaveReportModel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
|
@ -54,6 +56,15 @@ public class ReportHelper {
|
|||
portletModel.setReportId(portlet.getReport().getId());
|
||||
portletModel.setTitle(portlet.getTitle());
|
||||
portletModel.setType(portlet.getType());
|
||||
Set<PortletConfigurationItemModel> configurations = new HashSet<PortletConfigurationItemModel>();
|
||||
for( PortletConfiguration pc : portlet.getConfigurations() ){
|
||||
PortletConfigurationItemModel pcim = new PortletConfigurationItemModel();
|
||||
pcim.setId(pc.getId());
|
||||
pcim.setKey(pc.getKey());
|
||||
pcim.setValue(pc.getValue());
|
||||
configurations.add(pcim);
|
||||
}
|
||||
portletModel.setConfigurations(configurations);
|
||||
portletModels.add(portletModel);
|
||||
}
|
||||
reportModel.setPortlets(portletModels);
|
||||
|
@ -89,6 +100,16 @@ public class ReportHelper {
|
|||
portlet.setTitle(portletModel.getTitle());
|
||||
portlet.setType(portletModel.getType());
|
||||
|
||||
Set<PortletConfiguration> portletConfigurations = new HashSet<PortletConfiguration>();
|
||||
for( PortletConfigurationItemModel cim : portletModel.getConfigurations()){
|
||||
PortletConfiguration pc = new PortletConfiguration();
|
||||
pc.setId(cim.getId());
|
||||
pc.setKey(cim.getKey());
|
||||
pc.setValue(cim.getValue());
|
||||
pc.setPortlet(portlet);
|
||||
portletConfigurations.add(pc);
|
||||
}
|
||||
portlet.setConfigurations(portletConfigurations);
|
||||
portlets.add(portlet);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
package haflow.ui.model;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement(name = "portletConfiguration")
|
||||
public class PortletConfigurationItemModel {
|
||||
private UUID id;
|
||||
private String key;
|
||||
private String value;
|
||||
|
||||
@XmlElement
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,8 +1,10 @@
|
|||
package haflow.ui.model;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement(name="portlet")
|
||||
|
@ -13,6 +15,7 @@ public class PortletModel {
|
|||
private int position;
|
||||
|
||||
private UUID reportId;
|
||||
private Set<PortletConfigurationItemModel> configurations;
|
||||
|
||||
@XmlElement
|
||||
public UUID getId() {
|
||||
|
@ -53,4 +56,13 @@ public class PortletModel {
|
|||
public void setReportId(UUID reportId) {
|
||||
this.reportId = reportId;
|
||||
}
|
||||
|
||||
@XmlElementWrapper(name="configurations")
|
||||
@XmlElement(name="configuration")
|
||||
public Set<PortletConfigurationItemModel> getConfigurations() {
|
||||
return configurations;
|
||||
}
|
||||
public void setConfigurations(Set<PortletConfigurationItemModel> configurations) {
|
||||
this.configurations = configurations;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
<mapping class="haflow.dto.entity.Report" />
|
||||
<mapping class="haflow.dto.entity.Portlet" />
|
||||
<mapping class="haflow.dto.entity.PortletConfiguration" />
|
||||
|
||||
<mapping class="haflow.dto.profile.NodeAppearance" />
|
||||
<mapping class="haflow.dto.profile.NodeConfiguration" />
|
||||
|
|
|
@ -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");
|
||||
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 = "<div class=\"module\" id=\"module_"
|
||||
+ this.moduleList.modules[i].id + "\"><div>"
|
||||
+ this.moduleList.modules[i].name + "</div></div>";
|
||||
$("#" + 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 = "</br> >>></br> ";
|
||||
if( isError){
|
||||
text += "<div style=\"color:red\">" + message + "</div>";
|
||||
}else{
|
||||
text += "<div style=\"color:green\">" + message + "</div>";
|
||||
}
|
||||
var randomId = HAFlow.generateUUID();
|
||||
text += "<div id='" + randomId + "'>" + "" + "</div>";
|
||||
$("#" + _currentInstance.consoleContainerId).append(text);
|
||||
dojo.window.scrollIntoView(randomId);
|
||||
_currentInstance.ui.bottomContainer.selectChild(consoleContainer);
|
||||
};
|
||||
|
||||
//paintReportList --> haflow.report.js
|
||||
|
||||
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.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 = "<div class=\"module\" id=\"module_"
|
||||
+ this.moduleList.modules[i].id + "\"><div>"
|
||||
+ this.moduleList.modules[i].name + "</div></div>";
|
||||
$("#" + 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 = "</br> >>></br> ";
|
||||
if( isError){
|
||||
text += "<div style=\"color:red\">" + message + "</div>";
|
||||
}else{
|
||||
text += "<div style=\"color:green\">" + message + "</div>";
|
||||
}
|
||||
var randomId = HAFlow.generateUUID();
|
||||
text += "<div id='" + randomId + "'>" + "" + "</div>";
|
||||
$("#" + _currentInstance.consoleContainerId).append(text);
|
||||
dojo.window.scrollIntoView(randomId);
|
||||
_currentInstance.ui.bottomContainer.selectChild(consoleContainer);
|
||||
};
|
||||
|
||||
//paintReportList --> haflow.report.js
|
||||
|
||||
//end initData
|
||||
//end initData
|
||||
|
|
|
@ -2,12 +2,16 @@ dojo.require("dojox.widget.Portlet");
|
|||
dojo.require("dojox.charting.Chart");
|
||||
dojo.require("dojox.charting.plot2d.StackedAreas");
|
||||
dojo.require("dojox.charting.themes.Wetland");
|
||||
dojo.require("dojox/charting/themes/Claro");
|
||||
dojo.require("dojox.charting.axis2d.Default");
|
||||
dojo.require("dojox.charting.plot2d.Columns");
|
||||
dojo.require("dojo.fx.easing");
|
||||
dojo.require("dojox.fx.scroll");
|
||||
dojo.require("dijit.registry");
|
||||
dojo.require("dojo.window");
|
||||
dojo.require("dojox.charting.plot2d.Pie");
|
||||
dojo.require("dojox.charting.axis2d.Default");
|
||||
dojo.require("dojox/charting/action2d/Tooltip");
|
||||
|
||||
HAFlow.Main.prototype.newReport = function(parentId) {
|
||||
var newReportId = HAFlow.generateUUID();
|
||||
|
@ -199,31 +203,36 @@ HAFlow.Main.prototype.paintReportList = function() {
|
|||
HAFlow.Main.prototype.addReport = function(reportId, currentPortlet){
|
||||
var reportContainer = dijit.byId("reportContainer_" + reportId);
|
||||
var portlet = new dojox.widget.Portlet({
|
||||
title : currentPortlet.type
|
||||
title : currentPortlet.type,
|
||||
id : "portlet_" + currentPortlet.id,
|
||||
});
|
||||
if (currentPortlet.type == "text") {
|
||||
portlet.set("content", currentPortlet.text_content);
|
||||
// portlet.set("content", currentPortlet.text_content);
|
||||
portlet.startup();
|
||||
reportContainer.addChild(portlet);//, currentPortlet.index
|
||||
} else if (currentPortlet.type == "curve") {
|
||||
var chartId = currentPortlet.id;
|
||||
var chartDivId = "chart_" + chartId;
|
||||
var chartDivId = "chart_" + chartId + "_div_id";
|
||||
portlet.set("content", "<div id=\"" + chartDivId
|
||||
+ "\" style=\"height:180px; width:480px;\"></div>");
|
||||
portlet.startup();
|
||||
reportContainer.addChild(portlet);//, currentPortlet.index
|
||||
|
||||
var c = new dojox.charting.Chart(chartDivId, {
|
||||
var chart = new dojox.charting.Chart(chartDivId, {
|
||||
// id : "chart_" + chartId,
|
||||
title : currentPortlet.title,// "Production(Quantity)",
|
||||
titlePos : "bottom",
|
||||
titleGap : 25,
|
||||
titleFont : "normal normal normal 15pt Arial",
|
||||
titleFontColor : "orange"
|
||||
});
|
||||
|
||||
var chart_series = [ 1, 2, 0.5, 1.5, 1, 2.8, 0.4 ];
|
||||
c.addPlot("default", {
|
||||
type : dojox.charting.plot2d.StackedAreas,
|
||||
tension : 3
|
||||
// var chart_series2 = [ 2, 4, 1, 3, 2, 5.6, 0.8 ];
|
||||
chart.addPlot("default", {
|
||||
type : dojox.charting.plot2d.StackedAreas,//dojox.charting.plot2d.PiePlot,//StackedAreas,
|
||||
// tension : 3,
|
||||
markers: true,
|
||||
}).addAxis("x", {
|
||||
fixLower : "major",
|
||||
fixUpper : "major"
|
||||
|
@ -234,11 +243,111 @@ HAFlow.Main.prototype.addReport = function(reportId, currentPortlet){
|
|||
min : 0
|
||||
}).setTheme(dojox.charting.themes.Wetland).addSeries("Series A",
|
||||
chart_series).render();
|
||||
|
||||
chart.render();
|
||||
// chart.title = "newTitle";
|
||||
// chart.fullRender();
|
||||
// chart.addSeries("Series B", chart_series2).render();
|
||||
// chart.render();
|
||||
} else {
|
||||
alert("unknown report");
|
||||
}
|
||||
|
||||
dojo.connect(portlet, "onClick", function(event){
|
||||
var portletId = event.currentTarget.id;
|
||||
portletId = portletId.replace("portlet_", "");
|
||||
_currentInstance.onReportPortletClicked(portletId, chart);
|
||||
});
|
||||
};
|
||||
|
||||
HAFlow.Main.prototype.onReportPortletClicked = function(portletId, chart) {
|
||||
var instance = this;
|
||||
var reportInfo = instance.reports[this.currentReportId];
|
||||
var text = "";
|
||||
text += "<table border=\"0\">";
|
||||
text += "<tr style=\"tr\"><th align=\"left\">Portlet Info</th>" + "<td>" + portletId + "</td></tr>";
|
||||
var portlets = reportInfo.portlets;
|
||||
var portlet;
|
||||
for( var i = 0; i < portlets.length; i++ ){
|
||||
if( portlets[i].id == portletId){
|
||||
portlet = portlets[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
var configurations = portlet.configurations;
|
||||
for( var i = 0; i < configurations.length; i++ ){
|
||||
var configuration = configurations[i];
|
||||
var configurationTextBoxSpanId = "portlet_configuration_" + configuration.id + "_text_box_pane";
|
||||
text += "<tr style=\"tr\"><th align=\"left\">" + configuration.key + "</th>"
|
||||
+ "<td><span id=" + configurationTextBoxSpanId + ">" + "</span></td></tr>";
|
||||
}
|
||||
text += "<tr style=\"tr\"><td align=\"left\">" +
|
||||
"<div id=\"save_portlet_configurations_button_pane\" class=\"configuration-content\"></div>" +
|
||||
"</td></tr>";
|
||||
text += "</table>";
|
||||
$("#" + instance.informationContainerId).html(text);
|
||||
|
||||
for( var i = 0; i < configurations.length; i++ ){
|
||||
var configuration = configurations[i];
|
||||
var configurationTextBoxId = "portlet_configuration_" + configuration.id + "_text_box";
|
||||
var configurationTextBoxSpanId = "portlet_configuration_" + configuration.id + "_text_box_pane";
|
||||
if (dijit.byId(configurationTextBoxId) != null) {
|
||||
dijit.registry.remove(configurationTextBoxId);
|
||||
}
|
||||
var configurationTextBox = new dijit.form.TextBox({
|
||||
id : configurationTextBoxId,
|
||||
value : configuration.value,
|
||||
style : "width:300px;"
|
||||
});
|
||||
configurationTextBox.placeAt(dojo.byId(configurationTextBoxSpanId));
|
||||
configurationTextBox.startup();
|
||||
}
|
||||
|
||||
var button = new dijit.form.Button({
|
||||
label : "Save",
|
||||
onClick : function() {
|
||||
instance.savePortletConfiguration(portletId, chart);
|
||||
}
|
||||
});
|
||||
button.placeAt(dojo.byId("save_portlet_configurations_button_pane"));
|
||||
button.startup();
|
||||
|
||||
var informationPane = dijit.byId(instance.informationContainerId);
|
||||
_currentInstance.ui.bottomContainer.selectChild(informationPane);
|
||||
};
|
||||
|
||||
HAFlow.Main.prototype.savePortletConfiguration = function(portletId, chart){
|
||||
|
||||
this.addToConsole("something", false);
|
||||
var reportInfo = this.reports[this.currentReportId];
|
||||
var portlets = reportInfo.portlets;
|
||||
var portlet;
|
||||
for( var i = 0; i < portlets.length; i++ ){
|
||||
if( portlets[i].id == portletId){
|
||||
portlet = portlets[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var configurations = portlet.configurations;
|
||||
for( var i = 0; i < configurations.length; i++ ){
|
||||
var configuration = configurations[i];
|
||||
var configurationTextBoxId = "portlet_configuration_" + configuration.id + "_text_box";
|
||||
var newValue = dijit.byId(configurationTextBoxId).value;
|
||||
if( portlet.type == "text"){
|
||||
var portletWidget = dijit.byId("portlet_" + portletId);
|
||||
portletWidget.set(configuration.key, newValue);
|
||||
}else{
|
||||
//var chartDivId = "chart_" + portletId;
|
||||
var chartWidget = chart;//dijit.byId(chartDivId);
|
||||
// var chartWidget2 = dijit.byId(chartDivId);
|
||||
var plot = chart.getPlot("default");
|
||||
chartWidget.set(configuration.key, newValue);
|
||||
chart.render();
|
||||
}
|
||||
// alert(newValue);
|
||||
}
|
||||
};
|
||||
|
||||
//private
|
||||
HAFlow.Main.prototype.paintReport = function(reportId) {
|
||||
var currentReport = this.reports[reportId];
|
||||
|
@ -262,7 +371,8 @@ HAFlow.Main.prototype.onReportModuleAdded = function(currentInstance, reportId,
|
|||
type: "text",
|
||||
position: 1,
|
||||
|
||||
reportId: reportId,
|
||||
reportId: reportId,
|
||||
configurations : [{id: HAFlow.generateUUID(), key:"content", value:"hello world!"}]
|
||||
};
|
||||
this.reports[reportId].portlets.push(currentPortlet);
|
||||
this.addReport(reportId, currentPortlet);
|
||||
|
@ -273,7 +383,9 @@ HAFlow.Main.prototype.onReportModuleAdded = function(currentInstance, reportId,
|
|||
type: "curve",
|
||||
position: 1,
|
||||
|
||||
reportId: reportId,
|
||||
reportId: reportId,
|
||||
configurations : [{id: HAFlow.generateUUID(), key: 'type', value : "Pie"},
|
||||
{id: HAFlow.generateUUID(), key: 'markers', value: 'true'}]
|
||||
};
|
||||
this.reports[reportId].portlets.push(currentPortlet);
|
||||
this.addReport(reportId, currentPortlet);
|
||||
|
|
|
@ -1,246 +1,252 @@
|
|||
// public
|
||||
HAFlow.Main.prototype.initReportList = function() {
|
||||
var reportListContentPane = new dijit.layout.ContentPane({
|
||||
id: this.reportListContainerId,
|
||||
title: myfile.reports
|
||||
});
|
||||
this.ui.leadingContainer.addChild(reportListContentPane);
|
||||
// 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 += "<table border=\"0\">";
|
||||
text += "<tr style=\"tr\"><th align=\"left\">Flow Info</th>" + "<td>" + reportInfo.id + "</td></tr>";
|
||||
text += "<tr style=\"tr\"><th align=\"left\">IsDirectory</th><td>" + reportInfo.isdirectory + "</td></tr>";
|
||||
text += "<tr style=\"tr\"><th align=\"left\">ParentId</th><td>" + reportInfo.parentid + "</td></tr>";
|
||||
text += "<tr style=\"tr\"><th align=\"left\">Name</th><td><span id=\"report_name_text_box\" class=\"configuration-content\"></span></td></tr>";
|
||||
text += "<tr style=\"tr\"><td align=\"left\"><div id=\"save_report_name_button\" class=\"configuration-content\"></div></td></tr>";
|
||||
text += "</table>";
|
||||
$("#" + 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) {
|
||||
|
||||
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: 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 += "<table border=\"0\">";
|
||||
text += "<tr style=\"tr\"><th align=\"left\">Flow Info</th>" + "<td>" + reportInfo.id + "</td></tr>";
|
||||
text += "<tr style=\"tr\"><th align=\"left\">IsDirectory</th><td>" + reportInfo.isdirectory + "</td></tr>";
|
||||
text += "<tr style=\"tr\"><th align=\"left\">ParentId</th><td>" + reportInfo.parentid + "</td></tr>";
|
||||
text += "<tr style=\"tr\"><th align=\"left\">Name</th><td><span id=\"report_name_text_box\" class=\"configuration-content\"></span></td></tr>";
|
||||
text += "<tr style=\"tr\"><td align=\"left\"><div id=\"save_report_name_button\" class=\"configuration-content\"></div></td></tr>";
|
||||
text += "</table>";
|
||||
$("#" + 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) {
|
||||
|
||||
};
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue