@things-factory/notification 7.0.1-alpha.9 → 7.0.1-alpha.92
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/client/bootstrap.ts +2 -1
- package/client/pages/notification/notification-list-page.ts +6 -5
- package/client/pages/notification-rule/notification-rule-importer.ts +4 -11
- package/client/pages/notification-rule/notification-rule-list-page.ts +6 -5
- package/client/viewparts/notification-badge.ts +14 -17
- package/client/viewparts/notification-item.ts +8 -5
- package/client/viewparts/notification-list.ts +5 -5
- package/client/viewparts/notification-sender.ts +10 -22
- package/client/viewparts/notification-setting-let.ts +27 -22
- package/dist-client/bootstrap.js +1 -1
- package/dist-client/bootstrap.js.map +1 -1
- package/dist-client/pages/notification/notification-list-page.js +6 -5
- package/dist-client/pages/notification/notification-list-page.js.map +1 -1
- package/dist-client/pages/notification-rule/notification-rule-importer.d.ts +1 -0
- package/dist-client/pages/notification-rule/notification-rule-importer.js +4 -11
- package/dist-client/pages/notification-rule/notification-rule-importer.js.map +1 -1
- package/dist-client/pages/notification-rule/notification-rule-list-page.js +6 -5
- package/dist-client/pages/notification-rule/notification-rule-list-page.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-client/viewparts/notification-badge.d.ts +1 -0
- package/dist-client/viewparts/notification-badge.js +13 -17
- package/dist-client/viewparts/notification-badge.js.map +1 -1
- package/dist-client/viewparts/notification-item.d.ts +1 -1
- package/dist-client/viewparts/notification-item.js +7 -5
- package/dist-client/viewparts/notification-item.js.map +1 -1
- package/dist-client/viewparts/notification-list.d.ts +2 -2
- package/dist-client/viewparts/notification-list.js +4 -4
- package/dist-client/viewparts/notification-list.js.map +1 -1
- package/dist-client/viewparts/notification-sender.d.ts +1 -2
- package/dist-client/viewparts/notification-sender.js +8 -19
- package/dist-client/viewparts/notification-sender.js.map +1 -1
- package/dist-client/viewparts/notification-setting-let.d.ts +3 -4
- package/dist-client/viewparts/notification-setting-let.js +27 -17
- package/dist-client/viewparts/notification-setting-let.js.map +1 -1
- package/dist-server/service/notification/notification.js +1 -1
- package/dist-server/service/notification/notification.js.map +1 -1
- package/dist-server/service/notification-rule/notification-rule-history.js +1 -1
- package/dist-server/service/notification-rule/notification-rule-history.js.map +1 -1
- package/dist-server/service/notification-rule/notification-rule.js +1 -1
- package/dist-server/service/notification-rule/notification-rule.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -9
- package/server/service/notification/notification.ts +1 -1
- package/server/service/notification-rule/notification-rule-history.ts +3 -3
- package/server/service/notification-rule/notification-rule.ts +1 -1
package/client/bootstrap.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import gql from 'graphql-tag'
|
|
2
2
|
|
|
3
3
|
import { notify } from '@operato/layout'
|
|
4
|
-
import { auth } from '@things-factory/auth-base/dist-client'
|
|
4
|
+
import { auth } from '@things-factory/auth-base/dist-client/auth.js'
|
|
5
|
+
|
|
5
6
|
import { i18next } from '@operato/i18n'
|
|
6
7
|
import { notificationStore, route, store } from '@operato/shell'
|
|
7
8
|
import { subscribe as graphqlSubscribe } from '@operato/graphql'
|
|
@@ -85,7 +85,7 @@ export class NotificationListPage extends connect(store)(localize(i18next)(Scope
|
|
|
85
85
|
|
|
86
86
|
<div id="sorters">
|
|
87
87
|
Sort
|
|
88
|
-
<
|
|
88
|
+
<md-icon
|
|
89
89
|
@click=${e => {
|
|
90
90
|
const target = e.currentTarget
|
|
91
91
|
this.sortersControl.open({
|
|
@@ -93,7 +93,7 @@ export class NotificationListPage extends connect(store)(localize(i18next)(Scope
|
|
|
93
93
|
top: target.offsetTop + target.offsetHeight
|
|
94
94
|
})
|
|
95
95
|
}}
|
|
96
|
-
>expand_more</
|
|
96
|
+
>expand_more</md-icon
|
|
97
97
|
>
|
|
98
98
|
<ox-popup id="sorter-control">
|
|
99
99
|
<ox-sorters-control> </ox-sorters-control>
|
|
@@ -101,9 +101,10 @@ export class NotificationListPage extends connect(store)(localize(i18next)(Scope
|
|
|
101
101
|
</div>
|
|
102
102
|
|
|
103
103
|
<div id="modes">
|
|
104
|
-
<
|
|
105
|
-
<
|
|
106
|
-
<
|
|
104
|
+
<md-icon @click=${() => (this.mode = 'GRID')} ?active=${mode == 'GRID'}>grid_on</md-icon>
|
|
105
|
+
<md-icon @click=${() => (this.mode = 'LIST')} ?active=${mode == 'LIST'}>format_list_bulleted</md-icon>
|
|
106
|
+
<md-icon @click=${() => (this.mode = 'CARD')} ?active=${mode == 'CARD'}>apps</md-icon>
|
|
107
|
+
</div>
|
|
107
108
|
</div>
|
|
108
109
|
</div>
|
|
109
110
|
</ox-grist>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import '@material/web/icon/icon.js'
|
|
1
2
|
import '@operato/data-grist'
|
|
2
3
|
|
|
3
4
|
import gql from 'graphql-tag'
|
|
@@ -7,9 +8,11 @@ import { property } from 'lit/decorators.js'
|
|
|
7
8
|
import { client } from '@operato/graphql'
|
|
8
9
|
import { i18next } from '@operato/i18n'
|
|
9
10
|
import { isMobileDevice } from '@operato/utils'
|
|
11
|
+
import { ButtonContainerStyles } from '@operato/styles'
|
|
10
12
|
|
|
11
13
|
export class NotificationRuleImporter extends LitElement {
|
|
12
14
|
static styles = [
|
|
15
|
+
ButtonContainerStyles,
|
|
13
16
|
css`
|
|
14
17
|
:host {
|
|
15
18
|
display: flex;
|
|
@@ -21,16 +24,6 @@ export class NotificationRuleImporter extends LitElement {
|
|
|
21
24
|
ox-grist {
|
|
22
25
|
flex: 1;
|
|
23
26
|
}
|
|
24
|
-
|
|
25
|
-
.button-container {
|
|
26
|
-
display: flex;
|
|
27
|
-
margin-left: auto;
|
|
28
|
-
padding: var(--padding-default);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
mwc-button {
|
|
32
|
-
margin-left: var(--margin-default);
|
|
33
|
-
}
|
|
34
27
|
`
|
|
35
28
|
]
|
|
36
29
|
|
|
@@ -71,7 +64,7 @@ export class NotificationRuleImporter extends LitElement {
|
|
|
71
64
|
></ox-grist>
|
|
72
65
|
|
|
73
66
|
<div class="button-container">
|
|
74
|
-
<
|
|
67
|
+
<button @click="${this.save.bind(this)}"><md-icon>save</md-icon>${i18next.t('button.save')}</button>
|
|
75
68
|
</div>
|
|
76
69
|
`
|
|
77
70
|
}
|
|
@@ -100,7 +100,7 @@ export class NotificationRuleListPage extends connect(store)(localize(i18next)(S
|
|
|
100
100
|
|
|
101
101
|
<div id="sorters">
|
|
102
102
|
Sort
|
|
103
|
-
<
|
|
103
|
+
<md-icon
|
|
104
104
|
@click=${e => {
|
|
105
105
|
const target = e.currentTarget
|
|
106
106
|
this.sortersControl.open({
|
|
@@ -108,7 +108,7 @@ export class NotificationRuleListPage extends connect(store)(localize(i18next)(S
|
|
|
108
108
|
top: target.offsetTop + target.offsetHeight
|
|
109
109
|
})
|
|
110
110
|
}}
|
|
111
|
-
>expand_more</
|
|
111
|
+
>expand_more</md-icon
|
|
112
112
|
>
|
|
113
113
|
<ox-popup id="sorter-control">
|
|
114
114
|
<ox-sorters-control> </ox-sorters-control>
|
|
@@ -116,9 +116,10 @@ export class NotificationRuleListPage extends connect(store)(localize(i18next)(S
|
|
|
116
116
|
</div>
|
|
117
117
|
|
|
118
118
|
<div id="modes">
|
|
119
|
-
<
|
|
120
|
-
<
|
|
121
|
-
<
|
|
119
|
+
<md-icon @click=${() => (this.mode = 'GRID')} ?active=${mode == 'GRID'}>grid_on</md-icon>
|
|
120
|
+
<md-icon @click=${() => (this.mode = 'LIST')} ?active=${mode == 'LIST'}>format_list_bulleted</md-icon>
|
|
121
|
+
<md-icon @click=${() => (this.mode = 'CARD')} ?active=${mode == 'CARD'}>apps</md-icon>
|
|
122
|
+
</div>
|
|
122
123
|
</div>
|
|
123
124
|
</div>
|
|
124
125
|
</ox-grist>
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import '@material/web/icon/icon.js'
|
|
2
|
+
|
|
1
3
|
import { LitElement, html, css } from 'lit'
|
|
2
4
|
import { customElement, property } from 'lit/decorators.js'
|
|
3
5
|
|
|
@@ -11,48 +13,43 @@ export class NotificationBadge extends connect(store)(LitElement) {
|
|
|
11
13
|
:host {
|
|
12
14
|
font-size: 2em;
|
|
13
15
|
margin: 0 5px 0 0;
|
|
14
|
-
|
|
16
|
+
position: relative;
|
|
15
17
|
}
|
|
16
18
|
|
|
17
|
-
|
|
19
|
+
md-icon {
|
|
18
20
|
display: block;
|
|
19
21
|
}
|
|
20
22
|
|
|
21
|
-
|
|
22
|
-
position: relative;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
[data-badge]::after {
|
|
23
|
+
:host::after {
|
|
26
24
|
content: attr(data-badge);
|
|
27
25
|
position: absolute;
|
|
28
26
|
top: 0px;
|
|
29
27
|
right: -6px;
|
|
30
28
|
font-family: var(--theme-font);
|
|
31
|
-
font-size: 0.
|
|
32
|
-
background: var(--
|
|
29
|
+
font-size: 0.3em;
|
|
30
|
+
background: var(--md-sys-color-error, rgb(186 26 26));
|
|
33
31
|
color: var(--theme-white-color);
|
|
34
|
-
width:
|
|
35
|
-
height:
|
|
32
|
+
width: 14px;
|
|
33
|
+
height: 14px;
|
|
36
34
|
text-align: center;
|
|
37
|
-
line-height:
|
|
35
|
+
line-height: 14px;
|
|
38
36
|
border-radius: 50%;
|
|
39
37
|
box-shadow: var(--box-shadow);
|
|
40
38
|
}
|
|
41
39
|
|
|
42
|
-
[data-badge='0']::after {
|
|
40
|
+
:host([data-badge='0'])::after {
|
|
43
41
|
display: none;
|
|
44
42
|
}
|
|
45
43
|
`
|
|
46
44
|
]
|
|
47
45
|
|
|
48
|
-
@property({ type: Number }) badge?: number
|
|
46
|
+
@property({ type: Number, attribute: 'data-badge', reflect: true }) badge?: number
|
|
49
47
|
|
|
50
48
|
render() {
|
|
51
|
-
|
|
52
|
-
return html` <mwc-icon data-badge=${badge} class="badge">notifications_none</mwc-icon> `
|
|
49
|
+
return html` <md-icon>notifications_none</md-icon> `
|
|
53
50
|
}
|
|
54
51
|
|
|
55
52
|
stateChanged(state) {
|
|
56
|
-
this.badge = state.notification.badge
|
|
53
|
+
this.badge = state.notification.badge || 0
|
|
57
54
|
}
|
|
58
55
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import '@material/web/icon/icon.js'
|
|
2
|
+
|
|
1
3
|
import gql from 'graphql-tag'
|
|
2
4
|
import { LitElement, html, css } from 'lit'
|
|
3
5
|
import { customElement, property } from 'lit/decorators.js'
|
|
4
|
-
import '@material/mwc-icon'
|
|
5
6
|
import { client } from '@operato/graphql'
|
|
6
7
|
|
|
7
8
|
function isOriginSameAsLocation(url) {
|
|
@@ -40,7 +41,9 @@ export class NotificationItem extends LitElement {
|
|
|
40
41
|
padding: var(--padding-default);
|
|
41
42
|
border-left: 0 solid transparent;
|
|
42
43
|
border-bottom: var(--border-dark-color) !important;
|
|
43
|
-
transition:
|
|
44
|
+
transition:
|
|
45
|
+
border-left 300ms ease-in-out,
|
|
46
|
+
padding-left 300ms ease-in-out;
|
|
44
47
|
color: var(--scondary-color);
|
|
45
48
|
|
|
46
49
|
--type-dot-size: 9px;
|
|
@@ -98,7 +101,7 @@ export class NotificationItem extends LitElement {
|
|
|
98
101
|
border-radius: var(--border-radius);
|
|
99
102
|
font-size: 0.8em;
|
|
100
103
|
color: var(--theme-white-color);
|
|
101
|
-
--
|
|
104
|
+
--md-icon-size: 14px;
|
|
102
105
|
}
|
|
103
106
|
span.more * {
|
|
104
107
|
vertical-align: middle;
|
|
@@ -174,7 +177,7 @@ export class NotificationItem extends LitElement {
|
|
|
174
177
|
: html`<a href=${url}>${title}</a>`
|
|
175
178
|
: title}
|
|
176
179
|
</div>
|
|
177
|
-
<
|
|
180
|
+
<md-icon close @click=${e => this.dispatchEvent(new CustomEvent('close'))}>close</md-icon>
|
|
178
181
|
|
|
179
182
|
${image
|
|
180
183
|
? url
|
|
@@ -190,7 +193,7 @@ export class NotificationItem extends LitElement {
|
|
|
190
193
|
this.decipherErrorCode()
|
|
191
194
|
}}
|
|
192
195
|
>
|
|
193
|
-
<span class="more"><
|
|
196
|
+
<span class="more"><md-icon>expand_circle_down</md-icon> more</span>
|
|
194
197
|
</div>`
|
|
195
198
|
: html``}
|
|
196
199
|
${detail ? html`<div detail>${detail.message}</div>` : html``}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import '@material/web/icon/icon.js'
|
|
2
|
+
import './notification-item'
|
|
3
|
+
|
|
1
4
|
import { LitElement, html, css } from 'lit'
|
|
2
5
|
import { customElement, property } from 'lit/decorators.js'
|
|
3
6
|
import { connect } from 'pwa-helpers'
|
|
@@ -5,9 +8,6 @@ import { store, notificationStore } from '@operato/shell'
|
|
|
5
8
|
import { i18next, localize } from '@operato/i18n'
|
|
6
9
|
import { UPDATE_NOTIFICATION } from '../actions/notification-fcm'
|
|
7
10
|
|
|
8
|
-
import '@material/mwc-icon'
|
|
9
|
-
import './notification-item'
|
|
10
|
-
|
|
11
11
|
@customElement('notification-list')
|
|
12
12
|
export class NotificationList extends connect(store)(localize(i18next)(LitElement)) {
|
|
13
13
|
static styles = [
|
|
@@ -61,7 +61,7 @@ export class NotificationList extends connect(store)(localize(i18next)(LitElemen
|
|
|
61
61
|
font-weight: bold;
|
|
62
62
|
color: var(--secondary-color);
|
|
63
63
|
}
|
|
64
|
-
div
|
|
64
|
+
div md-icon {
|
|
65
65
|
display: block;
|
|
66
66
|
opacity: 0.3;
|
|
67
67
|
}
|
|
@@ -107,7 +107,7 @@ export class NotificationList extends connect(store)(localize(i18next)(LitElemen
|
|
|
107
107
|
`
|
|
108
108
|
: html`
|
|
109
109
|
<div no-notifications @click=${e => window.history.back()}>
|
|
110
|
-
<
|
|
110
|
+
<md-icon>notifications_off</md-icon>${i18next.t('text.no notification available')}
|
|
111
111
|
</div>
|
|
112
112
|
`
|
|
113
113
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import '@material/mwc-formfield'
|
|
2
1
|
import '@material/mwc-button'
|
|
3
|
-
import '@material/mwc-checkbox'
|
|
4
2
|
import '@operato/i18n/ox-i18n.js'
|
|
3
|
+
import '@material/web/checkbox/checkbox.js'
|
|
5
4
|
|
|
6
5
|
import { css, html, LitElement } from 'lit'
|
|
7
6
|
import { customElement, property } from 'lit/decorators.js'
|
|
8
|
-
import { auth } from '@things-factory/auth-base/dist-client'
|
|
7
|
+
import { auth } from '@things-factory/auth-base/dist-client/auth.js'
|
|
8
|
+
|
|
9
9
|
import { i18next, localize } from '@operato/i18n'
|
|
10
10
|
import { ScrollbarStyles } from '@operato/styles'
|
|
11
11
|
|
|
@@ -67,25 +67,15 @@ export class NotificationSender extends localize(i18next)(LitElement) {
|
|
|
67
67
|
required
|
|
68
68
|
icon="account_circle"
|
|
69
69
|
></mwc-textfield>
|
|
70
|
-
<mwc-textfield
|
|
71
|
-
type="text"
|
|
72
|
-
name="title"
|
|
73
|
-
.label=${i18next.t('field.title')}
|
|
74
|
-
required
|
|
75
|
-
icon="notifications_none"
|
|
76
|
-
></mwc-textfield>
|
|
70
|
+
<mwc-textfield type="text" name="title" .label=${i18next.t('field.title')} required icon="notifications_none"></mwc-textfield>
|
|
77
71
|
|
|
78
|
-
<mwc-textfield
|
|
79
|
-
type="text"
|
|
80
|
-
name="image"
|
|
81
|
-
.label=${i18next.t('field.image')}
|
|
82
|
-
icon="insert_photo"
|
|
83
|
-
></mwc-textfield>
|
|
72
|
+
<mwc-textfield type="text" name="image" .label=${i18next.t('field.image')} icon="insert_photo"></mwc-textfield>
|
|
84
73
|
<mwc-textfield type="text" name="url" .label=${i18next.t('field.url')} icon="link"></mwc-textfield>
|
|
85
74
|
<mwc-textarea type="text" name="body" .label=${i18next.t('field.body')} required rows="5"></mwc-textarea>
|
|
86
|
-
<
|
|
87
|
-
<
|
|
88
|
-
|
|
75
|
+
<label>
|
|
76
|
+
<md-checkbox name="inappmsg"></md-checkbox>
|
|
77
|
+
In-App Message
|
|
78
|
+
</label>
|
|
89
79
|
</div>
|
|
90
80
|
|
|
91
81
|
<div buttons>
|
|
@@ -118,9 +108,7 @@ export class NotificationSender extends localize(i18next)(LitElement) {
|
|
|
118
108
|
}
|
|
119
109
|
|
|
120
110
|
onReset() {
|
|
121
|
-
;['receivers', 'title', 'body', 'image', 'url'].map(
|
|
122
|
-
key => ((this.renderRoot.querySelector(`[name="${key}"]`)! as any).value = '')
|
|
123
|
-
)
|
|
111
|
+
;['receivers', 'title', 'body', 'image', 'url'].map(key => ((this.renderRoot.querySelector(`[name="${key}"]`)! as any).value = ''))
|
|
124
112
|
;(this.renderRoot.querySelector(`[name="inappmsg"]`)! as any).checked = false
|
|
125
113
|
}
|
|
126
114
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
+
import '@material/web/icon/icon.js'
|
|
2
|
+
import '@material/web/switch/switch.js'
|
|
3
|
+
import '@operato/i18n/ox-i18n.js'
|
|
1
4
|
import '@things-factory/setting-base'
|
|
2
5
|
import './notification-sender'
|
|
3
|
-
import '@material/mwc-formfield'
|
|
4
|
-
import '@material/mwc-switch'
|
|
5
|
-
import '@material/mwc-button'
|
|
6
|
-
import '@operato/i18n/ox-i18n.js'
|
|
7
6
|
|
|
8
7
|
import Clipboard from 'clipboard'
|
|
9
8
|
import { css, html, LitElement } from 'lit'
|
|
@@ -33,6 +32,10 @@ export class NotificationSettingLet extends localize(i18next)(LitElement) {
|
|
|
33
32
|
}
|
|
34
33
|
|
|
35
34
|
label {
|
|
35
|
+
display: flex;
|
|
36
|
+
gap: 10px;
|
|
37
|
+
align-items: center;
|
|
38
|
+
|
|
36
39
|
font: var(--label-font);
|
|
37
40
|
color: var(--label-color);
|
|
38
41
|
text-transform: var(--label-text-transform);
|
|
@@ -53,9 +56,15 @@ export class NotificationSettingLet extends localize(i18next)(LitElement) {
|
|
|
53
56
|
}
|
|
54
57
|
|
|
55
58
|
[button-in-field] {
|
|
59
|
+
--md-icon-size: 18px;
|
|
56
60
|
position: absolute;
|
|
57
61
|
top: 24px;
|
|
58
62
|
right: 4px;
|
|
63
|
+
width: 30px;
|
|
64
|
+
padding: 2px;
|
|
65
|
+
border-radius: var(--border-radius, 5px);
|
|
66
|
+
color: var(--theme-white-color, #fff);
|
|
67
|
+
background-color: var(--secondary-color, #394e64);
|
|
59
68
|
}
|
|
60
69
|
`
|
|
61
70
|
]
|
|
@@ -74,24 +83,20 @@ export class NotificationSettingLet extends localize(i18next)(LitElement) {
|
|
|
74
83
|
|
|
75
84
|
${supported
|
|
76
85
|
? html`
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
<mwc-button dense unelevated button-in-field clipboard-copy @click=${e =>
|
|
92
|
-
e.preventDefault()}><ox-i18n msgid="button.copy"></mwc-button>
|
|
93
|
-
</div>
|
|
94
|
-
`
|
|
86
|
+
<div slot="content" onoff>
|
|
87
|
+
<label>
|
|
88
|
+
<md-switch label="allow message" ?selected=${!!this.subscription} @click=${e => this.onClickSwitch(e)}></md-switch>
|
|
89
|
+
${String(i18next.t('label.allow push message'))}
|
|
90
|
+
</label>
|
|
91
|
+
<md-outlined-button test label=${String(i18next.t('button.push message test'))} @click=${e => this.ontest()}></md-outlined-button>
|
|
92
|
+
</div>
|
|
93
|
+
|
|
94
|
+
<div slot="content" info>
|
|
95
|
+
<label for="subscription-token"><ox-i18n msgid="label.subscription token"></ox-i18n></label>
|
|
96
|
+
<input id="subscription-token" type="text" name="subscription-token" .value=${this.subscription || ''} readonly />
|
|
97
|
+
<md-icon button-in-field clipboard-copy @click=${e => e.preventDefault()}>content_copy</md-icon>
|
|
98
|
+
</div>
|
|
99
|
+
`
|
|
95
100
|
: html` <div slot="content">${i18next.t('text.push notification is not supported in your browser')}</div>`}
|
|
96
101
|
</setting-let>
|
|
97
102
|
`
|
package/dist-client/bootstrap.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import gql from 'graphql-tag';
|
|
2
2
|
import { notify } from '@operato/layout';
|
|
3
|
-
import { auth } from '@things-factory/auth-base/dist-client';
|
|
3
|
+
import { auth } from '@things-factory/auth-base/dist-client/auth.js';
|
|
4
4
|
import { i18next } from '@operato/i18n';
|
|
5
5
|
import { notificationStore, route, store } from '@operato/shell';
|
|
6
6
|
import { subscribe as graphqlSubscribe } from '@operato/graphql';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../client/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,aAAa,CAAA;AAE7B,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../client/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,aAAa,CAAA;AAE7B,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,+CAA+C,CAAA;AAEpE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAChE,OAAO,EAAE,SAAS,IAAI,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAEhE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AACxF,OAAO,YAAY,MAAM,yBAAyB,CAAA;AAElD,IAAI,mBAAwB,CAAA;AAE5B,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,SAAS;IACrC,yBAAyB;IACzB,KAAK,CAAC,WAAW,CAAC,EAAE,YAAY,EAAE,CAAC,CAAA;IAEnC,KAAK,UAAU,cAAc,CAAC,YAAkB;QAC9C,KAAK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C,CAAC,CAAC,CAAA;QAEtC,IAAI,KAAK,KAAK,OAAO,EAAE;YACrB,cAAc,CAAC;gBACb,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;gBACrB,IAAI,EAAE,OAAO;gBACb,KAAK;gBACL,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO;aAChC,CAAC,CAAA;SACH;IACH,CAAC,CAAC,CAAA;IAEF,MAAM,cAAc,EAAE,CAAA;AACxB,CAAC","sourcesContent":["import gql from 'graphql-tag'\n\nimport { notify } from '@operato/layout'\nimport { auth } from '@things-factory/auth-base/dist-client/auth.js'\n\nimport { i18next } from '@operato/i18n'\nimport { notificationStore, route, store } from '@operato/shell'\nimport { subscribe as graphqlSubscribe } from '@operato/graphql'\n\nimport { subscribe, unsubscribe, UPDATE_NOTIFICATION } from './actions/notification-fcm'\nimport notification from './reducers/notification'\n\nvar graphqlSubscription: any\n\nexport default async function bootstrap() {\n /* initialize reducers */\n store.addReducers({ notification })\n\n async function onnotification(notification?: any) {\n store.dispatch((async dispatch => {\n if (notification) {\n await notificationStore.add(notification)\n await notificationStore.limit()\n }\n\n const history = await notificationStore.getAll()\n\n dispatch({\n type: UPDATE_NOTIFICATION,\n history: [...history]\n })\n }) as any)\n }\n\n auth.on('presignout', async () => {\n try {\n await unsubscribe()\n await notificationStore.clear()\n } catch (err) {\n console.warn(err)\n }\n })\n\n auth.on('profile', async ({ credential }) => {\n try {\n await subscribe()\n } catch (err) {\n console.warn(err)\n }\n\n /*\n * subscription graphql notifications\n */\n var query = gql`\n subscription notification($subjects: [String!]) {\n notification(subjects: $subjects) {\n subject\n type\n title\n body\n url\n image\n timestamp\n }\n }\n `\n\n graphqlSubscription = await graphqlSubscribe(\n {\n query,\n variables: {\n subjects: ['info', 'warn', 'error', 'reload']\n }\n },\n {\n next({ data }) {\n const { notification } = data || {}\n onnotification({\n timestamp: Date.now(),\n ...notification\n })\n }\n }\n )\n })\n\n /* subscription web-push notification */\n const channel = new BroadcastChannel('notification')\n channel.addEventListener('message', async ({ data }) => {\n const { type } = data || {}\n\n switch (type) {\n case 'notificationclick':\n const { action, notification } = data\n\n // TODO how to follow action with notification.data\n notification.url && route(notification.url)\n break\n\n case 'show-reload-snackbar':\n notify({\n level: 'info',\n message: i18next.t('text.the application has been updated'),\n option: {\n action: {\n label: i18next.t('button.reload'),\n callback: () => window.location.reload()\n },\n timer: -1\n }\n })\n break\n\n case 'notification':\n default:\n onnotification()\n }\n })\n\n document.addEventListener('notify', (event: Event) => {\n let { message, level, ex = '', option = {} } = (event as CustomEvent).detail\n const title = message.split(' .\\n')[0]\n\n if (level === 'error') {\n onnotification({\n timestamp: Date.now(),\n type: 'ERROR',\n title,\n body: ex ? ex.message : message\n })\n }\n })\n\n await onnotification()\n}\n"]}
|
|
@@ -51,7 +51,7 @@ let NotificationListPage = class NotificationListPage extends connect(store)(loc
|
|
|
51
51
|
|
|
52
52
|
<div id="sorters">
|
|
53
53
|
Sort
|
|
54
|
-
<
|
|
54
|
+
<md-icon
|
|
55
55
|
@click=${e => {
|
|
56
56
|
const target = e.currentTarget;
|
|
57
57
|
this.sortersControl.open({
|
|
@@ -59,7 +59,7 @@ let NotificationListPage = class NotificationListPage extends connect(store)(loc
|
|
|
59
59
|
top: target.offsetTop + target.offsetHeight
|
|
60
60
|
});
|
|
61
61
|
}}
|
|
62
|
-
>expand_more</
|
|
62
|
+
>expand_more</md-icon
|
|
63
63
|
>
|
|
64
64
|
<ox-popup id="sorter-control">
|
|
65
65
|
<ox-sorters-control> </ox-sorters-control>
|
|
@@ -67,9 +67,10 @@ let NotificationListPage = class NotificationListPage extends connect(store)(loc
|
|
|
67
67
|
</div>
|
|
68
68
|
|
|
69
69
|
<div id="modes">
|
|
70
|
-
<
|
|
71
|
-
<
|
|
72
|
-
<
|
|
70
|
+
<md-icon @click=${() => (this.mode = 'GRID')} ?active=${mode == 'GRID'}>grid_on</md-icon>
|
|
71
|
+
<md-icon @click=${() => (this.mode = 'LIST')} ?active=${mode == 'LIST'}>format_list_bulleted</md-icon>
|
|
72
|
+
<md-icon @click=${() => (this.mode = 'CARD')} ?active=${mode == 'CARD'}>apps</md-icon>
|
|
73
|
+
</div>
|
|
73
74
|
</div>
|
|
74
75
|
</div>
|
|
75
76
|
</ox-grist>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification-list-page.js","sourceRoot":"","sources":["../../../client/pages/notification/notification-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,MAAM,iBAAiB,CAAA;AACxC,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;AAGtB,IAAM,oBAAoB,GAA1B,MAAM,oBAAqB,SAAQ,OAAO,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC,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C,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;gBACtD,MAAM,WAAW,GAAG,KAAK,CAAC,eAAe,CAAA;gBACzC,KAAK,IAAI,GAAG,IAAI,WAAW,EAAE;oBAC3B,UAAU,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,KAAK,CAAA;iBACzC;gBACD,UAAU,CAAC,MAAM,GAAG,KAAK,CAAC,SAAS,CAAA;gBAEnC,OAAO,UAAU,CAAA;YACnB,CAAC,CAAC,CAAA;YAEF,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC;gBACnC,QAAQ,EAAE,GAAG,CAAA;;;;;;SAMZ;gBACD,SAAS,EAAE;oBACT,OAAO;iBACR;aACF,CAAC,CAAA;YAEF,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE;gBACpB,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;aACnB;SACF;IACH,CAAC;;AA3PM,2BAAM,GAAG;IACd,eAAe;IACf,iBAAiB;IACjB,GAAG,CAAA;;;;;;;;;;;;;;KAcF;CACF,CAAA;AAED;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;yDAAiB;AAC5C;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;kDAAoE;AAE/F;IAAC,KAAK,CAAC,UAAU,CAAC;8BAAiB,SAAS;mDAAA;AAC5C;IAAC,KAAK,CAAC,iBAAiB,CAAC;8BAA0B,OAAO;4DAAA;AAzB/C,oBAAoB;IADhC,aAAa,CAAC,wBAAwB,CAAC;GAC3B,oBAAoB,CA6PhC;SA7PY,oBAAoB","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 } 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\n@customElement('notification-list-page')\nexport class NotificationListPage 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: #8b0000;\n --grid-record-emphasized-color: #ff6b6b;\n }\n\n ox-grist {\n overflow-y: auto;\n flex: 1;\n }\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 title: i18next.t('title.notification list'),\n search: {\n handler: (search: string) => {\n this.grist.searchText = search\n },\n value: this.grist?.searchText || ''\n },\n filter: {\n handler: () => {\n this.grist.toggleHeadroom()\n }\n },\n help: 'notification/notification',\n actions: [\n {\n title: i18next.t('button.save'),\n action: this._updateNotification.bind(this),\n ...CommonButtonStyles.save\n },\n {\n title: i18next.t('button.delete'),\n action: this._deleteNotification.bind(this),\n ...CommonButtonStyles.delete\n }\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 fields: ['title', 'body'],\n details: ['state', 'updatedAt']\n },\n columns: [\n { type: 'gutter', gutterName: 'sequence' },\n { type: 'gutter', gutterName: 'row-selector', multiple: true },\n {\n type: 'string',\n name: 'title',\n header: i18next.t('field.title'),\n record: {\n editable: false\n },\n filter: 'search',\n sortable: true,\n width: 150\n },\n {\n type: 'string',\n name: 'body',\n header: i18next.t('field.body'),\n record: {\n editable: false\n },\n filter: 'search',\n width: 200\n },\n {\n type: 'checkbox',\n name: 'state',\n label: true,\n header: i18next.t('field.state'),\n record: {\n editable: true\n },\n filter: true,\n sortable: true,\n width: 60\n },\n {\n type: 'datetime',\n name: 'createdAt',\n header: i18next.t('field.created_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: 'createdAt',\n desc: true\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: notiBoxes(filters: $filters, pagination: $pagination, sortings: $sortings) {\n items {\n id\n title\n body\n state\n createdAt\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 _deleteNotification() {\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 deleteNotificationes(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 _updateNotification() {\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: [NotificationPatch!]!) {\n updateMultipleNotification(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"]}
|
|
1
|
+
{"version":3,"file":"notification-list-page.js","sourceRoot":"","sources":["../../../client/pages/notification/notification-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,qBA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,IAAI,EAAE,MAAM,EAAE,CAAC;;yDAAiB;AAC5C;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;kDAAoE;AAE/F;IAAC,KAAK,CAAC,UAAU,CAAC;8BAAiB,SAAS;mDAAA;AAC5C;IAAC,KAAK,CAAC,iBAAiB,CAAC;8BAA0B,OAAO;4DAAA;AAzB/C,oBAAoB;IADhC,aAAa,CAAC,wBAAwB,CAAC;GAC3B,oBAAoB,CA8PhC;SA9PY,oBAAoB","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 } 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\n@customElement('notification-list-page')\nexport class NotificationListPage 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: #8b0000;\n --grid-record-emphasized-color: #ff6b6b;\n }\n\n ox-grist {\n overflow-y: auto;\n flex: 1;\n }\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 title: i18next.t('title.notification list'),\n search: {\n handler: (search: string) => {\n this.grist.searchText = search\n },\n value: this.grist?.searchText || ''\n },\n filter: {\n handler: () => {\n this.grist.toggleHeadroom()\n }\n },\n help: 'notification/notification',\n actions: [\n {\n title: i18next.t('button.save'),\n action: this._updateNotification.bind(this),\n ...CommonButtonStyles.save\n },\n {\n title: i18next.t('button.delete'),\n action: this._deleteNotification.bind(this),\n ...CommonButtonStyles.delete\n }\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 <md-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</md-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 <md-icon @click=${() => (this.mode = 'GRID')} ?active=${mode == 'GRID'}>grid_on</md-icon>\n <md-icon @click=${() => (this.mode = 'LIST')} ?active=${mode == 'LIST'}>format_list_bulleted</md-icon>\n <md-icon @click=${() => (this.mode = 'CARD')} ?active=${mode == 'CARD'}>apps</md-icon>\n </div>\n </div>\n </div>\n </ox-grist>\n `\n }\n\n async pageInitialized(lifecycle: any) {\n this.gristConfig = {\n list: {\n fields: ['title', 'body'],\n details: ['state', 'updatedAt']\n },\n columns: [\n { type: 'gutter', gutterName: 'sequence' },\n { type: 'gutter', gutterName: 'row-selector', multiple: true },\n {\n type: 'string',\n name: 'title',\n header: i18next.t('field.title'),\n record: {\n editable: false\n },\n filter: 'search',\n sortable: true,\n width: 150\n },\n {\n type: 'string',\n name: 'body',\n header: i18next.t('field.body'),\n record: {\n editable: false\n },\n filter: 'search',\n width: 200\n },\n {\n type: 'checkbox',\n name: 'state',\n label: true,\n header: i18next.t('field.state'),\n record: {\n editable: true\n },\n filter: true,\n sortable: true,\n width: 60\n },\n {\n type: 'datetime',\n name: 'createdAt',\n header: i18next.t('field.created_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: 'createdAt',\n desc: true\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: notiBoxes(filters: $filters, pagination: $pagination, sortings: $sortings) {\n items {\n id\n title\n body\n state\n createdAt\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 _deleteNotification() {\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 deleteNotificationes(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 _updateNotification() {\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: [NotificationPatch!]!) {\n updateMultipleNotification(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"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import '@material/web/icon/icon.js';
|
|
2
3
|
import '@operato/data-grist';
|
|
3
4
|
import gql from 'graphql-tag';
|
|
4
5
|
import { css, html, LitElement } from 'lit';
|
|
@@ -6,6 +7,7 @@ import { property } from 'lit/decorators.js';
|
|
|
6
7
|
import { client } from '@operato/graphql';
|
|
7
8
|
import { i18next } from '@operato/i18n';
|
|
8
9
|
import { isMobileDevice } from '@operato/utils';
|
|
10
|
+
import { ButtonContainerStyles } from '@operato/styles';
|
|
9
11
|
export class NotificationRuleImporter extends LitElement {
|
|
10
12
|
constructor() {
|
|
11
13
|
super(...arguments);
|
|
@@ -46,7 +48,7 @@ export class NotificationRuleImporter extends LitElement {
|
|
|
46
48
|
></ox-grist>
|
|
47
49
|
|
|
48
50
|
<div class="button-container">
|
|
49
|
-
<
|
|
51
|
+
<button @click="${this.save.bind(this)}"><md-icon>save</md-icon>${i18next.t('button.save')}</button>
|
|
50
52
|
</div>
|
|
51
53
|
`;
|
|
52
54
|
}
|
|
@@ -66,6 +68,7 @@ export class NotificationRuleImporter extends LitElement {
|
|
|
66
68
|
}
|
|
67
69
|
}
|
|
68
70
|
NotificationRuleImporter.styles = [
|
|
71
|
+
ButtonContainerStyles,
|
|
69
72
|
css `
|
|
70
73
|
:host {
|
|
71
74
|
display: flex;
|
|
@@ -77,16 +80,6 @@ NotificationRuleImporter.styles = [
|
|
|
77
80
|
ox-grist {
|
|
78
81
|
flex: 1;
|
|
79
82
|
}
|
|
80
|
-
|
|
81
|
-
.button-container {
|
|
82
|
-
display: flex;
|
|
83
|
-
margin-left: auto;
|
|
84
|
-
padding: var(--padding-default);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
mwc-button {
|
|
88
|
-
margin-left: var(--margin-default);
|
|
89
|
-
}
|
|
90
83
|
`
|
|
91
84
|
];
|
|
92
85
|
__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification-rule-importer.js","sourceRoot":"","sources":["../../../client/pages/notification-rule/notification-rule-importer.ts"],"names":[],"mappings":";AAAA,OAAO,qBAAqB,CAAA;AAE5B,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE5C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"notification-rule-importer.js","sourceRoot":"","sources":["../../../client/pages/notification-rule/notification-rule-importer.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AACnC,OAAO,qBAAqB,CAAA;AAE5B,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE5C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AAEvD,MAAM,OAAO,wBAAyB,SAAQ,UAAU;IAAxD;;QAiB6B,sBAAiB,GAAU,EAAE,CAAA;QAC5B,YAAO,GAAG;YACpC,IAAI,EAAE,EAAE,MAAM,EAAE,CAAC,MAAM,EAAE,aAAa,CAAC,EAAE;YACzC,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;YAC9B,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,QAAQ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;mEAA8B;AACxD;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;yDAuB1B","sourcesContent":["import '@material/web/icon/icon.js'\nimport '@operato/data-grist'\n\nimport gql from 'graphql-tag'\nimport { css, html, LitElement } from 'lit'\nimport { property } from 'lit/decorators.js'\n\nimport { client } from '@operato/graphql'\nimport { i18next } from '@operato/i18n'\nimport { isMobileDevice } from '@operato/utils'\nimport { ButtonContainerStyles } from '@operato/styles'\n\nexport class NotificationRuleImporter extends LitElement {\n static styles = [\n ButtonContainerStyles,\n css`\n :host {\n display: flex;\n flex-direction: column;\n\n background-color: #fff;\n }\n\n ox-grist {\n flex: 1;\n }\n `\n ]\n\n @property({ type: Array }) notificationRules: any[] = []\n @property({ type: Object }) columns = {\n list: { fields: ['name', 'description'] },\n pagination: { infinite: true },\n columns: [\n {\n type: 'string',\n name: 'name',\n header: i18next.t('field.name'),\n width: 150\n },\n {\n type: 'string',\n name: 'description',\n header: i18next.t('field.description'),\n width: 200\n },\n {\n type: 'checkbox',\n name: 'active',\n header: i18next.t('field.active'),\n width: 60\n }\n ]\n }\n\n render() {\n return html`\n <ox-grist\n .mode=${isMobileDevice() ? 'LIST' : 'GRID'}\n .config=${this.columns}\n .data=${{\n records: this.notificationRules\n }}\n ></ox-grist>\n\n <div class=\"button-container\">\n <button @click=\"${this.save.bind(this)}\"><md-icon>save</md-icon>${i18next.t('button.save')}</button>\n </div>\n `\n }\n\n async save() {\n const response = await client.mutate({\n mutation: gql`\n mutation importNotificationRules($notificationRules: [NotificationRulePatch!]!) {\n importNotificationRules(notificationRules: $notificationRules)\n }\n `,\n variables: { notificationRules: this.notificationRules }\n })\n\n if (response.errors?.length) return\n\n this.dispatchEvent(new CustomEvent('imported'))\n }\n}\n"]}
|