Преглед изворни кода

Merge pull request #6831 from GordonSmith/HPCC-12801

HPCC-12801 ECL Watch allow user to select target folder for file upload

Reviewed-By: Miguel Vazquez <miguel.vazquez@lexisnexis.com>
Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman пре 10 година
родитељ
комит
7eedbca521

+ 27 - 9
esp/src/eclwatch/LZBrowseWidget.js

@@ -98,7 +98,8 @@ define([
             this.landingZonesTab = registry.byId(this.id + "_LandingZones");
             this.uploader = registry.byId(this.id + "Upload");
             this.uploadFileList = registry.byId(this.id + "UploadFileList");
-            this.dropZoneSelect = registry.byId(this.id + "DropZoneTargetSelect");
+            this.dropZoneTargetSelect = registry.byId(this.id + "DropZoneTargetSelect");
+            this.dropZoneFolderSelect = registry.byId(this.id + "DropZoneFolderSelect");
             this.fileListDialog = registry.byId(this.id + "FileListDialog");
             this.overwriteCheckbox = registry.byId(this.id + "FileOverwriteCheckbox");
 
@@ -176,11 +177,11 @@ define([
                 this._onUploadSubmit();
                 this.fileListDialog.hide();
             } else {
-                var item = context.dropZoneSelect.get("row");
+                var target = context.dropZoneTargetSelect.get("row");
                 FileSpray.FileList({
                     request: {
-                        Netaddr: item.machine.Netaddress,
-                        Path: item.machine.Directory
+                        Netaddr: target.machine.Netaddress,
+                        Path: context.getUploadPath()
                     }
                 }).then(function (response) {
                     var fileName = "";
@@ -216,9 +217,15 @@ define([
             }
         },
 
+        getUploadPath: function () {
+            var target = this.dropZoneTargetSelect.get("row");
+            var folder = this.dropZoneFolderSelect.get("row");
+            return target.machine.Directory + (this.endsWith(target.machine.Directory, "/") ? "" : "/") + folder.value;
+        },
+
         _onUploadSubmit: function (event) {
-            var item = this.dropZoneSelect.get("row");
-            this.uploader.set("uploadUrl", "/FileSpray/UploadFile.json?upload_&rawxml_=1&NetAddress=" + item.machine.Netaddress + "&OS=" + item.machine.OS + "&Path=" + item.machine.Directory);
+            var target = this.dropZoneTargetSelect.get("row");
+            this.uploader.set("uploadUrl", "/FileSpray/UploadFile.json?upload_&rawxml_=1&NetAddress=" + target.machine.Netaddress + "&OS=" + target.machine.OS + "&Path=" + this.getUploadPath());
             this.uploader.upload();
         },
 
@@ -427,10 +434,21 @@ define([
             this.sprayBlobDestinationSelect.init({
                 Groups: true
             });
-            this.dropZoneSelect.init({
-                DropZones: true
+            var context = this;
+            this.dropZoneTargetSelect.init({
+                DropZones: true,
+                callback: function (value, row) {
+                    if (context.dropZoneFolderSelect) {
+                        context.dropZoneFolderSelect._dropZoneTarget = row;
+                        context.dropZoneFolderSelect.defaultValue = context.dropZoneFolderSelect.get("value");
+                        context.dropZoneFolderSelect.loadDropZoneFolders();
+                    }
+                }
+            });
+            this.dropZoneFolderSelect.init({
+                DropZoneFolders: true,
+                includeBlank: true
             });
-
         },
 
         initTab: function () {

+ 28 - 0
esp/src/eclwatch/TargetSelectWidget.js

@@ -62,6 +62,8 @@ define([
                 this.loadGroups();
             } else if (params.DropZones === true) {
                 this.loadDropZones();
+            } else if (params.DropZoneFolders === true) {
+                this.loadDropZoneFolders();
             } else if (params.WUState === true) {
                 this.loadWUState();
             } else if (params.DFUState === true) {
@@ -131,6 +133,32 @@ define([
             });
         },
 
+        loadDropZoneFolders: function () {
+            var context = this;
+            if (this._dropZoneTarget) {
+                FileSpray.FileList({
+                    request: {
+                        Netaddr: this._dropZoneTarget.machine.Netaddress,
+                        Path: this._dropZoneTarget.machine.Directory,
+                        OS: this._dropZoneTarget.machine.OS
+                    }
+                }).then(function (response) {
+                    if (lang.exists("FileListResponse.files.PhysicalFileStruct", response)) {
+                        var files = response.FileListResponse.files.PhysicalFileStruct;
+                        for (var i = 0; i < files.length; ++i) {
+                            if (files[i].isDir) {
+                                context.options.push({
+                                    label: files[i].name,
+                                    value: files[i].name
+                                });
+                            }
+                        }
+                        context._postLoad();
+                    }
+                });
+            }
+        },
+
         loadGroups: function () {
             var context = this;
             WsTopology.TpGroupQuery({

+ 1 - 0
esp/src/eclwatch/nls/hpcc.js

@@ -167,6 +167,7 @@ define({root:
     FindPrevious: "Find Previous",
     FirstName: "First Name",
     Fixed: "Fixed",
+    Folder: "Folder",
     Format: "Format",
     FromDate: "From Date",
     FromSizes: "From Sizes",

+ 1 - 0
esp/src/eclwatch/templates/LZBrowseWidget.html

@@ -224,6 +224,7 @@
         <div class="dijitDialogPaneContentArea">
             <div data-dojo-props="cols:1" data-dojo-type="hpcc.TableContainer">
                 <input id="${id}DropZoneTargetSelect" title="${i18n.LandingZone}:" style="width: 95%;" data-dojo-type="TargetSelectWidget" />
+                <input id="${id}DropZoneFolderSelect" title="${i18n.Folder}:" style="width: 95%;" data-dojo-type="TargetSelectWidget" />
             </div>
             <p>
             <div id="${id}UploadFileList" class="dijitDialogPaneContentArea" data-dojo-props="uploaderId: '${id}Upload'" data-dojo-type="dojox.form.uploader.FileList"></div>