浏览代码

Merge pull request #9923 from miguelvazq/HPCC-16377

HPCC-16377 Display file history information

Reviewed-By: Gordon Smith <gordon.smith@lexisnexis.com>
Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 8 年之前
父节点
当前提交
d4e11c0731

+ 129 - 0
esp/src/eclwatch/FileHistoryWidget.js

@@ -0,0 +1,129 @@
+/*##############################################################################
+#    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/hpcc",
+    "dojo/_base/array",
+
+    "dijit/registry",
+
+    "dijit/form/Button",
+    "dijit/ToolbarSeparator",
+
+    "hpcc/GridDetailsWidget",
+    "hpcc/WsDfu",
+    "hpcc/ESPUtil"
+], function (declare, lang, i18n, nlsHPCC, arrayUtil,
+                registry, Button, ToolbarSeparator,
+                GridDetailsWidget, WsDfu, ESPUtil) {
+    return declare("FileHistoryWidget", [GridDetailsWidget], {
+        i18n: nlsHPCC,
+        gridTitle: nlsHPCC.History,
+        idProperty: "Name",
+
+        init: function (params) {
+            if (this.inherited(arguments))
+                return;
+            this._refreshActionState();
+            this.refreshGrid();
+            this.initTab();
+        },
+
+        _onRefresh: function (event) {
+            this.refreshGrid();
+        },
+
+        createGrid: function (domID) {
+            var context = this;
+
+            this.openButton = registry.byId(this.id + "Open");
+
+            this.eraseHistory = new Button({
+                label: context.i18n.EraseHistory,
+                onClick: function () { context._onErase(); }
+            }).placeAt(this.openButton, "after");
+
+            var tmpSplitter = new ToolbarSeparator().placeAt(this.eraseHistory.domNode, "before");
+
+            dojo.destroy(this.openButton);
+
+            var retVal = new declare([ESPUtil.Grid(true, true)])({
+                store: this.store,
+                columns: {
+                    Name: {label: this.i18n.Name, width:70, sortable: false},
+                    IP: {label: this.i18n.IP, width: 30, sortable: false},
+                    Operation: {label: this.i18n.Operation, width: 30, sortable: false},
+                    Owner: {label: this.i18n.Owner, width: 30, sortable: false},
+                    Path: {label: this.i18n.Path, width: 70, sortable: false},
+                    Timestamp: {label: this.i18n.TimeStamp, width: 30, sortable: false},
+                    Workunit: {label: this.i18n.Workunit, width: 30, sortable: false}
+                }
+            }, domID);
+
+            return retVal;
+        },
+
+        _onErase: function (event) {
+            var context = this;
+            if (confirm(this.i18n.EraseHistoryQ + "\n" + this.params.Name + "?")) {
+                WsDfu.EraseHistory({
+                    request: {
+                        Name: context.params.Name
+                    }
+                }).then(function (response) {
+                    if (response) {
+                        context.refreshGrid();
+                    }
+                });
+            }
+        },
+
+        refreshGrid: function () {
+            var context = this;
+
+            WsDfu.ListHistory({
+                request: {
+                    Name: context.params.Name
+                }
+            }).then(function (response) {
+                var results = [];
+                var newRows = [];
+                if (lang.exists("ListHistoryResponse.History.Origin", response)) {
+                    results = response.ListHistoryResponse.History.Origin;
+                }
+
+                if (results.length) {
+                    arrayUtil.forEach(results, function (row, idx) {
+                       newRows.push({
+                            Name: row.Name,
+                            IP: row.IP,
+                            Operation: row.Operation,
+                            Owner: row.Owner,
+                            Path: row.Path,
+                            Timestamp: row.Timestamp,
+                            Workunit: row.Workunit
+                        });
+                    });
+                }
+
+                context.store.setData(newRows);
+                context.grid.set("query", {});
+            });
+        }
+    });
+});

+ 9 - 2
esp/src/eclwatch/LFDetailsWidget.js

@@ -47,6 +47,7 @@ define([
     "hpcc/ESPDFUWorkunit",
     "hpcc/FileBelongsToWidget",
     "hpcc/FileSpray",
+    "hpcc/FileHistoryWidget",
 
     "dojo/text!../templates/LFDetailsWidget.html",
 
@@ -60,7 +61,7 @@ define([
 
 ], function (exports, declare, lang, i18n, nlsHPCC, arrayUtil, dom, domAttr, domClass, domForm, query,
                 BorderContainer, TabContainer, ContentPane, Toolbar, TooltipDialog, Form, SimpleTextarea, TextBox, Button, DropDownButton, TitlePane, registry,
-                _TabContainerWidget, DelayLoadWidget, TargetSelectWidget, TargetComboBoxWidget, ESPLogicalFile, ESPDFUWorkunit, FileBelongsToWidget, FileSpray,
+                _TabContainerWidget, DelayLoadWidget, TargetSelectWidget, TargetComboBoxWidget, ESPLogicalFile, ESPDFUWorkunit, FileBelongsToWidget, FileSpray, FileHistoryWidget,
                 template) {
     exports.fixCircularDependency = declare("LFDetailsWidget", [_TabContainerWidget], {
         templateString: template,
@@ -83,6 +84,7 @@ define([
         workunitWidget: null,
         dfuWorkunitWidget: null,
         fileBelongsTo: null,
+        fileHistoryWidget: null,
 
         logicalFile: null,
         prevState: "",
@@ -102,6 +104,7 @@ define([
             this.queriesWidget = registry.byId(this.id + "_Queries");
             this.workunitWidget = registry.byId(this.id + "_Workunit");
             this.dfuWorkunitWidget = registry.byId(this.id + "_DFUWorkunit");
+            this.fileHistoryWidget = registry.byId(this.id + "_FileHistory");
             this.copyTargetSelect = registry.byId(this.id + "CopyTargetSelect");
             this.desprayTargetSelect = registry.byId(this.id + "DesprayTargetSelect");
             this.desprayTooltiopDialog = registry.byId(this.id + "DesprayTooltipDialog");
@@ -299,6 +302,10 @@ define([
                         NodeGroup: this.logicalFile.NodeGroup,
                         Name: this.logicalFile.Name
                     });
+                 } else if (currSel.id == this.fileHistoryWidget.id) {
+                    this.fileHistoryWidget.init({
+                        Name: this.logicalFile.Name
+                    });
                  } else {
                     currSel.init(currSel.params);
                 }
@@ -411,4 +418,4 @@ define([
             this.setDisabled(this.id + "ReplicateDropDown", !this.logicalFile.CanReplicateFlag || this.logicalFile.ReplicateFlag === false);
         }
     });
-});
+});

+ 8 - 1
esp/src/eclwatch/WsDfu.js

@@ -171,6 +171,14 @@ define([
             return ESPRequest.send("WsDfu", "DFUSpace", params);
         },
 
+        ListHistory: function (params) {
+            return ESPRequest.send("WsDfu", "ListHistory", params);
+        },
+
+        EraseHistory: function (params) {
+            return ESPRequest.send("WsDfu", "EraseHistory", params);
+        },
+
         DFUInfo: function (params) {
             return ESPRequest.send("WsDfu", "DFUInfo", params).then(function (response) {
                 if (lang.exists("Exceptions.Exception", response)) {
@@ -220,4 +228,3 @@ define([
 
     return self;
 });
-

+ 6 - 1
esp/src/eclwatch/nls/es/hpcc.js

@@ -175,6 +175,8 @@ define(
     EnglishQ: "Ingles?",
     EnterAPercentage: "Entre un porcentaje",
     EnterAPercentageOrMB: "Entre un porcentaje o MB",
+    EraseHistory: "Borrar Historia",
+    EraseHistoryQ: "Borrar historia de archivo:",
     Error: "Error",
     Errorparsingserverresult: "Error analizando los resultados del servidor",
     Errors: "Errores",
@@ -395,6 +397,7 @@ define(
     OpenSafeMode: "Abrir (modo seguro)",
     OpenSource: "Código Abierto",
     OpenTreeMode: "Abrir (vista en arbol)",
+    Operation: "Operación",
     Operations: "Operaciones",
     Options: "Opciones",
     OriginalFile: "Archivo Original",
@@ -629,6 +632,7 @@ define(
     ThorNetworkAddress: "Dirección de red de Thor",
     ThorProcess: "Proceso de Thor",
     Time: "Tiempo",
+    TimeStamp: "Marca de hora",
     Timers: "Cronómetros",
     TimeSeconds: "Tiempo (Segundos)",
     TimeStarted: "Tiempo empezado",
@@ -664,6 +668,7 @@ define(
     title_HPCCPlatformOps: "ECL Watch - Operaciones",
     title_HPCCPlatformRoxie: "ECL Watch - Roxie",
     title_HPCCPlatformServicesPlugin: "ECL Watch - Plugins",
+    title_History: "Historia",
     title_Inputs: "Entradas",
     title_LFDetails: "Detalles de archivos lógicos",
     title_LibrariesUsed: "Librerias Usadas",
@@ -781,4 +786,4 @@ define(
     ZoomAll: "Aumentar todo",
     ZoomWidth: "Aumentar al ancho"
 })
-);
+);

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

@@ -181,6 +181,8 @@ define({root:
     EnglishQ: "English?",
     EnterAPercentage: "Enter a percentage",
     EnterAPercentageOrMB: "Enter A Percentage or MB",
+    EraseHistory: "Erase History",
+    EraseHistoryQ: "Erase history for:",
     Error: "Error",
     Errorparsingserverresult: "Error parsing server result",
     Errors: "Error(s)",
@@ -400,6 +402,7 @@ define({root:
     OpenLegacyMode: "Open (legacy)",
     OpenNativeMode: "Open (native)",
     OpenSource: "Open Source",
+    Operation: "Operation",
     Operations: "Operations",
     Options: "Options",
     OriginalFile: "Original File",
@@ -638,6 +641,7 @@ define({root:
     ThorMasterAddress: "Thor Master Address",
     ThorProcess: "Thor Process",
     Time: "Time",
+    TimeStamp: "Time Stamp",
     TimeSeconds: "Time (Seconds)",
     TimeStarted: "Time Started",
     TimeStopped: "Time Stopped",
@@ -673,6 +677,7 @@ define({root:
     title_HPCCPlatformOps: "ECL Watch - Operations",
     title_HPCCPlatformRoxie: "ECL Watch - Roxie",
     title_HPCCPlatformServicesPlugin: "ECL Watch - Plugins",
+    title_History: "History",
     title_Inputs: "Inputs",
     title_Log: "Log File",
     title_LFDetails: "Logical File Details",

+ 2 - 0
esp/src/eclwatch/templates/LFDetailsWidget.html

@@ -210,6 +210,8 @@
             </div>
             <div id="${id}_DFUWorkunit" title="${i18n.Workunit}" data-dojo-props="delayWidget: 'DFUWUDetailsWidget'" data-dojo-type="DelayLoadWidget">
             </div>
+            <div id="${id}_FileHistory" title="${i18n.History}" data-dojo-props="delayWidget: 'FileHistoryWidget'" data-dojo-type="DelayLoadWidget">
+            </div>
         </div>
     </div>
 </div>