Implemented table building functions
Change-Id: Ie4003080b13725561df22de41ec85f8c3f31c794
diff --git a/web/gui2/src/main/webapp/app/fw/util/fn.service.ts b/web/gui2/src/main/webapp/app/fw/util/fn.service.ts
index d355ce9..7b9ea24 100644
--- a/web/gui2/src/main/webapp/app/fw/util/fn.service.ts
+++ b/web/gui2/src/main/webapp/app/fw/util/fn.service.ts
@@ -415,6 +415,35 @@
}
/**
+ * returns true if the two objects have all the same properties
+ */
+ sameObjProps(obj1: Object, obj2: Object): boolean {
+ for (const key in obj1) {
+ if (obj1.hasOwnProperty(key)) {
+ if (!(obj1[key] === obj2[key])) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ /**
+ * returns true if the array contains the object
+ * does NOT use strict object reference equality,
+ * instead checks each property individually for equality
+ */
+ containsObj(arr: any[], obj: Object): boolean {
+ const len = arr.length;
+ for (let i = 0; i < len; i++) {
+ if (this.sameObjProps(arr[i], obj)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
* Return the given string with the first character capitalized.
*/
cap(s: string): string {
diff --git a/web/gui2/src/main/webapp/app/fw/util/lion.service.ts b/web/gui2/src/main/webapp/app/fw/util/lion.service.ts
index 5ab9f65..248fe51 100644
--- a/web/gui2/src/main/webapp/app/fw/util/lion.service.ts
+++ b/web/gui2/src/main/webapp/app/fw/util/lion.service.ts
@@ -34,7 +34,8 @@
})
export class LionService {
- ubercache: any[];
+ ubercache: any[] = [];
+ loadCb; // Function
/**
* Handler for uberlion event from WSS
@@ -50,6 +51,10 @@
this.log.info(' :=> ', p);
}
}
+ if (this.loadCb) {
+ this.log.debug('Calling the load callback');
+ this.loadCb();
+ }
this.log.debug('LION service: uber-lion bundle received:', data);
}
@@ -69,17 +74,15 @@
* returns a function that takes a string and returns a string
*/
bundle(bundleId: string): (string) => string {
- let bundle = this.ubercache[bundleId];
+ let bundleObj = this.ubercache[bundleId];
- if (!bundle) {
+ if (!bundleObj) {
this.log.warn('No lion bundle registered:', bundleId);
- bundle = {};
+ bundleObj = {};
}
- return this.getKey;
- }
-
- getKey(key: string): string {
- return this.bundle[key] || '%' + key + '%';
+ return (key) => {
+ return bundleObj[key] || '%' + key + '%';
+ };
}
}