@genesislcap/pbc-notify-ui 1.0.30 → 1.0.32
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.
- package/dist/dts/components/foundation-inbox/components/foundation-inbox-counter/foundation-inbox-counter.d.ts.map +1 -1
- package/dist/dts/components/foundation-inbox/inbox-base/inbox-base.d.ts +9 -9
- package/dist/dts/components/foundation-inbox/inbox-base/inbox-base.d.ts.map +1 -1
- package/dist/dts/components/foundation-inbox/inbox.template.d.ts.map +1 -1
- package/dist/dts/components/foundation-notification-dashboard/components/rules/rule-dialog/rule-condition-builder/rule-condition-builder.d.ts +12 -11
- package/dist/dts/components/foundation-notification-dashboard/components/rules/rule-dialog/rule-condition-builder/rule-condition-builder.d.ts.map +1 -1
- package/dist/dts/components/foundation-notification-dashboard/components/rules/rule-dialog/rule-condition-builder/rule-condition-builder.template.d.ts +1 -1
- package/dist/dts/components/foundation-notification-dashboard/components/rules/rule-dialog/rule-condition-builder/rule-condition-builder.template.d.ts.map +1 -1
- package/dist/dts/components/foundation-notification-dashboard/components/rules/rule-dialog/rule-condition-builder/rule-condition-builder.types.d.ts +4 -12
- package/dist/dts/components/foundation-notification-dashboard/components/rules/rule-dialog/rule-condition-builder/rule-condition-builder.types.d.ts.map +1 -1
- package/dist/dts/components/foundation-notification-dashboard/components/rules/rule-dialog/rule-dialog.d.ts +14 -9
- package/dist/dts/components/foundation-notification-dashboard/components/rules/rule-dialog/rule-dialog.d.ts.map +1 -1
- package/dist/dts/components/foundation-notification-dashboard/components/rules/rule-dialog/rule-dialog.template.d.ts.map +1 -1
- package/dist/dts/components/foundation-notification-dashboard/components/rules/rule-dialog/rule-dialog.types.d.ts +1 -6
- package/dist/dts/components/foundation-notification-dashboard/components/rules/rule-dialog/rule-dialog.types.d.ts.map +1 -1
- package/dist/dts/components/foundation-notification-dashboard/components/rules/rule-management.d.ts.map +1 -1
- package/dist/dts/components/foundation-notification-dashboard/components/templates/template-dialog/template-condition-builder/template-condition-builder.d.ts +29 -0
- package/dist/dts/components/foundation-notification-dashboard/components/templates/template-dialog/template-condition-builder/template-condition-builder.d.ts.map +1 -0
- package/dist/dts/components/foundation-notification-dashboard/components/templates/template-dialog/template-condition-builder/template-condition-builder.template.d.ts +3 -0
- package/dist/dts/components/foundation-notification-dashboard/components/templates/template-dialog/template-condition-builder/template-condition-builder.template.d.ts.map +1 -0
- package/dist/dts/components/foundation-notification-dashboard/components/templates/template-dialog/template-dialog.d.ts +13 -7
- package/dist/dts/components/foundation-notification-dashboard/components/templates/template-dialog/template-dialog.d.ts.map +1 -1
- package/dist/dts/components/foundation-notification-dashboard/components/templates/template-dialog/template-dialog.template.d.ts.map +1 -1
- package/dist/dts/components/foundation-notification-dashboard/components/templates/template-dialog/template-dialog.types.d.ts +1 -8
- package/dist/dts/components/foundation-notification-dashboard/components/templates/template-dialog/template-dialog.types.d.ts.map +1 -1
- package/dist/dts/components/foundation-notification-dashboard/components/templates/template-management.d.ts.map +1 -1
- package/dist/dts/components/foundation-notification-dashboard/notification-dashboard.utils.d.ts +42 -0
- package/dist/dts/components/foundation-notification-dashboard/notification-dashboard.utils.d.ts.map +1 -0
- package/dist/dts/components/foundation-notification-dashboard/styles/condition-builder.styles.d.ts.map +1 -0
- package/dist/dts/components/foundation-notification-dashboard/styles/dynamic-rule.styles.d.ts +3 -0
- package/dist/dts/components/foundation-notification-dashboard/styles/dynamic-rule.styles.d.ts.map +1 -0
- package/dist/dts/components/foundation-notification-dashboard/types/logical-operator.d.ts +4 -0
- package/dist/dts/components/foundation-notification-dashboard/types/logical-operator.d.ts.map +1 -1
- package/dist/dts/notify.types.d.ts +60 -0
- package/dist/dts/notify.types.d.ts.map +1 -0
- package/dist/dts/services/inbox.service.d.ts.map +1 -1
- package/dist/esm/components/components.js +2 -2
- package/dist/esm/components/foundation-inbox/components/foundation-inbox-counter/foundation-inbox-counter.js +3 -3
- package/dist/esm/components/foundation-inbox/inbox-base/inbox-base.js +10 -12
- package/dist/esm/components/foundation-inbox/inbox.template.js +1 -2
- package/dist/esm/components/foundation-notification-dashboard/components/rules/rule-dialog/rule-condition-builder/rule-condition-builder.js +84 -60
- package/dist/esm/components/foundation-notification-dashboard/components/rules/rule-dialog/rule-condition-builder/rule-condition-builder.template.js +42 -28
- package/dist/esm/components/foundation-notification-dashboard/components/rules/rule-dialog/rule-condition-builder/rule-condition-builder.types.js +5 -4
- package/dist/esm/components/foundation-notification-dashboard/components/rules/rule-dialog/rule-dialog.js +99 -101
- package/dist/esm/components/foundation-notification-dashboard/components/rules/rule-dialog/rule-dialog.template.js +30 -30
- package/dist/esm/components/foundation-notification-dashboard/components/rules/rule-dialog/rule-dialog.types.js +0 -7
- package/dist/esm/components/foundation-notification-dashboard/components/rules/rule-management.js +3 -5
- package/dist/esm/components/foundation-notification-dashboard/components/templates/template-dialog/template-condition-builder/template-condition-builder.js +169 -0
- package/dist/esm/components/foundation-notification-dashboard/components/templates/template-dialog/template-condition-builder/template-condition-builder.template.js +66 -0
- package/dist/esm/components/foundation-notification-dashboard/components/templates/template-dialog/template-dialog.js +106 -116
- package/dist/esm/components/foundation-notification-dashboard/components/templates/template-dialog/template-dialog.template.js +27 -31
- package/dist/esm/components/foundation-notification-dashboard/components/templates/template-management.js +3 -5
- package/dist/esm/components/foundation-notification-dashboard/notification-dashboard.utils.js +259 -0
- package/dist/esm/components/foundation-notification-dashboard/{components/templates/template-dialog/condition-builder → styles}/condition-builder.styles.js +6 -6
- package/dist/esm/components/foundation-notification-dashboard/{components/templates/template-dialog/template-dialog.styles.js → styles/dynamic-rule.styles.js} +57 -16
- package/dist/esm/components/foundation-notification-dashboard/types/logical-operator.js +4 -0
- package/dist/esm/notify.types.js +70 -0
- package/dist/esm/services/inbox.service.js +1 -5
- package/package.json +1 -1
- package/dist/dts/components/foundation-notification-dashboard/components/rules/rule-dialog/rule-condition-builder/rule-condition-builder.styles.d.ts +0 -2
- package/dist/dts/components/foundation-notification-dashboard/components/rules/rule-dialog/rule-condition-builder/rule-condition-builder.styles.d.ts.map +0 -1
- package/dist/dts/components/foundation-notification-dashboard/components/rules/rule-dialog/rule-dialog.styles.d.ts +0 -2
- package/dist/dts/components/foundation-notification-dashboard/components/rules/rule-dialog/rule-dialog.styles.d.ts.map +0 -1
- package/dist/dts/components/foundation-notification-dashboard/components/templates/template-dialog/condition-builder/condition-builder.d.ts +0 -32
- package/dist/dts/components/foundation-notification-dashboard/components/templates/template-dialog/condition-builder/condition-builder.d.ts.map +0 -1
- package/dist/dts/components/foundation-notification-dashboard/components/templates/template-dialog/condition-builder/condition-builder.styles.d.ts.map +0 -1
- package/dist/dts/components/foundation-notification-dashboard/components/templates/template-dialog/condition-builder/condition-builder.template.d.ts +0 -3
- package/dist/dts/components/foundation-notification-dashboard/components/templates/template-dialog/condition-builder/condition-builder.template.d.ts.map +0 -1
- package/dist/dts/components/foundation-notification-dashboard/components/templates/template-dialog/template-dialog.styles.d.ts +0 -2
- package/dist/dts/components/foundation-notification-dashboard/components/templates/template-dialog/template-dialog.styles.d.ts.map +0 -1
- package/dist/dts/components/foundation-notification-dashboard/components/templates/template-dialog/template-dialog.utils.d.ts +0 -41
- package/dist/dts/components/foundation-notification-dashboard/components/templates/template-dialog/template-dialog.utils.d.ts.map +0 -1
- package/dist/dts/components/foundation-notification-dashboard/styles/rules-and-templates.styles.d.ts +0 -2
- package/dist/dts/components/foundation-notification-dashboard/styles/rules-and-templates.styles.d.ts.map +0 -1
- package/dist/esm/components/foundation-notification-dashboard/components/rules/rule-dialog/rule-condition-builder/rule-condition-builder.styles.js +0 -53
- package/dist/esm/components/foundation-notification-dashboard/components/rules/rule-dialog/rule-dialog.styles.js +0 -95
- package/dist/esm/components/foundation-notification-dashboard/components/templates/template-dialog/condition-builder/condition-builder.js +0 -179
- package/dist/esm/components/foundation-notification-dashboard/components/templates/template-dialog/condition-builder/condition-builder.template.js +0 -42
- package/dist/esm/components/foundation-notification-dashboard/components/templates/template-dialog/template-dialog.utils.js +0 -119
- package/dist/esm/components/foundation-notification-dashboard/styles/rules-and-templates.styles.js +0 -17
- /package/dist/dts/components/foundation-notification-dashboard/{components/templates/template-dialog/condition-builder → styles}/condition-builder.styles.d.ts +0 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { __awaiter, __decorate } from "tslib";
|
|
2
|
-
import { Auth } from
|
|
3
|
-
import { FASTElement, observable } from
|
|
4
|
-
import { AlertService } from
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { logger } from
|
|
9
|
-
import { InboxTab } from
|
|
10
|
-
import {
|
|
2
|
+
import { Auth } from '@genesislcap/foundation-comms';
|
|
3
|
+
import { FASTElement, observable } from '@microsoft/fast-element';
|
|
4
|
+
import { AlertService } from '../../../services/alert.service';
|
|
5
|
+
import { FoundationInboxService } from '../../../services/inbox.service';
|
|
6
|
+
import { RuleService } from '../../../services/rule.service';
|
|
7
|
+
import { TemplateService } from '../../../services/template.service';
|
|
8
|
+
import { logger } from '../../../utils';
|
|
9
|
+
import { InboxTab } from '../inbox.template';
|
|
10
|
+
import { AlertStatus, RuleStatus, } from '../inbox.types';
|
|
11
11
|
export class FoundationInboxBase extends FASTElement {
|
|
12
12
|
constructor() {
|
|
13
13
|
super(...arguments);
|
|
@@ -59,9 +59,7 @@ export class FoundationInboxBase extends FASTElement {
|
|
|
59
59
|
}
|
|
60
60
|
// #region Tabs
|
|
61
61
|
checkActiveTab(inboxTab) {
|
|
62
|
-
return this.tabs.activeid === inboxTab.toString()
|
|
63
|
-
? ''
|
|
64
|
-
: 'display: none;';
|
|
62
|
+
return this.tabs.activeid === inboxTab.toString() ? '' : 'display: none;';
|
|
65
63
|
}
|
|
66
64
|
inboxTabChanged(inboxTab) {
|
|
67
65
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -93,8 +93,7 @@ export const FoundationInboxTemplate = html `
|
|
|
93
93
|
`)}
|
|
94
94
|
|
|
95
95
|
<!-- Alerts -->
|
|
96
|
-
${(_) => alertsTab(InboxTab.AlertsNew)}
|
|
97
|
-
${(_) => alertsTab(InboxTab.AlertHistory)}
|
|
96
|
+
${(_) => alertsTab(InboxTab.AlertsNew)} ${(_) => alertsTab(InboxTab.AlertHistory)}
|
|
98
97
|
${when((x) => { var _a; return (_a = x.auth.currentUser) === null || _a === void 0 ? void 0 : _a.hasPermission(NotifyPermission.NotificationRuleView); }, html `
|
|
99
98
|
<!-- Rules -->
|
|
100
99
|
<zero-tab-panel
|
|
@@ -1,104 +1,128 @@
|
|
|
1
1
|
import { __awaiter, __decorate } from "tslib";
|
|
2
2
|
import { customElement, FASTElement, observable } from '@microsoft/fast-element';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
3
|
+
import { LogicalOperator, nullAndBlankLogicalOperatorValues, } from '../../../../../../notify.types';
|
|
4
|
+
import { logger } from '../../../../../../utils';
|
|
5
|
+
import { ConditionBuilderStyles } from '../../../../styles/condition-builder.styles';
|
|
6
|
+
import { RuleConditionBuilderTemplate } from './rule-condition-builder.template';
|
|
7
|
+
import { RightCriteria } from './rule-condition-builder.types';
|
|
8
8
|
let RuleConditionBuilder = class RuleConditionBuilder extends FASTElement {
|
|
9
9
|
constructor() {
|
|
10
10
|
super(...arguments);
|
|
11
|
-
this.
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
this.leftValueItems = [];
|
|
12
|
+
this.rightCriteria = RightCriteria.VALUE;
|
|
13
|
+
}
|
|
14
|
+
deleteCondition() {
|
|
15
|
+
this.$emit('delete', this.condition);
|
|
14
16
|
}
|
|
15
17
|
conditionChanged() {
|
|
16
18
|
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
-
this.
|
|
18
|
-
|
|
19
|
-
this.resourceFields = yield this.systemService.getFields(this.resource);
|
|
19
|
+
if (this.fields) {
|
|
20
|
+
this.leftValueItems = this.fields;
|
|
20
21
|
}
|
|
21
22
|
this.assignLeftValue();
|
|
22
23
|
this.logicalOperator = this.condition.LOGICAL_OPERATOR;
|
|
23
24
|
this.rightCriteria = this.condition.RIGHT_CRITERIA;
|
|
24
25
|
this.assignRightValue();
|
|
25
|
-
this.
|
|
26
|
+
this.$emit('edit', this.condition);
|
|
26
27
|
});
|
|
27
28
|
}
|
|
29
|
+
fieldsChanged() {
|
|
30
|
+
if (!Array.isArray(this.fields) || !this.fields.length) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
this.leftValueItems = this.fields;
|
|
34
|
+
this.leftValue = JSON.stringify(this.leftValueItems[0]);
|
|
35
|
+
}
|
|
28
36
|
assignLeftValue() {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
+
// Add (fresh new; assign the 1st element)
|
|
38
|
+
if (!this.condition.LEFT_VALUE) {
|
|
39
|
+
this.leftValue = JSON.stringify(this.leftValueItems[0]);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
// Add (value changed)
|
|
43
|
+
if (typeof this.condition.LEFT_VALUE !== 'string') {
|
|
44
|
+
this.leftValue = JSON.stringify(this.condition.LEFT_VALUE);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
// Edit
|
|
48
|
+
this.leftValue = JSON.stringify(this.leftValueItems.find((item) => item.FIELD_NAME === this.condition.LEFT_VALUE));
|
|
37
49
|
}
|
|
38
50
|
assignRightValue() {
|
|
39
|
-
if (this.condition.RIGHT_CRITERIA ===
|
|
51
|
+
if (this.condition.RIGHT_CRITERIA === RightCriteria.VALUE) {
|
|
40
52
|
this.rightValueText = this.condition.RIGHT_VALUE;
|
|
53
|
+
return;
|
|
41
54
|
}
|
|
42
|
-
|
|
43
|
-
this.rightValueUserEntry = null;
|
|
44
|
-
}
|
|
45
|
-
this.$emit('edit', this.condition);
|
|
55
|
+
this.rightValueSelect = null;
|
|
46
56
|
}
|
|
47
57
|
leftValueChanged() {
|
|
48
|
-
if (this.condition) {
|
|
49
|
-
|
|
50
|
-
this.$emit('edit', this.condition);
|
|
58
|
+
if (!this.condition) {
|
|
59
|
+
return;
|
|
51
60
|
}
|
|
61
|
+
this.condition.LEFT_VALUE = JSON.parse(this.leftValue);
|
|
62
|
+
this.$emit('edit', this.condition);
|
|
52
63
|
}
|
|
53
64
|
logicalOperatorChanged() {
|
|
54
|
-
if (this.condition) {
|
|
55
|
-
|
|
56
|
-
this.$emit('edit', this.condition);
|
|
65
|
+
if (!this.condition) {
|
|
66
|
+
return;
|
|
57
67
|
}
|
|
68
|
+
if (nullAndBlankLogicalOperatorValues.includes(LogicalOperator[this.logicalOperator])) {
|
|
69
|
+
this.rightCriteria = RightCriteria.VALUE;
|
|
70
|
+
this.clearRightValueText();
|
|
71
|
+
}
|
|
72
|
+
this.condition.LOGICAL_OPERATOR = this.logicalOperator;
|
|
73
|
+
this.$emit('edit', this.condition);
|
|
58
74
|
}
|
|
59
75
|
rightCriteriaChanged() {
|
|
60
|
-
if (this.condition) {
|
|
61
|
-
|
|
62
|
-
if (this.condition.RIGHT_CRITERIA === RIGHT_CRITERIA.VALUE) {
|
|
63
|
-
this.rightValueText = '';
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
this.rightValueUserEntry = this.resourceFields[0].FIELD_NAME;
|
|
67
|
-
}
|
|
68
|
-
this.$emit('edit', this.condition);
|
|
76
|
+
if (!this.condition) {
|
|
77
|
+
return;
|
|
69
78
|
}
|
|
79
|
+
this.condition.RIGHT_CRITERIA = this.rightCriteria;
|
|
80
|
+
switch (this.rightCriteria) {
|
|
81
|
+
case RightCriteria.VALUE:
|
|
82
|
+
this.clearRightValueText();
|
|
83
|
+
break;
|
|
84
|
+
case RightCriteria.FIELD:
|
|
85
|
+
this.clearRightValueSelect();
|
|
86
|
+
break;
|
|
87
|
+
default:
|
|
88
|
+
logger.error(`Unknown RightCriteria: ${this.rightCriteria}`);
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
this.$emit('edit', this.condition);
|
|
92
|
+
}
|
|
93
|
+
clearRightValueText() {
|
|
94
|
+
this.rightValueText = '';
|
|
95
|
+
}
|
|
96
|
+
clearRightValueSelect() {
|
|
97
|
+
this.rightValueSelect = this.fields[0].FIELD_NAME;
|
|
70
98
|
}
|
|
71
99
|
rightValueTextChanged() {
|
|
72
|
-
if (this.condition) {
|
|
73
|
-
|
|
74
|
-
this.$emit('edit', this.condition);
|
|
100
|
+
if (!this.condition) {
|
|
101
|
+
return;
|
|
75
102
|
}
|
|
103
|
+
this.condition.RIGHT_VALUE = this.rightValueText;
|
|
104
|
+
this.$emit('edit', this.condition);
|
|
76
105
|
}
|
|
77
|
-
|
|
78
|
-
if (this.condition) {
|
|
79
|
-
|
|
80
|
-
this.$emit('edit', this.condition);
|
|
106
|
+
rightValueSelectChanged() {
|
|
107
|
+
if (!this.condition) {
|
|
108
|
+
return;
|
|
81
109
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
this.$emit('delete', this.condition);
|
|
110
|
+
this.condition.RIGHT_VALUE = this.rightValueSelect;
|
|
111
|
+
this.$emit('edit', this.condition);
|
|
85
112
|
}
|
|
86
113
|
};
|
|
87
|
-
__decorate([
|
|
88
|
-
SystemService
|
|
89
|
-
], RuleConditionBuilder.prototype, "systemService", void 0);
|
|
90
114
|
__decorate([
|
|
91
115
|
observable
|
|
92
116
|
], RuleConditionBuilder.prototype, "condition", void 0);
|
|
93
117
|
__decorate([
|
|
94
118
|
observable
|
|
95
|
-
], RuleConditionBuilder.prototype, "
|
|
119
|
+
], RuleConditionBuilder.prototype, "fields", void 0);
|
|
96
120
|
__decorate([
|
|
97
121
|
observable
|
|
98
|
-
], RuleConditionBuilder.prototype, "
|
|
122
|
+
], RuleConditionBuilder.prototype, "leftValue", void 0);
|
|
99
123
|
__decorate([
|
|
100
124
|
observable
|
|
101
|
-
], RuleConditionBuilder.prototype, "
|
|
125
|
+
], RuleConditionBuilder.prototype, "leftValueItems", void 0);
|
|
102
126
|
__decorate([
|
|
103
127
|
observable
|
|
104
128
|
], RuleConditionBuilder.prototype, "logicalOperator", void 0);
|
|
@@ -110,12 +134,12 @@ __decorate([
|
|
|
110
134
|
], RuleConditionBuilder.prototype, "rightValueText", void 0);
|
|
111
135
|
__decorate([
|
|
112
136
|
observable
|
|
113
|
-
], RuleConditionBuilder.prototype, "
|
|
137
|
+
], RuleConditionBuilder.prototype, "rightValueSelect", void 0);
|
|
114
138
|
RuleConditionBuilder = __decorate([
|
|
115
139
|
customElement({
|
|
116
|
-
name,
|
|
117
|
-
template,
|
|
118
|
-
styles,
|
|
140
|
+
name: 'rule-condition-builder',
|
|
141
|
+
template: RuleConditionBuilderTemplate,
|
|
142
|
+
styles: ConditionBuilderStyles,
|
|
119
143
|
})
|
|
120
144
|
], RuleConditionBuilder);
|
|
121
145
|
export { RuleConditionBuilder };
|
|
@@ -1,50 +1,64 @@
|
|
|
1
1
|
import { sync } from '@genesislcap/foundation-utils';
|
|
2
|
-
import { html, repeat } from '@microsoft/fast-element';
|
|
2
|
+
import { html, repeat, when } from '@microsoft/fast-element';
|
|
3
3
|
import { classNames } from '@microsoft/fast-web-utilities';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
export const
|
|
4
|
+
import { LogicalOperator, nullAndBlankLogicalOperatorValues } from '../../../../../../notify.types';
|
|
5
|
+
import { RightCriteria } from './rule-condition-builder.types';
|
|
6
|
+
export const RuleConditionBuilderTemplate = html `
|
|
7
7
|
<div class="condition-builder">
|
|
8
8
|
<zero-select
|
|
9
9
|
:value=${sync((x) => x.leftValue)}
|
|
10
10
|
:initialValue=${sync((x) => x.leftValue)}
|
|
11
11
|
class="left-value"
|
|
12
12
|
>
|
|
13
|
-
${repeat((x) => x.
|
|
13
|
+
${repeat((x) => x.fields, html `
|
|
14
14
|
<zero-option value=${(x) => JSON.stringify(x)}>${(x) => x.FIELD_NAME}</zero-option>
|
|
15
15
|
`)}
|
|
16
16
|
</zero-select>
|
|
17
17
|
|
|
18
|
-
<zero-select
|
|
19
|
-
${
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
${repeat((
|
|
18
|
+
<zero-select
|
|
19
|
+
class="logical-operator${(x) => classNames([
|
|
20
|
+
'-null-and-blank',
|
|
21
|
+
nullAndBlankLogicalOperatorValues.includes(LogicalOperator[x.logicalOperator]),
|
|
22
|
+
])}"
|
|
23
|
+
:value=${sync((x) => x.logicalOperator)}
|
|
24
|
+
>
|
|
25
|
+
${repeat((_) => Object.values(LogicalOperator), html `
|
|
26
26
|
<zero-option value=${(x) => x}>${(x) => x}</zero-option>
|
|
27
27
|
`)}
|
|
28
28
|
</zero-select>
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
${when((x) => !nullAndBlankLogicalOperatorValues.includes(LogicalOperator[x.logicalOperator]), html `
|
|
31
|
+
<zero-select class="right-criteria" :value=${sync((x) => x.rightCriteria)}>
|
|
32
|
+
${repeat((x) => Object.values(RightCriteria), html `
|
|
33
|
+
<zero-option value=${(x) => x}>${(x) => x}</zero-option>
|
|
34
|
+
`)}
|
|
35
|
+
</zero-select>
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
37
|
+
${when((x) => x.rightCriteria === RightCriteria.VALUE, html `
|
|
38
|
+
<zero-text-field
|
|
39
|
+
class="right-criteria-text"
|
|
40
|
+
:value=${sync((x) => x.rightValueText)}
|
|
41
|
+
placeholder="Value"
|
|
42
|
+
autocomplete="off"
|
|
43
|
+
></zero-text-field>
|
|
44
|
+
`)}
|
|
45
|
+
${when((x) => x.rightCriteria === RightCriteria.FIELD, html `
|
|
46
|
+
<zero-select class="right-criteria-select" :value=${sync((x) => x.rightValueSelect)}>
|
|
47
|
+
${repeat((x) => x.fields, html `
|
|
48
|
+
<zero-option value=${(x) => x.FIELD_NAME}>${(x) => x.FIELD_NAME}</zero-option>
|
|
49
|
+
`)}
|
|
50
|
+
</zero-select>
|
|
51
|
+
`)}
|
|
52
|
+
`)}
|
|
45
53
|
|
|
46
54
|
<zero-button appearance="icon" class="delete" @click=${(x) => x.deleteCondition()}>
|
|
47
|
-
<zero-icon
|
|
55
|
+
<zero-icon
|
|
56
|
+
style="opacity: 0.5"
|
|
57
|
+
variant="regular"
|
|
58
|
+
name="trash-alt"
|
|
59
|
+
size="lg"
|
|
60
|
+
part="icon"
|
|
61
|
+
></zero-icon>
|
|
48
62
|
</zero-button>
|
|
49
63
|
</div>
|
|
50
64
|
`;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
export var RightCriteria;
|
|
2
|
+
(function (RightCriteria) {
|
|
3
|
+
RightCriteria["VALUE"] = "VALUE";
|
|
4
|
+
RightCriteria["FIELD"] = "FIELD";
|
|
5
|
+
})(RightCriteria || (RightCriteria = {}));
|
|
@@ -1,90 +1,103 @@
|
|
|
1
1
|
import { __awaiter, __decorate } from "tslib";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { customElement, FASTElement, observable, volatile } from '@microsoft/fast-element';
|
|
3
|
+
import { Assignment, defaultUpdateType, Severity, } from '../../../../../notify.types';
|
|
4
4
|
import { NotifyService } from '../../../../../services/notify.service';
|
|
5
5
|
import { RuleService } from '../../../../../services/rule.service';
|
|
6
6
|
import { SystemService } from '../../../../../services/system.service';
|
|
7
7
|
import { humanize } from '../../../../../utils';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { SEVERITY_INFORMATION } from '../../../types/severity';
|
|
11
|
-
import { createAssignment, createConditions, getAssignmentValue, UUIDGenerator, } from '../../templates/template-dialog/template-dialog.utils';
|
|
12
|
-
import { RIGHT_CRITERIA, } from './rule-condition-builder/rule-condition-builder.types';
|
|
13
|
-
import { RuleDialogStyles } from './rule-dialog.styles';
|
|
8
|
+
import { DynamicRuleUtils, RuleUtils, showNotificationError, isEmpty, } from '../../../notification-dashboard.utils';
|
|
9
|
+
import { DynamicRuleDialogStyles } from '../../../styles/dynamic-rule.styles';
|
|
14
10
|
import { RuleDialogTemplate } from './rule-dialog.template';
|
|
15
|
-
import {
|
|
11
|
+
import { RuleDialogMode } from './rule-dialog.types';
|
|
16
12
|
let RuleDialog = class RuleDialog extends FASTElement {
|
|
17
13
|
constructor() {
|
|
18
14
|
super(...arguments);
|
|
19
|
-
this.resource = ''; // Tables + Views
|
|
15
|
+
this.resource = ''; // TODO: Tables + Views
|
|
20
16
|
this.topic = '';
|
|
21
17
|
this.severity = '';
|
|
22
18
|
this.updateType = defaultUpdateType;
|
|
23
19
|
this.conditions = [];
|
|
24
20
|
this.resources = [];
|
|
21
|
+
this.fields = [];
|
|
22
|
+
this.requiredFields = () => [this.name, this.description, this.header, this.message];
|
|
25
23
|
}
|
|
26
24
|
openDialog(params) {
|
|
27
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
var _a, _b, _c;
|
|
29
|
-
this.resources = yield this.systemService.getResources();
|
|
30
26
|
this.topics = yield this.notifyService.getNotifyRouteTopics();
|
|
27
|
+
this.resources = yield this.systemService.getResources();
|
|
31
28
|
this.ruleDialogMode = params.mode;
|
|
32
29
|
switch (params.mode) {
|
|
33
30
|
case RuleDialogMode.CREATE:
|
|
34
|
-
this.
|
|
35
|
-
this.resource = this.resources[0];
|
|
36
|
-
this.resourceFields = yield this.systemService.getFields(this.resource);
|
|
37
|
-
this.topic = this.topics[0];
|
|
38
|
-
this.severity = SEVERITY_INFORMATION;
|
|
39
|
-
this.updateType = defaultUpdateType;
|
|
31
|
+
yield this.createRule();
|
|
40
32
|
break;
|
|
41
33
|
case RuleDialogMode.EDIT:
|
|
42
|
-
|
|
43
|
-
this.ruleId = rule.DYNAMIC_RULE_ID;
|
|
44
|
-
this.name = rule.RULE_NAME;
|
|
45
|
-
this.description = rule.RULE_DESCRIPTION;
|
|
46
|
-
this.resource = rule.RULE_TABLE;
|
|
47
|
-
this.updateType = rule.TABLE_OPERATIONS;
|
|
48
|
-
// Conditions
|
|
49
|
-
this.conditions = (_a = rule.RULE_EXPRESSION.CONDITIONS) === null || _a === void 0 ? void 0 : _a.map((condition) => {
|
|
50
|
-
var _a, _b;
|
|
51
|
-
return {
|
|
52
|
-
ID: UUIDGenerator.createUuid(),
|
|
53
|
-
LEFT_VALUE: (_a = condition.LEFT.VALUE) !== null && _a !== void 0 ? _a : condition.LEFT.NAME,
|
|
54
|
-
LOGICAL_OPERATOR: condition.OPERATION,
|
|
55
|
-
RIGHT_CRITERIA: condition.RIGHT.TYPE === 'FIELD' ? RIGHT_CRITERIA.FIELD : RIGHT_CRITERIA.VALUE,
|
|
56
|
-
RIGHT_VALUE: condition.RIGHT.TYPE === EXPRESSION_TYPE_PLACEHOLDER
|
|
57
|
-
? condition.RIGHT.KEY
|
|
58
|
-
: (_b = condition.RIGHT.VALUE) !== null && _b !== void 0 ? _b : condition.RIGHT.NAME,
|
|
59
|
-
};
|
|
60
|
-
});
|
|
61
|
-
// Assignments
|
|
62
|
-
const assignments = (_b = rule.RESULT_EXPRESSION) === null || _b === void 0 ? void 0 : _b.ASSIGNMENTS;
|
|
63
|
-
if (assignments) {
|
|
64
|
-
this.header = getAssignmentValue(assignments, 'HEADER');
|
|
65
|
-
this.message = getAssignmentValue(assignments, 'BODY');
|
|
66
|
-
this.severity = (_c = getAssignmentValue(assignments, 'NOTIFY_SEVERITY')) === null || _c === void 0 ? void 0 : _c.toUpperCase();
|
|
67
|
-
this.topic = getAssignmentValue(assignments, 'TOPIC');
|
|
68
|
-
}
|
|
34
|
+
yield this.editRule(params.data);
|
|
69
35
|
break;
|
|
70
36
|
}
|
|
71
37
|
this.dialog.show();
|
|
72
38
|
});
|
|
73
39
|
}
|
|
40
|
+
close() {
|
|
41
|
+
// Objects
|
|
42
|
+
this.ruleId = null;
|
|
43
|
+
this.name = null;
|
|
44
|
+
this.description = null;
|
|
45
|
+
this.header = null;
|
|
46
|
+
this.message = null;
|
|
47
|
+
this.resource = null;
|
|
48
|
+
this.topic = null;
|
|
49
|
+
this.severity = null;
|
|
50
|
+
this.ruleDialogMode = null;
|
|
51
|
+
// Arrays
|
|
52
|
+
this.resources = [];
|
|
53
|
+
this.topics = [];
|
|
54
|
+
this.conditions = [];
|
|
55
|
+
this.updateType = [];
|
|
56
|
+
this.dialog.close();
|
|
57
|
+
this.$emit('close');
|
|
58
|
+
}
|
|
59
|
+
createRule() {
|
|
60
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
this.conditions.push(DynamicRuleUtils.createEmptyCondition());
|
|
62
|
+
this.resource = this.resources[0];
|
|
63
|
+
this.fields = yield this.systemService.getFields(this.resource);
|
|
64
|
+
this.topic = this.topics[0];
|
|
65
|
+
this.severity = Severity.INFORMATION;
|
|
66
|
+
this.updateType = defaultUpdateType;
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
editRule(data) {
|
|
70
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
var _a;
|
|
72
|
+
const rule = data;
|
|
73
|
+
this.ruleId = rule.DYNAMIC_RULE_ID;
|
|
74
|
+
this.name = rule.RULE_NAME;
|
|
75
|
+
this.description = rule.RULE_DESCRIPTION;
|
|
76
|
+
this.resource = rule.RULE_TABLE;
|
|
77
|
+
this.updateType = rule.TABLE_OPERATIONS;
|
|
78
|
+
this.fields = yield this.systemService.getFields(this.resource);
|
|
79
|
+
this.conditions = RuleUtils.getConditions(rule.RULE_EXPRESSION.CONDITIONS);
|
|
80
|
+
this.attributeAssignments((_a = rule.RESULT_EXPRESSION) === null || _a === void 0 ? void 0 : _a.ASSIGNMENTS);
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
attributeAssignments(assignments) {
|
|
84
|
+
var _a;
|
|
85
|
+
if (!assignments || !assignments.length) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
this.header = DynamicRuleUtils.getAssignmentValue(assignments, Assignment.HEADER);
|
|
89
|
+
this.message = DynamicRuleUtils.getAssignmentValue(assignments, Assignment.BODY);
|
|
90
|
+
this.severity = (_a = DynamicRuleUtils.getAssignmentValue(assignments, Assignment.NOTIFY_SEVERITY)) === null || _a === void 0 ? void 0 : _a.toUpperCase();
|
|
91
|
+
this.topic = DynamicRuleUtils.getAssignmentValue(assignments, Assignment.TOPIC);
|
|
92
|
+
}
|
|
74
93
|
get ruleDialogTitle() {
|
|
75
94
|
return `${this.ruleDialogMode === RuleDialogMode.CREATE ? 'Create' : 'Edit'} Rule`;
|
|
76
95
|
}
|
|
77
96
|
submit() {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
createAssignment('TOPIC', this.topic),
|
|
83
|
-
createAssignment('HEADER', this.header),
|
|
84
|
-
createAssignment('BODY', this.message),
|
|
85
|
-
createAssignment('NOTIFY_SEVERITY', humanize(this.severity)),
|
|
86
|
-
],
|
|
87
|
-
} });
|
|
97
|
+
if (this.requiredFields().some((value) => isEmpty(value))) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
const rule = this.createRuleObject();
|
|
88
101
|
switch (this.ruleDialogMode) {
|
|
89
102
|
case RuleDialogMode.CREATE:
|
|
90
103
|
this.ruleService.createRule(rule).then((response) => this.validateResponse(response));
|
|
@@ -94,40 +107,34 @@ let RuleDialog = class RuleDialog extends FASTElement {
|
|
|
94
107
|
break;
|
|
95
108
|
}
|
|
96
109
|
}
|
|
110
|
+
createRuleObject() {
|
|
111
|
+
return Object.assign(Object.assign({}, (this.ruleDialogMode === RuleDialogMode.EDIT && { DYNAMIC_RULE_ID: this.ruleId })), { RULE_NAME: this.name, RULE_DESCRIPTION: this.description, RULE_TABLE: this.resource, TABLE_OPERATIONS: this.updateType, RULE_EXPRESSION: {
|
|
112
|
+
CONDITIONS: DynamicRuleUtils.createConditions(this.conditions),
|
|
113
|
+
}, RESULT_EXPRESSION: {
|
|
114
|
+
ASSIGNMENTS: [
|
|
115
|
+
DynamicRuleUtils.createAssignment(Assignment.TOPIC, this.topic),
|
|
116
|
+
DynamicRuleUtils.createAssignment(Assignment.HEADER, this.header),
|
|
117
|
+
DynamicRuleUtils.createAssignment(Assignment.BODY, this.message),
|
|
118
|
+
DynamicRuleUtils.createAssignment(Assignment.NOTIFY_SEVERITY, humanize(this.severity)),
|
|
119
|
+
],
|
|
120
|
+
} });
|
|
121
|
+
}
|
|
97
122
|
validateResponse(response) {
|
|
98
|
-
var _a, _b;
|
|
99
123
|
if (response.MESSAGE_TYPE === 'EVENT_ACK') {
|
|
100
124
|
this.close();
|
|
101
125
|
return;
|
|
102
126
|
}
|
|
103
|
-
|
|
104
|
-
title: (_a = response.ERROR[0]) === null || _a === void 0 ? void 0 : _a.CODE,
|
|
105
|
-
body: (_b = response.ERROR[0]) === null || _b === void 0 ? void 0 : _b.TEXT,
|
|
106
|
-
config: {
|
|
107
|
-
snackbar: {
|
|
108
|
-
type: 'error',
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
}, 'zero');
|
|
127
|
+
showNotificationError(response.ERROR);
|
|
112
128
|
}
|
|
113
|
-
|
|
114
|
-
this
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
this.header = null;
|
|
119
|
-
this.message = null;
|
|
120
|
-
this.resource = null;
|
|
121
|
-
this.resources = [];
|
|
122
|
-
this.topic = null;
|
|
123
|
-
this.topics = [];
|
|
124
|
-
this.severity = null;
|
|
125
|
-
this.updateType = defaultUpdateType;
|
|
126
|
-
this.conditions = [];
|
|
129
|
+
resourceChanged() {
|
|
130
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
131
|
+
this.conditions = [DynamicRuleUtils.createEmptyCondition()];
|
|
132
|
+
this.fields = yield this.systemService.getFields(this.resource);
|
|
133
|
+
});
|
|
127
134
|
}
|
|
128
135
|
// #region Condition
|
|
129
136
|
newCondition() {
|
|
130
|
-
this.conditions.push(
|
|
137
|
+
this.conditions.push(DynamicRuleUtils.createEmptyCondition());
|
|
131
138
|
}
|
|
132
139
|
editCondition(editedCondition) { }
|
|
133
140
|
deleteCondition(deletedCondition) {
|
|
@@ -137,20 +144,8 @@ let RuleDialog = class RuleDialog extends FASTElement {
|
|
|
137
144
|
this.conditions = this.conditions.filter((condition) => condition !== deletedCondition);
|
|
138
145
|
}
|
|
139
146
|
// #endregion
|
|
140
|
-
|
|
141
|
-
return
|
|
142
|
-
this.conditions = [this.createEmptyCondition()];
|
|
143
|
-
this.resourceFields = yield this.systemService.getFields(this.resource);
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
createEmptyCondition() {
|
|
147
|
-
return {
|
|
148
|
-
ID: null,
|
|
149
|
-
LEFT_VALUE: null,
|
|
150
|
-
LOGICAL_OPERATOR: LOGICAL_OPERATOR_EQUALS,
|
|
151
|
-
RIGHT_CRITERIA: RIGHT_CRITERIA.VALUE,
|
|
152
|
-
RIGHT_VALUE: null,
|
|
153
|
-
};
|
|
147
|
+
get validateRequiredFields() {
|
|
148
|
+
return this.requiredFields().some((value) => isEmpty(value));
|
|
154
149
|
}
|
|
155
150
|
};
|
|
156
151
|
__decorate([
|
|
@@ -177,12 +172,6 @@ __decorate([
|
|
|
177
172
|
__decorate([
|
|
178
173
|
observable
|
|
179
174
|
], RuleDialog.prototype, "topic", void 0);
|
|
180
|
-
__decorate([
|
|
181
|
-
observable
|
|
182
|
-
], RuleDialog.prototype, "topics", void 0);
|
|
183
|
-
__decorate([
|
|
184
|
-
observable
|
|
185
|
-
], RuleDialog.prototype, "resourceFields", void 0);
|
|
186
175
|
__decorate([
|
|
187
176
|
observable
|
|
188
177
|
], RuleDialog.prototype, "severity", void 0);
|
|
@@ -201,11 +190,20 @@ __decorate([
|
|
|
201
190
|
__decorate([
|
|
202
191
|
observable
|
|
203
192
|
], RuleDialog.prototype, "resources", void 0);
|
|
193
|
+
__decorate([
|
|
194
|
+
observable
|
|
195
|
+
], RuleDialog.prototype, "fields", void 0);
|
|
196
|
+
__decorate([
|
|
197
|
+
observable
|
|
198
|
+
], RuleDialog.prototype, "topics", void 0);
|
|
199
|
+
__decorate([
|
|
200
|
+
volatile
|
|
201
|
+
], RuleDialog.prototype, "validateRequiredFields", null);
|
|
204
202
|
RuleDialog = __decorate([
|
|
205
203
|
customElement({
|
|
206
204
|
name: 'rule-dialog',
|
|
207
205
|
template: RuleDialogTemplate,
|
|
208
|
-
styles:
|
|
206
|
+
styles: DynamicRuleDialogStyles,
|
|
209
207
|
})
|
|
210
208
|
], RuleDialog);
|
|
211
209
|
export { RuleDialog };
|