diff --git a/src/main/webapp/script/haflow.admin.js b/src/main/webapp/script/haflow.admin.js index 7453636..f0826fc 100644 --- a/src/main/webapp/script/haflow.admin.js +++ b/src/main/webapp/script/haflow.admin.js @@ -89,7 +89,8 @@ HAFlow.Admin.prototype.loadModuleListData = function() { _currentInstance.generateModuleList(_currentInstance); }, error : function(request, status, error) { - alert(error); + HAFlow.showDialog("Error", + "An error occurred while loading module list: " + error); } }); }; @@ -146,11 +147,17 @@ HAFlow.Admin.prototype.removeModule = function(instance, moduleId) { data : JSON.stringify({}), dataType : "json", success : function(data, status) { - alert(data.success); + if (data.success) { + HAFlow.showDialog("Remove Module", "Module removed."); + } else { + HAFlow.showDialog("Remove Module", + "An error occurred while removing module."); + } instance.loadModuleListData(); }, error : function(request, status, error) { - alert(error); + HAFlow.showDialog("Error", + "An error occurred while removing module: " + error); } }); }; @@ -163,11 +170,17 @@ HAFlow.Admin.prototype.addModule = function(instance, module) { data : JSON.stringify(module), dataType : "json", success : function(data, status) { - alert(data.success); + if (data.success) { + HAFlow.showDialog("Add Module", "Module added."); + } else { + HAFlow.showDialog("Add Module", + "An error occurred while adding module."); + } instance.loadModuleListData(); }, error : function(request, status, error) { - alert(error); + HAFlow.showDialog("Error", + "An error occurred while adding module: " + error); } }); }; diff --git a/src/main/webapp/script/haflow.js b/src/main/webapp/script/haflow.js index 8814080..d58cb93 100644 --- a/src/main/webapp/script/haflow.js +++ b/src/main/webapp/script/haflow.js @@ -1,3 +1,5 @@ +dojo.require("dijit.Dialog"); + function HAFlow() { }; @@ -16,4 +18,13 @@ HAFlow.generateUUID = function() { return b(a(32), 8) + "-" + b(a(16), 4) + "-" + b(16384 | a(12), 4) + "-" + b(32768 | a(14), 4) + "-" + b(a(48), 12); +}; + +HAFlow.showDialog = function(title, content) { + var dialog = new dijit.Dialog({ + title : title, + content : content, + style : "width:400px" + }); + dialog.show(); }; \ No newline at end of file diff --git a/src/main/webapp/script/haflow.main.js b/src/main/webapp/script/haflow.main.js index c56a03f..0c31371 100644 --- a/src/main/webapp/script/haflow.main.js +++ b/src/main/webapp/script/haflow.main.js @@ -49,12 +49,12 @@ HAFlow.Main.prototype.initFlowListData = function() { dataType : "json", success : function(data, status) { _currentInstance.flowList = data; - _currentInstance.buildFlowListTree(); _currentInstance.initModuleListData(); }, error : function(request, status, error) { - alert(error); + HAFlow.showDialog("Error", + "An error occurred while loading flow list: " + error); } }); }; @@ -68,14 +68,20 @@ HAFlow.Main.prototype.initModuleListData = function() { dataType : "json", success : function(data, status) { _currentInstance.moduleList = data; - _currentInstance.paintModuleList(); + _currentInstance.drawLists(_currentInstance); }, error : function(request, status, error) { - alert(error); + HAFlow.showDialog("Error", + "An error occurred while loading module list: " + error); } }); }; +HAFlow.Main.prototype.drawLists = function(instance) { + instance.paintModuleList(); + instance.buildFlowListTree(); +}; + HAFlow.Main.prototype.doInit = function() { this.flows = {}; this.jsPlumb = {}; @@ -326,7 +332,7 @@ HAFlow.Main.prototype.saveFlowName = function(instance, flowId) { var value = $("#" + "flow_" + flowId + "_name").val(); instance.flows[flowId].name = value; instance.getFlowBriefById(instance, flowId).name = value; - var pane=dijit.byId("flowContainerPane_" + flowId); + var pane = dijit.byId("flowContainerPane_" + flowId); pane.title = value; instance.ui.centerContainer.removeChild(pane); instance.ui.centerContainer.addChild(pane); @@ -339,7 +345,8 @@ HAFlow.Main.prototype.saveFlowName = function(instance, flowId) { }); } else { - alert("Please load the flow first!"); + HAFlow.showDialog("Error", + "Please load the flow before saving flow metadata!"); } }; @@ -726,7 +733,8 @@ HAFlow.Main.prototype.refreshFlowList = function() { _currentInstance.flowList = data; }, error : function(request, status, error) { - alert(error); + HAFlow.showDialog("Error", + "An error occurred while refreshing flow list: " + error); } }); }; @@ -795,7 +803,8 @@ HAFlow.Main.prototype.loadFlow = function(flowId) { .byId("flowContainerPane_" + flowId)); }, error : function(request, status, error) { - alert(error); + HAFlow.showDialog("Error", + "An error occurred while loading flow: " + error); } }); } else { @@ -813,11 +822,12 @@ HAFlow.Main.prototype.saveFlow = function(flowId) { contentType : "application/json", data : JSON.stringify(_currentInstance.flows[flowId]), success : function(data, status) { - alert("success"); + HAFlow.showDialog("Save Flow", "Flow saved."); _currentInstance.refreshFlowList(); }, error : function(request, status, error) { - alert(error); + HAFlow.showDialog("Error", "An error occurred while saving flow: " + + error); } }); }; @@ -831,15 +841,16 @@ HAFlow.Main.prototype.removeFlow = function(flowId) { contentType : "application/json", data : JSON.stringify({}), success : function(data, status) { - alert("success"); + HAFlow.showDialog("Remove Flow", "Flow removed."); _currentInstance.ui.centerContainer.removeChild(dijit - .byId("flowContainer_" + flowId)); + .byId("flowContainerPane_" + flowId)); _currentInstance.refreshFlowList(); _currentInstance.flowListStore .remove(_currentInstance.flows[flowId].id); }, error : function(request, status, error) { - alert(error); + HAFlow.showDialog("Error", + "An error occurred while removing flow: " + error); } }); }; diff --git a/src/main/webapp/style/haflow.ui.css b/src/main/webapp/style/haflow.ui.css index 2573cd9..b620946 100644 --- a/src/main/webapp/style/haflow.ui.css +++ b/src/main/webapp/style/haflow.ui.css @@ -15,6 +15,10 @@ body { width: 100%; } +.claro .dijitDialogUnderlay { + background: #000; +} + #main { padding: 0px; width: 100%;