@things-factory/notification 6.1.18 → 6.1.22

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 (108) hide show
  1. package/client/{bootstrap.js → bootstrap.ts} +13 -9
  2. package/client/pages/notification/notification-list-page.ts +267 -0
  3. package/client/pages/notification-rule/notification-rule-importer.ts +93 -0
  4. package/client/pages/notification-rule/notification-rule-list-page.ts +395 -0
  5. package/client/route.ts +10 -0
  6. package/client/tsconfig.json +13 -0
  7. package/client/viewparts/notification-badge.ts +58 -0
  8. package/client/viewparts/notification-item.ts +242 -0
  9. package/client/viewparts/notification-list.ts +171 -0
  10. package/client/viewparts/notification-sender.ts +126 -0
  11. package/client/viewparts/{notification-setting-let.js → notification-setting-let.ts} +48 -52
  12. package/dist-client/actions/notification-fcm.d.ts +7 -0
  13. package/dist-client/actions/notification-fcm.js +125 -0
  14. package/dist-client/actions/notification-fcm.js.map +1 -0
  15. package/dist-client/bootstrap.d.ts +1 -0
  16. package/dist-client/bootstrap.js +112 -0
  17. package/dist-client/bootstrap.js.map +1 -0
  18. package/dist-client/index.d.ts +5 -0
  19. package/dist-client/index.js +6 -0
  20. package/dist-client/index.js.map +1 -0
  21. package/dist-client/pages/notification/notification-list-page.d.ts +49 -0
  22. package/dist-client/pages/notification/notification-list-page.js +262 -0
  23. package/dist-client/pages/notification/notification-list-page.js.map +1 -0
  24. package/dist-client/pages/notification-rule/notification-rule-importer.d.ts +22 -0
  25. package/dist-client/pages/notification-rule/notification-rule-importer.js +100 -0
  26. package/dist-client/pages/notification-rule/notification-rule-importer.js.map +1 -0
  27. package/dist-client/pages/notification-rule/notification-rule-list-page.d.ts +62 -0
  28. package/dist-client/pages/notification-rule/notification-rule-list-page.js +380 -0
  29. package/dist-client/pages/notification-rule/notification-rule-list-page.js.map +1 -0
  30. package/dist-client/reducers/notification.d.ts +8 -0
  31. package/dist-client/reducers/notification.js +22 -0
  32. package/dist-client/reducers/notification.js.map +1 -0
  33. package/dist-client/route.d.ts +1 -0
  34. package/dist-client/route.js +11 -0
  35. package/dist-client/route.js.map +1 -0
  36. package/dist-client/tsconfig.tsbuildinfo +1 -0
  37. package/dist-client/viewparts/notification-badge.d.ts +15 -0
  38. package/dist-client/viewparts/notification-badge.js +61 -0
  39. package/dist-client/viewparts/notification-badge.js.map +1 -0
  40. package/dist-client/viewparts/notification-item.d.ts +16 -0
  41. package/dist-client/viewparts/notification-item.js +249 -0
  42. package/dist-client/viewparts/notification-item.js.map +1 -0
  43. package/dist-client/viewparts/notification-list.d.ts +20 -0
  44. package/dist-client/viewparts/notification-list.js +160 -0
  45. package/dist-client/viewparts/notification-list.js.map +1 -0
  46. package/dist-client/viewparts/notification-sender.d.ts +13 -0
  47. package/dist-client/viewparts/notification-sender.js +122 -0
  48. package/dist-client/viewparts/notification-sender.js.map +1 -0
  49. package/dist-client/viewparts/notification-setting-let.d.ts +20 -0
  50. package/dist-client/viewparts/notification-setting-let.js +193 -0
  51. package/dist-client/viewparts/notification-setting-let.js.map +1 -0
  52. package/dist-server/service/index.js +10 -1
  53. package/dist-server/service/index.js.map +1 -1
  54. package/dist-server/service/notification/index.js +6 -3
  55. package/dist-server/service/notification/index.js.map +1 -1
  56. package/dist-server/service/notification/notification-mutation.js +110 -0
  57. package/dist-server/service/notification/notification-mutation.js.map +1 -0
  58. package/dist-server/service/notification/notification-query.js +109 -0
  59. package/dist-server/service/notification/notification-query.js.map +1 -0
  60. package/dist-server/service/notification/notification-subscription.js +45 -0
  61. package/dist-server/service/notification/notification-subscription.js.map +1 -0
  62. package/dist-server/service/notification/notification-type.js +82 -0
  63. package/dist-server/service/notification/notification-type.js.map +1 -0
  64. package/dist-server/service/notification/notification.js +81 -8
  65. package/dist-server/service/notification/notification.js.map +1 -1
  66. package/dist-server/service/notification-rule/event-subscriber.js +21 -0
  67. package/dist-server/service/notification-rule/event-subscriber.js.map +1 -0
  68. package/dist-server/service/notification-rule/index.js +12 -0
  69. package/dist-server/service/notification-rule/index.js.map +1 -0
  70. package/dist-server/service/notification-rule/notification-rule-history.js +146 -0
  71. package/dist-server/service/notification-rule/notification-rule-history.js.map +1 -0
  72. package/dist-server/service/notification-rule/notification-rule-mutation.js +170 -0
  73. package/dist-server/service/notification-rule/notification-rule-mutation.js.map +1 -0
  74. package/dist-server/service/notification-rule/notification-rule-query.js +97 -0
  75. package/dist-server/service/notification-rule/notification-rule-query.js.map +1 -0
  76. package/dist-server/service/notification-rule/notification-rule-type.js +102 -0
  77. package/dist-server/service/notification-rule/notification-rule-type.js.map +1 -0
  78. package/dist-server/service/notification-rule/notification-rule.js +146 -0
  79. package/dist-server/service/notification-rule/notification-rule.js.map +1 -0
  80. package/dist-server/tsconfig.tsbuildinfo +1 -1
  81. package/helps/notification/noti-box.md +160 -0
  82. package/helps/notification/noti-rule.md +160 -0
  83. package/helps/notification/notibox.md +160 -0
  84. package/package.json +15 -12
  85. package/server/service/index.ts +14 -0
  86. package/server/service/notification/index.ts +6 -3
  87. package/server/service/notification/notification-mutation.ts +119 -0
  88. package/server/service/notification/notification-query.ts +70 -0
  89. package/server/service/notification/{notification-resolver.ts → notification-subscription.ts} +4 -4
  90. package/server/service/notification/notification-type.ts +55 -0
  91. package/server/service/notification/notification.ts +87 -14
  92. package/server/service/notification-rule/event-subscriber.ts +20 -0
  93. package/server/service/notification-rule/index.ts +9 -0
  94. package/server/service/notification-rule/notification-rule-history.ts +130 -0
  95. package/server/service/notification-rule/notification-rule-mutation.ts +203 -0
  96. package/server/service/notification-rule/notification-rule-query.ts +62 -0
  97. package/server/service/notification-rule/notification-rule-type.ts +71 -0
  98. package/server/service/notification-rule/notification-rule.ts +125 -0
  99. package/server/tsconfig.json +9 -0
  100. package/things-factory.config.js +7 -1
  101. package/client/viewparts/notification-badge.js +0 -63
  102. package/client/viewparts/notification-item.js +0 -250
  103. package/client/viewparts/notification-list.js +0 -177
  104. package/client/viewparts/notification-sender.js +0 -128
  105. package/tsconfig.json +0 -9
  106. /package/client/actions/{notification-fcm.js → notification-fcm.ts} +0 -0
  107. /package/client/{index.js → index.ts} +0 -0
  108. /package/client/reducers/{notification.js → notification.ts} +0 -0
@@ -0,0 +1,62 @@
1
+ import '@operato/data-grist';
2
+ import { PageView } from '@operato/shell';
3
+ import { FetchOption } from '@operato/data-grist';
4
+ import { NotificationRuleImporter } from './notification-rule-importer';
5
+ declare const NotificationRuleListPage_base: (new (...args: any[]) => {
6
+ _storeUnsubscribe: import("redux").Unsubscribe;
7
+ connectedCallback(): void;
8
+ disconnectedCallback(): void;
9
+ stateChanged(_state: unknown): void;
10
+ readonly isConnected: boolean;
11
+ }) & (new (...args: any[]) => import("lit").LitElement) & typeof PageView & import("@open-wc/dedupe-mixin").Constructor<import("@open-wc/scoped-elements/types/src/types").ScopedElementsHost>;
12
+ export declare class NotificationRuleListPage extends NotificationRuleListPage_base {
13
+ static styles: import("lit").CSSResult[];
14
+ static get scopedElements(): {
15
+ 'notification-rule-importer': typeof NotificationRuleImporter;
16
+ };
17
+ gristConfig: any;
18
+ mode: 'CARD' | 'GRID' | 'LIST';
19
+ private grist;
20
+ private sortersControl;
21
+ get context(): {
22
+ search: {
23
+ handler: (search: string) => void;
24
+ placeholder: string;
25
+ value: string;
26
+ };
27
+ filter: {
28
+ handler: () => void;
29
+ };
30
+ help: string;
31
+ actions: {
32
+ icon: string;
33
+ emphasis: {
34
+ raised: boolean;
35
+ outlined: boolean;
36
+ dense: boolean;
37
+ danger: boolean;
38
+ };
39
+ title: string;
40
+ action: () => Promise<void>;
41
+ }[];
42
+ exportable: {
43
+ name: string;
44
+ data: () => Promise<{}[]>;
45
+ };
46
+ importable: {
47
+ handler: (records: any) => Promise<void>;
48
+ };
49
+ };
50
+ render(): import("lit-html").TemplateResult<1>;
51
+ pageInitialized(lifecycle: any): Promise<void>;
52
+ pageUpdated(changes: any, lifecycle: any): Promise<void>;
53
+ fetchHandler({ page, limit, sortings, filters }: FetchOption): Promise<{
54
+ total: any;
55
+ records: any;
56
+ }>;
57
+ _deleteNotificationRule(): Promise<void>;
58
+ _updateNotificationRule(): Promise<void>;
59
+ exportHandler(): Promise<{}[]>;
60
+ importHandler(records: any): Promise<void>;
61
+ }
62
+ export {};
@@ -0,0 +1,380 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import '@operato/data-grist';
3
+ import { CommonButtonStyles, CommonGristStyles, ScrollbarStyles } from '@operato/styles';
4
+ import { PageView, store } from '@operato/shell';
5
+ import { css, html } from 'lit';
6
+ import { customElement, property, query } from 'lit/decorators.js';
7
+ import { ScopedElementsMixin } from '@open-wc/scoped-elements';
8
+ import { DataGrist } from '@operato/data-grist';
9
+ import { client } from '@operato/graphql';
10
+ import { i18next, localize } from '@operato/i18n';
11
+ import { notify, openPopup } from '@operato/layout';
12
+ import { OxPopup } from '@operato/popup';
13
+ import { isMobileDevice } from '@operato/utils';
14
+ import { connect } from 'pwa-helpers/connect-mixin';
15
+ import gql from 'graphql-tag';
16
+ import { NotificationRuleImporter } from './notification-rule-importer';
17
+ let NotificationRuleListPage = class NotificationRuleListPage extends connect(store)(localize(i18next)(ScopedElementsMixin(PageView))) {
18
+ constructor() {
19
+ super(...arguments);
20
+ this.mode = isMobileDevice() ? 'CARD' : 'GRID';
21
+ }
22
+ static get scopedElements() {
23
+ return {
24
+ 'notification-rule-importer': NotificationRuleImporter
25
+ };
26
+ }
27
+ get context() {
28
+ return {
29
+ search: {
30
+ handler: (search) => {
31
+ this.grist.searchText = search;
32
+ },
33
+ placeholder: i18next.t('title.notification-rule list'),
34
+ value: this.grist.searchText
35
+ },
36
+ filter: {
37
+ handler: () => {
38
+ this.grist.toggleHeadroom();
39
+ }
40
+ },
41
+ help: 'notification/notification-rule',
42
+ actions: [
43
+ Object.assign({ title: i18next.t('button.save'), action: this._updateNotificationRule.bind(this) }, CommonButtonStyles.save),
44
+ Object.assign({ title: i18next.t('button.delete'), action: this._deleteNotificationRule.bind(this) }, CommonButtonStyles.delete)
45
+ ],
46
+ exportable: {
47
+ name: i18next.t('title.notification-rule list'),
48
+ data: this.exportHandler.bind(this)
49
+ },
50
+ importable: {
51
+ handler: this.importHandler.bind(this)
52
+ }
53
+ };
54
+ }
55
+ render() {
56
+ const mode = this.mode || (isMobileDevice() ? 'CARD' : 'GRID');
57
+ return html `
58
+ <ox-grist .mode=${mode} .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)}>
59
+ <div slot="headroom">
60
+ <div id="filters">
61
+ <ox-filters-form autofocus></ox-filters-form>
62
+ </div>
63
+
64
+ <div id="sorters">
65
+ Sort
66
+ <mwc-icon
67
+ @click=${e => {
68
+ const target = e.currentTarget;
69
+ this.sortersControl.open({
70
+ right: 0,
71
+ top: target.offsetTop + target.offsetHeight
72
+ });
73
+ }}
74
+ >expand_more</mwc-icon
75
+ >
76
+ <ox-popup id="sorter-control">
77
+ <ox-sorters-control> </ox-sorters-control>
78
+ </ox-popup>
79
+ </div>
80
+
81
+ <div id="modes">
82
+ <mwc-icon @click=${() => (this.mode = 'GRID')} ?active=${mode == 'GRID'}>grid_on</mwc-icon>
83
+ <mwc-icon @click=${() => (this.mode = 'LIST')} ?active=${mode == 'LIST'}>format_list_bulleted</mwc-icon>
84
+ <mwc-icon @click=${() => (this.mode = 'CARD')} ?active=${mode == 'CARD'}>apps</mwc-icon>
85
+ </div>
86
+ </div>
87
+ </ox-grist>
88
+ `;
89
+ }
90
+ async pageInitialized(lifecycle) {
91
+ this.gristConfig = {
92
+ list: {
93
+ thumbnail: 'thumbnail',
94
+ fields: ['name', 'description'],
95
+ details: ['title', 'updatedAt']
96
+ },
97
+ columns: [
98
+ { type: 'gutter', gutterName: 'sequence' },
99
+ { type: 'gutter', gutterName: 'row-selector', multiple: true },
100
+ {
101
+ type: 'string',
102
+ name: 'name',
103
+ header: i18next.t('field.name'),
104
+ record: {
105
+ editable: true
106
+ },
107
+ filter: 'search',
108
+ sortable: true,
109
+ width: 150
110
+ },
111
+ {
112
+ type: 'string',
113
+ name: 'description',
114
+ header: i18next.t('field.description'),
115
+ record: {
116
+ editable: true
117
+ },
118
+ filter: 'search',
119
+ width: 200
120
+ },
121
+ {
122
+ type: 'string',
123
+ name: 'title',
124
+ header: i18next.t('field.title'),
125
+ record: {
126
+ editable: true
127
+ },
128
+ filter: 'search',
129
+ sortable: true,
130
+ width: 150
131
+ },
132
+ {
133
+ type: 'text',
134
+ name: 'body',
135
+ header: i18next.t('field.body'),
136
+ record: {
137
+ editable: true
138
+ },
139
+ filter: 'search',
140
+ sortable: true,
141
+ width: 150
142
+ },
143
+ {
144
+ type: 'string',
145
+ name: 'url',
146
+ header: i18next.t('field.url'),
147
+ record: {
148
+ editable: true
149
+ },
150
+ sortable: true,
151
+ width: 150
152
+ },
153
+ {
154
+ type: 'image',
155
+ name: 'thumbnail',
156
+ header: i18next.t('field.thumbnail'),
157
+ record: { editable: true },
158
+ width: 120
159
+ },
160
+ {
161
+ type: 'select',
162
+ name: 'state',
163
+ label: true,
164
+ header: i18next.t('field.state'),
165
+ record: {
166
+ options: [
167
+ {},
168
+ {
169
+ display: i18next.t('text.draft'),
170
+ value: 'DRAFT'
171
+ },
172
+ {
173
+ display: i18next.t('text.released'),
174
+ value: 'RELEASED'
175
+ }
176
+ ]
177
+ },
178
+ sortable: true,
179
+ filter: true,
180
+ width: 60
181
+ },
182
+ {
183
+ type: 'recipients',
184
+ name: 'recipients',
185
+ header: i18next.t('field.recipients'),
186
+ record: {
187
+ editable: true
188
+ },
189
+ width: 50
190
+ },
191
+ {
192
+ type: 'resource-object',
193
+ name: 'updater',
194
+ header: i18next.t('field.updater'),
195
+ record: {
196
+ editable: false
197
+ },
198
+ sortable: true,
199
+ width: 120
200
+ },
201
+ {
202
+ type: 'datetime',
203
+ name: 'updatedAt',
204
+ header: i18next.t('field.updated_at'),
205
+ record: {
206
+ editable: false
207
+ },
208
+ sortable: true,
209
+ width: 180
210
+ }
211
+ ],
212
+ rows: {
213
+ selectable: {
214
+ multiple: true
215
+ }
216
+ },
217
+ sorters: [
218
+ {
219
+ name: 'name'
220
+ }
221
+ ]
222
+ };
223
+ }
224
+ async pageUpdated(changes, lifecycle) {
225
+ if (this.active) {
226
+ // do something here when this page just became as active
227
+ }
228
+ }
229
+ async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [] }) {
230
+ const response = await client.query({
231
+ query: gql `
232
+ query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
233
+ responses: notificationRules(filters: $filters, pagination: $pagination, sortings: $sortings) {
234
+ items {
235
+ id
236
+ name
237
+ description
238
+ title
239
+ body
240
+ url
241
+ thumbnail
242
+ state
243
+ updater {
244
+ id
245
+ name
246
+ }
247
+ updatedAt
248
+ }
249
+ total
250
+ }
251
+ }
252
+ `,
253
+ variables: {
254
+ filters,
255
+ pagination: { page, limit },
256
+ sortings
257
+ }
258
+ });
259
+ return {
260
+ total: response.data.responses.total || 0,
261
+ records: response.data.responses.items || []
262
+ };
263
+ }
264
+ async _deleteNotificationRule() {
265
+ if (confirm(i18next.t('text.sure_to_x', { x: i18next.t('text.delete') }))) {
266
+ const ids = this.grist.selected.map(record => record.id);
267
+ if (ids && ids.length > 0) {
268
+ const response = await client.mutate({
269
+ mutation: gql `
270
+ mutation ($ids: [String!]!) {
271
+ deleteNotificationRules(ids: $ids)
272
+ }
273
+ `,
274
+ variables: {
275
+ ids
276
+ }
277
+ });
278
+ if (!response.errors) {
279
+ this.grist.fetch();
280
+ notify({
281
+ message: i18next.t('text.info_x_successfully', { x: i18next.t('text.delete') })
282
+ });
283
+ }
284
+ }
285
+ }
286
+ }
287
+ async _updateNotificationRule() {
288
+ let patches = this.grist.dirtyRecords;
289
+ if (patches && patches.length) {
290
+ patches = patches.map(patch => {
291
+ let patchField = patch.id ? { id: patch.id } : {};
292
+ const dirtyFields = patch.__dirtyfields__;
293
+ for (let key in dirtyFields) {
294
+ patchField[key] = dirtyFields[key].after;
295
+ }
296
+ patchField.cuFlag = patch.__dirty__;
297
+ return patchField;
298
+ });
299
+ const response = await client.mutate({
300
+ mutation: gql `
301
+ mutation ($patches: [NotificationRulePatch!]!) {
302
+ updateMultipleNotificationRule(patches: $patches) {
303
+ name
304
+ }
305
+ }
306
+ `,
307
+ variables: {
308
+ patches
309
+ }
310
+ });
311
+ if (!response.errors) {
312
+ this.grist.fetch();
313
+ }
314
+ }
315
+ }
316
+ async exportHandler() {
317
+ const exportTargets = this.grist.selected.length ? this.grist.selected : this.grist.dirtyData.records;
318
+ const targetFieldSet = new Set(['id', 'name', 'description', 'active']);
319
+ return exportTargets.map(notificationRule => {
320
+ let tempObj = {};
321
+ for (const field of targetFieldSet) {
322
+ tempObj[field] = notificationRule[field];
323
+ }
324
+ return tempObj;
325
+ });
326
+ }
327
+ async importHandler(records) {
328
+ const popup = openPopup(html `
329
+ <notification-rule-importer
330
+ .notificationRules=${records}
331
+ @imported=${() => {
332
+ history.back();
333
+ this.grist.fetch();
334
+ }}
335
+ ></notification-rule-importer>
336
+ `, {
337
+ backdrop: true,
338
+ size: 'large',
339
+ title: i18next.t('title.import notification-rule')
340
+ });
341
+ popup.onclosed = () => {
342
+ this.grist.fetch();
343
+ };
344
+ }
345
+ };
346
+ NotificationRuleListPage.styles = [
347
+ ScrollbarStyles,
348
+ CommonGristStyles,
349
+ css `
350
+ :host {
351
+ display: flex;
352
+
353
+ width: 100%;
354
+
355
+ --grid-record-emphasized-background-color: red;
356
+ --grid-record-emphasized-color: yellow;
357
+ }
358
+ `
359
+ ];
360
+ __decorate([
361
+ property({ type: Object }),
362
+ __metadata("design:type", Object)
363
+ ], NotificationRuleListPage.prototype, "gristConfig", void 0);
364
+ __decorate([
365
+ property({ type: String }),
366
+ __metadata("design:type", String)
367
+ ], NotificationRuleListPage.prototype, "mode", void 0);
368
+ __decorate([
369
+ query('ox-grist'),
370
+ __metadata("design:type", DataGrist)
371
+ ], NotificationRuleListPage.prototype, "grist", void 0);
372
+ __decorate([
373
+ query('#sorter-control'),
374
+ __metadata("design:type", OxPopup)
375
+ ], NotificationRuleListPage.prototype, "sortersControl", void 0);
376
+ NotificationRuleListPage = __decorate([
377
+ customElement('notification-rule-list-page')
378
+ ], NotificationRuleListPage);
379
+ export { NotificationRuleListPage };
380
+ //# sourceMappingURL=notification-rule-list-page.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notification-rule-list-page.js","sourceRoot":"","sources":["../../../client/pages/notification-rule/notification-rule-list-page.ts"],"names":[],"mappings":";AAAA,OAAO,qBAAqB,CAAA;AAE5B,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACxF,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,EAAgB,SAAS,EAA+B,MAAM,qBAAqB,CAAA;AAC1F,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAE/C,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AACnD,OAAO,GAAG,MAAM,aAAa,CAAA;AAE7B,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAA;AAGhE,IAAM,wBAAwB,GAA9B,MAAM,wBAAyB,SAAQ,OAAO,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC;IAAvG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IAAC,KAAK,CAAC,UAAU,CAAC;8BAAiB,SAAS;uDAAA;AAC5C;IAAC,KAAK,CAAC,iBAAiB,CAAC;8BAA0B,OAAO;gEAAA;AA1B/C,wBAAwB;IADpC,aAAa,CAAC,6BAA6B,CAAC;GAChC,wBAAwB,CAsXpC;SAtXY,wBAAwB","sourcesContent":["import '@operato/data-grist'\n\nimport { CommonButtonStyles, CommonGristStyles, ScrollbarStyles } from '@operato/styles'\nimport { PageView, store } from '@operato/shell'\nimport { css, html } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\nimport { ScopedElementsMixin } from '@open-wc/scoped-elements'\nimport { ColumnConfig, DataGrist, FetchOption, SortersControl } from '@operato/data-grist'\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { notify, openPopup } from '@operato/layout'\nimport { OxPopup } from '@operato/popup'\nimport { isMobileDevice } from '@operato/utils'\n\nimport { connect } from 'pwa-helpers/connect-mixin'\nimport gql from 'graphql-tag'\n\nimport { NotificationRuleImporter } from './notification-rule-importer'\n\n@customElement('notification-rule-list-page')\nexport class NotificationRuleListPage extends connect(store)(localize(i18next)(ScopedElementsMixin(PageView))) {\n static styles = [\n ScrollbarStyles,\n CommonGristStyles,\n css`\n :host {\n display: flex;\n\n width: 100%;\n\n --grid-record-emphasized-background-color: red;\n --grid-record-emphasized-color: yellow;\n }\n `\n ]\n\n static get scopedElements() {\n return {\n 'notification-rule-importer': NotificationRuleImporter\n }\n }\n\n @property({ type: Object }) gristConfig: any\n @property({ type: String }) mode: 'CARD' | 'GRID' | 'LIST' = isMobileDevice() ? 'CARD' : 'GRID'\n\n @query('ox-grist') private grist!: DataGrist\n @query('#sorter-control') private sortersControl!: OxPopup\n\n get context() {\n return {\n search: {\n handler: (search: string) => {\n this.grist.searchText = search\n },\n placeholder: i18next.t('title.notification-rule list'),\n value: this.grist.searchText\n },\n filter: {\n handler: () => {\n this.grist.toggleHeadroom()\n }\n },\n help: 'notification/notification-rule',\n actions: [\n {\n title: i18next.t('button.save'),\n action: this._updateNotificationRule.bind(this),\n ...CommonButtonStyles.save\n },\n {\n title: i18next.t('button.delete'),\n action: this._deleteNotificationRule.bind(this),\n ...CommonButtonStyles.delete\n }\n ],\n exportable: {\n name: i18next.t('title.notification-rule list'),\n data: this.exportHandler.bind(this)\n },\n importable: {\n handler: this.importHandler.bind(this)\n }\n }\n }\n\n render() {\n const mode = this.mode || (isMobileDevice() ? 'CARD' : 'GRID')\n\n return html`\n <ox-grist .mode=${mode} .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)}>\n <div slot=\"headroom\">\n <div id=\"filters\">\n <ox-filters-form autofocus></ox-filters-form>\n </div>\n\n <div id=\"sorters\">\n Sort\n <mwc-icon\n @click=${e => {\n const target = e.currentTarget\n this.sortersControl.open({\n right: 0,\n top: target.offsetTop + target.offsetHeight\n })\n }}\n >expand_more</mwc-icon\n >\n <ox-popup id=\"sorter-control\">\n <ox-sorters-control> </ox-sorters-control>\n </ox-popup>\n </div>\n\n <div id=\"modes\">\n <mwc-icon @click=${() => (this.mode = 'GRID')} ?active=${mode == 'GRID'}>grid_on</mwc-icon>\n <mwc-icon @click=${() => (this.mode = 'LIST')} ?active=${mode == 'LIST'}>format_list_bulleted</mwc-icon>\n <mwc-icon @click=${() => (this.mode = 'CARD')} ?active=${mode == 'CARD'}>apps</mwc-icon>\n </div>\n </div>\n </ox-grist>\n `\n }\n\n async pageInitialized(lifecycle: any) {\n this.gristConfig = {\n list: {\n thumbnail: 'thumbnail',\n fields: ['name', 'description'],\n details: ['title', 'updatedAt']\n },\n columns: [\n { type: 'gutter', gutterName: 'sequence' },\n { type: 'gutter', gutterName: 'row-selector', multiple: true },\n {\n type: 'string',\n name: 'name',\n header: i18next.t('field.name'),\n record: {\n editable: true\n },\n filter: 'search',\n sortable: true,\n width: 150\n },\n {\n type: 'string',\n name: 'description',\n header: i18next.t('field.description'),\n record: {\n editable: true\n },\n filter: 'search',\n width: 200\n },\n {\n type: 'string',\n name: 'title',\n header: i18next.t('field.title'),\n record: {\n editable: true\n },\n filter: 'search',\n sortable: true,\n width: 150\n },\n {\n type: 'text',\n name: 'body',\n header: i18next.t('field.body'),\n record: {\n editable: true\n },\n filter: 'search',\n sortable: true,\n width: 150\n },\n {\n type: 'string',\n name: 'url',\n header: i18next.t('field.url'),\n record: {\n editable: true\n },\n sortable: true,\n width: 150\n },\n {\n type: 'image',\n name: 'thumbnail',\n header: i18next.t('field.thumbnail'),\n record: { editable: true },\n width: 120\n },\n {\n type: 'select',\n name: 'state',\n label: true,\n header: i18next.t('field.state'),\n record: {\n options: [\n {},\n {\n display: i18next.t('text.draft'),\n value: 'DRAFT'\n },\n {\n display: i18next.t('text.released'),\n value: 'RELEASED'\n }\n ]\n },\n sortable: true,\n filter: true,\n width: 60\n },\n {\n type: 'recipients',\n name: 'recipients',\n header: i18next.t('field.recipients'),\n record: {\n editable: true\n },\n width: 50\n },\n {\n type: 'resource-object',\n name: 'updater',\n header: i18next.t('field.updater'),\n record: {\n editable: false\n },\n sortable: true,\n width: 120\n },\n {\n type: 'datetime',\n name: 'updatedAt',\n header: i18next.t('field.updated_at'),\n record: {\n editable: false\n },\n sortable: true,\n width: 180\n }\n ],\n rows: {\n selectable: {\n multiple: true\n }\n },\n sorters: [\n {\n name: 'name'\n }\n ]\n }\n }\n\n async pageUpdated(changes: any, lifecycle: any) {\n if (this.active) {\n // do something here when this page just became as active\n }\n }\n\n async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [] }: FetchOption) {\n const response = await client.query({\n query: gql`\n query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {\n responses: notificationRules(filters: $filters, pagination: $pagination, sortings: $sortings) {\n items {\n id\n name\n description\n title\n body\n url\n thumbnail\n state\n updater {\n id\n name\n }\n updatedAt\n }\n total\n }\n }\n `,\n variables: {\n filters,\n pagination: { page, limit },\n sortings\n }\n })\n\n return {\n total: response.data.responses.total || 0,\n records: response.data.responses.items || []\n }\n }\n\n async _deleteNotificationRule() {\n if (confirm(i18next.t('text.sure_to_x', { x: i18next.t('text.delete') }))) {\n const ids = this.grist.selected.map(record => record.id)\n if (ids && ids.length > 0) {\n const response = await client.mutate({\n mutation: gql`\n mutation ($ids: [String!]!) {\n deleteNotificationRules(ids: $ids)\n }\n `,\n variables: {\n ids\n }\n })\n\n if (!response.errors) {\n this.grist.fetch()\n notify({\n message: i18next.t('text.info_x_successfully', { x: i18next.t('text.delete') })\n })\n }\n }\n }\n }\n\n async _updateNotificationRule() {\n let patches = this.grist.dirtyRecords\n if (patches && patches.length) {\n patches = patches.map(patch => {\n let patchField: any = patch.id ? { id: patch.id } : {}\n const dirtyFields = patch.__dirtyfields__\n for (let key in dirtyFields) {\n patchField[key] = dirtyFields[key].after\n }\n patchField.cuFlag = patch.__dirty__\n\n return patchField\n })\n\n const response = await client.mutate({\n mutation: gql`\n mutation ($patches: [NotificationRulePatch!]!) {\n updateMultipleNotificationRule(patches: $patches) {\n name\n }\n }\n `,\n variables: {\n patches\n }\n })\n\n if (!response.errors) {\n this.grist.fetch()\n }\n }\n }\n\n async exportHandler() {\n const exportTargets = this.grist.selected.length ? this.grist.selected : this.grist.dirtyData.records\n const targetFieldSet = new Set(['id', 'name', 'description', 'active'])\n\n return exportTargets.map(notificationRule => {\n let tempObj = {}\n for (const field of targetFieldSet) {\n tempObj[field] = notificationRule[field]\n }\n\n return tempObj\n })\n }\n\n async importHandler(records) {\n const popup = openPopup(\n html`\n <notification-rule-importer\n .notificationRules=${records}\n @imported=${() => {\n history.back()\n this.grist.fetch()\n }}\n ></notification-rule-importer>\n `,\n {\n backdrop: true,\n size: 'large',\n title: i18next.t('title.import notification-rule')\n }\n )\n\n popup.onclosed = () => {\n this.grist.fetch()\n }\n }\n}\n"]}
@@ -0,0 +1,8 @@
1
+ declare const notification: (state: {
2
+ badge: number;
3
+ history: never[];
4
+ } | undefined, action: any) => {
5
+ badge: any;
6
+ history: any;
7
+ };
8
+ export default notification;
@@ -0,0 +1,22 @@
1
+ import { UPDATE_NOTIFICATION } from '../actions/notification-fcm';
2
+ const INITIAL_STATE = {
3
+ badge: 0,
4
+ history: []
5
+ };
6
+ function countBadge(history) {
7
+ return history.filter(notification => !notification.confirmed).length;
8
+ }
9
+ const notification = (state = INITIAL_STATE, action) => {
10
+ switch (action.type) {
11
+ case UPDATE_NOTIFICATION:
12
+ var history = action.history;
13
+ return {
14
+ badge: countBadge(history),
15
+ history
16
+ };
17
+ default:
18
+ return state;
19
+ }
20
+ };
21
+ export default notification;
22
+ //# sourceMappingURL=notification.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notification.js","sourceRoot":"","sources":["../../client/reducers/notification.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAwB,MAAM,6BAA6B,CAAA;AAEvF,MAAM,aAAa,GAAG;IACpB,KAAK,EAAE,CAAC;IACR,OAAO,EAAE,EAAE;CACZ,CAAA;AAED,SAAS,UAAU,CAAC,OAAO;IACzB,OAAO,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,MAAM,CAAA;AACvE,CAAC;AAED,MAAM,YAAY,GAAG,CAAC,KAAK,GAAG,aAAa,EAAE,MAAM,EAAE,EAAE;IACrD,QAAQ,MAAM,CAAC,IAAI,EAAE;QACnB,KAAK,mBAAmB;YACtB,IAAI,OAAO,GAAG,MAAM,CAAC,OAAO,CAAA;YAE5B,OAAO;gBACL,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC;gBAC1B,OAAO;aACR,CAAA;QAEH;YACE,OAAO,KAAK,CAAA;KACf;AACH,CAAC,CAAA;AAED,eAAe,YAAY,CAAA","sourcesContent":["import { UPDATE_NOTIFICATION, CONFIRM_NOTIFICATION } from '../actions/notification-fcm'\n\nconst INITIAL_STATE = {\n badge: 0,\n history: []\n}\n\nfunction countBadge(history) {\n return history.filter(notification => !notification.confirmed).length\n}\n\nconst notification = (state = INITIAL_STATE, action) => {\n switch (action.type) {\n case UPDATE_NOTIFICATION:\n var history = action.history\n\n return {\n badge: countBadge(history),\n history\n }\n\n default:\n return state\n }\n}\n\nexport default notification\n"]}
@@ -0,0 +1 @@
1
+ export default function route(page: string): "notification-list" | "notification-rule-list" | undefined;
@@ -0,0 +1,11 @@
1
+ export default function route(page) {
2
+ switch (page) {
3
+ case 'notification-list':
4
+ import('./pages/notification/notification-list-page');
5
+ return page;
6
+ case 'notification-rule-list':
7
+ import('./pages/notification-rule/notification-rule-list-page');
8
+ return page;
9
+ }
10
+ }
11
+ //# sourceMappingURL=route.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route.js","sourceRoot":"","sources":["../client/route.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,IAAY;IACxC,QAAQ,IAAI,EAAE;QACZ,KAAK,mBAAmB;YACtB,MAAM,CAAC,6CAA6C,CAAC,CAAA;YACrD,OAAO,IAAI,CAAA;QACb,KAAK,wBAAwB;YAC3B,MAAM,CAAC,uDAAuD,CAAC,CAAA;YAC/D,OAAO,IAAI,CAAA;KACd;AACH,CAAC","sourcesContent":["export default function route(page: string) {\n switch (page) {\n case 'notification-list':\n import('./pages/notification/notification-list-page')\n return page\n case 'notification-rule-list':\n import('./pages/notification-rule/notification-rule-list-page')\n return page\n }\n}\n"]}