123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297 |
- /*##############################################################################
- # 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([
- "exports",
- "dojo/_base/declare",
- "dojo/_base/lang",
- "dojo/_base/array",
- "dojo/dom",
- "dojo/dom-attr",
- "dojo/dom-class",
- "dojo/dom-form",
- "dojo/query",
- "dijit/layout/BorderContainer",
- "dijit/layout/TabContainer",
- "dijit/layout/ContentPane",
- "dijit/Toolbar",
- "dijit/TooltipDialog",
- "dijit/form/Form",
- "dijit/form/SimpleTextarea",
- "dijit/form/TextBox",
- "dijit/form/Button",
- "dijit/form/DropDownButton",
- "dijit/TitlePane",
- "dijit/registry",
- "hpcc/_TabContainerWidget",
- "hpcc/ResultWidget",
- "hpcc/ECLSourceWidget",
- "hpcc/FilePartsWidget",
- "hpcc/WUDetailsWidget",
- "hpcc/DFUWUDetailsWidget",
- "hpcc/TargetSelectWidget",
- "hpcc/ESPLogicalFile",
- "hpcc/ESPDFUWorkunit",
- "dojo/text!../templates/LFDetailsWidget.html",
- "dijit/TooltipDialog"
- ], function (exports, declare, lang, arrayUtil, dom, domAttr, domClass, domForm, query,
- BorderContainer, TabContainer, ContentPane, Toolbar, TooltipDialog, Form, SimpleTextarea, TextBox, Button, DropDownButton, TitlePane, registry,
- _TabContainerWidget, ResultWidget, EclSourceWidget, FilePartsWidget, WUDetailsWidget, DFUWUDetailsWidget, TargetSelectWidget, ESPLogicalFile, ESPDFUWorkunit,
- template) {
- exports.fixCircularDependency = declare("LFDetailsWidget", [_TabContainerWidget], {
- templateString: template,
- baseClass: "LFDetailsWidget",
- borderContainer: null,
- copyDialog: null,
- renameDialog: null,
- desprayDialog: null,
- summaryWidget: null,
- contentWidget: null,
- sourceWidget: null,
- defWidget: null,
- xmlWidget: null,
- filePartsWidget: null,
- workunitWidget: null,
- dfuWorkunitWidget: null,
- logicalFile: null,
- prevState: "",
- postCreate: function (args) {
- this.inherited(arguments);
- this.copyDialog = registry.byId(this.id + "CopyDialog");
- this.renameDialog = registry.byId(this.id + "RenameDialog");
- this.desprayDialog = registry.byId(this.id + "DesprayDialog");
- this.summaryWidget = registry.byId(this.id + "_Summary");
- this.contentWidget = registry.byId(this.id + "_Content");
- this.sourceWidget = registry.byId(this.id + "_Source");
- this.defWidget = registry.byId(this.id + "_DEF");
- this.xmlWidget = registry.byId(this.id + "_XML");
- this.filePartsWidget = registry.byId(this.id + "_FileParts");
- this.workunitWidget = registry.byId(this.id + "_Workunit");
- this.dfuWorkunitWidget = registry.byId(this.id + "_DFUWorkunit");
- this.copyTargetSelect = registry.byId(this.id + "CopyTargetSelect");
- this.desprayTargetSelect = registry.byId(this.id + "DesprayTargetSelect");
- },
- // Hitched actions ---
- _onRefresh: function (event) {
- this.logicalFile.refresh();
- },
- _onSave: function (event) {
- var context = this;
- this.logicalFile.save(dom.byId(context.id + "Description").value);
- },
- _onDelete: function (event) {
- this.logicalFile.doDelete({
- load: function (response) {
- }
- });
- },
- getTitle: function () {
- return "Logical File Details";
- },
- _handleResponse: function (wuidQualifier, response) {
- if (lang.exists(wuidQualifier, response)) {
- var wu = ESPDFUWorkunit.Get(lang.getObject(wuidQualifier, false, response));
- wu.startMonitor(true);
- var tab = this.ensurePane(this.id + "_" + wu.ID, {
- Wuid: wu.ID
- });
- if (tab) {
- this.selectChild(tab);
- }
- }
- },
- _onCopyOk: function (event) {
- if (this.copyDialog.validate()) {
- var context = this;
- this.logicalFile.copy({
- request: domForm.toObject(this.id + "CopyDialog")
- }).then(function (response) {
- context._handleResponse("CopyResponse.result", response);
- });
- registry.byId(this.id + "CopyDropDown").closeDropDown();
- }
- },
- _onRenameOk: function (event) {
- if (this.renameDialog.validate()) {
- var context = this;
- this.logicalFile.rename({
- request: domForm.toObject(this.id + "RenameDialog")
- }).then(function (response) {
- context._handleResponse("RenameResponse.wuid", response);
- });
- registry.byId(this.id + "RenameDropDown").closeDropDown();
- }
- },
- _onDesprayOk: function (event) {
- if (this.desprayDialog.validate()) {
- var context = this;
- this.logicalFile.despray({
- request: domForm.toObject(this.id + "DesprayDialog")
- }).then(function (response) {
- context._handleResponse("DesprayResponse.wuid", response);
- });
- registry.byId(this.id + "DesprayDropDown").closeDropDown();
- }
- },
- // Implementation ---
- init: function (params) {
- if (this.inherited(arguments))
- return;
- var context = this;
- if (params.Name) {
- this.logicalFile = ESPLogicalFile.Get(params.Name);
- var data = this.logicalFile.getData();
- for (var key in data) {
- this.updateInput(key, null, data[key]);
- }
- this.logicalFile.watch(function (name, oldValue, newValue) {
- context.updateInput(name, oldValue, newValue);
- });
- this.logicalFile.refresh();
- }
- this.selectChild(this.summaryWidget, true);
- this.copyTargetSelect.init({
- Groups: true
- });
- this.desprayTargetSelect.init({
- DropZones: true,
- callback: function (value, item) {
- context.updateInput("DesprayTargetIPAddress", null, item.machine.Netaddress);
- context.updateInput("DesprayTargetPath", null, item.machine.Directory + "/" + context.logicalFile.Filename);
- }
- });
- },
- initTab: function() {
- var currSel = this.getSelectedChild();
- if (currSel && !currSel.initalized) {
- if (currSel.id == this.summaryWidget.id) {
- } else if (currSel.id == this.contentWidget.id) {
- this.contentWidget.init({
- LogicalName: this.logicalFile.Name
- });
- } else if (currSel.id == this.sourceWidget.id) {
- this.sourceWidget.init({
- ECL: this.logicalFile.Ecl
- });
- } else if (currSel.id == this.defWidget.id) {
- var context = this;
- this.logicalFile.fetchDEF(function (response) {
- context.defWidget.init({
- ECL: response
- });
- });
- } else if (currSel.id == this.xmlWidget.id) {
- var context = this;
- this.logicalFile.fetchXML(function (response) {
- context.xmlWidget.init({
- ECL: response
- });
- });
- } else if (currSel.id == this.filePartsWidget.id) {
- this.filePartsWidget.init({
- fileParts: lang.exists("logicalFile.DFUFileParts.DFUPart", this) ? this.logicalFile.DFUFileParts.DFUPart : []
- });
- } else if (this.workunitWidget && currSel.id == this.workunitWidget.id) {
- this.workunitWidget.init({
- Wuid: this.logicalFile.Wuid
- });
- } else if (this.dfuWorkunitWidget && currSel.id == this.dfuWorkunitWidget.id) {
- this.dfuWorkunitWidget.init({
- Wuid: this.logicalFile.Wuid
- });
- } else {
- currSel.init(currSel.params);
- }
- }
- },
- showMessage: function (msg) {
- },
- updateInput: function (name, oldValue, newValue) {
- var registryNode = registry.byId(this.id + name);
- if (registryNode) {
- registryNode.set("value", newValue);
- } else {
- var domElem = dom.byId(this.id + name);
- if (domElem) {
- switch (domElem.tagName) {
- case "SPAN":
- case "DIV":
- domAttr.set(this.id + name, "innerHTML", newValue);
- break;
- case "INPUT":
- case "TEXTAREA":
- domAttr.set(this.id + name, "value", newValue);
- break;
- default:
- alert(domElem.tagName);
- }
- }
- }
- if (name === "Wuid") {
- if (!newValue) {
- this.removeChild(this.workunitWidget);
- this.workunitWidget = null;
- this.removeChild(this.dfuWorkunitWidget);
- this.dfuWorkunitWidget = null;
- } else if (this.workunitWidget && newValue[0] === "D") {
- this.removeChild(this.workunitWidget);
- this.workunitWidget = null;
- } else if (this.dfuWorkunitWidget) {
- this.removeChild(this.dfuWorkunitWidget);
- this.dfuWorkunitWidget = null;
- }
- }
- if (name === "Name") {
- this.updateInput("RenameSourceName", oldValue, newValue);
- this.updateInput("RenameTargetName", oldValue, newValue);
- this.updateInput("DespraySourceName", oldValue, newValue);
- this.updateInput("CopySourceName", oldValue, newValue);
- this.updateInput("CopyTargetName", oldValue, newValue);
- }
- },
- ensurePane: function (id, params) {
- var retVal = registry.byId(id);
- if (!retVal) {
- var context = this;
- retVal = new DFUWUDetailsWidget.fixCircularDependency({
- id: id,
- title: params.Wuid,
- closable: true,
- params: params
- });
- this.addChild(retVal);
- }
- return retVal;
- }
- });
- });
|