@things-factory/notification 6.1.46 → 6.1.48

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 (45) hide show
  1. package/dist-client/pages/noti-box/noti-box-list-page.d.ts +49 -0
  2. package/dist-client/pages/noti-box/noti-box-list-page.js +262 -0
  3. package/dist-client/pages/noti-box/noti-box-list-page.js.map +1 -0
  4. package/dist-client/pages/noti-rule/noti-rule-importer.d.ts +22 -0
  5. package/dist-client/pages/noti-rule/noti-rule-importer.js +100 -0
  6. package/dist-client/pages/noti-rule/noti-rule-importer.js.map +1 -0
  7. package/dist-client/pages/noti-rule/noti-rule-list-page.d.ts +62 -0
  8. package/dist-client/pages/noti-rule/noti-rule-list-page.js +380 -0
  9. package/dist-client/pages/noti-rule/noti-rule-list-page.js.map +1 -0
  10. package/dist-server/service/noti-box/index.js +9 -0
  11. package/dist-server/service/noti-box/index.js.map +1 -0
  12. package/dist-server/service/noti-box/noti-box-mutation.js +110 -0
  13. package/dist-server/service/noti-box/noti-box-mutation.js.map +1 -0
  14. package/dist-server/service/noti-box/noti-box-query.js +109 -0
  15. package/dist-server/service/noti-box/noti-box-query.js.map +1 -0
  16. package/dist-server/service/noti-box/noti-box-type.js +69 -0
  17. package/dist-server/service/noti-box/noti-box-type.js.map +1 -0
  18. package/dist-server/service/noti-box/noti-box.js +107 -0
  19. package/dist-server/service/noti-box/noti-box.js.map +1 -0
  20. package/dist-server/service/noti-rule/event-subscriber.js +21 -0
  21. package/dist-server/service/noti-rule/event-subscriber.js.map +1 -0
  22. package/dist-server/service/noti-rule/index.js +12 -0
  23. package/dist-server/service/noti-rule/index.js.map +1 -0
  24. package/dist-server/service/noti-rule/noti-rule-history.js +139 -0
  25. package/dist-server/service/noti-rule/noti-rule-history.js.map +1 -0
  26. package/dist-server/service/noti-rule/noti-rule-mutation.js +168 -0
  27. package/dist-server/service/noti-rule/noti-rule-mutation.js.map +1 -0
  28. package/dist-server/service/noti-rule/noti-rule-query.js +97 -0
  29. package/dist-server/service/noti-rule/noti-rule-query.js.map +1 -0
  30. package/dist-server/service/noti-rule/noti-rule-type.js +102 -0
  31. package/dist-server/service/noti-rule/noti-rule-type.js.map +1 -0
  32. package/dist-server/service/noti-rule/noti-rule.js +146 -0
  33. package/dist-server/service/noti-rule/noti-rule.js.map +1 -0
  34. package/dist-server/service/notification-old/directive-notification.js +59 -0
  35. package/dist-server/service/notification-old/directive-notification.js.map +1 -0
  36. package/dist-server/service/notification-old/index.js +14 -0
  37. package/dist-server/service/notification-old/index.js.map +1 -0
  38. package/dist-server/service/notification-old/notification-resolver.js +45 -0
  39. package/dist-server/service/notification-old/notification-resolver.js.map +1 -0
  40. package/dist-server/service/notification-old/notification.js +49 -0
  41. package/dist-server/service/notification-old/notification.js.map +1 -0
  42. package/dist-server/tsconfig.tsbuildinfo +1 -1
  43. package/package.json +8 -8
  44. package/dist-server/migrations/index.js +0 -12
  45. package/dist-server/migrations/index.js.map +0 -1
@@ -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 { NotiRuleImporter } from './noti-rule-importer';
17
+ let NotiRuleListPage = class NotiRuleListPage 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
+ 'noti-rule-importer': NotiRuleImporter
25
+ };
26
+ }
27
+ get context() {
28
+ return {
29
+ search: {
30
+ handler: (search) => {
31
+ this.grist.searchText = search;
32
+ },
33
+ placeholder: i18next.t('title.noti-rule list'),
34
+ value: this.grist.searchText
35
+ },
36
+ filter: {
37
+ handler: () => {
38
+ this.grist.toggleHeadroom();
39
+ }
40
+ },
41
+ help: 'notification/noti-rule',
42
+ actions: [
43
+ Object.assign({ title: i18next.t('button.save'), action: this._updateNotiRule.bind(this) }, CommonButtonStyles.save),
44
+ Object.assign({ title: i18next.t('button.delete'), action: this._deleteNotiRule.bind(this) }, CommonButtonStyles.delete)
45
+ ],
46
+ exportable: {
47
+ name: i18next.t('title.noti-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: notiRules(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 _deleteNotiRule() {
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
+ deleteNotiRules(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 _updateNotiRule() {
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: [NotiRulePatch!]!) {
302
+ updateMultipleNotiRule(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(notiRule => {
320
+ let tempObj = {};
321
+ for (const field of targetFieldSet) {
322
+ tempObj[field] = notiRule[field];
323
+ }
324
+ return tempObj;
325
+ });
326
+ }
327
+ async importHandler(records) {
328
+ const popup = openPopup(html `
329
+ <noti-rule-importer
330
+ .notiRules=${records}
331
+ @imported=${() => {
332
+ history.back();
333
+ this.grist.fetch();
334
+ }}
335
+ ></noti-rule-importer>
336
+ `, {
337
+ backdrop: true,
338
+ size: 'large',
339
+ title: i18next.t('title.import noti-rule')
340
+ });
341
+ popup.onclosed = () => {
342
+ this.grist.fetch();
343
+ };
344
+ }
345
+ };
346
+ NotiRuleListPage.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
+ ], NotiRuleListPage.prototype, "gristConfig", void 0);
364
+ __decorate([
365
+ property({ type: String }),
366
+ __metadata("design:type", String)
367
+ ], NotiRuleListPage.prototype, "mode", void 0);
368
+ __decorate([
369
+ query('ox-grist'),
370
+ __metadata("design:type", DataGrist)
371
+ ], NotiRuleListPage.prototype, "grist", void 0);
372
+ __decorate([
373
+ query('#sorter-control'),
374
+ __metadata("design:type", OxPopup)
375
+ ], NotiRuleListPage.prototype, "sortersControl", void 0);
376
+ NotiRuleListPage = __decorate([
377
+ customElement('noti-rule-list-page')
378
+ ], NotiRuleListPage);
379
+ export { NotiRuleListPage };
380
+ //# sourceMappingURL=noti-rule-list-page.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"noti-rule-list-page.js","sourceRoot":"","sources":["../../../client/pages/noti-rule/noti-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;A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,EAAE,OAAO;YACb,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,wBAAwB,CAAC;SAC3C,CACF,CAAA;QAED,KAAK,CAAC,QAAQ,GAAG,GAAG,EAAE;YACpB,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;QACpB,CAAC,CAAA;IACH,CAAC;;AApXM,uBAAM,GAAG;IACd,eAAe;IACf,iBAAiB;IACjB,GAAG,CAAA;;;;;;;;;KASF;CACF,CAAA;AAQD;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;qDAAiB;AAC5C;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;8CAAoE;AAE/F;IAAC,KAAK,CAAC,UAAU,CAAC;8BAAiB,SAAS;+CAAA;AAC5C;IAAC,KAAK,CAAC,iBAAiB,CAAC;8BAA0B,OAAO;wDAAA;AA1B/C,gBAAgB;IAD5B,aAAa,CAAC,qBAAqB,CAAC;GACxB,gBAAgB,CAsX5B;SAtXY,gBAAgB","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 { NotiRuleImporter } from './noti-rule-importer'\n\n@customElement('noti-rule-list-page')\nexport class NotiRuleListPage 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 'noti-rule-importer': NotiRuleImporter\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.noti-rule list'),\n value: this.grist.searchText\n },\n filter: {\n handler: () => {\n this.grist.toggleHeadroom()\n }\n },\n help: 'notification/noti-rule',\n actions: [\n {\n title: i18next.t('button.save'),\n action: this._updateNotiRule.bind(this),\n ...CommonButtonStyles.save\n },\n {\n title: i18next.t('button.delete'),\n action: this._deleteNotiRule.bind(this),\n ...CommonButtonStyles.delete\n }\n ],\n exportable: {\n name: i18next.t('title.noti-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: notiRules(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 _deleteNotiRule() {\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 deleteNotiRules(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 _updateNotiRule() {\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: [NotiRulePatch!]!) {\n updateMultipleNotiRule(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(notiRule => {\n let tempObj = {}\n for (const field of targetFieldSet) {\n tempObj[field] = notiRule[field]\n }\n\n return tempObj\n })\n }\n\n async importHandler(records) {\n const popup = openPopup(\n html`\n <noti-rule-importer\n .notiRules=${records}\n @imported=${() => {\n history.back()\n this.grist.fetch()\n }}\n ></noti-rule-importer>\n `,\n {\n backdrop: true,\n size: 'large',\n title: i18next.t('title.import noti-rule')\n }\n )\n\n popup.onclosed = () => {\n this.grist.fetch()\n }\n }\n}\n"]}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolvers = exports.entities = void 0;
4
+ const noti_box_1 = require("./noti-box");
5
+ const noti_box_query_1 = require("./noti-box-query");
6
+ const noti_box_mutation_1 = require("./noti-box-mutation");
7
+ exports.entities = [noti_box_1.NotiBox];
8
+ exports.resolvers = [noti_box_query_1.NotiBoxQuery, noti_box_mutation_1.NotiBoxMutation];
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/noti-box/index.ts"],"names":[],"mappings":";;;AAAA,yCAAoC;AACpC,qDAA+C;AAC/C,2DAAqD;AAExC,QAAA,QAAQ,GAAG,CAAC,kBAAO,CAAC,CAAA;AACpB,QAAA,SAAS,GAAG,CAAC,6BAAY,EAAE,mCAAe,CAAC,CAAA","sourcesContent":["import { NotiBox } from './noti-box'\nimport { NotiBoxQuery } from './noti-box-query'\nimport { NotiBoxMutation } from './noti-box-mutation'\n\nexport const entities = [NotiBox]\nexport const resolvers = [NotiBoxQuery, NotiBoxMutation]\n"]}
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NotiBoxMutation = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const type_graphql_1 = require("type-graphql");
6
+ const typeorm_1 = require("typeorm");
7
+ const noti_box_1 = require("./noti-box");
8
+ const noti_box_type_1 = require("./noti-box-type");
9
+ let NotiBoxMutation = class NotiBoxMutation {
10
+ async createNotiBox(notiBox, context) {
11
+ const { domain, user, tx } = context.state;
12
+ return await tx.getRepository(noti_box_1.NotiBox).save(Object.assign(Object.assign({}, notiBox), { domain, creator: user, updater: user }));
13
+ }
14
+ async updateNotiBox(id, patch, context) {
15
+ const { domain, user, tx } = context.state;
16
+ const repository = tx.getRepository(noti_box_1.NotiBox);
17
+ const notiBox = await repository.findOne({
18
+ where: { domain: { id: domain.id }, id }
19
+ });
20
+ const result = await repository.save(Object.assign(Object.assign(Object.assign({}, notiBox), patch), { updater: user }));
21
+ return result;
22
+ }
23
+ async updateMultipleNotiBox(patches, context) {
24
+ const { domain, user, tx } = context.state;
25
+ let results = [];
26
+ const _createRecords = patches.filter((patch) => patch.cuFlag.toUpperCase() === '+');
27
+ const _updateRecords = patches.filter((patch) => patch.cuFlag.toUpperCase() === 'M');
28
+ const notiBoxRepo = tx.getRepository(noti_box_1.NotiBox);
29
+ if (_createRecords.length > 0) {
30
+ for (let i = 0; i < _createRecords.length; i++) {
31
+ const newRecord = _createRecords[i];
32
+ const result = await notiBoxRepo.save(Object.assign(Object.assign({}, newRecord), { domain, creator: user, updater: user }));
33
+ results.push(Object.assign(Object.assign({}, result), { cuFlag: '+' }));
34
+ }
35
+ }
36
+ if (_updateRecords.length > 0) {
37
+ for (let i = 0; i < _updateRecords.length; i++) {
38
+ const updateRecord = _updateRecords[i];
39
+ const notiBox = await notiBoxRepo.findOneBy({ id: updateRecord.id });
40
+ const result = await notiBoxRepo.save(Object.assign(Object.assign(Object.assign({}, notiBox), updateRecord), { updater: user }));
41
+ results.push(Object.assign(Object.assign({}, result), { cuFlag: 'M' }));
42
+ }
43
+ }
44
+ return results;
45
+ }
46
+ async deleteNotiBox(id, context) {
47
+ const { domain, tx } = context.state;
48
+ await tx.getRepository(noti_box_1.NotiBox).delete({ domain: { id: domain.id }, id });
49
+ return true;
50
+ }
51
+ async deleteNotiBoxes(ids, context) {
52
+ const { domain, tx } = context.state;
53
+ await tx.getRepository(noti_box_1.NotiBox).delete({
54
+ domain: { id: domain.id },
55
+ id: (0, typeorm_1.In)(ids)
56
+ });
57
+ return true;
58
+ }
59
+ };
60
+ tslib_1.__decorate([
61
+ (0, type_graphql_1.Directive)('@transaction'),
62
+ (0, type_graphql_1.Mutation)(returns => noti_box_1.NotiBox, { description: 'To create new NotiBox' }),
63
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('notiBox')),
64
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
65
+ tslib_1.__metadata("design:type", Function),
66
+ tslib_1.__metadata("design:paramtypes", [noti_box_type_1.NewNotiBox, Object]),
67
+ tslib_1.__metadata("design:returntype", Promise)
68
+ ], NotiBoxMutation.prototype, "createNotiBox", null);
69
+ tslib_1.__decorate([
70
+ (0, type_graphql_1.Directive)('@transaction'),
71
+ (0, type_graphql_1.Mutation)(returns => noti_box_1.NotiBox, { description: 'To modify NotiBox information' }),
72
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
73
+ tslib_1.__param(1, (0, type_graphql_1.Arg)('patch')),
74
+ tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
75
+ tslib_1.__metadata("design:type", Function),
76
+ tslib_1.__metadata("design:paramtypes", [String, noti_box_type_1.NotiBoxPatch, Object]),
77
+ tslib_1.__metadata("design:returntype", Promise)
78
+ ], NotiBoxMutation.prototype, "updateNotiBox", null);
79
+ tslib_1.__decorate([
80
+ (0, type_graphql_1.Directive)('@transaction'),
81
+ (0, type_graphql_1.Mutation)(returns => [noti_box_1.NotiBox], { description: "To modify multiple NotiBoxes' information" }),
82
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('patches', type => [noti_box_type_1.NotiBoxPatch])),
83
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
84
+ tslib_1.__metadata("design:type", Function),
85
+ tslib_1.__metadata("design:paramtypes", [Array, Object]),
86
+ tslib_1.__metadata("design:returntype", Promise)
87
+ ], NotiBoxMutation.prototype, "updateMultipleNotiBox", null);
88
+ tslib_1.__decorate([
89
+ (0, type_graphql_1.Directive)('@transaction'),
90
+ (0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete NotiBox' }),
91
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
92
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
93
+ tslib_1.__metadata("design:type", Function),
94
+ tslib_1.__metadata("design:paramtypes", [String, Object]),
95
+ tslib_1.__metadata("design:returntype", Promise)
96
+ ], NotiBoxMutation.prototype, "deleteNotiBox", null);
97
+ tslib_1.__decorate([
98
+ (0, type_graphql_1.Directive)('@transaction'),
99
+ (0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete multiple NotiBoxes' }),
100
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('ids', type => [String])),
101
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
102
+ tslib_1.__metadata("design:type", Function),
103
+ tslib_1.__metadata("design:paramtypes", [Array, Object]),
104
+ tslib_1.__metadata("design:returntype", Promise)
105
+ ], NotiBoxMutation.prototype, "deleteNotiBoxes", null);
106
+ NotiBoxMutation = tslib_1.__decorate([
107
+ (0, type_graphql_1.Resolver)(noti_box_1.NotiBox)
108
+ ], NotiBoxMutation);
109
+ exports.NotiBoxMutation = NotiBoxMutation;
110
+ //# sourceMappingURL=noti-box-mutation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"noti-box-mutation.js","sourceRoot":"","sources":["../../../server/service/noti-box/noti-box-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA4B;AAE5B,yCAAoC;AACpC,mDAA0D;AAGnD,IAAM,eAAe,GAArB,MAAM,eAAe;IAGpB,AAAN,KAAK,CAAC,aAAa,CAAiB,OAAmB,EAAS,OAAwB;QACtF,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,OAAO,MAAM,EAAE,CAAC,aAA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E,CAAA;;;;4DAwCP;AAIK;IAFL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,mBAAmB,EAAE,CAAC;IAC9C,mBAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IAAc,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;oDAMhD;AAIK;IAFL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,8BAA8B,EAAE,CAAC;IAE3E,mBAAA,IAAA,kBAAG,EAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;IAC5B,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;sDAUP;AA3GU,eAAe;IAD3B,IAAA,uBAAQ,EAAC,kBAAO,CAAC;GACL,eAAe,CA4G3B;AA5GY,0CAAe","sourcesContent":["import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'\nimport { In } from 'typeorm'\n\nimport { NotiBox } from './noti-box'\nimport { NewNotiBox, NotiBoxPatch } from './noti-box-type'\n\n@Resolver(NotiBox)\nexport class NotiBoxMutation {\n @Directive('@transaction')\n @Mutation(returns => NotiBox, { description: 'To create new NotiBox' })\n async createNotiBox(@Arg('notiBox') notiBox: NewNotiBox, @Ctx() context: ResolverContext): Promise<NotiBox> {\n const { domain, user, tx } = context.state\n\n return await tx.getRepository(NotiBox).save({\n ...notiBox,\n domain,\n creator: user,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Mutation(returns => NotiBox, { description: 'To modify NotiBox information' })\n async updateNotiBox(\n @Arg('id') id: string,\n @Arg('patch') patch: NotiBoxPatch,\n @Ctx() context: ResolverContext\n ): Promise<NotiBox> {\n const { domain, user, tx } = context.state\n\n const repository = tx.getRepository(NotiBox)\n const notiBox = await repository.findOne({\n where: { domain: { id: domain.id }, id }\n })\n\n const result = await repository.save({\n ...notiBox,\n ...patch,\n updater: user\n })\n\n return result\n }\n\n @Directive('@transaction')\n @Mutation(returns => [NotiBox], { description: \"To modify multiple NotiBoxes' information\" })\n async updateMultipleNotiBox(\n @Arg('patches', type => [NotiBoxPatch]) patches: NotiBoxPatch[],\n @Ctx() context: ResolverContext\n ): Promise<NotiBox[]> {\n const { domain, user, tx } = context.state\n\n let results = []\n const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')\n const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')\n const notiBoxRepo = tx.getRepository(NotiBox)\n\n if (_createRecords.length > 0) {\n for (let i = 0; i < _createRecords.length; i++) {\n const newRecord = _createRecords[i]\n\n const result = await notiBoxRepo.save({\n ...newRecord,\n domain,\n creator: user,\n updater: user\n })\n\n results.push({ ...result, cuFlag: '+' })\n }\n }\n\n if (_updateRecords.length > 0) {\n for (let i = 0; i < _updateRecords.length; i++) {\n const updateRecord = _updateRecords[i]\n const notiBox = await notiBoxRepo.findOneBy({ id: updateRecord.id })\n\n const result = await notiBoxRepo.save({\n ...notiBox,\n ...updateRecord,\n updater: user\n })\n\n results.push({ ...result, cuFlag: 'M' })\n }\n }\n\n return results\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete NotiBox' })\n async deleteNotiBox(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(NotiBox).delete({ domain: { id: domain.id }, id })\n\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete multiple NotiBoxes' })\n async deleteNotiBoxes(\n @Arg('ids', type => [String]) ids: string[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(NotiBox).delete({\n domain: { id: domain.id },\n id: In(ids)\n })\n\n return true\n }\n}\n"]}