@oicl/openbridge-webcomponents-full-bundle 2.1.0-next.1 → 2.1.0-next.2
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/.storybook/main.ts +2 -0
- package/bundle/openbridge-webcomponents.bundle.js +352 -244
- package/bundle/openbridge-webcomponents.bundle.js.map +1 -1
- package/custom-elements.json +1031 -97
- package/dist/building-blocks/alert-list/alert-list-base.d.ts +60 -0
- package/dist/building-blocks/alert-list/alert-list-base.d.ts.map +1 -0
- package/dist/building-blocks/alert-list/alert-list-base.js +191 -0
- package/dist/building-blocks/alert-list/alert-list-base.js.map +1 -0
- package/dist/building-blocks/alert-list/alert-list.css.js.map +1 -1
- package/dist/building-blocks/alert-list/alert-list.d.ts +13 -26
- package/dist/building-blocks/alert-list/alert-list.d.ts.map +1 -1
- package/dist/building-blocks/alert-list/alert-list.js +7 -142
- package/dist/building-blocks/alert-list/alert-list.js.map +1 -1
- package/dist/components/alert-icon/alert-icon.d.ts.map +1 -1
- package/dist/components/alert-icon/alert-icon.js +6 -5
- package/dist/components/alert-icon/alert-icon.js.map +1 -1
- package/dist/components/alert-list-details/alert-list-details.css.js +4 -1
- package/dist/components/alert-list-details/alert-list-details.css.js.map +1 -1
- package/dist/components/alert-menu/alert-menu.css.js +3 -42
- package/dist/components/alert-menu/alert-menu.css.js.map +1 -1
- package/dist/components/alert-menu/alert-menu.d.ts +28 -6
- package/dist/components/alert-menu/alert-menu.d.ts.map +1 -1
- package/dist/components/alert-menu/alert-menu.js +81 -60
- package/dist/components/alert-menu/alert-menu.js.map +1 -1
- package/dist/components/alert-menu-item/alert-menu-item.d.ts +16 -6
- package/dist/components/alert-menu-item/alert-menu-item.d.ts.map +1 -1
- package/dist/components/alert-menu-item/alert-menu-item.js +11 -2
- package/dist/components/alert-menu-item/alert-menu-item.js.map +1 -1
- package/dist/components/number-input-field/number-input-field.css.js +8 -2
- package/dist/components/number-input-field/number-input-field.css.js.map +1 -1
- package/dist/components/number-input-field/number-input-field.d.ts +15 -1
- package/dist/components/number-input-field/number-input-field.d.ts.map +1 -1
- package/dist/components/number-input-field/number-input-field.js +38 -44
- package/dist/components/number-input-field/number-input-field.js.map +1 -1
- package/dist/components/textbox/textbox.css.js +3 -9
- package/dist/components/textbox/textbox.css.js.map +1 -1
- package/dist/components/textbox/textbox.d.ts +3 -0
- package/dist/components/textbox/textbox.d.ts.map +1 -1
- package/dist/components/textbox/textbox.js.map +1 -1
- package/dist/generated/locales/es-419.d.ts +1 -1
- package/dist/generated/locales/es-419.js +1 -1
- package/dist/generated/locales/es-419.js.map +1 -1
- package/dist/navigation-instruments/readout-list-item/readout-list-item.css.js +2 -1
- package/dist/navigation-instruments/readout-list-item/readout-list-item.css.js.map +1 -1
- package/dist/pages/alert-detail-page/alert-detail-page.js +1 -1
- package/dist/pages/alert-detail-page/alert-detail-page.js.map +1 -1
- package/dist/pages/alert-list-page-small/alert-list-page-small-base.d.ts +59 -0
- package/dist/pages/alert-list-page-small/alert-list-page-small-base.d.ts.map +1 -0
- package/dist/pages/alert-list-page-small/alert-list-page-small-base.js +126 -0
- package/dist/pages/alert-list-page-small/alert-list-page-small-base.js.map +1 -0
- package/dist/pages/alert-list-page-small/alert-list-page-small.d.ts +12 -15
- package/dist/pages/alert-list-page-small/alert-list-page-small.d.ts.map +1 -1
- package/dist/pages/alert-list-page-small/alert-list-page-small.js +41 -92
- package/dist/pages/alert-list-page-small/alert-list-page-small.js.map +1 -1
- package/docs/GettingStarted.mdx +1 -0
- package/docs/MigrationGuide.mdx +2 -0
- package/package.json +1 -1
- package/src/building-blocks/alert-list/alert-list-base.ts +266 -0
- package/src/building-blocks/alert-list/alert-list.css +1 -23
- package/src/building-blocks/alert-list/alert-list.spec.ts +22 -0
- package/src/building-blocks/alert-list/alert-list.ts +15 -207
- package/src/components/alert-icon/alert-icon.spec.ts +39 -0
- package/src/components/alert-icon/alert-icon.ts +11 -7
- package/src/components/alert-list-details/alert-list-details.css +1 -20
- package/src/components/alert-menu/alert-menu.css +5 -28
- package/src/components/alert-menu/alert-menu.spec.ts +113 -0
- package/src/components/alert-menu/alert-menu.ts +142 -79
- package/src/components/alert-menu-item/alert-menu-item.spec.ts +39 -0
- package/src/components/alert-menu-item/alert-menu-item.stories.ts +22 -0
- package/src/components/alert-menu-item/alert-menu-item.ts +22 -6
- package/src/components/number-input-field/number-input-field.css +8 -2
- package/src/components/number-input-field/number-input-field.spec.ts +260 -2
- package/src/components/number-input-field/number-input-field.stories.ts +74 -0
- package/src/components/number-input-field/number-input-field.ts +45 -74
- package/src/components/textbox/textbox.css +3 -9
- package/src/components/textbox/textbox.stories.ts +24 -0
- package/src/components/textbox/textbox.ts +3 -0
- package/src/generated/locales/es-419.ts +1 -1
- package/src/mixins/alert-list-empty.css +32 -0
- package/src/navigation-instruments/readout-list-item/readout-list-item.css +2 -1
- package/src/pages/alert-detail-page/alert-detail-page.spec.ts +41 -0
- package/src/pages/alert-detail-page/alert-detail-page.ts +1 -1
- package/src/pages/alert-list-page-small/alert-list-page-small-base.ts +152 -0
- package/src/pages/alert-list-page-small/alert-list-page-small.spec.ts +84 -0
- package/src/pages/alert-list-page-small/alert-list-page-small.ts +43 -112
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import {afterEach, describe, expect, it} from 'vitest';
|
|
2
|
+
import './alert-detail-page.js';
|
|
3
|
+
import {AlertType, type Alert} from '../../types.js';
|
|
4
|
+
|
|
5
|
+
const ALERT: Alert = {
|
|
6
|
+
id: 'a',
|
|
7
|
+
tagId: 'a',
|
|
8
|
+
source: 'Source',
|
|
9
|
+
text: 'Text',
|
|
10
|
+
acknowledged: false,
|
|
11
|
+
active: true,
|
|
12
|
+
type: AlertType.Alarm,
|
|
13
|
+
time: new Date('2024-01-15T14:32:15Z'),
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
async function setup(alert: Alert) {
|
|
17
|
+
const el = document.createElement('obc-alert-detail-page');
|
|
18
|
+
el.alert = alert;
|
|
19
|
+
document.body.append(el);
|
|
20
|
+
await el.updateComplete;
|
|
21
|
+
return el.shadowRoot!.querySelector('.wrapper')!.classList;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
afterEach(() => {
|
|
25
|
+
document.body.innerHTML = '';
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
describe('obc-alert-detail-page status', () => {
|
|
29
|
+
it('marks a cleared alert as resolved, and an active one not', async () => {
|
|
30
|
+
const active = await setup(ALERT);
|
|
31
|
+
const cleared = await setup({
|
|
32
|
+
...ALERT,
|
|
33
|
+
active: {rectifiedTime: new Date('2024-01-15T14:40:00Z')},
|
|
34
|
+
});
|
|
35
|
+
expect([
|
|
36
|
+
active.contains('status-resolved'),
|
|
37
|
+
cleared.contains('status-resolved'),
|
|
38
|
+
]).toEqual([false, true]);
|
|
39
|
+
expect(active.contains('status-unacknowledged')).toBe(true);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
@@ -154,7 +154,7 @@ export class ObcAlertDetailPage extends LitElement {
|
|
|
154
154
|
isAcknowledged(this.alert) && isActive(this.alert),
|
|
155
155
|
'status-unacknowledged':
|
|
156
156
|
!isAcknowledged(this.alert) && isActive(this.alert),
|
|
157
|
-
'status-resolved': isActive(this.alert),
|
|
157
|
+
'status-resolved': !isActive(this.alert),
|
|
158
158
|
})}
|
|
159
159
|
>
|
|
160
160
|
<div class="header">
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CSSResultGroup,
|
|
3
|
+
LitElement,
|
|
4
|
+
TemplateResult,
|
|
5
|
+
html,
|
|
6
|
+
nothing,
|
|
7
|
+
unsafeCSS,
|
|
8
|
+
} from 'lit';
|
|
9
|
+
import {property} from 'lit/decorators.js';
|
|
10
|
+
import {msg} from '@lit/localize';
|
|
11
|
+
import compentStyle from './alert-list-page-small.css?inline';
|
|
12
|
+
import '../../components/icon-button/icon-button.js';
|
|
13
|
+
import '../../components/button/button.js';
|
|
14
|
+
import {ButtonVariant} from '../../components/button/button.js';
|
|
15
|
+
import '../../components/dropdown-button/dropdown-button.js';
|
|
16
|
+
import {ObcDropdownButtonChangeEvent} from '../../components/dropdown-button/dropdown-button.js';
|
|
17
|
+
import '../../icons/icon-silence-iec.js';
|
|
18
|
+
|
|
19
|
+
/** One entry of the mode dropdown. */
|
|
20
|
+
export interface AlertListPageMode {
|
|
21
|
+
value: string;
|
|
22
|
+
label: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* `ObcAlertListPageSmallBase` – Compact alert list page: a list of alerts over a
|
|
27
|
+
* bar with a mode dropdown, a silence button and "ACK visible".
|
|
28
|
+
*
|
|
29
|
+
* Not registered as an element: the subclasses supply the list and the
|
|
30
|
+
* modes. `obc-alert-list-page-small` renders `obc-alert-list-details`.
|
|
31
|
+
*
|
|
32
|
+
* ### Features
|
|
33
|
+
* - **Modes:** the dropdown offers `modes` and shows `mode`; picking one calls
|
|
34
|
+
* `selectMode()`.
|
|
35
|
+
* - **ACK visible:** enabled while `canAckAll` holds; a click reports the
|
|
36
|
+
* alerts `visibleAlerts()` returns, and the mode, in `ack-all-visible-click`.
|
|
37
|
+
* - **Silence:** the icon button fires `silence-click`.
|
|
38
|
+
*
|
|
39
|
+
* The base holds no alerts: each page declares `alerts` in the alert type it
|
|
40
|
+
* lists.
|
|
41
|
+
*
|
|
42
|
+
* @property hasShelved - Whether the dropdown offers the shelved alerts.
|
|
43
|
+
* @property showTime - Whether the list shows when each alert was raised.
|
|
44
|
+
* @property timeFormatter - Formats the time the list shows.
|
|
45
|
+
* @availableWhen timeFormatter showTime==true
|
|
46
|
+
*/
|
|
47
|
+
export class ObcAlertListPageSmallBase extends LitElement {
|
|
48
|
+
@property({type: Boolean}) hasShelved: boolean = false;
|
|
49
|
+
@property({type: Boolean}) showTime: boolean = false;
|
|
50
|
+
@property({attribute: false}) timeFormatter: (time: Date) => string = (
|
|
51
|
+
time: Date
|
|
52
|
+
) => time.toLocaleTimeString(undefined, {hour12: false});
|
|
53
|
+
|
|
54
|
+
/** The dropdown's options, in order. */
|
|
55
|
+
protected get modes(): AlertListPageMode[] {
|
|
56
|
+
return [];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** The mode the list filters by and the dropdown shows. */
|
|
60
|
+
protected get mode(): string {
|
|
61
|
+
return '';
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
protected selectMode(_mode: string) {}
|
|
65
|
+
|
|
66
|
+
/** Whether an alert the list shows in `mode` can still be acknowledged. */
|
|
67
|
+
protected get canAckAll(): boolean {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Whether the page offers "ACK visible" at all; `canAckAll` enables it. */
|
|
72
|
+
protected get offersAckAll(): boolean {
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** The alerts in view, which "ACK visible" reports. */
|
|
77
|
+
protected visibleAlerts(): unknown[] {
|
|
78
|
+
return [];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
protected renderList(): TemplateResult | typeof nothing {
|
|
82
|
+
return nothing;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
protected dispatchAckClick(alert: unknown) {
|
|
86
|
+
this.dispatchEvent(new CustomEvent('ack-click', {detail: {alert}}));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
protected dispatchRowClick(alert: unknown) {
|
|
90
|
+
this.dispatchEvent(new CustomEvent('row-click', {detail: {alert}}));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
private handleAckAllVisibleClick() {
|
|
94
|
+
this.dispatchEvent(
|
|
95
|
+
new CustomEvent('ack-all-visible-click', {
|
|
96
|
+
detail: {
|
|
97
|
+
alerts: this.visibleAlerts(),
|
|
98
|
+
mode: this.mode,
|
|
99
|
+
},
|
|
100
|
+
})
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
private onModeSelect(e: ObcDropdownButtonChangeEvent) {
|
|
105
|
+
this.selectMode(e.detail.value as string);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
override render() {
|
|
109
|
+
return html`
|
|
110
|
+
<div class="wrapper">
|
|
111
|
+
${this.renderList()}
|
|
112
|
+
<div class="action">
|
|
113
|
+
<div class="btn-group">
|
|
114
|
+
<obc-dropdown-button
|
|
115
|
+
.value=${this.mode}
|
|
116
|
+
@change=${this.onModeSelect}
|
|
117
|
+
.options=${this.modes}
|
|
118
|
+
>
|
|
119
|
+
</obc-dropdown-button>
|
|
120
|
+
</div>
|
|
121
|
+
|
|
122
|
+
<div class="btn-group">
|
|
123
|
+
<obc-icon-button
|
|
124
|
+
variant="normal"
|
|
125
|
+
@click=${() =>
|
|
126
|
+
this.dispatchEvent(new CustomEvent('silence-click'))}
|
|
127
|
+
aria-label=${msg('Silence')}
|
|
128
|
+
>
|
|
129
|
+
<obi-silence-iec></obi-silence-iec>
|
|
130
|
+
</obc-icon-button>
|
|
131
|
+
${
|
|
132
|
+
this.offersAckAll
|
|
133
|
+
? html`<obc-button
|
|
134
|
+
.variant=${ButtonVariant.raised}
|
|
135
|
+
.disabled=${!this.canAckAll}
|
|
136
|
+
fullWidth
|
|
137
|
+
class="btn"
|
|
138
|
+
data-testid="ack-all-visible-button"
|
|
139
|
+
@click=${() => this.handleAckAllVisibleClick()}
|
|
140
|
+
>
|
|
141
|
+
${msg('ACK visible')}
|
|
142
|
+
</obc-button>`
|
|
143
|
+
: nothing
|
|
144
|
+
}
|
|
145
|
+
</div>
|
|
146
|
+
</div>
|
|
147
|
+
</div>
|
|
148
|
+
`;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
static override styles: CSSResultGroup = unsafeCSS(compentStyle);
|
|
152
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import {afterEach, describe, expect, it} from 'vitest';
|
|
2
|
+
import './alert-list-page-small.js';
|
|
3
|
+
import {
|
|
4
|
+
AlertListMode,
|
|
5
|
+
ObcAlertListPageAckAllClickEvent,
|
|
6
|
+
ObcAlertListPageSmall,
|
|
7
|
+
} from './alert-list-page-small.js';
|
|
8
|
+
import type {ObcButton} from '../../components/button/button.js';
|
|
9
|
+
import {AlertType, type Alert} from '../../types.js';
|
|
10
|
+
|
|
11
|
+
const ALERTS: Alert[] = [
|
|
12
|
+
{
|
|
13
|
+
id: 'acked',
|
|
14
|
+
tagId: 'acked',
|
|
15
|
+
source: 'Source',
|
|
16
|
+
text: 'Acked',
|
|
17
|
+
acknowledged: {acknowledgedBy: 'Operator', acknowledgedAt: new Date()},
|
|
18
|
+
active: true,
|
|
19
|
+
type: AlertType.Alarm,
|
|
20
|
+
time: new Date('2024-01-15T14:32:15Z'),
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: 'shelved',
|
|
24
|
+
tagId: 'shelved',
|
|
25
|
+
source: 'Source',
|
|
26
|
+
text: 'Shelved',
|
|
27
|
+
acknowledged: false,
|
|
28
|
+
active: true,
|
|
29
|
+
type: AlertType.Warning,
|
|
30
|
+
time: new Date('2024-01-15T14:33:15Z'),
|
|
31
|
+
shelved: {shelvedStartTime: new Date()},
|
|
32
|
+
},
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
let page: ObcAlertListPageSmall;
|
|
36
|
+
|
|
37
|
+
afterEach(() => page?.remove());
|
|
38
|
+
|
|
39
|
+
async function renderPage() {
|
|
40
|
+
page = document.createElement('obc-alert-list-page-small');
|
|
41
|
+
page.hasShelved = true;
|
|
42
|
+
page.alerts = ALERTS;
|
|
43
|
+
page.style.height = '480px';
|
|
44
|
+
page.style.display = 'block';
|
|
45
|
+
document.body.append(page);
|
|
46
|
+
await page.updateComplete;
|
|
47
|
+
return page;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const ackVisibleButton = (el: ObcAlertListPageSmall) =>
|
|
51
|
+
el.shadowRoot!.querySelector<ObcButton>(
|
|
52
|
+
'[data-testid="ack-all-visible-button"]'
|
|
53
|
+
)!;
|
|
54
|
+
|
|
55
|
+
async function chooseMode(el: ObcAlertListPageSmall, mode: AlertListMode) {
|
|
56
|
+
el.shadowRoot!.querySelector('obc-dropdown-button')!.dispatchEvent(
|
|
57
|
+
new CustomEvent('change', {detail: {value: mode}})
|
|
58
|
+
);
|
|
59
|
+
await el.updateComplete;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
describe('obc-alert-list-page-small', () => {
|
|
63
|
+
it('enables ACK visible for the mode chosen in the dropdown', async () => {
|
|
64
|
+
const el = await renderPage();
|
|
65
|
+
expect(ackVisibleButton(el).disabled).toBe(true);
|
|
66
|
+
|
|
67
|
+
await chooseMode(el, AlertListMode.SHELVED);
|
|
68
|
+
|
|
69
|
+
expect(ackVisibleButton(el).disabled).toBe(false);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('reports the mode chosen in the dropdown with ACK visible', async () => {
|
|
73
|
+
const el = await renderPage();
|
|
74
|
+
await chooseMode(el, AlertListMode.SHELVED);
|
|
75
|
+
let mode: AlertListMode | undefined;
|
|
76
|
+
el.addEventListener('ack-all-visible-click', (e) => {
|
|
77
|
+
mode = (e as ObcAlertListPageAckAllClickEvent).detail.mode;
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
ackVisibleButton(el).shadowRoot!.querySelector('button')!.click();
|
|
81
|
+
|
|
82
|
+
expect(mode).toBe(AlertListMode.SHELVED);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {PropertyValues, html} from 'lit';
|
|
2
2
|
import {customElement} from '../../decorator.js';
|
|
3
|
-
import compentStyle from './alert-list-page-small.css?inline';
|
|
4
3
|
import {msg} from '@lit/localize';
|
|
5
4
|
import {property, query, state} from 'lit/decorators.js';
|
|
5
|
+
import {
|
|
6
|
+
ObcAlertListPageSmallBase,
|
|
7
|
+
type AlertListPageMode,
|
|
8
|
+
} from './alert-list-page-small-base.js';
|
|
6
9
|
import '../../building-blocks/alert-list/alert-list.js';
|
|
7
|
-
import '../../components/icon-button/icon-button.js';
|
|
8
|
-
import '../../components/button/button.js';
|
|
9
|
-
import '../../icons/icon-silence-iec.js';
|
|
10
10
|
import '../../icons/icon-alerts.js';
|
|
11
11
|
import '../../icons/icon-alerts-shelf.js';
|
|
12
12
|
import '../../icons/icon-unacknowledged.js';
|
|
13
|
-
import '../../components/dropdown-button/dropdown-button.js';
|
|
14
|
-
import {ObcDropdownButtonChangeEvent} from '../../components/dropdown-button/dropdown-button.js';
|
|
15
13
|
import '../../icons/icon-alarm-noack-iec.js';
|
|
16
14
|
import '../../icons/icon-warning-noack-iec.js';
|
|
17
15
|
import {Alert} from '../../types.js';
|
|
@@ -21,7 +19,6 @@ import {
|
|
|
21
19
|
getAlertListModeData,
|
|
22
20
|
ObcAlertListDetails,
|
|
23
21
|
} from '../../components/alert-list-details/alert-list-details.js';
|
|
24
|
-
import {ButtonVariant} from '../../components/button/button.js';
|
|
25
22
|
|
|
26
23
|
export enum AlertListMode {
|
|
27
24
|
UNACKED = 'unacked',
|
|
@@ -43,6 +40,7 @@ export type ObcRowClickEvent = CustomEvent<{
|
|
|
43
40
|
}>;
|
|
44
41
|
|
|
45
42
|
/**
|
|
43
|
+
* @property alerts - Alerts to list.
|
|
46
44
|
* @fires {ObcAlertListPageAckAllClickEvent} ack-all-visible-click - Fired when the user clicks the "ACK visible" button.
|
|
47
45
|
* @fires {ObcAckClickEvent} ack-click - Fired when the user clicks the "ACK" button.
|
|
48
46
|
* @fires {ObcRowClickEvent} row-click - Fired when the user clicks a row.
|
|
@@ -50,14 +48,9 @@ export type ObcRowClickEvent = CustomEvent<{
|
|
|
50
48
|
* @beta
|
|
51
49
|
*/
|
|
52
50
|
@customElement('obc-alert-list-page-small')
|
|
53
|
-
export class ObcAlertListPageSmall extends
|
|
54
|
-
@property({type: Boolean}) hasShelved: boolean = false;
|
|
55
|
-
@property({type: String}) selectedMode: AlertListMode = AlertListMode.ALL;
|
|
51
|
+
export class ObcAlertListPageSmall extends ObcAlertListPageSmallBase {
|
|
56
52
|
@property({type: Array}) alerts: Alert[] = [];
|
|
57
|
-
@property({type:
|
|
58
|
-
@property({attribute: false}) timeFormatter: (time: Date) => string = (
|
|
59
|
-
time: Date
|
|
60
|
-
) => time.toLocaleTimeString(undefined, {hour12: false});
|
|
53
|
+
@property({type: String}) selectedMode: AlertListMode = AlertListMode.ALL;
|
|
61
54
|
|
|
62
55
|
@state() private _mode: AlertListMode = AlertListMode.ALL;
|
|
63
56
|
|
|
@@ -73,117 +66,55 @@ export class ObcAlertListPageSmall extends LitElement {
|
|
|
73
66
|
}
|
|
74
67
|
}
|
|
75
68
|
|
|
76
|
-
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}) as ObcAlertListPageAckAllClickEvent
|
|
86
|
-
);
|
|
69
|
+
protected override get modes(): AlertListPageMode[] {
|
|
70
|
+
const modes = [
|
|
71
|
+
{value: AlertListMode.ALL, label: msg('All')},
|
|
72
|
+
{value: AlertListMode.UNACKED, label: msg('Unacked')},
|
|
73
|
+
];
|
|
74
|
+
if (this.hasShelved) {
|
|
75
|
+
modes.push({value: AlertListMode.SHELVED, label: msg('Shelved')});
|
|
76
|
+
}
|
|
77
|
+
return modes;
|
|
87
78
|
}
|
|
88
79
|
|
|
89
|
-
|
|
90
|
-
this._mode
|
|
80
|
+
protected override get mode(): AlertListMode {
|
|
81
|
+
return this._mode;
|
|
91
82
|
}
|
|
92
83
|
|
|
93
|
-
|
|
94
|
-
|
|
84
|
+
protected override selectMode(mode: string) {
|
|
85
|
+
this._mode = mode as AlertListMode;
|
|
95
86
|
}
|
|
96
87
|
|
|
97
|
-
|
|
98
|
-
this.
|
|
99
|
-
|
|
100
|
-
detail: {
|
|
101
|
-
alert: e.detail.alert,
|
|
102
|
-
},
|
|
103
|
-
}) as ObcAckClickEvent
|
|
88
|
+
protected override get canAckAll(): boolean {
|
|
89
|
+
return this.alerts.some(
|
|
90
|
+
canAckFilter(getAlertListModeData(this._mode).filter)
|
|
104
91
|
);
|
|
105
92
|
}
|
|
106
93
|
|
|
107
|
-
|
|
108
|
-
this.
|
|
109
|
-
new CustomEvent('row-click', {
|
|
110
|
-
detail: {alert: e.detail.alert},
|
|
111
|
-
}) as ObcRowClickEvent
|
|
112
|
-
);
|
|
94
|
+
protected override visibleAlerts(): Alert[] {
|
|
95
|
+
return this.alertList.getVisibleAlerts();
|
|
113
96
|
}
|
|
114
97
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
name: AlertListMode.ALL,
|
|
119
|
-
title: msg('All'),
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
name: AlertListMode.UNACKED,
|
|
123
|
-
title: msg('Unacked'),
|
|
124
|
-
},
|
|
125
|
-
];
|
|
126
|
-
if (this.hasShelved) {
|
|
127
|
-
lists.push({
|
|
128
|
-
name: AlertListMode.SHELVED,
|
|
129
|
-
title: msg('Shelved'),
|
|
130
|
-
});
|
|
131
|
-
}
|
|
98
|
+
private onAckClick(e: ObcAckClickEvent) {
|
|
99
|
+
this.dispatchAckClick(e.detail.alert);
|
|
100
|
+
}
|
|
132
101
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
return html`
|
|
137
|
-
<div class="wrapper">
|
|
138
|
-
<obc-alert-list-details
|
|
139
|
-
class="alert-list"
|
|
140
|
-
.small=${true}
|
|
141
|
-
.alerts=${this.alerts}
|
|
142
|
-
.selectedMode=${this._mode}
|
|
143
|
-
.showTime=${this.showTime}
|
|
144
|
-
.timeFormatter=${this.timeFormatter}
|
|
145
|
-
@ack-click=${this.onAckClick}
|
|
146
|
-
@row-click=${this.onRowClick}
|
|
147
|
-
></obc-alert-list-details>
|
|
148
|
-
<div class="action">
|
|
149
|
-
<div class="btn-group">
|
|
150
|
-
<obc-dropdown-button
|
|
151
|
-
.value=${this._mode}
|
|
152
|
-
@change=${this.onModeSelect}
|
|
153
|
-
.options=${lists.map((v) => ({
|
|
154
|
-
value: v.name,
|
|
155
|
-
label: v.title,
|
|
156
|
-
}))}
|
|
157
|
-
>
|
|
158
|
-
</obc-dropdown-button>
|
|
159
|
-
</div>
|
|
160
|
-
|
|
161
|
-
<div class="btn-group">
|
|
162
|
-
<obc-icon-button
|
|
163
|
-
variant="normal"
|
|
164
|
-
@click=${() =>
|
|
165
|
-
this.dispatchEvent(new CustomEvent('silence-click'))}
|
|
166
|
-
aria-label=${msg('Silence')}
|
|
167
|
-
>
|
|
168
|
-
<obi-silence-iec></obi-silence-iec>
|
|
169
|
-
</obc-icon-button>
|
|
170
|
-
<obc-button
|
|
171
|
-
.variant=${ButtonVariant.raised}
|
|
172
|
-
.disabled=${!canAckAll}
|
|
173
|
-
fullWidth
|
|
174
|
-
class="btn"
|
|
175
|
-
data-testid="ack-all-visible-button"
|
|
176
|
-
@click=${() => this.handleAckAllVisibleClick()}
|
|
177
|
-
>
|
|
178
|
-
${msg('ACK visible')}
|
|
179
|
-
</obc-button>
|
|
180
|
-
</div>
|
|
181
|
-
</div>
|
|
182
|
-
</div>
|
|
183
|
-
`;
|
|
102
|
+
private onRowClick(e: ObcRowClickEvent) {
|
|
103
|
+
this.dispatchRowClick(e.detail.alert);
|
|
184
104
|
}
|
|
185
105
|
|
|
186
|
-
|
|
106
|
+
protected override renderList() {
|
|
107
|
+
return html`<obc-alert-list-details
|
|
108
|
+
class="alert-list"
|
|
109
|
+
.small=${true}
|
|
110
|
+
.alerts=${this.alerts}
|
|
111
|
+
.selectedMode=${this._mode}
|
|
112
|
+
.showTime=${this.showTime}
|
|
113
|
+
.timeFormatter=${this.timeFormatter}
|
|
114
|
+
@ack-click=${this.onAckClick}
|
|
115
|
+
@row-click=${this.onRowClick}
|
|
116
|
+
></obc-alert-list-details>`;
|
|
117
|
+
}
|
|
187
118
|
}
|
|
188
119
|
|
|
189
120
|
declare global {
|