Bläddra i källkod

Merge pull request #15932 from GordonSmith/HPCC-27392

HPCC-27392: FluentUI Grid not honouring clearSelection of refresh

Reviewed-By: Jeremy Clements <jeremy.clements@lexisnexisrisk.com>
Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 3 år sedan
förälder
incheckning
6df7319721

+ 6 - 6
esp/src/package-lock.json

@@ -5376,9 +5376,9 @@
       }
       }
     },
     },
     "node_modules/minimist": {
     "node_modules/minimist": {
-      "version": "1.2.5",
-      "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
-      "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==",
+      "version": "1.2.6",
+      "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz",
+      "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==",
       "dev": true
       "dev": true
     },
     },
     "node_modules/mkdirp": {
     "node_modules/mkdirp": {
@@ -12118,9 +12118,9 @@
       }
       }
     },
     },
     "minimist": {
     "minimist": {
-      "version": "1.2.5",
-      "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
-      "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==",
+      "version": "1.2.6",
+      "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz",
+      "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==",
       "dev": true
       "dev": true
     },
     },
     "mkdirp": {
     "mkdirp": {

+ 1 - 1
esp/src/package.json

@@ -4,7 +4,7 @@
   "description": "'ECL Watch' Web interface for HPCC Platform.",
   "description": "'ECL Watch' Web interface for HPCC Platform.",
   "scripts": {
   "scripts": {
     "clean": "rimraf ./build ./lib ./src/nlsHPCCType.ts",
     "clean": "rimraf ./build ./lib ./src/nlsHPCCType.ts",
-    "lint": "eslint eclwatch/**/*.js src/**/*.ts? src-react/**/*.ts?",
+    "lint": "eslint ./eclwatch ./src ./src-react",
     "lint-fix": "eslint --fix eclwatch/**/*.js src/**/*.ts src-react/**/*.ts?",
     "lint-fix": "eslint --fix eclwatch/**/*.js src/**/*.ts src-react/**/*.ts?",
     "copy-res-es6-promise": "copyfiles -u 3 \"./node_modules/es6-promise/dist/es6-promise.auto.min.js\" ./build/node_modules/es6-promise/dist/",
     "copy-res-es6-promise": "copyfiles -u 3 \"./node_modules/es6-promise/dist/es6-promise.auto.min.js\" ./build/node_modules/es6-promise/dist/",
     "copy-res-eclwatch-img": "copyfiles -u 2 \"./eclwatch/img/**/*.{png,jpg,gif}\" ./build/eclwatch/img/",
     "copy-res-eclwatch-img": "copyfiles -u 2 \"./eclwatch/img/**/*.{png,jpg,gif}\" ./build/eclwatch/img/",

+ 1 - 1
esp/src/src-react/hooks/activity.ts

@@ -23,7 +23,7 @@ export function useActivity(): [Activity, number, () => void] {
         return () => {
         return () => {
             active = false;
             active = false;
             handle.release();
             handle.release();
-        }
+        };
     }, [count]);
     }, [count]);
 
 
     return [activity, lastUpdate, increment];
     return [activity, lastUpdate, increment];

+ 13 - 10
esp/src/src-react/hooks/grid.tsx

@@ -125,7 +125,7 @@ interface useFluentStoreGridResponse {
     selection: any[],
     selection: any[],
     copyButtons: ICommandBarItemProps[],
     copyButtons: ICommandBarItemProps[],
     total: number,
     total: number,
-    refreshTable: () => void
+    refreshTable: (clearSelection?: boolean) => void
 }
 }
 
 
 function useFluentStoreGrid({
 function useFluentStoreGrid({
@@ -144,8 +144,17 @@ function useFluentStoreGrid({
     const [items, setItems] = React.useState<any[]>([]);
     const [items, setItems] = React.useState<any[]>([]);
     const [total, setTotal] = React.useState<number>(0);
     const [total, setTotal] = React.useState<number>(0);
 
 
-    const refreshTable = React.useCallback(() => {
+    const selectionHandler = useConst(new Selection({
+        onSelectionChanged: () => {
+            setSelection(selectionHandler.getSelection());
+        }
+    }));
+
+    const refreshTable = React.useCallback((clearSelection = false) => {
         if (isNaN(start) || (isNaN(count) || count === 0)) return;
         if (isNaN(start) || (isNaN(count) || count === 0)) return;
+        if (clearSelection) {
+            selectionHandler.setItems([], true);
+        }
         const storeQuery = store.query(query ?? {}, { start, count, sort: sorted ? [sorted] : undefined });
         const storeQuery = store.query(query ?? {}, { start, count, sort: sorted ? [sorted] : undefined });
         storeQuery.total.then(total => {
         storeQuery.total.then(total => {
             setTotal(total);
             setTotal(total);
@@ -153,7 +162,7 @@ function useFluentStoreGrid({
         storeQuery.then(items => {
         storeQuery.then(items => {
             setItems(items);
             setItems(items);
         });
         });
-    }, [count, query, sorted, start, store]);
+    }, [count, query, selectionHandler, sorted, start, store]);
 
 
     React.useEffect(() => {
     React.useEffect(() => {
         refreshTable();
         refreshTable();
@@ -183,12 +192,6 @@ function useFluentStoreGrid({
         });
         });
     }, [constColumns]);
     }, [constColumns]);
 
 
-    const selectionHandler = useConst(new Selection({
-        onSelectionChanged: () => {
-            setSelection(selectionHandler.getSelection());
-        }
-    }));
-
     const renderDetailsHeader = React.useCallback((props: IDetailsHeaderProps, defaultRender?: any) => {
     const renderDetailsHeader = React.useCallback((props: IDetailsHeaderProps, defaultRender?: any) => {
         return defaultRender({
         return defaultRender({
             ...props,
             ...props,
@@ -262,7 +265,7 @@ interface useFluentPagedGridResponse {
     Grid: React.FunctionComponent<{ height?: string }>,
     Grid: React.FunctionComponent<{ height?: string }>,
     GridPagination: React.FunctionComponent<Partial<IStackProps>>,
     GridPagination: React.FunctionComponent<Partial<IStackProps>>,
     selection: any[],
     selection: any[],
-    refreshTable: (full?: boolean) => void,
+    refreshTable: (clearSelection?: boolean) => void,
     copyButtons: ICommandBarItemProps[]
     copyButtons: ICommandBarItemProps[]
 }
 }
 
 

+ 2 - 2
esp/src/src-react/hooks/metrics.ts

@@ -36,11 +36,11 @@ export function useMetricsOptions(): [MetricsOptions, (opts: MetricsOptions) =>
             options[key] = opts[key];
             options[key] = opts[key];
         }
         }
         refresh();
         refresh();
-    }, [options, refresh]);
+    }, [refresh]);
 
 
     const save = React.useCallback(() => {
     const save = React.useCallback(() => {
         store?.set("MetricOptions", JSON.stringify(options), true);
         store?.set("MetricOptions", JSON.stringify(options), true);
-    }, [options, store]);
+    }, [store]);
 
 
     const reset = React.useCallback((toDefaults: boolean = false) => {
     const reset = React.useCallback((toDefaults: boolean = false) => {
         if (toDefaults) {
         if (toDefaults) {

+ 24 - 24
esp/src/src/ECLArchiveWidget.ts

@@ -412,10 +412,10 @@ export class ECLArchiveWidget {
         function updateSummary(markers) {
         function updateSummary(markers) {
             const propCounts = {};
             const propCounts = {};
             const propFormats = {};
             const propFormats = {};
-            const propSums = markers.reduce((ret, n)=>{
-                n.properties.forEach(prop=>{
-                    if(prop.Measure !== undefined){
-                        if(!propCounts[prop.Name]){
+            const propSums = markers.reduce((ret, n) => {
+                n.properties.forEach(prop => {
+                    if (prop.Measure !== undefined) {
+                        if (!propCounts[prop.Name]) {
                             propCounts[prop.Name] = 0;
                             propCounts[prop.Name] = 0;
                             propFormats[prop.Name] = prop.Measure;
                             propFormats[prop.Name] = prop.Measure;
                             ret[prop.Name] = 0;
                             ret[prop.Name] = 0;
@@ -426,21 +426,21 @@ export class ECLArchiveWidget {
                 });
                 });
                 return ret;
                 return ret;
             }, {});
             }, {});
-            const propAvgs = Object.keys(propSums).reduce((ret, k)=>{
+            const propAvgs = Object.keys(propSums).reduce((ret, k) => {
                 ret[k] = propSums[k] / propCounts[k];
                 ret[k] = propSums[k] / propCounts[k];
                 return ret;
                 return ret;
             }, {});
             }, {});
             context.summaryTable
             context.summaryTable
                 .columns(["Name", "Cnt", "Avg", "Sum"])
                 .columns(["Name", "Cnt", "Avg", "Sum"])
                 .data([
                 .data([
-                    ...Object.keys(propSums).map(k=>{
+                    ...Object.keys(propSums).map(k => {
                         let avg = propAvgs[k];
                         let avg = propAvgs[k];
                         let sum = propSums[k];
                         let sum = propSums[k];
 
 
                         const isTime = propFormats[k] === "ns";
                         const isTime = propFormats[k] === "ns";
                         const isSize = propFormats[k] === "sz";
                         const isSize = propFormats[k] === "sz";
 
 
-                        if(isTime) {
+                        if (isTime) {
                             avg = _formatTime(avg);
                             avg = _formatTime(avg);
                             sum = _formatTime(sum);
                             sum = _formatTime(sum);
                         } else if (isSize) {
                         } else if (isSize) {
@@ -460,17 +460,17 @@ export class ECLArchiveWidget {
                 ])
                 ])
                 .lazyRender()
                 .lazyRender()
                 ;
                 ;
-            function _formatTime(v){
-                if(v > 1000000000) {
+            function _formatTime(v) {
+                if (v > 1000000000) {
                     return (v / 1000000000).toFixed(3) + "s";
                     return (v / 1000000000).toFixed(3) + "s";
                 }
                 }
                 return (v / 1000000).toFixed(3) + "ms";
                 return (v / 1000000).toFixed(3) + "ms";
             }
             }
-            function _formatSize(v){
-                if(v > 1000000000) {
+            function _formatSize(v) {
+                if (v > 1000000000) {
                     return (v * 0.000000000931).toFixed(3) + "Gb";
                     return (v * 0.000000000931).toFixed(3) + "Gb";
                 }
                 }
-                else if(v > 1000000) {
+                else if (v > 1000000) {
                     return (v * 0.0000009537).toFixed(3) + "Mb";
                     return (v * 0.0000009537).toFixed(3) + "Mb";
                 }
                 }
                 return (v * 0.000977).toFixed(3) + "Kb";
                 return (v * 0.000977).toFixed(3) + "Kb";
@@ -579,10 +579,10 @@ export class ECLArchiveWidget {
                     marker.color,
                     marker.color,
                     "Verdana",
                     "Verdana",
                     "12px",
                     "12px",
-                    () => {},
-                    () => {},
+                    () => { },
+                    () => { },
                     () => {
                     () => {
-                        if(context.selectedMarker === marker.lineNum) {
+                        if (context.selectedMarker === marker.lineNum) {
                             updateSummary(markers);
                             updateSummary(markers);
                             context.selectedMarker = -1;
                             context.selectedMarker = -1;
                             const columnArr = context.summaryTable.columns();
                             const columnArr = context.summaryTable.columns();
@@ -594,9 +594,9 @@ export class ECLArchiveWidget {
                         } else {
                         } else {
 
 
                             const _data = markerTableData(marker);
                             const _data = markerTableData(marker);
-                            
+
                             context.summaryTable
                             context.summaryTable
-                                .columns(["Line: "+marker.lineNum, ...Array(_data[0].length).fill("")])
+                                .columns(["Line: " + marker.lineNum, ...Array(_data[0].length).fill("")])
                                 .data(_data)
                                 .data(_data)
                                 .lazyRender()
                                 .lazyRender()
                                 ;
                                 ;
@@ -675,16 +675,16 @@ export class ECLArchiveWidget {
             return ret;
             return ret;
 
 
             function nsToTime(nanoseconds) {
             function nsToTime(nanoseconds) {
-                let subSecond:string|number = Math.floor(nanoseconds % 100000000);
-                let seconds:string|number = Math.floor((nanoseconds / 1000000000) % 60);
-                let minutes:string|number = Math.floor((nanoseconds / (1000000000 * 60)) % 60);
-                let hours:string|number = Math.floor((nanoseconds / (1000000000 * 60 * 60)) % 24);
-                
+                const subSecond: string | number = Math.floor(nanoseconds % 100000000);
+                let seconds: string | number = Math.floor((nanoseconds / 1000000000) % 60);
+                let minutes: string | number = Math.floor((nanoseconds / (1000000000 * 60)) % 60);
+                let hours: string | number = Math.floor((nanoseconds / (1000000000 * 60 * 60)) % 24);
+
                 hours = (hours < 10) ? "0" + hours : hours;
                 hours = (hours < 10) ? "0" + hours : hours;
                 minutes = (minutes < 10) ? "0" + minutes : minutes;
                 minutes = (minutes < 10) ? "0" + minutes : minutes;
                 seconds = (seconds < 10) ? "0" + seconds : seconds;
                 seconds = (seconds < 10) ? "0" + seconds : seconds;
-                
-                return String(hours).padStart(2,"0") + ":" + String(minutes) + ":" + String(seconds) + "." + String(subSecond).padStart(9,"0");
+
+                return String(hours).padStart(2, "0") + ":" + String(minutes) + ":" + String(seconds) + "." + String(subSecond).padStart(9, "0");
             }
             }
         }
         }
     }
     }

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

@@ -343,7 +343,7 @@ export function searchAll(searchText: string,
         searchParams.text = searchParams.text.trim();
         searchParams.text = searchParams.text.trim();
 
 
         return searchParams;
         return searchParams;
-    }
+    };
 
 
     const searchArray = [];
     const searchArray = [];
     const searchParams = generateSearchParams(searchText);
     const searchParams = generateSearchParams(searchText);

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

@@ -21,7 +21,7 @@ class UsersStore extends ESPRequest.Store {
     startProperty = "PageStartFrom";
     startProperty = "PageStartFrom";
     countProperty = "PageSize";
     countProperty = "PageSize";
 
 
-    SortbyProperty = "SortBy"
+    SortbyProperty = "SortBy";
 
 
     groupname: string;
     groupname: string;
 
 
@@ -398,7 +398,7 @@ class PermissionsStore extends Memory {
         const tmp = id.split(CONCAT_SYMBOL);
         const tmp = id.split(CONCAT_SYMBOL);
         if (tmp.length > 0) {
         if (tmp.length > 0) {
             const parentID = tmp[0];
             const parentID = tmp[0];
-            const parent = super.get(parentID);  
+            const parent = super.get(parentID);
             if (tmp.length === 1) {
             if (tmp.length === 1) {
                 return parent;
                 return parent;
             }
             }