Commit 349909be8788b60a12e33dc336ea4e8e33230e35
1 parent
21d7350e
Fix dashboards entity data query mapping. UI: Fixed entity subscription creation…
…. UI: Improve resource load failure handling.
Showing
3 changed files
with
34 additions
and
33 deletions
@@ -72,6 +72,7 @@ public class EntityKeyMapping { | @@ -72,6 +72,7 @@ public class EntityKeyMapping { | ||
72 | private static final String PHONE = "phone"; | 72 | private static final String PHONE = "phone"; |
73 | 73 | ||
74 | public static final List<String> commonEntityFields = Arrays.asList(CREATED_TIME, ENTITY_TYPE, NAME); | 74 | public static final List<String> commonEntityFields = Arrays.asList(CREATED_TIME, ENTITY_TYPE, NAME); |
75 | + public static final List<String> dashboardEntityFields = Arrays.asList(CREATED_TIME, ENTITY_TYPE, TITLE); | ||
75 | public static final List<String> labeledEntityFields = Arrays.asList(CREATED_TIME, ENTITY_TYPE, NAME, TYPE, LABEL); | 76 | public static final List<String> labeledEntityFields = Arrays.asList(CREATED_TIME, ENTITY_TYPE, NAME, TYPE, LABEL); |
76 | public static final List<String> contactBasedEntityFields = Arrays.asList(CREATED_TIME, ENTITY_TYPE, EMAIL, TITLE, COUNTRY, STATE, CITY, ADDRESS, ADDRESS_2, ZIP, PHONE); | 77 | public static final List<String> contactBasedEntityFields = Arrays.asList(CREATED_TIME, ENTITY_TYPE, EMAIL, TITLE, COUNTRY, STATE, CITY, ADDRESS, ADDRESS_2, ZIP, PHONE); |
77 | 78 | ||
@@ -89,7 +90,7 @@ public class EntityKeyMapping { | @@ -89,7 +90,7 @@ public class EntityKeyMapping { | ||
89 | 90 | ||
90 | allowedEntityFieldMap.put(EntityType.USER, new HashSet<>(Arrays.asList(CREATED_TIME, FIRST_NAME, LAST_NAME, EMAIL))); | 91 | allowedEntityFieldMap.put(EntityType.USER, new HashSet<>(Arrays.asList(CREATED_TIME, FIRST_NAME, LAST_NAME, EMAIL))); |
91 | 92 | ||
92 | - allowedEntityFieldMap.put(EntityType.DASHBOARD, new HashSet<>(commonEntityFields)); | 93 | + allowedEntityFieldMap.put(EntityType.DASHBOARD, new HashSet<>(dashboardEntityFields)); |
93 | allowedEntityFieldMap.put(EntityType.RULE_CHAIN, new HashSet<>(commonEntityFields)); | 94 | allowedEntityFieldMap.put(EntityType.RULE_CHAIN, new HashSet<>(commonEntityFields)); |
94 | allowedEntityFieldMap.put(EntityType.RULE_NODE, new HashSet<>(commonEntityFields)); | 95 | allowedEntityFieldMap.put(EntityType.RULE_NODE, new HashSet<>(commonEntityFields)); |
95 | allowedEntityFieldMap.put(EntityType.WIDGET_TYPE, new HashSet<>(commonEntityFields)); | 96 | allowedEntityFieldMap.put(EntityType.WIDGET_TYPE, new HashSet<>(commonEntityFields)); |
@@ -118,12 +119,12 @@ public class EntityKeyMapping { | @@ -118,12 +119,12 @@ public class EntityKeyMapping { | ||
118 | contactBasedAliases.put(LABEL, TITLE); | 119 | contactBasedAliases.put(LABEL, TITLE); |
119 | aliases.put(EntityType.TENANT, contactBasedAliases); | 120 | aliases.put(EntityType.TENANT, contactBasedAliases); |
120 | aliases.put(EntityType.CUSTOMER, contactBasedAliases); | 121 | aliases.put(EntityType.CUSTOMER, contactBasedAliases); |
122 | + aliases.put(EntityType.DASHBOARD, contactBasedAliases); | ||
121 | Map<String, String> commonEntityAliases = new HashMap<>(); | 123 | Map<String, String> commonEntityAliases = new HashMap<>(); |
122 | commonEntityAliases.put(TITLE, NAME); | 124 | commonEntityAliases.put(TITLE, NAME); |
123 | aliases.put(EntityType.DEVICE, commonEntityAliases); | 125 | aliases.put(EntityType.DEVICE, commonEntityAliases); |
124 | aliases.put(EntityType.ASSET, commonEntityAliases); | 126 | aliases.put(EntityType.ASSET, commonEntityAliases); |
125 | aliases.put(EntityType.ENTITY_VIEW, commonEntityAliases); | 127 | aliases.put(EntityType.ENTITY_VIEW, commonEntityAliases); |
126 | - aliases.put(EntityType.DASHBOARD, commonEntityAliases); | ||
127 | aliases.put(EntityType.WIDGETS_BUNDLE, commonEntityAliases); | 128 | aliases.put(EntityType.WIDGETS_BUNDLE, commonEntityAliases); |
128 | 129 | ||
129 | Map<String, String> userEntityAliases = new HashMap<>(); | 130 | Map<String, String> userEntityAliases = new HashMap<>(); |
@@ -127,33 +127,39 @@ export class ResourcesService { | @@ -127,33 +127,39 @@ export class ResourcesService { | ||
127 | } | 127 | } |
128 | SystemJS.import(url).then( | 128 | SystemJS.import(url).then( |
129 | (module) => { | 129 | (module) => { |
130 | - let modules; | ||
131 | try { | 130 | try { |
132 | - modules = this.extractNgModules(module); | ||
133 | - } catch (e) {} | ||
134 | - if (modules && modules.length) { | ||
135 | - const tasks: Promise<ModuleWithComponentFactories<any>>[] = []; | ||
136 | - for (const m of modules) { | ||
137 | - tasks.push(this.compiler.compileModuleAndAllComponentsAsync(m)); | 131 | + let modules; |
132 | + try { | ||
133 | + modules = this.extractNgModules(module); | ||
134 | + } catch (e) { | ||
138 | } | 135 | } |
139 | - forkJoin(tasks).subscribe((compiled) => { | ||
140 | - try { | ||
141 | - for (const c of compiled) { | ||
142 | - c.ngModuleFactory.create(this.injector); | 136 | + if (modules && modules.length) { |
137 | + const tasks: Promise<ModuleWithComponentFactories<any>>[] = []; | ||
138 | + for (const m of modules) { | ||
139 | + tasks.push(this.compiler.compileModuleAndAllComponentsAsync(m)); | ||
140 | + } | ||
141 | + forkJoin(tasks).subscribe((compiled) => { | ||
142 | + try { | ||
143 | + for (const c of compiled) { | ||
144 | + c.ngModuleFactory.create(this.injector); | ||
145 | + } | ||
146 | + this.loadedModules[url].next(modules); | ||
147 | + this.loadedModules[url].complete(); | ||
148 | + } catch (e) { | ||
149 | + this.loadedModules[url].error(new Error(`Unable to init module from url: ${url}`)); | ||
150 | + delete this.loadedModules[url]; | ||
143 | } | 151 | } |
144 | - this.loadedModules[url].next(modules); | ||
145 | - this.loadedModules[url].complete(); | ||
146 | - } catch (e) { | ||
147 | - this.loadedModules[url].error(new Error(`Unable to init module from url: ${url}`)); | 152 | + }, |
153 | + (e) => { | ||
154 | + this.loadedModules[url].error(new Error(`Unable to compile module from url: ${url}`)); | ||
148 | delete this.loadedModules[url]; | 155 | delete this.loadedModules[url]; |
149 | - } | ||
150 | - }, | ||
151 | - (e) => { | ||
152 | - this.loadedModules[url].error(new Error(`Unable to compile module from url: ${url}`)); | ||
153 | - delete this.loadedModules[url]; | ||
154 | - }); | ||
155 | - } else { | ||
156 | - this.loadedModules[url].error(new Error(`Module '${url}' doesn't have default export or not NgModule!`)); | 156 | + }); |
157 | + } else { | ||
158 | + this.loadedModules[url].error(new Error(`Module '${url}' doesn't have default export or not NgModule!`)); | ||
159 | + delete this.loadedModules[url]; | ||
160 | + } | ||
161 | + } catch (e) { | ||
162 | + this.loadedModules[url].error(new Error(`Unable to load module from url: ${url}`)); | ||
157 | delete this.loadedModules[url]; | 163 | delete this.loadedModules[url]; |
158 | } | 164 | } |
159 | }, | 165 | }, |
@@ -794,16 +794,10 @@ export class WidgetComponent extends PageComponent implements OnInit, AfterViewI | @@ -794,16 +794,10 @@ export class WidgetComponent extends PageComponent implements OnInit, AfterViewI | ||
794 | options.useDashboardTimewindow = true; | 794 | options.useDashboardTimewindow = true; |
795 | } | 795 | } |
796 | } | 796 | } |
797 | - let datasource: Datasource; | ||
798 | if (options.type === widgetType.alarm) { | 797 | if (options.type === widgetType.alarm) { |
799 | - datasource = this.entityService.createAlarmSourceFromSubscriptionInfo(subscriptionsInfo[0]); | 798 | + options.alarmSource = this.entityService.createAlarmSourceFromSubscriptionInfo(subscriptionsInfo[0]); |
800 | } else { | 799 | } else { |
801 | - datasource = this.entityService.createDatasourcesFromSubscriptionsInfo(subscriptionsInfo); | ||
802 | - } | ||
803 | - if (options.type === widgetType.alarm) { | ||
804 | - options.alarmSource = datasource; | ||
805 | - } else { | ||
806 | - options.datasources = [datasource]; | 800 | + options.datasources = this.entityService.createDatasourcesFromSubscriptionsInfo(subscriptionsInfo); |
807 | } | 801 | } |
808 | this.createSubscription(options, subscribe).subscribe( | 802 | this.createSubscription(options, subscribe).subscribe( |
809 | (subscription) => { | 803 | (subscription) => { |