浏览代码

HPCC-25348 Tighten Memory Class

Remove mixins
Fix typo in Workunits filter

Signed-off-by: Gordon Smith <GordonJSmith@gmail.com>
Gordon Smith 4 年之前
父节点
当前提交
8736226c2c

+ 1 - 4
esp/src/eclwatch/FilePartsWidget.js

@@ -41,10 +41,7 @@ define([
 
             startup: function (args) {
                 this.inherited(arguments);
-                var store = new MemoryMod.Memory({
-                    idProperty: "__hpcc_id",
-                    data: []
-                });
+                var store = new MemoryMod.Memory("__hpcc_id");
                 this.filePartsStore = new Observable(store);
 
                 this.filePartsGrid = new declare([OnDemandGrid, Keyboard, ColumnResizer, DijitRegistry])({

+ 2 - 4
esp/src/eclwatch/FullResultWidget.js

@@ -131,10 +131,8 @@ define([
                 arrayUtil.forEach(result, function (item, idx) {
                     item["__hpcc_id"] = idx;
                 });
-                var store = new MemoryMod.Memory({
-                    idProperty: "__hpcc_id",
-                    data: result
-                });
+                var store = new MemoryMod.Memory("__hpcc_id");
+                store.setData(result);
                 this.store = new Observable(store);
                 this.grid = new declare([ESPUtil.Grid(false, true)])({
                     columns: columns,

+ 1 - 4
esp/src/eclwatch/GridDetailsWidget.js

@@ -98,10 +98,7 @@ define([
 
         initGrid: function () {
             var context = this;
-            var store = new MemoryMod.AlphaNumSortMemory(this.alphanumSort, {
-                idProperty: this.idProperty,
-                data: []
-            });
+            var store = new MemoryMod.AlphaNumSortMemory(this.idProperty, this.alphanumSort);
             this.store = new Observable(store);
             this.grid = this.createGrid(this.id + "Grid");
             this.setGridNoDataMessage(this.i18n.loadingMessage);

+ 1 - 4
esp/src/eclwatch/InfoGridWidget.js

@@ -110,10 +110,7 @@ define([
                 }
 
                 var context = this;
-                var store = new MemoryMod.Memory({
-                    idProperty: "id",
-                    data: []
-                });
+                var store = new MemoryMod.Memory("id");
                 this.infoStore = new Observable(store);
 
                 this.infoGrid = new declare([ESPUtil.Grid(false, true)])({

+ 1 - 4
esp/src/eclwatch/SFDetailsWidget.js

@@ -171,10 +171,7 @@ define([
 
         initSubfilesGrid: function () {
             var context = this;
-            var store = new MemoryMod.Memory({
-                idProperty: "Name",
-                data: []
-            });
+            var store = new MemoryMod.Memory("Name");
             this.subfilesStore = new Observable(store);
             this.subfilesGrid = new declare([ESPUtil.Grid(false, true)])({
                 columns: {

+ 4 - 4
esp/src/eclwatch/SearchResultsWidget.js

@@ -93,10 +93,10 @@ define([
         },
 
         createGrid: function (domID) {
-            this.eclStore = new Observable(new MemoryMod.Memory({ idProperty: "Wuid", data: [] }));
-            this.dfuStore = new Observable(new MemoryMod.Memory({ idProperty: "ID", data: [] }));
-            this.fileStore = new Observable(new MemoryMod.Memory({ idProperty: "__hpcc_id", data: [] }));
-            this.queryStore = new Observable(new MemoryMod.Memory({ idProperty: "__hpcc_id", data: [] }));
+            this.eclStore = new Observable(new MemoryMod.Memory("Wuid"));
+            this.dfuStore = new Observable(new MemoryMod.Memory("ID"));
+            this.fileStore = new Observable(new MemoryMod.Memory("__hpcc_id"));
+            this.queryStore = new Observable(new MemoryMod.Memory("__hpcc_id"));
             this.eclTab = this.ensurePane({ id: this.i18n.ECLWorkunit }, { type: this.i18n.ECLWorkunit });
             this.dfuTab = this.ensurePane({ id: this.i18n.DFUWorkunit }, { type: this.i18n.DFUWorkunit });
             this.fileTab = this.ensurePane({ id: this.i18n.LogicalFile }, { type: this.i18n.LogicalFile });

+ 1 - 4
esp/src/eclwatch/SelectionGridWidget.js

@@ -49,10 +49,7 @@
         //  Implementation ---
         createGrid: function (args) {
             this.idProperty = args.idProperty;
-            var store = new MemoryMod.Memory({
-                idProperty: this.idProperty,
-                data: []
-            });
+            var store = new MemoryMod.Memory(this.idProperty);
             this.store = new Observable(store);
 
             this.grid = new declare([OnDemandGrid, Keyboard, Selection, ColumnResizer, DijitRegistry])({

+ 8 - 9
esp/src/eclwatch/TargetSelectClass.js

@@ -416,15 +416,14 @@ define([
             if (this._dropZoneTarget) {
                 this._loadDropZoneFolders(pathSepChar, this._dropZoneTarget.machine.Netaddress, this._dropZoneTarget.machine.Directory, this._dropZoneTarget.machine.OS).then(function (results) {
                     results.sort();
-                    var store = new MemoryMod.Memory({
-                        data: arrayUtil.map(results, function (_path) {
-                            var path = _path.substring(context._dropZoneTarget.machine.Directory.length);
-                            return {
-                                name: path,
-                                id: _path
-                            };
-                        })
-                    });
+                    var store = new MemoryMod.Memory();
+                    store.setData(arrayUtil.map(results, function (_path) {
+                        var path = _path.substring(context._dropZoneTarget.machine.Directory.length);
+                        return {
+                            name: path,
+                            id: _path
+                        };
+                    }));
                     context.set("store", store);
                     context.set("placeholder", defaultPath);
                     context._postLoad();

+ 1 - 0
esp/src/eclwatch/TimingPageWidget.js

@@ -20,6 +20,7 @@ define([
     "dijit/layout/ContentPane",
     "dijit/Toolbar",
     "dijit/ToolbarSeparator",
+    "dijit/form/Form",
     "dijit/form/Button",
     "dijit/form/ToggleButton",
     "dijit/form/Select",

+ 2 - 4
esp/src/eclwatch/TimingTreeMapWidget.js

@@ -232,10 +232,8 @@ define([
                         }, timers[i]));
                     }
                 }
-                this.store = new MemoryMod.Memory({
-                    idProperty: "__hpcc_id",
-                    data: timerData
-                });
+                this.store = new MemoryMod.Memory("__hpcc_id");
+                this.store.setData(timerData);
 
                 var context = this;
                 this.treeMap.set("store", this.store);

+ 8 - 22
esp/src/src-react/components/Results.tsx

@@ -1,7 +1,7 @@
 import * as React from "react";
 import { CommandBar, ContextualMenuItemType, ICommandBarItemProps } from "@fluentui/react";
 import { useConst } from "@fluentui/react-hooks";
-import * as Memory from "dojo/store/Memory";
+import { AlphaNumSortMemory } from "src/Memory";
 import * as Observable from "dojo/store/Observable";
 import * as Utility from "src/Utility";
 import nlsHPCC from "src/nlsHPCC";
@@ -10,19 +10,6 @@ import { HolyGrail } from "../layouts/HolyGrail";
 import { ShortVerticalDivider } from "./Common";
 import { DojoGrid, selector } from "./DojoGrid";
 
-class MyMemory extends Memory {
-    idProperty: "__hpcc_id";
-    alphanumSort: { [column: string]: boolean } = {};
-
-    query(query, options) {
-        const retVal = super.query(query, options);
-        if (options.sort && options.sort.length && this.alphanumSort[options.sort[0].attribute]) {
-            Utility.alphanumSort(retVal, options.sort[0].attribute, options.sort[0].descending);
-        }
-        return retVal;
-    }
-}
-
 const defaultUIState = {
     hasSelection: false
 };
@@ -66,10 +53,8 @@ export const Results: React.FunctionComponent<ResultsProps> = ({
     ];
 
     //  Grid ---
-    const gridStore = useConst(new Observable(new MyMemory()));
-    gridStore.alphanumSort["Name"] = true;
-    gridStore.alphanumSort["Value"] = true;
-
+    const gridStore = useConst(new Observable(new AlphaNumSortMemory("__hpcc_id", { Name: true, Value: true })));
+    const gridQuery = useConst({});
     const gridSort = useConst([{ attribute: "Wuid", "descending": true }]);
     const gridColumns = useConst({
         col1: selector({
@@ -106,7 +91,7 @@ export const Results: React.FunctionComponent<ResultsProps> = ({
     });
 
     const refreshTable = (clearSelection = false) => {
-        grid?.set("query", {});
+        grid?.set("query", gridQuery);
         if (clearSelection) {
             grid?.clearSelection();
         }
@@ -125,13 +110,14 @@ export const Results: React.FunctionComponent<ResultsProps> = ({
 
     React.useEffect(() => {
         gridStore.setData(results.map(row => {
-            const tmp: any = row.ResultViews;
+            const tmp: any = row?.ResultViews;
             return {
                 __hpcc_id: row.Sequence,
                 Name: row.Name,
                 FileName: row.FileName,
                 Value: row.Value,
-                ResultViews: tmp.View,
+                ResultViews: tmp?.View,
+                Sequence: row.Sequence
             };
         }));
         refreshTable();
@@ -141,7 +127,7 @@ export const Results: React.FunctionComponent<ResultsProps> = ({
     return <HolyGrail
         header={<CommandBar items={buttons} overflowButtonProps={{}} farItems={rightButtons} />}
         main={
-            <DojoGrid store={gridStore} query={{}} sort={gridSort} columns={gridColumns} setGrid={setGrid} setSelection={setSelection} />
+            <DojoGrid store={gridStore} query={gridQuery} sort={gridSort} columns={gridColumns} setGrid={setGrid} setSelection={setSelection} />
         }
     />;
 };

+ 1 - 1
esp/src/src-react/components/Workunits.tsx

@@ -16,7 +16,7 @@ const FilterFields: Fields = {
     "Type": { type: "checkbox", label: nlsHPCC.ArchivedOnly },
     "Wuid": { type: "string", label: nlsHPCC.WUID, placeholder: "W20200824-060035" },
     "Owner": { type: "string", label: nlsHPCC.Owner, placeholder: nlsHPCC.jsmi },
-    "JobName": { type: "string", label: nlsHPCC.JobName, placeholder: nlsHPCC.log_analysis_1 },
+    "Jobname": { type: "string", label: nlsHPCC.JobName, placeholder: nlsHPCC.log_analysis_1 },
     "Cluster": { type: "target-cluster", label: nlsHPCC.Cluster, placeholder: nlsHPCC.Owner },
     "State": { type: "workunit-state", label: nlsHPCC.State, placeholder: nlsHPCC.Created },
     "ECL": { type: "string", label: nlsHPCC.ECL, placeholder: nlsHPCC.dataset },

+ 1 - 1
esp/src/src-react/components/WorkunitsDashboard.tsx

@@ -168,7 +168,7 @@ export const WorkunitsDashboard: React.FunctionComponent<WorkunitsDashboardProps
         ;
 
     //  Table ---
-    const workunitsStore = useConst(new Observable(new Memory({ idProperty: "Wuid", data: [] })));
+    const workunitsStore = useConst(new Observable(new Memory("Wuid")));
     const tablePipeline = chain(
         filter<WorkunitEx>(row => filterProps.cluster === undefined || row.Cluster === filterProps.cluster),
         filter(row => filterProps.owner === undefined || row.Owner === filterProps.owner),

+ 11 - 9
esp/src/src-react/layouts/DojoAdapter.tsx

@@ -5,23 +5,25 @@ import * as registry from "dijit/registry";
 import nlsHPCC from "src/nlsHPCC";
 import { resolve } from "src/Utility";
 
+export interface DojoState {
+    uid: number;
+    widgetClassID?: string;
+    widget: any;
+}
+
 export interface DojoAdapterProps {
     widgetClassID?: string;
     widgetClass?: any;
     params?: object;
+    delayProps?: object;
     onWidgetMount?: (widget) => void;
 }
 
-export interface DojoState {
-    uid: number;
-    widgetClassID?: string;
-    widget: any;
-}
-
 export const DojoAdapter: React.FunctionComponent<DojoAdapterProps> = ({
     widgetClassID,
     widgetClass,
     params,
+    delayProps,
     onWidgetMount
 }) => {
 
@@ -54,9 +56,9 @@ export const DojoAdapter: React.FunctionComponent<DojoAdapterProps> = ({
                         padding: "0px",
                         width: "100%",
                         height: "100%"
-                    }
+                    },
+                    ...delayProps
                 }, elem);
-                // widget.placeAt(elem, "replace");
                 widget.startup();
                 widget.resize();
                 if (widget.init) {
@@ -84,7 +86,7 @@ export const DojoAdapter: React.FunctionComponent<DojoAdapterProps> = ({
             }
             widget = null;  //  Avoid race condition  ---
         };
-    }, [onWidgetMount, params, uid, widgetClass, widgetClassID]);
+    }, [onWidgetMount, params, delayProps, uid, widgetClass, widgetClassID]);
 
     return <div ref={myRef} style={{ width: "100%", height: "100%" }}>{nlsHPCC.Loading} {widgetClassID}...</div>;
 };

+ 5 - 3
esp/src/src/ESPActivity.ts

@@ -13,7 +13,9 @@ import { Memory } from "./Memory";
 
 class Store extends Memory {
 
-    idProperty = "__hpcc_id";
+    constructor() {
+        super("__hpcc_id");
+    }
 
     mayHaveChildren(item) {
         return (item.getChildCount && item.getChildCount());
@@ -217,7 +219,7 @@ export function Get() {
     return globalActivity;
 }
 
-export function CreateActivityStore(options) {
-    const store = new Store(options);
+export function CreateActivityStore() {
+    const store = new Store();
     return new Observable(store);
 }

+ 5 - 5
esp/src/src/ESPQueue.ts

@@ -8,16 +8,16 @@ import * as WsSMC from "./WsSMC";
 import { Memory } from "./Memory";
 
 class Store extends Memory {
-    idProperty: "__hpcc_id"
+
+    constructor() {
+        super("__hpcc_id");
+    }
 }
 
 class QueueMemory extends Memory {
 
-    idProperty = "__hpcc_id";
-    data = [];
-
     constructor(protected parent) {
-        super();
+        super("__hpcc_id");
     }
 
 }

+ 5 - 5
esp/src/src/ESPSearch.ts

@@ -1,9 +1,9 @@
-import * as Memory from "dojo/store/Memory";
 import * as Observable from "dojo/store/Observable";
 import * as ESPWorkunit from "src/ESPWorkunit";
 import * as ESPDFUWorkunit from "src/ESPDFUWorkunit";
 import * as ESPLogicalFile from "src/ESPLogicalFile";
 import * as ESPQuery from "src/ESPQuery";
+import { Memory } from "./Memory";
 import * as WsWorkunits from "./WsWorkunits";
 import * as FileSpray from "./FileSpray";
 import * as WsDfu from "./WsDfu";
@@ -19,10 +19,10 @@ export class ESPSearch {
     protected _searchText: string;
 
     store = Observable(new Memory());
-    eclStore = Observable(new Memory({ idProperty: "Wuid", data: [] }));
-    dfuStore = Observable(new Memory({ idProperty: "ID", data: [] }));
-    fileStore = Observable(new Memory({ idProperty: "__hpcc_id", data: [] }));
-    queryStore = Observable(new Memory({ idProperty: "__hpcc_id", data: [] }));
+    eclStore = Observable(new Memory("Wuid"));
+    dfuStore = Observable(new Memory("ID"));
+    fileStore = Observable(new Memory("__hpcc_id"));
+    queryStore = Observable(new Memory("__hpcc_id"));
 
     constructor(private begin: (searchCount: number) => void, private update: () => void, private end: (success: boolean) => void) {
     }

+ 2 - 5
esp/src/src/ESPTree.ts

@@ -1,7 +1,5 @@
 import * as arrayUtil from "dojo/_base/array";
 import * as declare from "dojo/_base/declare";
-// import * as Memory from "dojo/store/Memory";
-
 import * as ESPUtil from "./ESPUtil";
 import { Memory } from "./Memory";
 
@@ -69,7 +67,6 @@ const TreeNode = declare(null, {
 });
 
 class TreeStore extends Memory {
-    idProperty = "__hpcc_id";
 
     treeSeparator = "->";
     cachedTreeNodes: object;
@@ -77,8 +74,8 @@ class TreeStore extends Memory {
     out_edges: any;
     in_edges: any;
 
-    constructor(args) {
-        super(args);
+    constructor() {
+        super("__hpcc_id");
         this.clear();
     }
 

+ 2 - 2
esp/src/src/ESPUtil.ts

@@ -399,8 +399,8 @@ export const FormHelper = declare(null, {
 
 export class UndefinedMemory extends Memory {
 
-    constructor() {
-        super();
+    constructor(idProperty: string = "id") {
+        super(idProperty);
     }
 
     query(query: any, options: any) {

+ 3 - 5
esp/src/src/GraphStore.ts

@@ -4,12 +4,11 @@ import * as QueryResults from "dojo/store/util/QueryResults";
 import { UndefinedMemory } from "./ESPUtil";
 
 export class GraphStore extends UndefinedMemory {
-    idProperty: string;
+
     cacheColumns = {};
 
     constructor(idProperty: string = "id") {
-        super();
-        this.idProperty = idProperty;
+        super(idProperty);
     }
 
     setData(data) {
@@ -118,11 +117,10 @@ export class GraphStore extends UndefinedMemory {
 }
 
 export class GraphTreeStore extends GraphStore {
-    idProperty = "id";
 
     //  Store API  ---
     constructor() {
-        super();
+        super("id");
     }
 
     query(query, options) {

+ 8 - 10
esp/src/src/Memory.ts

@@ -12,15 +12,13 @@ export interface MemoryOptions {
 
 export class Memory {
 
-    data = null;
-    idProperty = "id";
-    index = null;
-    queryEngine = SimpleQueryEngine;
+    protected data = null;
+    private idProperty: string;
+    private index = null;
+    protected queryEngine = SimpleQueryEngine;
 
-    constructor(options: MemoryOptions = {}) {
-        for (const i in options) {
-            this[i] = options[i];
-        }
+    constructor(idProperty: string = "id") {
+        this.idProperty = idProperty;
         this.setData(this.data || []);
     }
 
@@ -83,8 +81,8 @@ export class Memory {
 
 export class AlphaNumSortMemory extends Memory {
 
-    constructor(protected alphanumSort: { [id: string]: boolean }, options: MemoryOptions = {}) {
-        super(options);
+    constructor(idProperty: string = "id", protected alphanumSort: { [id: string]: boolean }) {
+        super(idProperty);
     }
 
     query(query, options) {

+ 1 - 2
esp/src/src/WsDfu.ts

@@ -14,8 +14,7 @@ import { Memory } from "./Memory";
 class DiskUsageStore extends Memory {
 
     constructor() {
-        super();
-        this.idProperty = "__hpcc_id";
+        super("__hpcc_id");
     }
 
     query(query, options) {

+ 1 - 2
esp/src/src/WsTopology.ts

@@ -16,8 +16,7 @@ declare const dojoConfig;
 class TpLogFileStore extends Memory {
 
     constructor() {
-        super();
-        this.idProperty = "__hpcc_id";
+        super("__hpcc_id");
     }
 
     //  Evented  ---

+ 5 - 11
esp/src/src/ws_access.ts

@@ -64,8 +64,7 @@ class ResourcesStore extends Memory {
     name: string;
 
     constructor() {
-        super();
-        this.idProperty = "__hpcc_id";
+        super("__hpcc_id");
     }
 
     put(row, options) {
@@ -162,8 +161,7 @@ class InheritedPermissionStore extends Memory {
     IncludeGroup: boolean;
 
     constructor() {
-        super();
-        this.idProperty = "__hpcc_id";
+        super("__hpcc_id");
     }
 
     put(row, options) {
@@ -245,8 +243,7 @@ class AccountResourcesStore extends Memory {
     IncludeGroup: boolean;
 
     constructor() {
-        super();
-        this.idProperty = "__hpcc_id";
+        super("__hpcc_id");
     }
 
     put(row, options) {
@@ -320,8 +317,7 @@ class IndividualPermissionsStore extends Memory {
     basedn: string;
 
     constructor() {
-        super();
-        this.idProperty = "__hpcc_id";
+        super("__hpcc_id");
     }
 
     put(row, options) {
@@ -391,13 +387,11 @@ class PermissionsStore extends Memory {
     service = "ws_access";
     action = "Permissions";
     responseQualifier = "BasednsResponse.Basedns.Basedn";
-    idProperty = "__hpcc_id";
     groupname: string;
     username: string;
 
     constructor() {
-        super();
-        this.idProperty = "__hpcc_id";
+        super("__hpcc_id");
     }
 
     get(id) {