@sunbird-cb/resolver 0.0.3 → 1.0.0-ang-9-12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/bundles/sunbird-cb-resolver.umd.js +945 -732
  2. package/bundles/sunbird-cb-resolver.umd.js.map +1 -1
  3. package/esm2015/lib/invalid-permission/invalid-permission.component.js +33 -30
  4. package/esm2015/lib/invalid-registration/invalid-registration.component.js +27 -24
  5. package/esm2015/lib/restricted/restricted.component.js +27 -24
  6. package/esm2015/lib/unresolved/unresolved.component.js +34 -33
  7. package/esm2015/lib/widget-base.component.js +60 -51
  8. package/esm2015/lib/widget-resolver.constant.js +4 -4
  9. package/esm2015/lib/widget-resolver.directive.js +35 -43
  10. package/esm2015/lib/widget-resolver.model.js +2 -57
  11. package/esm2015/lib/widget-resolver.module.js +77 -65
  12. package/esm2015/lib/widget-resolver.permissions.js +74 -74
  13. package/esm2015/lib/widget-resolver.service.js +96 -114
  14. package/esm2015/public-api.js +7 -6
  15. package/esm2015/sunbird-cb-resolver.js +2 -8
  16. package/fesm2015/sunbird-cb-resolver.js +402 -467
  17. package/fesm2015/sunbird-cb-resolver.js.map +1 -1
  18. package/lib/invalid-permission/invalid-permission.component.d.ts +14 -11
  19. package/lib/invalid-registration/invalid-registration.component.d.ts +11 -8
  20. package/lib/restricted/restricted.component.d.ts +11 -8
  21. package/lib/unresolved/unresolved.component.d.ts +13 -10
  22. package/lib/widget-base.component.d.ts +18 -15
  23. package/lib/widget-resolver.constant.d.ts +4 -4
  24. package/lib/widget-resolver.directive.d.ts +15 -12
  25. package/lib/widget-resolver.model.d.ts +48 -48
  26. package/lib/widget-resolver.module.d.ts +20 -6
  27. package/lib/widget-resolver.permissions.d.ts +3 -3
  28. package/lib/widget-resolver.service.d.ts +23 -22
  29. package/package.json +17 -20
  30. package/public-api.d.ts +6 -5
  31. package/sunbird-cb-resolver.d.ts +2 -8
  32. package/bundles/sunbird-cb-resolver.umd.min.js +0 -16
  33. package/bundles/sunbird-cb-resolver.umd.min.js.map +0 -1
  34. package/esm5/lib/invalid-permission/invalid-permission.component.js +0 -35
  35. package/esm5/lib/invalid-registration/invalid-registration.component.js +0 -29
  36. package/esm5/lib/restricted/restricted.component.js +0 -29
  37. package/esm5/lib/unresolved/unresolved.component.js +0 -38
  38. package/esm5/lib/widget-base.component.js +0 -54
  39. package/esm5/lib/widget-resolver.constant.js +0 -4
  40. package/esm5/lib/widget-resolver.directive.js +0 -45
  41. package/esm5/lib/widget-resolver.model.js +0 -57
  42. package/esm5/lib/widget-resolver.module.js +0 -69
  43. package/esm5/lib/widget-resolver.permissions.js +0 -79
  44. package/esm5/lib/widget-resolver.service.js +0 -120
  45. package/esm5/public-api.js +0 -6
  46. package/esm5/sunbird-cb-resolver.js +0 -8
  47. package/fesm5/sunbird-cb-resolver.js +0 -517
  48. package/fesm5/sunbird-cb-resolver.js.map +0 -1
  49. package/sunbird-cb-resolver.metadata.json +0 -1
@@ -1,489 +1,424 @@
1
- import { InjectionToken, Component, Input, HostBinding, Injectable, ComponentFactoryResolver, Inject, ɵɵdefineInjectable, ɵɵinject, Directive, ViewContainerRef, NgModule } from '@angular/core';
1
+ import * as i0 from '@angular/core';
2
+ import { InjectionToken, Component, Input, HostBinding, Injectable, Inject, Directive, NgModule } from '@angular/core';
3
+ import * as i4 from '@angular/common';
2
4
  import { CommonModule } from '@angular/common';
3
- import { LoggerService, ConfigurationsService } from '@sunbird-cb/utils';
4
- import { DomSanitizer } from '@angular/platform-browser';
5
- import { MatButtonModule, MatIconModule, MatCardModule } from '@angular/material';
5
+ import * as i1 from '@angular/material/card';
6
+ import { MatCardModule } from '@angular/material/card';
7
+ import * as i2 from '@angular/material/icon';
8
+ import { MatIconModule } from '@angular/material/icon';
9
+ import * as i3 from '@angular/material/button';
10
+ import { MatButtonModule } from '@angular/material/button';
11
+ import * as i1$1 from '@angular/platform-browser';
12
+ import * as i2$1 from '@sunbird-cb/utils';
13
+ import { ConfigurationsService } from '@sunbird-cb/utils';
6
14
 
7
- const WIDGET_RESOLVER_GLOBAL_CONFIG = new InjectionToken('Global Registration Configuration for Widget Resolvers');
15
+ const WIDGET_RESOLVER_GLOBAL_CONFIG = new InjectionToken('Global Registration Configuration for Widget Resolvers');
8
16
  const WIDGET_RESOLVER_SCOPED_CONFIG = new InjectionToken('Scoped Registration Configuration for Widget Resolvers');
9
17
 
10
- function isStringArray(strArr) {
11
- return Array.isArray(strArr) && strArr.every((u => typeof u === 'string'));
12
- }
13
- function isCheckRequired(requiredPermission) {
14
- if (requiredPermission === undefined ||
15
- requiredPermission === null ||
16
- requiredPermission === '' ||
17
- (Array.isArray(requiredPermission) && requiredPermission.length === 0)) {
18
- return false;
19
- }
20
- return true;
21
- }
22
- function flipBoolean(value, flip = false) {
23
- return flip ? !value : value;
24
- }
25
- function permissionTest(testFor, requiredPermission, matchAgainst, isRestrictive = false) {
26
- if (!isCheckRequired(requiredPermission)) {
27
- return true;
28
- }
29
- if (typeof requiredPermission === 'string') {
30
- switch (testFor) {
31
- case 'all':
32
- case 'some':
33
- return flipBoolean(matchAgainst.has(requiredPermission), isRestrictive);
34
- case 'none':
35
- return flipBoolean(!matchAgainst.has(requiredPermission), isRestrictive);
36
- }
37
- }
38
- if (Array.isArray(requiredPermission)) {
39
- const matcher = ((u) => typeof u === 'string' && flipBoolean(matchAgainst.has(u), isRestrictive));
40
- switch (testFor) {
41
- case 'all':
42
- return requiredPermission.every(matcher);
43
- case 'some':
44
- return requiredPermission.some(matcher);
45
- case 'none':
46
- return !requiredPermission.every(matcher);
47
- }
48
- }
49
- return false;
50
- }
51
- function hasUnitPermission(requiredPermission, matchAgainst, isRestrictive = false) {
52
- if (!isCheckRequired(requiredPermission)) {
53
- return true;
54
- }
55
- const accessValues = matchAgainst instanceof Set
56
- ? matchAgainst
57
- : Array.isArray(matchAgainst) && isStringArray(matchAgainst)
58
- ? new Set(matchAgainst)
59
- : typeof matchAgainst === 'string'
60
- ? new Set([matchAgainst])
61
- : new Set();
62
- if (typeof requiredPermission === 'object' && requiredPermission !== null) {
63
- if (Array.isArray(requiredPermission)) {
64
- return permissionTest('all', requiredPermission, accessValues, isRestrictive);
65
- }
66
- return (permissionTest('all', 'all' in requiredPermission ? requiredPermission.all : null, accessValues, isRestrictive) &&
67
- permissionTest('some', 'some' in requiredPermission ? requiredPermission.some : null, accessValues, isRestrictive) &&
68
- permissionTest('none', 'none' in requiredPermission ? requiredPermission.none : null, accessValues, isRestrictive));
69
- }
70
- return false;
71
- }
72
- function hasPermissions(requiredPermission, availableRoles, availableGroups, restrictedFeatures) {
73
- if (!requiredPermission) {
74
- return true;
75
- }
76
- if (!requiredPermission.available || !requiredPermission.enabled) {
77
- return false;
78
- }
79
- return (hasUnitPermission(requiredPermission.groups, availableGroups) &&
80
- hasUnitPermission(requiredPermission.roles, availableRoles) &&
81
- hasUnitPermission(requiredPermission.features, restrictedFeatures, true));
18
+ function isStringArray(strArr) {
19
+ return Array.isArray(strArr) && strArr.every(u => typeof u === 'string');
82
20
  }
83
-
84
- class WidgetBaseComponent {
85
- constructor() {
86
- this.widgetType = '';
87
- this.widgetSubType = '';
88
- }
89
- updateBaseComponent(widgetType, widgetSubType, widgetInstanceId, widgetHostClass, widgetSafeStyle) {
90
- this.widgetType = widgetType;
91
- this.widgetSubType = widgetSubType;
92
- this.widgetInstanceId = widgetInstanceId;
93
- this.widgetHostClass = widgetHostClass;
94
- this.widgetSafeStyle = widgetSafeStyle;
95
- if (this.widgetHostClass) {
96
- this.className = `${this.className} ${this.widgetHostClass}`;
97
- }
98
- }
99
- ngAfterViewInit() {
100
- const hash = window.location.hash ? window.location.hash.split('#')[1] : '';
101
- if (hash && !isNaN(hash) && hash === this.widgetInstanceId) {
102
- setTimeout((() => {
103
- const element = document.getElementById(this.widgetInstanceId || '');
104
- if (element) {
105
- element.scrollIntoView();
106
- }
107
- }), 200);
108
- }
109
- }
110
- }
111
- WidgetBaseComponent.decorators = [
112
- { type: Component, args: [{
113
- selector: 'ws-resolver-base',
114
- template: 'Base Component'
115
- }] }
116
- ];
117
- WidgetBaseComponent.propDecorators = {
118
- widgetType: [{ type: Input }],
119
- widgetSubType: [{ type: Input }],
120
- widgetHostClass: [{ type: Input }],
121
- widgetInstanceId: [{ type: Input }, { type: HostBinding, args: ['id',] }],
122
- widgetSafeStyle: [{ type: Input }, { type: HostBinding, args: ['style',] }],
123
- className: [{ type: Input }, { type: HostBinding, args: ['class',] }]
124
- };
125
- if (false) {
126
- WidgetBaseComponent.prototype.widgetType;
127
- WidgetBaseComponent.prototype.widgetSubType;
128
- WidgetBaseComponent.prototype.widgetHostClass;
129
- WidgetBaseComponent.prototype.widgetInstanceId;
130
- WidgetBaseComponent.prototype.widgetSafeStyle;
131
- WidgetBaseComponent.prototype.className;
21
+ function isCheckRequired(requiredPermission) {
22
+ if (requiredPermission === undefined ||
23
+ requiredPermission === null ||
24
+ requiredPermission === '' ||
25
+ (Array.isArray(requiredPermission) && requiredPermission.length === 0)) {
26
+ return false;
27
+ }
28
+ return true;
29
+ }
30
+ function flipBoolean(value, flip = false) {
31
+ return flip ? !value : value;
32
+ }
33
+ function permissionTest(testFor, requiredPermission, matchAgainst, isRestrictive = false) {
34
+ if (!isCheckRequired(requiredPermission)) {
35
+ return true;
36
+ }
37
+ if (typeof requiredPermission === 'string') {
38
+ switch (testFor) {
39
+ case 'all':
40
+ case 'some':
41
+ return flipBoolean(matchAgainst.has(requiredPermission), isRestrictive);
42
+ case 'none':
43
+ return flipBoolean(!matchAgainst.has(requiredPermission), isRestrictive);
44
+ }
45
+ }
46
+ if (Array.isArray(requiredPermission)) {
47
+ const matcher = (u) => typeof u === 'string' && flipBoolean(matchAgainst.has(u), isRestrictive);
48
+ switch (testFor) {
49
+ case 'all':
50
+ return requiredPermission.every(matcher);
51
+ case 'some':
52
+ return requiredPermission.some(matcher);
53
+ case 'none':
54
+ return !requiredPermission.every(matcher);
55
+ }
56
+ }
57
+ return false;
58
+ }
59
+ function hasUnitPermission(requiredPermission, matchAgainst, isRestrictive = false) {
60
+ if (!isCheckRequired(requiredPermission)) {
61
+ return true;
62
+ }
63
+ const accessValues = matchAgainst instanceof Set
64
+ ? matchAgainst
65
+ : Array.isArray(matchAgainst) && isStringArray(matchAgainst)
66
+ ? new Set(matchAgainst)
67
+ : typeof matchAgainst === 'string'
68
+ ? new Set([matchAgainst])
69
+ : new Set();
70
+ if (typeof requiredPermission === 'object' && requiredPermission !== null) {
71
+ if (Array.isArray(requiredPermission)) {
72
+ return permissionTest('all', requiredPermission, accessValues, isRestrictive);
73
+ }
74
+ return (permissionTest('all', 'all' in requiredPermission ? requiredPermission.all : null, accessValues, isRestrictive) &&
75
+ permissionTest('some', 'some' in requiredPermission ? requiredPermission.some : null, accessValues, isRestrictive) &&
76
+ permissionTest('none', 'none' in requiredPermission ? requiredPermission.none : null, accessValues, isRestrictive));
77
+ }
78
+ return false;
79
+ }
80
+ function hasPermissions(requiredPermission, availableRoles, availableGroups, restrictedFeatures) {
81
+ if (!requiredPermission) {
82
+ return true;
83
+ }
84
+ if (!requiredPermission.available || !requiredPermission.enabled) {
85
+ return false;
86
+ }
87
+ return (hasUnitPermission(requiredPermission.groups, availableGroups) &&
88
+ hasUnitPermission(requiredPermission.roles, availableRoles) &&
89
+ hasUnitPermission(requiredPermission.features, restrictedFeatures, true));
132
90
  }
133
91
 
134
- class RestrictedComponent extends WidgetBaseComponent {
135
- constructor() {
136
- super(...arguments);
137
- this.showData = true;
138
- }
139
- ngOnInit() { }
140
- }
141
- RestrictedComponent.decorators = [
142
- { type: Component, args: [{
143
- selector: 'ws-resolver-restricted',
144
- template: "<mat-card class=\"margin-m\">\r\n <mat-card-header>\r\n <div mat-card-avatar class=\"mat-card-avatar-override\">\r\n <mat-icon color=\"warn\">report_problem</mat-icon>\r\n </div>\r\n <mat-card-title>\r\n <ng-container i18n>\r\n Error as Restricted Widget\r\n </ng-container>\r\n </mat-card-title>\r\n </mat-card-header>\r\n <div class=\"flex flex-wrap flex-between\">\r\n <div>\r\n <div class=\"margin-top-s\">\r\n <span class=\"mat-body-2 font-bold\" i18n>\r\n Widget Type :\r\n </span>\r\n {{ widgetType }}\r\n </div>\r\n <div class=\"margin-top-s\">\r\n <span class=\"mat-body-2 font-bold\" i18n>\r\n Widget Sub Type :\r\n </span>\r\n {{ widgetSubType }}\r\n </div>\r\n </div>\r\n <div>\r\n <ng-container *ngIf=\"widgetData\">\r\n <button mat-raised-button class=\"margin-top-m\" color=\"primary\" *ngIf=\"!showData\" (click)=\"showData = true\">\r\n <ng-container i18n>See Details</ng-container>\r\n <mat-icon>arrow_drop_down</mat-icon>\r\n </button>\r\n <button mat-raised-button class=\"margin-top-m\" color=\"primary\" *ngIf=\"showData\" (click)=\"showData = false\">\r\n <ng-container i18n>Hide Details</ng-container>\r\n <mat-icon>arrow_drop_up</mat-icon>\r\n </button>\r\n </ng-container>\r\n </div>\r\n </div>\r\n <ng-container *ngIf=\"widgetData\">\r\n <pre *ngIf=\"showData\" class=\"margin-top-s \"><span i18n class=\"mat-body-2 font-bold\">Widget Data :</span>\r\n{{ widgetData | json }}\r\n </pre>\r\n </ng-container>\r\n</mat-card>",
145
- styles: [".mat-card-avatar-override{height:24px!important;width:24px!important}"]
146
- }] }
147
- ];
148
- RestrictedComponent.propDecorators = {
149
- widgetData: [{ type: Input }]
150
- };
151
- if (false) {
152
- RestrictedComponent.prototype.widgetData;
153
- RestrictedComponent.prototype.showData;
92
+ class WidgetBaseComponent {
93
+ constructor() {
94
+ this.widgetType = '';
95
+ this.widgetSubType = '';
96
+ }
97
+ updateBaseComponent(widgetType, widgetSubType, widgetInstanceId, widgetHostClass, widgetSafeStyle) {
98
+ this.widgetType = widgetType;
99
+ this.widgetSubType = widgetSubType;
100
+ this.widgetInstanceId = widgetInstanceId;
101
+ this.widgetHostClass = widgetHostClass;
102
+ this.widgetSafeStyle = widgetSafeStyle;
103
+ if (this.widgetHostClass) {
104
+ this.className = `${this.className} ${this.widgetHostClass}`;
105
+ }
106
+ }
107
+ ngAfterViewInit() {
108
+ const hash = window.location.hash ? window.location.hash.split('#')[1] : '';
109
+ if (hash && !isNaN(hash) && hash === this.widgetInstanceId) {
110
+ setTimeout(() => {
111
+ const element = document.getElementById(this.widgetInstanceId || '');
112
+ if (element) {
113
+ element.scrollIntoView();
114
+ }
115
+ }, 200);
116
+ }
117
+ }
154
118
  }
119
+ WidgetBaseComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: WidgetBaseComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
120
+ WidgetBaseComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: WidgetBaseComponent, selector: "ws-resolver-base", inputs: { widgetType: "widgetType", widgetSubType: "widgetSubType", widgetHostClass: "widgetHostClass", widgetInstanceId: "widgetInstanceId", widgetSafeStyle: "widgetSafeStyle", className: "className" }, host: { properties: { "id": "this.widgetInstanceId", "style": "this.widgetSafeStyle", "class": "this.className" } }, ngImport: i0, template: 'Base Component', isInline: true });
121
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: WidgetBaseComponent, decorators: [{
122
+ type: Component,
123
+ args: [{
124
+ selector: 'ws-resolver-base',
125
+ template: 'Base Component',
126
+ }]
127
+ }], propDecorators: { widgetType: [{
128
+ type: Input
129
+ }], widgetSubType: [{
130
+ type: Input
131
+ }], widgetHostClass: [{
132
+ type: Input
133
+ }], widgetInstanceId: [{
134
+ type: Input
135
+ }, {
136
+ type: HostBinding,
137
+ args: ['id']
138
+ }], widgetSafeStyle: [{
139
+ type: Input
140
+ }, {
141
+ type: HostBinding,
142
+ args: ['style']
143
+ }], className: [{
144
+ type: Input
145
+ }, {
146
+ type: HostBinding,
147
+ args: ['class']
148
+ }] } });
155
149
 
156
- class InvalidRegistrationComponent extends WidgetBaseComponent {
157
- constructor() {
158
- super(...arguments);
159
- this.showData = true;
160
- }
161
- ngOnInit() { }
162
- }
163
- InvalidRegistrationComponent.decorators = [
164
- { type: Component, args: [{
165
- selector: 'ws-resolver-invalid-registration',
166
- template: "<mat-card class=\"margin-m\">\r\n <mat-card-header>\r\n <div mat-card-avatar class=\"mat-card-avatar-override\">\r\n <mat-icon color=\"warn\">report_problem</mat-icon>\r\n </div>\r\n <mat-card-title>\r\n <ng-container i18n>\r\n Error as Invalid Registration for Widget\r\n </ng-container>\r\n </mat-card-title>\r\n </mat-card-header>\r\n <div class=\"flex flex-wrap flex-between\">\r\n <div>\r\n <div class=\"margin-top-s\">\r\n <span class=\"mat-body-2 font-bold\" i18n>\r\n Widget Type :\r\n </span>\r\n {{ widgetType }}\r\n </div>\r\n <div class=\"margin-top-s\">\r\n <span class=\"mat-body-2 font-bold\" i18n>\r\n Widget Sub Type :\r\n </span>\r\n {{ widgetSubType }}\r\n </div>\r\n </div>\r\n <div>\r\n <ng-container *ngIf=\"widgetData\">\r\n <button mat-raised-button class=\"margin-top-m\" color=\"primary\" *ngIf=\"!showData\" (click)=\"showData = true\">\r\n <ng-container i18n>See Details</ng-container>\r\n <mat-icon>arrow_drop_down</mat-icon>\r\n </button>\r\n <button mat-raised-button class=\"margin-top-m\" color=\"primary\" *ngIf=\"showData\" (click)=\"showData = false\">\r\n <ng-container i18n>Hide Details</ng-container>\r\n <mat-icon>arrow_drop_up</mat-icon>\r\n </button>\r\n </ng-container>\r\n </div>\r\n </div>\r\n <ng-container *ngIf=\"widgetData\">\r\n <pre *ngIf=\"showData\" class=\"margin-top-s \"><span i18n class=\"mat-body-2 font-bold\">Widget Data :</span>\r\n{{ widgetData | json }}\r\n </pre>\r\n </ng-container>\r\n</mat-card>",
167
- styles: [".mat-card-avatar-override{height:24px!important;width:24px!important}"]
168
- }] }
169
- ];
170
- InvalidRegistrationComponent.propDecorators = {
171
- widgetData: [{ type: Input }]
172
- };
173
- if (false) {
174
- InvalidRegistrationComponent.prototype.widgetData;
175
- InvalidRegistrationComponent.prototype.showData;
150
+ class RestrictedComponent extends WidgetBaseComponent {
151
+ constructor() {
152
+ super(...arguments);
153
+ this.showData = true;
154
+ }
155
+ ngOnInit() { }
176
156
  }
157
+ RestrictedComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RestrictedComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
158
+ RestrictedComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: RestrictedComponent, selector: "ws-resolver-restricted", inputs: { widgetData: "widgetData" }, usesInheritance: true, ngImport: i0, template: "<mat-card class=\"margin-m\">\r\n <mat-card-header>\r\n <div mat-card-avatar class=\"mat-card-avatar-override\">\r\n <mat-icon color=\"warn\">report_problem</mat-icon>\r\n </div>\r\n <mat-card-title>\r\n <ng-container i18n>\r\n Error as Restricted Widget\r\n </ng-container>\r\n </mat-card-title>\r\n </mat-card-header>\r\n <div class=\"flex flex-wrap flex-between\">\r\n <div>\r\n <div class=\"margin-top-s\">\r\n <span class=\"mat-body-2 font-bold\" i18n>\r\n Widget Type :\r\n </span>\r\n {{ widgetType }}\r\n </div>\r\n <div class=\"margin-top-s\">\r\n <span class=\"mat-body-2 font-bold\" i18n>\r\n Widget Sub Type :\r\n </span>\r\n {{ widgetSubType }}\r\n </div>\r\n </div>\r\n <div>\r\n <ng-container *ngIf=\"widgetData\">\r\n <button mat-raised-button class=\"margin-top-m\" color=\"primary\" *ngIf=\"!showData\" (click)=\"showData = true\">\r\n <ng-container i18n>See Details</ng-container>\r\n <mat-icon>arrow_drop_down</mat-icon>\r\n </button>\r\n <button mat-raised-button class=\"margin-top-m\" color=\"primary\" *ngIf=\"showData\" (click)=\"showData = false\">\r\n <ng-container i18n>Hide Details</ng-container>\r\n <mat-icon>arrow_drop_up</mat-icon>\r\n </button>\r\n </ng-container>\r\n </div>\r\n </div>\r\n <ng-container *ngIf=\"widgetData\">\r\n <pre *ngIf=\"showData\" class=\"margin-top-s \"><span i18n class=\"mat-body-2 font-bold\">Widget Data :</span>\r\n{{ widgetData | json }}\r\n </pre>\r\n </ng-container>\r\n</mat-card>", styles: [".mat-card-avatar-override{height:24px!important;width:24px!important}\n"], components: [{ type: i1.MatCard, selector: "mat-card", exportAs: ["matCard"] }, { type: i1.MatCardHeader, selector: "mat-card-header" }, { type: i2.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { type: i3.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }], directives: [{ type: i1.MatCardAvatar, selector: "[mat-card-avatar], [matCardAvatar]" }, { type: i1.MatCardTitle, selector: "mat-card-title, [mat-card-title], [matCardTitle]" }, { type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], pipes: { "json": i4.JsonPipe } });
159
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RestrictedComponent, decorators: [{
160
+ type: Component,
161
+ args: [{
162
+ selector: 'ws-resolver-restricted',
163
+ templateUrl: './restricted.component.html',
164
+ styleUrls: ['./restricted.component.scss'],
165
+ }]
166
+ }], propDecorators: { widgetData: [{
167
+ type: Input
168
+ }] } });
177
169
 
178
- class InvalidPermissionComponent extends WidgetBaseComponent {
179
- constructor() {
180
- super(...arguments);
181
- this.showData = true;
182
- }
183
- ngOnInit() { }
184
- }
185
- InvalidPermissionComponent.decorators = [
186
- { type: Component, args: [{
187
- selector: 'ws-resolver-invalid-permission',
188
- template: "<mat-card class=\"margin-m\">\r\n <mat-card-header>\r\n <div mat-card-avatar class=\"mat-card-avatar-override\">\r\n <mat-icon color=\"warn\">report_problem</mat-icon>\r\n </div>\r\n <mat-card-title>\r\n <ng-container i18n>\r\n Error as Invalid Permission for Widget\r\n </ng-container>\r\n </mat-card-title>\r\n </mat-card-header>\r\n <div class=\"flex flex-wrap flex-between\">\r\n <div>\r\n <div class=\"margin-top-s\">\r\n <span class=\"mat-body-2 font-bold\" i18n>\r\n Widget Type :\r\n </span>\r\n {{ widgetType }}\r\n </div>\r\n <div class=\"margin-top-s\">\r\n <span class=\"mat-body-2 font-bold\" i18n>\r\n Widget Sub Type :\r\n </span>\r\n {{ widgetSubType }}\r\n </div>\r\n </div>\r\n <div>\r\n <ng-container *ngIf=\"widgetData\">\r\n <button mat-raised-button class=\"margin-top-m\" color=\"primary\" *ngIf=\"!showData\" (click)=\"showData = true\">\r\n <ng-container i18n>See Details</ng-container>\r\n <mat-icon>arrow_drop_down</mat-icon>\r\n </button>\r\n <button mat-raised-button class=\"margin-top-m\" color=\"primary\" *ngIf=\"showData\" (click)=\"showData = false\">\r\n <ng-container i18n>Hide Details</ng-container>\r\n <mat-icon>arrow_drop_up</mat-icon>\r\n </button>\r\n </ng-container>\r\n </div>\r\n </div>\r\n <ng-container *ngIf=\"widgetData\">\r\n <pre *ngIf=\"showData\" class=\"margin-top-s \"><span i18n class=\"mat-body-2 font-bold\">Widget Data :</span>\r\n{{ widgetData | json }}\r\n </pre>\r\n </ng-container>\r\n</mat-card>",
189
- styles: [".mat-card-avatar-override{height:24px!important;width:24px!important}"]
190
- }] }
191
- ];
192
- InvalidPermissionComponent.propDecorators = {
193
- widgetType: [{ type: Input }],
194
- widgetSubType: [{ type: Input }],
195
- widgetInstanceId: [{ type: Input }],
196
- widgetData: [{ type: Input }]
197
- };
198
- if (false) {
199
- InvalidPermissionComponent.prototype.widgetType;
200
- InvalidPermissionComponent.prototype.widgetSubType;
201
- InvalidPermissionComponent.prototype.widgetInstanceId;
202
- InvalidPermissionComponent.prototype.widgetData;
203
- InvalidPermissionComponent.prototype.showData;
170
+ class InvalidRegistrationComponent extends WidgetBaseComponent {
171
+ constructor() {
172
+ super(...arguments);
173
+ this.showData = true;
174
+ }
175
+ ngOnInit() { }
204
176
  }
177
+ InvalidRegistrationComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InvalidRegistrationComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
178
+ InvalidRegistrationComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: InvalidRegistrationComponent, selector: "ws-resolver-invalid-registration", inputs: { widgetData: "widgetData" }, usesInheritance: true, ngImport: i0, template: "<mat-card class=\"margin-m\">\r\n <mat-card-header>\r\n <div mat-card-avatar class=\"mat-card-avatar-override\">\r\n <mat-icon color=\"warn\">report_problem</mat-icon>\r\n </div>\r\n <mat-card-title>\r\n <ng-container i18n>\r\n Error as Invalid Registration for Widget\r\n </ng-container>\r\n </mat-card-title>\r\n </mat-card-header>\r\n <div class=\"flex flex-wrap flex-between\">\r\n <div>\r\n <div class=\"margin-top-s\">\r\n <span class=\"mat-body-2 font-bold\" i18n>\r\n Widget Type :\r\n </span>\r\n {{ widgetType }}\r\n </div>\r\n <div class=\"margin-top-s\">\r\n <span class=\"mat-body-2 font-bold\" i18n>\r\n Widget Sub Type :\r\n </span>\r\n {{ widgetSubType }}\r\n </div>\r\n </div>\r\n <div>\r\n <ng-container *ngIf=\"widgetData\">\r\n <button mat-raised-button class=\"margin-top-m\" color=\"primary\" *ngIf=\"!showData\" (click)=\"showData = true\">\r\n <ng-container i18n>See Details</ng-container>\r\n <mat-icon>arrow_drop_down</mat-icon>\r\n </button>\r\n <button mat-raised-button class=\"margin-top-m\" color=\"primary\" *ngIf=\"showData\" (click)=\"showData = false\">\r\n <ng-container i18n>Hide Details</ng-container>\r\n <mat-icon>arrow_drop_up</mat-icon>\r\n </button>\r\n </ng-container>\r\n </div>\r\n </div>\r\n <ng-container *ngIf=\"widgetData\">\r\n <pre *ngIf=\"showData\" class=\"margin-top-s \"><span i18n class=\"mat-body-2 font-bold\">Widget Data :</span>\r\n{{ widgetData | json }}\r\n </pre>\r\n </ng-container>\r\n</mat-card>", styles: [".mat-card-avatar-override{height:24px!important;width:24px!important}\n"], components: [{ type: i1.MatCard, selector: "mat-card", exportAs: ["matCard"] }, { type: i1.MatCardHeader, selector: "mat-card-header" }, { type: i2.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { type: i3.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }], directives: [{ type: i1.MatCardAvatar, selector: "[mat-card-avatar], [matCardAvatar]" }, { type: i1.MatCardTitle, selector: "mat-card-title, [mat-card-title], [matCardTitle]" }, { type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], pipes: { "json": i4.JsonPipe } });
179
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InvalidRegistrationComponent, decorators: [{
180
+ type: Component,
181
+ args: [{
182
+ selector: 'ws-resolver-invalid-registration',
183
+ templateUrl: './invalid-registration.component.html',
184
+ styleUrls: ['./invalid-registration.component.scss'],
185
+ }]
186
+ }], propDecorators: { widgetData: [{
187
+ type: Input
188
+ }] } });
205
189
 
206
- class UnresolvedComponent extends WidgetBaseComponent {
207
- constructor() {
208
- super(...arguments);
209
- this.showData = true;
210
- this.previewMode = false;
211
- this.searchArray = ['preview', 'channel'];
212
- }
213
- ngOnInit() {
214
- const url = window.location.href;
215
- this.previewMode = this.searchArray.some(((word) => {
216
- return url.indexOf(word) > -1;
217
- }));
218
- }
219
- }
220
- UnresolvedComponent.decorators = [
221
- { type: Component, args: [{
222
- selector: 'ws-resolver-unresolved',
223
- template: "<ng-container *ngIf=\"previewMode\" [ngTemplateOutlet]=\"previewCardTemplate\"></ng-container>\r\n<ng-container *ngIf=\"!previewMode\" [ngTemplateOutlet]=\"unresolvedTemplate\"></ng-container>\r\n\r\n<ng-template #unresolvedTemplate>\r\n <mat-card class=\"margin-m\">\r\n <mat-card-header>\r\n <div mat-card-avatar class=\"mat-card-avatar-override\">\r\n <mat-icon color=\"warn\">report_problem</mat-icon>\r\n </div>\r\n <mat-card-title>\r\n <ng-container i18n>\r\n Error in Resolving Json for Widget\r\n </ng-container>\r\n </mat-card-title>\r\n </mat-card-header>\r\n <div class=\"flex flex-wrap flex-between\">\r\n <div>\r\n <div class=\"margin-top-s\">\r\n <span class=\"mat-body-2 font-bold\" i18n>\r\n Widget Type :\r\n </span>\r\n {{ widgetType }}\r\n </div>\r\n <div class=\"margin-top-s\">\r\n <span class=\"mat-body-2 font-bold\" i18n>\r\n Widget Sub Type :\r\n </span>\r\n {{ widgetSubType }}\r\n </div>\r\n </div>\r\n <div>\r\n <ng-container *ngIf=\"widgetData\">\r\n <button mat-raised-button class=\"margin-top-m\" color=\"primary\" *ngIf=\"!showData\" (click)=\"showData = true\">\r\n <ng-container i18n>See Details</ng-container>\r\n <mat-icon>arrow_drop_down</mat-icon>\r\n </button>\r\n <button mat-raised-button class=\"margin-top-m\" color=\"primary\" *ngIf=\"showData\" (click)=\"showData = false\">\r\n <ng-container i18n>Hide Details</ng-container>\r\n <mat-icon>arrow_drop_up</mat-icon>\r\n </button>\r\n </ng-container>\r\n </div>\r\n </div>\r\n <ng-container *ngIf=\"widgetData\">\r\n <pre *ngIf=\"showData\" class=\"margin-top-s\"><span i18n class=\"mat-body-2 font-bold\">Widget Data :</span>\r\n{{ widgetData | json }}\r\n </pre>\r\n </ng-container>\r\n </mat-card>\r\n</ng-template>\r\n<ng-template #previewCardTemplate>\r\n <mat-card>\r\n <div class=\"w-full\">\r\n <div class=\"p-4\">\r\n <div class=\"text-3xl font-semibold text-center leading-tight\" i18n>\r\n Content not available\r\n </div>\r\n <br />\r\n <div class=\"text-base font-medium text-center leading-normal\" i18n>\r\n Please add widget or provide data to widget template\r\n </div>\r\n </div>\r\n </div>\r\n </mat-card>\r\n</ng-template>",
224
- styles: [".mat-card-avatar-override{height:24px!important;width:24px!important}"]
225
- }] }
226
- ];
227
- UnresolvedComponent.propDecorators = {
228
- widgetData: [{ type: Input }]
229
- };
230
- if (false) {
231
- UnresolvedComponent.prototype.widgetData;
232
- UnresolvedComponent.prototype.showData;
233
- UnresolvedComponent.prototype.previewMode;
234
- UnresolvedComponent.prototype.searchArray;
190
+ class InvalidPermissionComponent extends WidgetBaseComponent {
191
+ constructor() {
192
+ super(...arguments);
193
+ this.showData = true;
194
+ }
195
+ ngOnInit() { }
235
196
  }
197
+ InvalidPermissionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InvalidPermissionComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
198
+ InvalidPermissionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: InvalidPermissionComponent, selector: "ws-resolver-invalid-permission", inputs: { widgetType: "widgetType", widgetSubType: "widgetSubType", widgetInstanceId: "widgetInstanceId", widgetData: "widgetData" }, usesInheritance: true, ngImport: i0, template: "<mat-card class=\"margin-m\">\r\n <mat-card-header>\r\n <div mat-card-avatar class=\"mat-card-avatar-override\">\r\n <mat-icon color=\"warn\">report_problem</mat-icon>\r\n </div>\r\n <mat-card-title>\r\n <ng-container i18n>\r\n Error as Invalid Permission for Widget\r\n </ng-container>\r\n </mat-card-title>\r\n </mat-card-header>\r\n <div class=\"flex flex-wrap flex-between\">\r\n <div>\r\n <div class=\"margin-top-s\">\r\n <span class=\"mat-body-2 font-bold\" i18n>\r\n Widget Type :\r\n </span>\r\n {{ widgetType }}\r\n </div>\r\n <div class=\"margin-top-s\">\r\n <span class=\"mat-body-2 font-bold\" i18n>\r\n Widget Sub Type :\r\n </span>\r\n {{ widgetSubType }}\r\n </div>\r\n </div>\r\n <div>\r\n <ng-container *ngIf=\"widgetData\">\r\n <button mat-raised-button class=\"margin-top-m\" color=\"primary\" *ngIf=\"!showData\" (click)=\"showData = true\">\r\n <ng-container i18n>See Details</ng-container>\r\n <mat-icon>arrow_drop_down</mat-icon>\r\n </button>\r\n <button mat-raised-button class=\"margin-top-m\" color=\"primary\" *ngIf=\"showData\" (click)=\"showData = false\">\r\n <ng-container i18n>Hide Details</ng-container>\r\n <mat-icon>arrow_drop_up</mat-icon>\r\n </button>\r\n </ng-container>\r\n </div>\r\n </div>\r\n <ng-container *ngIf=\"widgetData\">\r\n <pre *ngIf=\"showData\" class=\"margin-top-s \"><span i18n class=\"mat-body-2 font-bold\">Widget Data :</span>\r\n{{ widgetData | json }}\r\n </pre>\r\n </ng-container>\r\n</mat-card>", styles: [".mat-card-avatar-override{height:24px!important;width:24px!important}\n"], components: [{ type: i1.MatCard, selector: "mat-card", exportAs: ["matCard"] }, { type: i1.MatCardHeader, selector: "mat-card-header" }, { type: i2.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { type: i3.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }], directives: [{ type: i1.MatCardAvatar, selector: "[mat-card-avatar], [matCardAvatar]" }, { type: i1.MatCardTitle, selector: "mat-card-title, [mat-card-title], [matCardTitle]" }, { type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], pipes: { "json": i4.JsonPipe } });
199
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: InvalidPermissionComponent, decorators: [{
200
+ type: Component,
201
+ args: [{
202
+ selector: 'ws-resolver-invalid-permission',
203
+ templateUrl: './invalid-permission.component.html',
204
+ styleUrls: ['./invalid-permission.component.scss'],
205
+ }]
206
+ }], propDecorators: { widgetType: [{
207
+ type: Input
208
+ }], widgetSubType: [{
209
+ type: Input
210
+ }], widgetInstanceId: [{
211
+ type: Input
212
+ }], widgetData: [{
213
+ type: Input
214
+ }] } });
236
215
 
237
- class WidgetResolverService {
238
- constructor(domSanitizer, componentFactoryResolver, loggerSvc, globalConfig, scopedConfig) {
239
- this.domSanitizer = domSanitizer;
240
- this.componentFactoryResolver = componentFactoryResolver;
241
- this.loggerSvc = loggerSvc;
242
- this.globalConfig = globalConfig;
243
- this.scopedConfig = scopedConfig;
244
- this.roles = null;
245
- this.groups = null;
246
- this.restrictedFeatures = null;
247
- this.isInitialized = false;
248
- this.availableRegisteredWidgets = null;
249
- this.restrictedWidgetKeys = null;
250
- }
251
- static getWidgetKey(config) {
252
- return `widget:${config.widgetType}::${config.widgetSubType}`;
253
- }
254
- initialize(restrictedWidgetKeys, roles, groups, restrictedFeatures) {
255
- this.roles = roles;
256
- this.groups = groups;
257
- this.restrictedFeatures = restrictedFeatures;
258
- const restrictedWidgetKeysSet = restrictedWidgetKeys
259
- ? restrictedWidgetKeys
260
- : new Set();
261
- const registrationConfig = new Map();
262
- const allWidgetsConfigurations = [];
263
- if (this.globalConfig && Array.isArray(this.globalConfig)) {
264
- allWidgetsConfigurations.push(...this.globalConfig);
265
- }
266
- if (this.scopedConfig && Array.isArray(this.scopedConfig)) {
267
- allWidgetsConfigurations.push(...this.scopedConfig);
268
- }
269
- allWidgetsConfigurations.forEach((u => {
270
- const key = WidgetResolverService.getWidgetKey(u);
271
- if (!restrictedWidgetKeysSet.has(key)) {
272
- registrationConfig.set(key, u);
273
- }
274
- }));
275
- this.restrictedWidgetKeys = restrictedWidgetKeysSet;
276
- this.availableRegisteredWidgets = registrationConfig;
277
- this.isInitialized = true;
278
- this.loggerSvc.log(`Widget Configurations`, this.globalConfig, this.scopedConfig, this.availableRegisteredWidgets);
279
- }
280
- resolveWidget(receivedConfig, containerRef) {
281
- const key = WidgetResolverService.getWidgetKey(receivedConfig);
282
- if (this.restrictedWidgetKeys && this.restrictedWidgetKeys.has(key)) {
283
- return this.widgetResolved(containerRef, receivedConfig, RestrictedComponent);
284
- }
285
- if (this.availableRegisteredWidgets && this.availableRegisteredWidgets.has(key)) {
286
- if (hasPermissions(receivedConfig.widgetPermission, this.roles, this.groups, this.restrictedFeatures)) {
287
- const config = this.availableRegisteredWidgets.get(key);
288
- if (config && config.component) {
289
- return this.widgetResolved(containerRef, receivedConfig, config.component);
290
- }
291
- return this.widgetResolved(containerRef, receivedConfig, InvalidRegistrationComponent);
292
- }
293
- return this.widgetResolved(containerRef, receivedConfig, InvalidPermissionComponent);
294
- }
295
- return this.widgetResolved(containerRef, receivedConfig, UnresolvedComponent);
296
- }
297
- widgetResolved(containerRef, compData, component) {
298
- const factory = this.componentFactoryResolver.resolveComponentFactory(component);
299
- containerRef.clear();
300
- const compRef = containerRef.createComponent(factory);
301
- compRef.instance.widgetData = compData.widgetData;
302
- if (compRef.instance.updateBaseComponent) {
303
- const widgetSafeStyle = compData.widgetHostStyle
304
- ? this.domSanitizer.bypassSecurityTrustStyle(Object.entries(compData.widgetHostStyle).reduce(((s, [k, v]) => `${s}${k}:${v};`), ''))
305
- : undefined;
306
- compRef.instance.updateBaseComponent(compData.widgetType, compData.widgetSubType, compData.widgetInstanceId, compData.widgetHostClass, widgetSafeStyle);
307
- }
308
- return compRef;
309
- }
310
- }
311
- WidgetResolverService.decorators = [
312
- { type: Injectable, args: [{
313
- providedIn: 'root',
314
- },] }
315
- ];
316
- WidgetResolverService.ctorParameters = () => [
317
- { type: DomSanitizer },
318
- { type: ComponentFactoryResolver },
319
- { type: LoggerService },
320
- { type: undefined, decorators: [{ type: Inject, args: [WIDGET_RESOLVER_GLOBAL_CONFIG,] }] },
321
- { type: undefined, decorators: [{ type: Inject, args: [WIDGET_RESOLVER_SCOPED_CONFIG,] }] }
322
- ];
323
- /** @nocollapse */ WidgetResolverService.ngInjectableDef = ɵɵdefineInjectable({ factory: function WidgetResolverService_Factory() { return new WidgetResolverService(ɵɵinject(DomSanitizer), ɵɵinject(ComponentFactoryResolver), ɵɵinject(LoggerService), ɵɵinject(WIDGET_RESOLVER_GLOBAL_CONFIG), ɵɵinject(WIDGET_RESOLVER_SCOPED_CONFIG)); }, token: WidgetResolverService, providedIn: "root" });
324
- if (false) {
325
- WidgetResolverService.prototype.roles;
326
- WidgetResolverService.prototype.groups;
327
- WidgetResolverService.prototype.restrictedFeatures;
328
- WidgetResolverService.prototype.isInitialized;
329
- WidgetResolverService.prototype.availableRegisteredWidgets;
330
- WidgetResolverService.prototype.restrictedWidgetKeys;
331
- WidgetResolverService.prototype.domSanitizer;
332
- WidgetResolverService.prototype.componentFactoryResolver;
333
- WidgetResolverService.prototype.loggerSvc;
334
- WidgetResolverService.prototype.globalConfig;
335
- WidgetResolverService.prototype.scopedConfig;
216
+ class UnresolvedComponent extends WidgetBaseComponent {
217
+ constructor() {
218
+ super(...arguments);
219
+ this.showData = true;
220
+ this.previewMode = false;
221
+ this.searchArray = ['preview', 'channel'];
222
+ }
223
+ ngOnInit() {
224
+ const url = window.location.href;
225
+ this.previewMode = this.searchArray.some((word) => {
226
+ return url.indexOf(word) > -1;
227
+ });
228
+ }
336
229
  }
230
+ UnresolvedComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: UnresolvedComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
231
+ UnresolvedComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: UnresolvedComponent, selector: "ws-resolver-unresolved", inputs: { widgetData: "widgetData" }, usesInheritance: true, ngImport: i0, template: "<ng-container *ngIf=\"previewMode\" [ngTemplateOutlet]=\"previewCardTemplate\"></ng-container>\r\n<ng-container *ngIf=\"!previewMode\" [ngTemplateOutlet]=\"unresolvedTemplate\"></ng-container>\r\n\r\n<ng-template #unresolvedTemplate>\r\n <mat-card class=\"margin-m\">\r\n <mat-card-header>\r\n <div mat-card-avatar class=\"mat-card-avatar-override\">\r\n <mat-icon color=\"warn\">report_problem</mat-icon>\r\n </div>\r\n <mat-card-title>\r\n <ng-container i18n>\r\n Error in Resolving Json for Widget\r\n </ng-container>\r\n </mat-card-title>\r\n </mat-card-header>\r\n <div class=\"flex flex-wrap flex-between\">\r\n <div>\r\n <div class=\"margin-top-s\">\r\n <span class=\"mat-body-2 font-bold\" i18n>\r\n Widget Type :\r\n </span>\r\n {{ widgetType }}\r\n </div>\r\n <div class=\"margin-top-s\">\r\n <span class=\"mat-body-2 font-bold\" i18n>\r\n Widget Sub Type :\r\n </span>\r\n {{ widgetSubType }}\r\n </div>\r\n </div>\r\n <div>\r\n <ng-container *ngIf=\"widgetData\">\r\n <button mat-raised-button class=\"margin-top-m\" color=\"primary\" *ngIf=\"!showData\" (click)=\"showData = true\">\r\n <ng-container i18n>See Details</ng-container>\r\n <mat-icon>arrow_drop_down</mat-icon>\r\n </button>\r\n <button mat-raised-button class=\"margin-top-m\" color=\"primary\" *ngIf=\"showData\" (click)=\"showData = false\">\r\n <ng-container i18n>Hide Details</ng-container>\r\n <mat-icon>arrow_drop_up</mat-icon>\r\n </button>\r\n </ng-container>\r\n </div>\r\n </div>\r\n <ng-container *ngIf=\"widgetData\">\r\n <pre *ngIf=\"showData\" class=\"margin-top-s\"><span i18n class=\"mat-body-2 font-bold\">Widget Data :</span>\r\n{{ widgetData | json }}\r\n </pre>\r\n </ng-container>\r\n </mat-card>\r\n</ng-template>\r\n<ng-template #previewCardTemplate>\r\n <mat-card>\r\n <div class=\"w-full\">\r\n <div class=\"p-4\">\r\n <div class=\"text-3xl font-semibold text-center leading-tight\" i18n>\r\n Content not available\r\n </div>\r\n <br />\r\n <div class=\"text-base font-medium text-center leading-normal\" i18n>\r\n Please add widget or provide data to widget template\r\n </div>\r\n </div>\r\n </div>\r\n </mat-card>\r\n</ng-template>", styles: [".mat-card-avatar-override{height:24px!important;width:24px!important}\n"], components: [{ type: i1.MatCard, selector: "mat-card", exportAs: ["matCard"] }, { type: i1.MatCardHeader, selector: "mat-card-header" }, { type: i2.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { type: i3.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }], directives: [{ type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i4.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }, { type: i1.MatCardAvatar, selector: "[mat-card-avatar], [matCardAvatar]" }, { type: i1.MatCardTitle, selector: "mat-card-title, [mat-card-title], [matCardTitle]" }], pipes: { "json": i4.JsonPipe } });
232
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: UnresolvedComponent, decorators: [{
233
+ type: Component,
234
+ args: [{
235
+ selector: 'ws-resolver-unresolved',
236
+ templateUrl: './unresolved.component.html',
237
+ styleUrls: ['./unresolved.component.scss'],
238
+ }]
239
+ }], propDecorators: { widgetData: [{
240
+ type: Input
241
+ }] } });
337
242
 
338
- class WidgetResolverDirective {
339
- constructor(viewContainerRef, widgetResolverSvc, logger) {
340
- this.viewContainerRef = viewContainerRef;
341
- this.widgetResolverSvc = widgetResolverSvc;
342
- this.logger = logger;
343
- this.wsResolverWidget = null;
344
- }
345
- ngOnChanges() {
346
- if (!this.widgetResolverSvc.isInitialized) {
347
- this.logger.error('Widgets Registration Not Done. Used Before Initialization.', this.wsResolverWidget);
348
- return;
349
- }
350
- if (this.wsResolverWidget) {
351
- const compRef = this.widgetResolverSvc.resolveWidget(this.wsResolverWidget, this.viewContainerRef);
352
- if (compRef) {
353
- compRef.changeDetectorRef.detectChanges();
354
- }
355
- }
356
- }
357
- }
358
- WidgetResolverDirective.decorators = [
359
- { type: Directive, args: [{
360
- selector: '[wsResolverWidget]',
361
- },] }
362
- ];
363
- WidgetResolverDirective.ctorParameters = () => [
364
- { type: ViewContainerRef },
365
- { type: WidgetResolverService },
366
- { type: LoggerService }
367
- ];
368
- WidgetResolverDirective.propDecorators = {
369
- wsResolverWidget: [{ type: Input }]
370
- };
371
- if (false) {
372
- WidgetResolverDirective.prototype.wsResolverWidget;
373
- WidgetResolverDirective.prototype.viewContainerRef;
374
- WidgetResolverDirective.prototype.widgetResolverSvc;
375
- WidgetResolverDirective.prototype.logger;
243
+ class WidgetResolverService {
244
+ constructor(domSanitizer, componentFactoryResolver, globalConfig, scopedConfig) {
245
+ this.domSanitizer = domSanitizer;
246
+ this.componentFactoryResolver = componentFactoryResolver;
247
+ this.globalConfig = globalConfig;
248
+ this.scopedConfig = scopedConfig;
249
+ this.roles = null;
250
+ this.groups = null;
251
+ this.restrictedFeatures = null;
252
+ this.isInitialized = false;
253
+ this.availableRegisteredWidgets = null;
254
+ this.restrictedWidgetKeys = null;
255
+ }
256
+ static getWidgetKey(config) {
257
+ return `widget:${config.widgetType}::${config.widgetSubType}`;
258
+ }
259
+ initialize(restrictedWidgetKeys, roles, groups, restrictedFeatures) {
260
+ this.roles = roles;
261
+ this.groups = groups;
262
+ this.restrictedFeatures = restrictedFeatures;
263
+ const restrictedWidgetKeysSet = restrictedWidgetKeys
264
+ ? restrictedWidgetKeys
265
+ : new Set();
266
+ const registrationConfig = new Map();
267
+ const allWidgetsConfigurations = [];
268
+ if (this.globalConfig && Array.isArray(this.globalConfig)) {
269
+ allWidgetsConfigurations.push(...this.globalConfig);
270
+ }
271
+ if (this.scopedConfig && Array.isArray(this.scopedConfig)) {
272
+ allWidgetsConfigurations.push(...this.scopedConfig);
273
+ }
274
+ allWidgetsConfigurations.forEach(u => {
275
+ const key = WidgetResolverService.getWidgetKey(u);
276
+ if (!restrictedWidgetKeysSet.has(key)) {
277
+ registrationConfig.set(key, u);
278
+ }
279
+ });
280
+ this.restrictedWidgetKeys = restrictedWidgetKeysSet;
281
+ this.availableRegisteredWidgets = registrationConfig;
282
+ this.isInitialized = true;
283
+ }
284
+ resolveWidget(receivedConfig, containerRef) {
285
+ const key = WidgetResolverService.getWidgetKey(receivedConfig);
286
+ if (this.restrictedWidgetKeys && this.restrictedWidgetKeys.has(key)) {
287
+ return this.widgetResolved(containerRef, receivedConfig, RestrictedComponent);
288
+ }
289
+ if (this.availableRegisteredWidgets && this.availableRegisteredWidgets.has(key)) {
290
+ if (hasPermissions(receivedConfig.widgetPermission, this.roles, this.groups, this.restrictedFeatures)) {
291
+ const config = this.availableRegisteredWidgets.get(key);
292
+ if (config && config.component) {
293
+ return this.widgetResolved(containerRef, receivedConfig, config.component);
294
+ }
295
+ return this.widgetResolved(containerRef, receivedConfig, InvalidRegistrationComponent);
296
+ }
297
+ return this.widgetResolved(containerRef, receivedConfig, InvalidPermissionComponent);
298
+ }
299
+ return this.widgetResolved(containerRef, receivedConfig, UnresolvedComponent);
300
+ }
301
+ widgetResolved(containerRef, compData, component) {
302
+ const factory = this.componentFactoryResolver.resolveComponentFactory(component);
303
+ containerRef.clear();
304
+ const compRef = containerRef.createComponent(factory);
305
+ compRef.instance.widgetData = compData.widgetData;
306
+ if (compRef.instance.updateBaseComponent) {
307
+ const widgetSafeStyle = compData.widgetHostStyle
308
+ ? this.domSanitizer.bypassSecurityTrustStyle(Object.entries(compData.widgetHostStyle).reduce((s, [k, v]) => `${s}${k}:${v};`, ''))
309
+ : undefined;
310
+ compRef.instance.updateBaseComponent(compData.widgetType, compData.widgetSubType, compData.widgetInstanceId, compData.widgetHostClass, widgetSafeStyle);
311
+ }
312
+ return compRef;
313
+ }
376
314
  }
315
+ WidgetResolverService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: WidgetResolverService, deps: [{ token: i1$1.DomSanitizer }, { token: i0.ComponentFactoryResolver }, { token: WIDGET_RESOLVER_GLOBAL_CONFIG }, { token: WIDGET_RESOLVER_SCOPED_CONFIG }], target: i0.ɵɵFactoryTarget.Injectable });
316
+ WidgetResolverService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: WidgetResolverService, providedIn: 'root' });
317
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: WidgetResolverService, decorators: [{
318
+ type: Injectable,
319
+ args: [{
320
+ providedIn: 'root',
321
+ }]
322
+ }], ctorParameters: function () { return [{ type: i1$1.DomSanitizer }, { type: i0.ComponentFactoryResolver }, { type: undefined, decorators: [{
323
+ type: Inject,
324
+ args: [WIDGET_RESOLVER_GLOBAL_CONFIG]
325
+ }] }, { type: undefined, decorators: [{
326
+ type: Inject,
327
+ args: [WIDGET_RESOLVER_SCOPED_CONFIG]
328
+ }] }]; } });
377
329
 
378
- class WidgetResolverModule {
379
- static forRoot(config) {
380
- return {
381
- ngModule: WidgetResolverModule,
382
- providers: [
383
- WidgetResolverService,
384
- {
385
- provide: WIDGET_RESOLVER_GLOBAL_CONFIG,
386
- useValue: config,
387
- },
388
- {
389
- provide: WIDGET_RESOLVER_SCOPED_CONFIG,
390
- useValue: [],
391
- },
392
- ],
393
- };
394
- }
395
- static forChild(config) {
396
- return {
397
- ngModule: WidgetResolverModule,
398
- providers: [
399
- WidgetResolverService,
400
- {
401
- provide: WIDGET_RESOLVER_SCOPED_CONFIG,
402
- useValue: config,
403
- },
404
- ],
405
- };
406
- }
407
- }
408
- WidgetResolverModule.decorators = [
409
- { type: NgModule, args: [{
410
- declarations: [
411
- WidgetBaseComponent,
412
- WidgetResolverDirective,
413
- RestrictedComponent,
414
- InvalidRegistrationComponent,
415
- InvalidPermissionComponent,
416
- UnresolvedComponent,
417
- ],
418
- imports: [CommonModule, MatButtonModule, MatIconModule, MatCardModule],
419
- exports: [WidgetResolverDirective, WidgetBaseComponent],
420
- entryComponents: [
421
- RestrictedComponent,
422
- InvalidRegistrationComponent,
423
- InvalidPermissionComponent,
424
- UnresolvedComponent,
425
- WidgetBaseComponent,
426
- ],
427
- providers: [ConfigurationsService],
428
- },] }
429
- ];
330
+ class WidgetResolverDirective {
331
+ constructor(viewContainerRef, widgetResolverSvc, logger) {
332
+ this.viewContainerRef = viewContainerRef;
333
+ this.widgetResolverSvc = widgetResolverSvc;
334
+ this.logger = logger;
335
+ this.wsResolverWidget = null;
336
+ }
337
+ ngOnChanges() {
338
+ if (!this.widgetResolverSvc.isInitialized) {
339
+ this.logger.error('Widgets Registration Not Done. Used Before Initialization.', this.wsResolverWidget);
340
+ return;
341
+ }
342
+ if (this.wsResolverWidget) {
343
+ const compRef = this.widgetResolverSvc.resolveWidget(this.wsResolverWidget, this.viewContainerRef);
344
+ if (compRef) {
345
+ compRef.changeDetectorRef.detectChanges();
346
+ }
347
+ }
348
+ }
349
+ }
350
+ WidgetResolverDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: WidgetResolverDirective, deps: [{ token: i0.ViewContainerRef }, { token: WidgetResolverService }, { token: i2$1.LoggerService }], target: i0.ɵɵFactoryTarget.Directive });
351
+ WidgetResolverDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.17", type: WidgetResolverDirective, selector: "[wsResolverWidget]", inputs: { wsResolverWidget: "wsResolverWidget" }, usesOnChanges: true, ngImport: i0 });
352
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: WidgetResolverDirective, decorators: [{
353
+ type: Directive,
354
+ args: [{
355
+ selector: '[wsResolverWidget]',
356
+ }]
357
+ }], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: WidgetResolverService }, { type: i2$1.LoggerService }]; }, propDecorators: { wsResolverWidget: [{
358
+ type: Input
359
+ }] } });
430
360
 
431
- var NsWidgetResolver;
432
- (function (NsWidgetResolver) {
433
- function IUnitPermissionObject() { }
434
- NsWidgetResolver.IUnitPermissionObject = IUnitPermissionObject;
435
- if (false) {
436
- IUnitPermissionObject.prototype.all;
437
- IUnitPermissionObject.prototype.none;
438
- IUnitPermissionObject.prototype.some;
439
- }
440
- function IPermissions() { }
441
- NsWidgetResolver.IPermissions = IPermissions;
442
- if (false) {
443
- IPermissions.prototype.enabled;
444
- IPermissions.prototype.available;
445
- IPermissions.prototype.roles;
446
- IPermissions.prototype.features;
447
- IPermissions.prototype.groups;
448
- }
449
- function IBaseConfig() { }
450
- NsWidgetResolver.IBaseConfig = IBaseConfig;
451
- if (false) {
452
- IBaseConfig.prototype.widgetType;
453
- IBaseConfig.prototype.widgetSubType;
454
- }
455
- function IRegistrationConfig() { }
456
- NsWidgetResolver.IRegistrationConfig = IRegistrationConfig;
457
- if (false) {
458
- IRegistrationConfig.prototype.component;
459
- }
460
- function IRegistrationsPermissionConfig() { }
461
- NsWidgetResolver.IRegistrationsPermissionConfig = IRegistrationsPermissionConfig;
462
- if (false) {
463
- IRegistrationsPermissionConfig.prototype.widgetPermission;
464
- }
465
- function IRenderConfigWithTypedData() { }
466
- NsWidgetResolver.IRenderConfigWithTypedData = IRenderConfigWithTypedData;
467
- if (false) {
468
- IRenderConfigWithTypedData.prototype.widgetData;
469
- IRenderConfigWithTypedData.prototype.widgetInstanceId;
470
- IRenderConfigWithTypedData.prototype.widgetHostClass;
471
- IRenderConfigWithTypedData.prototype.widgetHostStyle;
472
- }
473
- function IWidgetData() { }
474
- NsWidgetResolver.IWidgetData = IWidgetData;
475
- if (false) {
476
- IWidgetData.prototype.widgetSafeStyle;
477
- IWidgetData.prototype.updateBaseComponent;
478
- }
479
- function ITitle() { }
480
- NsWidgetResolver.ITitle = ITitle;
481
- if (false) {
482
- ITitle.prototype.title;
483
- ITitle.prototype.url;
484
- ITitle.prototype.icon;
485
- }
486
- })(NsWidgetResolver || (NsWidgetResolver = {}));
361
+ class WidgetResolverModule {
362
+ static forRoot(config) {
363
+ return {
364
+ ngModule: WidgetResolverModule,
365
+ providers: [
366
+ WidgetResolverService,
367
+ {
368
+ provide: WIDGET_RESOLVER_GLOBAL_CONFIG,
369
+ useValue: config,
370
+ },
371
+ {
372
+ provide: WIDGET_RESOLVER_SCOPED_CONFIG,
373
+ useValue: [],
374
+ },
375
+ ],
376
+ };
377
+ }
378
+ static forChild(config) {
379
+ return {
380
+ ngModule: WidgetResolverModule,
381
+ providers: [
382
+ WidgetResolverService,
383
+ {
384
+ provide: WIDGET_RESOLVER_SCOPED_CONFIG,
385
+ useValue: config,
386
+ },
387
+ ],
388
+ };
389
+ }
390
+ }
391
+ WidgetResolverModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: WidgetResolverModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
392
+ WidgetResolverModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: WidgetResolverModule, declarations: [WidgetBaseComponent,
393
+ WidgetResolverDirective,
394
+ RestrictedComponent,
395
+ InvalidRegistrationComponent,
396
+ InvalidPermissionComponent,
397
+ UnresolvedComponent], imports: [CommonModule, MatButtonModule, MatIconModule, MatCardModule], exports: [WidgetResolverDirective, WidgetBaseComponent] });
398
+ WidgetResolverModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: WidgetResolverModule, providers: [ConfigurationsService], imports: [[CommonModule, MatButtonModule, MatIconModule, MatCardModule]] });
399
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: WidgetResolverModule, decorators: [{
400
+ type: NgModule,
401
+ args: [{
402
+ declarations: [
403
+ WidgetBaseComponent,
404
+ WidgetResolverDirective,
405
+ RestrictedComponent,
406
+ InvalidRegistrationComponent,
407
+ InvalidPermissionComponent,
408
+ UnresolvedComponent,
409
+ ],
410
+ imports: [CommonModule, MatButtonModule, MatIconModule, MatCardModule],
411
+ exports: [WidgetResolverDirective, WidgetBaseComponent],
412
+ entryComponents: [
413
+ RestrictedComponent,
414
+ InvalidRegistrationComponent,
415
+ InvalidPermissionComponent,
416
+ UnresolvedComponent,
417
+ WidgetBaseComponent,
418
+ ],
419
+ providers: [ConfigurationsService],
420
+ }]
421
+ }] });
487
422
 
488
- export { WidgetBaseComponent, WidgetResolverModule, WidgetResolverService, hasPermissions, hasUnitPermission, WidgetResolverDirective as ɵa, WIDGET_RESOLVER_GLOBAL_CONFIG as ɵb, WIDGET_RESOLVER_SCOPED_CONFIG as ɵc, RestrictedComponent as ɵe, InvalidRegistrationComponent as ɵf, InvalidPermissionComponent as ɵg, UnresolvedComponent as ɵh };
423
+ export { WidgetBaseComponent, WidgetResolverDirective, WidgetResolverModule, WidgetResolverService, hasPermissions, hasUnitPermission };
489
424
  //# sourceMappingURL=sunbird-cb-resolver.js.map