/*############################################################################## # HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. ############################################################################## */ define([ "dojo/_base/declare", "dojo/_base/lang", "dojo/i18n", "dojo/i18n!./nls/common", "dojo/i18n!./nls/WUDetailsWidget", "dojo/dom", "dojo/dom-form", "dojo/dom-attr", "dojo/request/iframe", "dojo/dom-class", "dojo/query", "dojo/store/Memory", "dojo/store/Observable", "dijit/registry", "dgrid/OnDemandGrid", "dgrid/Keyboard", "dgrid/Selection", "dgrid/selector", "dgrid/extensions/ColumnResizer", "dgrid/extensions/DijitRegistry", "hpcc/_TabContainerWidget", "hpcc/ESPWorkunit", "hpcc/ESPRequest", "hpcc/ECLSourceWidget", "hpcc/TargetSelectWidget", "hpcc/GraphsWidget", "hpcc/ResultsWidget", "hpcc/SourceFilesWidget", "hpcc/InfoGridWidget", "hpcc/LogsWidget", "hpcc/TimingPageWidget", "hpcc/ECLPlaygroundWidget", "hpcc/VizWidget", "hpcc/WsWorkunits", "dojo/text!../templates/WUDetailsWidget.html", "dijit/layout/BorderContainer", "dijit/layout/TabContainer", "dijit/layout/ContentPane", "dijit/form/Form", "dijit/form/Textarea", "dijit/form/Button", "dijit/Toolbar", "dijit/TooltipDialog", "dijit/TitlePane", "dijit/form/TextBox", "dijit/Dialog", "dijit/form/SimpleTextarea", "hpcc/TableContainer" ], function (declare, lang, i18n, nlsCommon, nlsSpecific, dom, domForm, domAttr, iframe, domClass, query, Memory, Observable, registry, OnDemandGrid, Keyboard, Selection, selector, ColumnResizer, DijitRegistry, _TabContainerWidget, ESPWorkunit, ESPRequest, EclSourceWidget, TargetSelectWidget, GraphsWidget, ResultsWidget, SourceFilesWidget, InfoGridWidget, LogsWidget, TimingPageWidget, ECLPlaygroundWidget, VizWidget, WsWorkunits, template) { return declare("WUDetailsWidget", [_TabContainerWidget], { templateString: template, baseClass: "WUDetailsWidget", i18n: lang.mixin(nlsCommon, nlsSpecific), summaryWidget: null, resultsWidget: null, resultsWidgetLoaded: false, filesWidget: null, filesWidgetLoaded: false, timersWidget: null, timersWidgetLoaded: false, graphsWidget: null, graphsWidgetLoaded: false, vizWidget: null, vizWidgetLoaded: false, sourceWidget: null, sourceWidgetLoaded: false, logsWidget: null, logsWidgetLoaded: false, playgroundWidget: null, playgroundWidgetLoaded: false, xmlWidget: null, xmlWidgetLoaded: false, publishForm: null, wu: null, buildVersion: null, espIPAddress: null, thorIPAddress: null, zapDescription: null, warnHistory: null, warnTimings: null, prevState: "", postCreate: function (args) { this.inherited(arguments); this.summaryWidget = registry.byId(this.id + "_Summary"); this.variablesWidget = registry.byId(this.id + "_Variables"); this.resultsWidget = registry.byId(this.id + "_Results"); this.filesWidget = registry.byId(this.id + "_Files"); this.vizWidget = registry.byId(this.id + "_Visualize"); this.timersWidget = registry.byId(this.id + "_Timers"); this.graphsWidget = registry.byId(this.id + "_Graphs"); this.sourceWidget = registry.byId(this.id + "_Source"); this.logsWidget = registry.byId(this.id + "_Logs"); this.playgroundWidget = registry.byId(this.id + "_Playground"); this.xmlWidget = registry.byId(this.id + "_XML"); this.publishForm = registry.byId(this.id + "PublishForm"); this.zapDescription = registry.byId(this.id + "ZapDescription"); this.warnHistory = registry.byId(this.id + "WarnHistory"); this.warnTimings = registry.byId(this.id + "WarnTimings"); this.infoGridWidget = registry.byId(this.id + "InfoContainer"); this.zapDialog = registry.byId(this.id + "ZapDialog"); }, startup: function (args) { this.inherited(arguments); var store = new Memory({ idProperty: "Id", data: [] }); this.variablesStore = Observable(store); this.variablesGrid = new declare([OnDemandGrid, Keyboard, ColumnResizer, DijitRegistry])({ allowSelectAll: true, columns: { Name: { label: "Name", width: 360 }, Value: { label: "Value" } }, store: this.variablesStore }, this.id + "VariablesGrid"); this.variablesGrid.startup(); }, destroy: function (args) { this.zapDialog.destroyRecursive(); this.inherited(arguments); }, getTitle: function () { return this.i18n.title; }, _onCancelDialog: function (){ this.zapDialog.hide(); }, // Hitched actions --- _onSave: function (event) { var protectedCheckbox = registry.byId(this.id + "Protected"); var context = this; this.wu.update({ Description: dom.byId(context.id + "Description").value, Jobname: dom.byId(context.id + "Jobname").value, Protected: protectedCheckbox.get("value") }, null); }, _onRefresh: function (event) { this.wu.refresh(true); }, _onClone: function (event) { this.wu.clone(); }, _onDelete: function (event) { this.wu.doDelete(); }, _onResubmit: function (event) { this.wu.resubmit(); }, _onSetToFailed: function (event) { this.wu.setToFailed(); }, _onAbort: function (event) { this.wu.abort(); }, _onRestart: function (event) { this.wu.restart(); }, _onPublish: function (event) { if (this.publishForm.validate()) { registry.byId(this.id + "Publish").closeDropDown(); this.wu.publish(dom.byId(this.id + "Jobname2").value, dom.byId(this.id + "RemoteDali").value); } }, onZapReport: function (event) { var context = this; WsWorkunits.WUGetZAPInfo({ request: { WUID: this.wu.Wuid } }).then(function (response) { context.zapDialog.show(); if (lang.exists("WUGetZAPInfoResponse", response)) { context.updateInput("ZapWUID", null, response.WUGetZAPInfoResponse.WUID); context.updateInput("BuildVersion", null, response.WUGetZAPInfoResponse.BuildVersion); context.updateInput("ESPIPAddress", null, response.WUGetZAPInfoResponse.ESPIPAddress); context.updateInput("ThorIPAddress", null, response.WUGetZAPInfoResponse.ThorIPAddress); context.buildVersion = response.WUGetZAPInfoResponse.BuildVersion; context.espIPAddress = response.WUGetZAPInfoResponse.ESPIPAddress; context.thorIPAddress = response.WUGetZAPInfoResponse.ThorIPAddress; } }); }, // Implementation --- init: function (params) { if (this.inherited(arguments)) return; if (params.Wuid) { this.summaryWidget.set("title", params.Wuid); dom.byId(this.id + "Wuid").innerHTML = params.Wuid; this.wu = ESPWorkunit.Get(params.Wuid); var data = this.wu.getData(); for (var key in data) { this.updateInput(key, null, data[key]); } var context = this; this.wu.watch(function (name, oldValue, newValue) { context.updateInput(name, oldValue, newValue); }); this.wu.refresh(); } this.infoGridWidget.init(params); this.selectChild(this.summaryWidget, true); }, initTab: function () { if (!this.wu) { return } var currSel = this.getSelectedChild(); if (currSel.id == this.resultsWidget.id && !this.resultsWidgetLoaded) { this.resultsWidgetLoaded = true; this.resultsWidget.init({ Wuid: this.wu.Wuid }); } else if (currSel.id == this.filesWidget.id && !this.filesWidgetLoaded) { this.filesWidgetLoaded = true; this.filesWidget.init({ Wuid: this.wu.Wuid, SourceFiles: true }); } else if (currSel.id == this.timersWidget.id && !this.timersWidgetLoaded) { this.timersWidgetLoaded = true; this.timersWidget.init({ Wuid: this.wu.Wuid }); } else if (currSel.id == this.graphsWidget.id && !this.graphsWidgetLoaded) { this.graphsWidgetLoaded = true; this.graphsWidget.init({ Wuid: this.wu.Wuid }); } else if (currSel.id == this.vizWidget.id && !this.vizWidgetLoaded) { this.vizWidgetLoaded = true; this.vizWidget.init({ Wuid: this.wu.Wuid }); } else if (currSel.id == this.sourceWidget.id && !this.sourceWidgetLoaded) { this.sourceWidgetLoaded = true; this.sourceWidget.init({ Wuid: this.wu.Wuid }); } else if (currSel.id == this.logsWidget.id && !this.logsWidgetLoaded) { this.logsWidgetLoaded = true; this.logsWidget.init({ Wuid: this.wu.Wuid }); } else if (currSel.id == this.playgroundWidget.id && !this.playgroundWidgetLoaded) { this.playgroundWidgetLoaded = true; this.playgroundWidget.init({ Wuid: this.wu.Wuid, Target: this.wu.Cluster }); } else if (currSel.id == this.xmlWidget.id && !this.xmlWidgetLoaded) { this.xmlWidgetLoaded = true; this.xmlWidget.init({ Wuid: this.wu.Wuid }); } }, resetPage: function () { }, objectToText: function (obj) { var text = "" for (var key in obj) { text += "