@things-factory/auth-ui 4.3.114 → 4.3.121

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.
@@ -0,0 +1,299 @@
1
+ import '@things-factory/form-ui'
2
+ import '@things-factory/grist-ui'
3
+ import _ from 'lodash'
4
+
5
+ import gql from 'graphql-tag'
6
+ import { css, html } from 'lit'
7
+ import isEmpty from 'lodash-es/isEmpty'
8
+
9
+ import { i18next, localize } from '@things-factory/i18n-base'
10
+ import { client, CustomAlert, gqlContext, PageView } from '@things-factory/shell'
11
+ import { CommonButtonStyles, ScrollbarStyles } from '@things-factory/styles'
12
+ import { isMobileDevice } from '@things-factory/utils'
13
+
14
+ export class PartnerAccountCodes extends localize(i18next)(PageView) {
15
+ static get properties() {
16
+ return {
17
+ searchFields: Array,
18
+ config: Object,
19
+ data: Object
20
+ }
21
+ }
22
+
23
+ static get styles() {
24
+ return [
25
+ ScrollbarStyles,
26
+ css`
27
+ :host {
28
+ display: flex;
29
+ flex-direction: column;
30
+ padding: var(--padding-wide);
31
+ overflow: auto;
32
+ }
33
+ search-form {
34
+ overflow: visible;
35
+ }
36
+ data-grist {
37
+ overflow-y: auto;
38
+ flex: 1;
39
+ }
40
+ `
41
+ ]
42
+ }
43
+
44
+ render() {
45
+ return html`
46
+ <search-form .fields=${this.searchFields} @submit=${e => this.dataGrist.fetch()}></search-form>
47
+
48
+ <data-grist
49
+ .mode=${isMobileDevice() ? 'LIST' : 'GRID'}
50
+ .config=${this.config}
51
+ .data=${this.data}
52
+ .fetchHandler="${this.fetchHandler.bind(this)}"
53
+ ></data-grist>
54
+ `
55
+ }
56
+
57
+ get context() {
58
+ return {
59
+ title: i18next.t('title.partner_listing'),
60
+ actions: [
61
+ {
62
+ title: i18next.t('button.save'),
63
+ action: () => this._saveAccountCode(this.dataGrist.exportPatchList({ flagName: 'cuFlag' })),
64
+ // action: this._saveAccountCode.bind(this),
65
+ ...CommonButtonStyles.save
66
+ },
67
+ {
68
+ title: i18next.t('button.generate_account_code'),
69
+ action: this._generateAccountCode.bind(this),
70
+ ...CommonButtonStyles.add
71
+ },
72
+ {
73
+ title: i18next.t('button.back'),
74
+ action: this._navigateToPartnerManagement.bind(this),
75
+ ...CommonButtonStyles.back
76
+ }
77
+ ],
78
+ exportable: {
79
+ name: i18next.t('title.partner_listing'),
80
+ data: this._exportableData.bind(this)
81
+ }
82
+ }
83
+ }
84
+
85
+ constructor() {
86
+ super()
87
+ this.data = { ...this.data, records: [] }
88
+ }
89
+
90
+ get searchForm() {
91
+ return this.shadowRoot.querySelector('search-form')
92
+ }
93
+
94
+ get dataGrist() {
95
+ return this.shadowRoot.querySelector('data-grist')
96
+ }
97
+
98
+ // searchfield
99
+ async pageInitialized() {
100
+ this.searchFields = [
101
+ {
102
+ label: i18next.t('field.account_code'),
103
+ name: 'accountCode',
104
+ type: 'text',
105
+ props: { searchOper: 'i_like' }
106
+ },
107
+ {
108
+ label: i18next.t('field.name'),
109
+ name: 'partnerName',
110
+ type: 'text',
111
+ props: { searchOper: 'i_like' }
112
+ }
113
+ ]
114
+
115
+ this.config = {
116
+ rows: {
117
+ selectable: {
118
+ multiple: true
119
+ }
120
+ },
121
+ pagination: { infinite: true },
122
+ columns: [
123
+ { type: 'gutter', gutterName: 'dirty' },
124
+ { type: 'gutter', gutterName: 'sequence' },
125
+ { type: 'gutter', gutterName: 'row-selector', multiple: true },
126
+ {
127
+ type: 'string',
128
+ name: 'accountCode',
129
+ record: { editable: true },
130
+ imex: {
131
+ header: i18next.t('field.account_code'),
132
+ key: 'accountCode',
133
+ width: 40,
134
+ type: 'string'
135
+ },
136
+ header: i18next.t('field.account_code'),
137
+ width: 250
138
+ },
139
+ {
140
+ type: 'object',
141
+ name: 'domain',
142
+ record: { editable: false },
143
+ imex: {
144
+ header: i18next.t('field.name'),
145
+ key: 'domain.name',
146
+ width: 60,
147
+ type: 'string'
148
+ },
149
+ header: i18next.t('field.name'),
150
+ width: 350
151
+ }
152
+ ]
153
+ }
154
+ }
155
+
156
+ pageUpdated(changes, lifecycle) {
157
+ if (this.active) {
158
+ this.dataGrist.fetch()
159
+ }
160
+ }
161
+
162
+ _navigateToPartnerManagement() {
163
+ history.back()
164
+ }
165
+
166
+ // fetching data
167
+ async fetchHandler({ sorters = [{ name: 'name' }] }) {
168
+ try {
169
+ const filters = this.searchForm.queryFilters
170
+ const sortings = sorters
171
+
172
+ const response = await client.query({
173
+ query: gql`
174
+ query ($filters: [Filter!], $sortings: [Sorting!]) {
175
+ partnerLists(filters: $filters, sortings: $sortings) {
176
+ id
177
+ accountCode
178
+ domain {
179
+ id
180
+ name
181
+ description
182
+ }
183
+ partnerDomain {
184
+ id
185
+ name
186
+ description
187
+ }
188
+ }
189
+ }
190
+ `,
191
+ variables: { filters, sortings },
192
+ context: gqlContext()
193
+ })
194
+
195
+ let data = []
196
+ if (!response.errors?.length) {
197
+ data = response.data.partnerLists
198
+ }
199
+
200
+ this.data = { records: [...data] }
201
+ } catch (error) {
202
+ console.log(error)
203
+ }
204
+ }
205
+
206
+ // save data
207
+ async _saveAccountCode(patches) {
208
+ try {
209
+ if (!patches?.length) {
210
+ return this.showToast(i18next.t('text.nothing_changed'))
211
+ }
212
+
213
+ const response = await client.mutate({
214
+ mutation: gql`
215
+ mutation updateMultipleAcountCode($patches: [PartnerPatch!]!) {
216
+ updateMultipleAcountCode(patches: $patches) {
217
+ accountCode
218
+ }
219
+ }
220
+ `,
221
+ variables: { patches },
222
+ context: gqlContext()
223
+ })
224
+
225
+ if (!response.errors) {
226
+ this.showToast(i18next.t('text.data_updated_successfully'))
227
+ this.dataGrist.fetch()
228
+ }
229
+ } catch (error) {
230
+ this.showToast(error)
231
+ }
232
+ }
233
+
234
+ // generate account code
235
+ async _generateAccountCode() {
236
+ // to generate the data as dirty data
237
+ if (this.dataGrist.selected && this.dataGrist.selected.length > 0) {
238
+ this.dataGrist.dirtyData.records.map(record => {
239
+ if (record?.__selected__ && '' === (record?.accountCode || '')) {
240
+ record.accountCode = this._accountCodeGenerator()
241
+ record.__dirty__ = 'M'
242
+ record.__dirtyfields__ = { accountCode: { before: record.__origin__.accountCode, after: record.accountCode } }
243
+ }
244
+
245
+ return record
246
+ })
247
+
248
+ this.data = {
249
+ ...this.data,
250
+ records: [...this.dataGrist.dirtyData.records]
251
+ }
252
+ }
253
+ }
254
+
255
+ // random number generator
256
+ _accountCodeGenerator() {
257
+ let accountCode = Math.floor(Math.random() * 99 * Date.now())
258
+ accountCode = `ACC-${accountCode}`.substring(0, 14)
259
+ return accountCode.toString()
260
+ }
261
+
262
+ // export
263
+ async _exportableData() {
264
+ let records = []
265
+ if (this.dataGrist.selected && this.dataGrist.selected.length > 0) {
266
+ records = this.dataGrist.selected
267
+ } else {
268
+ records = this.dataGrist.data.records
269
+ }
270
+
271
+ var headerSetting = this.dataGrist._config.columns
272
+ .filter(column => column.type !== 'gutter' && column.imex !== undefined)
273
+ .map(column => {
274
+ return column.imex
275
+ })
276
+
277
+ var data = records.map(item => {
278
+ return {
279
+ id: item.id,
280
+ ...this.config.columns
281
+ .filter(column => column.type !== 'gutter' && column.imex !== undefined)
282
+ .reduce((record, column) => {
283
+ record[column.imex.key] = column.imex.key
284
+ .split('.')
285
+ .reduce((obj, key) => (obj && obj[key] !== 'undefined' ? obj[key] : undefined), item)
286
+ return record
287
+ }, {})
288
+ }
289
+ })
290
+
291
+ return { header: headerSetting, data: data }
292
+ }
293
+
294
+ showToast(message) {
295
+ document.dispatchEvent(new CustomEvent('notify', { detail: { message, option: { timer: 1000 } } }))
296
+ }
297
+ }
298
+
299
+ window.customElements.define('partner-account-codes', PartnerAccountCodes)
@@ -6,9 +6,10 @@ import '../../components/invite-customer'
6
6
  import gql from 'graphql-tag'
7
7
  import { css, html } from 'lit'
8
8
  import { connect } from 'pwa-helpers/connect-mixin.js'
9
+ import { CommonButtonStyles } from '@things-factory/styles'
9
10
 
10
11
  import { i18next } from '@operato/i18n'
11
- import { client, gqlContext, PageView, store } from '@things-factory/shell'
12
+ import { client, gqlContext, PageView, store, navigate } from '@things-factory/shell'
12
13
 
13
14
  class PartnerManagement extends connect(store)(PageView) {
14
15
  static get styles() {
@@ -22,6 +23,9 @@ class PartnerManagement extends connect(store)(PageView) {
22
23
 
23
24
  overflow: auto;
24
25
  }
26
+ mwc-button {
27
+ margin: var(--input-margin);
28
+ }
25
29
  h2 {
26
30
  margin: var(--title-margin);
27
31
  font: var(--title-font);
@@ -44,7 +48,17 @@ class PartnerManagement extends connect(store)(PageView) {
44
48
  get context() {
45
49
  return {
46
50
  title: `${i18next.t('title.partners')}`,
47
- help: 'operato-hub/partners'
51
+ help: 'operato-hub/partners',
52
+ actions: [
53
+ {
54
+ title: i18next.t('label.details'),
55
+ action: e =>
56
+ navigate(
57
+ `partner-account-codes/${this.lifecycle.resourceId}?__context__=${this.lifecycle.params.__context__}`
58
+ ),
59
+ ...CommonButtonStyles.edit
60
+ }
61
+ ]
48
62
  }
49
63
  }
50
64
 
@@ -72,18 +86,21 @@ class PartnerManagement extends connect(store)(PageView) {
72
86
  `}"
73
87
  >
74
88
  </quick-find-list>
75
-
76
- <invite-customer
77
- .customers=${this.customers || []}
78
- @invitationCompleted="${this.refreshPartners.bind(this)}"
79
- ></invite-customer>
89
+ <div>
90
+ <invite-customer
91
+ .customers=${this.customers || []}
92
+ @invitationCompleted="${this.refreshPartners.bind(this)}"
93
+ ></invite-customer>
94
+ </div>
80
95
  `
81
96
  }
82
97
 
83
- pageUpdated() {
98
+ pageUpdated(changes, lifecycle) {
84
99
  if (this.active) {
85
100
  this.refreshPartners()
101
+ this.lifecycle = lifecycle
86
102
  } else {
103
+ lifecycle = null
87
104
  /* this page is deactivated */
88
105
  }
89
106
  }
package/client/route.js CHANGED
@@ -55,5 +55,9 @@ export default function route(page) {
55
55
  case 'domains':
56
56
  import('./pages/domain/domain-management')
57
57
  return page
58
+
59
+ case 'partner-account-codes':
60
+ import('./pages/partner/partner-account-codes')
61
+ return page
58
62
  }
59
63
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/auth-ui",
3
- "version": "4.3.114",
3
+ "version": "4.3.121",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -34,10 +34,10 @@
34
34
  "@operato/i18n": "^0.4.6",
35
35
  "@operato/layout": "^0.4.6",
36
36
  "@operato/lottie-player": "^0.4.6",
37
- "@things-factory/auth-base": "^4.3.114",
37
+ "@things-factory/auth-base": "^4.3.121",
38
38
  "@things-factory/i18n-base": "^4.3.114",
39
39
  "@things-factory/more-base": "^4.3.114",
40
40
  "clipboard": "^2.0.6"
41
41
  },
42
- "gitHead": "6f16bd9dfb3210e848e5118d894424972ed83773"
42
+ "gitHead": "c715bdf668bdab572f5d96bde248d5ce184fac92"
43
43
  }
@@ -55,6 +55,10 @@ export default {
55
55
  {
56
56
  tagname: 'domain-management',
57
57
  page: 'domains'
58
+ },
59
+ {
60
+ tagname: 'partner-account-codes',
61
+ page: 'partner-account-codes'
58
62
  }
59
63
  ],
60
64
  bootstrap
@@ -15,6 +15,7 @@
15
15
  "button.save": "save",
16
16
  "button.submit": "submit",
17
17
  "button.terminate contract": "terminate",
18
+ "button.generate_account_code": "generate account code",
18
19
  "error.domain not allowed": "this domain is not allowed for you",
19
20
  "error.new_password_and_confirm_password_do_not_match": "new password and confirm password do not match",
20
21
  "error.not valid pattern of type": "not valid pattern of {type}",
@@ -38,6 +39,7 @@
38
39
  "field.user-type": "user type",
39
40
  "field.accessed_at": "accessed at",
40
41
  "field.ip_address": "ip address",
42
+ "field.account_code": "account code",
41
43
  "label.activated-user": "activated",
42
44
  "label.admin-user": "admin",
43
45
  "label.application": "application",
@@ -72,6 +74,7 @@
72
74
  "label.x name": "{x} name",
73
75
  "label.x description": "{x} description",
74
76
  "label.login_history": "login history",
77
+ "label.details": "details",
75
78
  "text.appliance": "terminal appliance",
76
79
  "text.application management": "application management",
77
80
  "text.are_you_sure_to_transfer_owner": "are you sure to transfer owner?",
@@ -122,5 +125,6 @@
122
125
  "title.reset password": "reset password",
123
126
  "title.sign in": "sign in",
124
127
  "title.sign up": "sign up",
125
- "title.unlock account": "unlock account"
128
+ "title.unlock account": "unlock account",
129
+ "title.partner_listing": "partner listing"
126
130
  }
@@ -15,6 +15,7 @@
15
15
  "button.save": "저장",
16
16
  "button.submit": "전송",
17
17
  "button.terminate contract": "계약 해지",
18
+ "button.generate_account_code": "[ko]generate account code",
18
19
 
19
20
  "error.domain not allowed": "'{subdomain}' 영역은 이 사용자에게 허가되지 않았습니다.",
20
21
  "error.new_password_and_confirm_password_do_not_match": "새 비밀번호와 확인 비밀번호가 일치하지 않습니다.",
@@ -40,6 +41,7 @@
40
41
  "field.user-type": "사용자유형",
41
42
  "field.accessed_at": "로그인 일시",
42
43
  "field.ip_address": "ip 주소",
44
+ "field.account_code": "[ko]account code",
43
45
 
44
46
  "label.activated-user": "정상",
45
47
  "label.admin-user": "관리자",
@@ -75,6 +77,7 @@
75
77
  "label.x name": "{x} 이름",
76
78
  "label.x description": "{x} 설명",
77
79
  "label.login_history": "로그인 이력",
80
+ "label.details": "[ko]details",
78
81
 
79
82
  "text.appliance": "단말장치",
80
83
  "text.application management": "응용프로그램 관리",
@@ -127,5 +130,6 @@
127
130
  "title.reset password": "패스워드 초기화",
128
131
  "title.sign in": "로그인",
129
132
  "title.sign up": "사용자 등록",
130
- "title.unlock account": "계정 잠금 해제"
133
+ "title.unlock account": "계정 잠금 해제",
134
+ "title.partner_listing": "[ko]partner listing"
131
135
  }
@@ -15,6 +15,7 @@
15
15
  "button.save": "simpan",
16
16
  "button.submit": "hantar",
17
17
  "button.terminate contract": "tamatkan",
18
+ "button.generate_account_code": "[ms]generate account code",
18
19
 
19
20
  "error.domain not allowed": "anda tidak dibenarkan akses domain ini",
20
21
  "error.new_password_and_confirm_password_do_not_match": "kata laluan baharu dan pengesahan berbeza",
@@ -40,6 +41,7 @@
40
41
  "field.user-type": "jenis pengguna",
41
42
  "field.accessed_at": "[ms]accessed at",
42
43
  "field.ip_address": "[ms]ip address",
44
+ "field.account_code": "[ms]account code",
43
45
 
44
46
  "label.activated-user": "diaktifkan",
45
47
  "label.admin-user": "admin",
@@ -75,6 +77,7 @@
75
77
  "label.x name": "{x} nama",
76
78
  "label.x description": "{x} penerangan",
77
79
  "label.login_history": "[ms]login history",
80
+ "label.details": "[ms]details",
78
81
 
79
82
  "text.appliance": "perkakas terminal",
80
83
  "text.application management": "pengurusan aplikasi",
@@ -127,5 +130,6 @@
127
130
  "title.reset password": "reset kata laluan",
128
131
  "title.sign in": "log masuk",
129
132
  "title.sign up": "daftar",
130
- "title.unlock account": "buka semula akaun"
133
+ "title.unlock account": "buka semula akaun",
134
+ "title.partner_listing": "[ms]partner listing"
131
135
  }
@@ -15,6 +15,7 @@
15
15
  "button.save": "保存",
16
16
  "button.submit": "提交",
17
17
  "button.terminate contract": "终止合同",
18
+ "button.generate_account_code": "[zh]generate account code",
18
19
 
19
20
  "error.domain not allowed": "您无权限使用此域",
20
21
  "error.new_password_and_confirm_password_do_not_match": "新密码与认证密码不同",
@@ -40,6 +41,7 @@
40
41
  "field.user-type": "用户类型",
41
42
  "field.accessed_at": "[zh]accessed at",
42
43
  "field.ip_address": "[zh]ip address",
44
+ "field.account_code": "[zh]account code",
43
45
 
44
46
  "label.activated-user": "用户已激活",
45
47
  "label.admin-user": "管理用户",
@@ -75,6 +77,7 @@
75
77
  "label.x name": "{x} 名称",
76
78
  "label.x description": "{x} 描述",
77
79
  "label.login_history": "[zh]login history",
80
+ "label.details": "[zh]details",
78
81
 
79
82
  "text.appliance": "终端设备",
80
83
  "text.application management": "应用管理",
@@ -127,5 +130,6 @@
127
130
  "title.reset password": "重置密码",
128
131
  "title.sign in": "登录",
129
132
  "title.sign up": "注册",
130
- "title.unlock account": "解锁帐户"
133
+ "title.unlock account": "解锁帐户",
134
+ "title.partner_listing": "[zh]partner listing"
131
135
  }