@things-factory/auth-ui 8.0.0-beta.9 → 8.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/auth-style-sign.ts +194 -0
- package/client/bootstrap.ts +51 -0
- package/client/components/abstract-auth-page.ts +301 -0
- package/client/components/abstract-password-reset.ts +168 -0
- package/client/components/abstract-sign.ts +127 -0
- package/client/components/change-password.ts +153 -0
- package/client/components/contact-us.ts +113 -0
- package/client/components/create-domain-popup.ts +141 -0
- package/client/components/create-role.ts +123 -0
- package/client/components/create-user.ts +95 -0
- package/client/components/credential-manager.ts +64 -0
- package/client/components/delete-user-popup.ts +117 -0
- package/client/components/domain-switch.ts +127 -0
- package/client/components/invite-customer.ts +104 -0
- package/client/components/invite-user.ts +96 -0
- package/client/components/my-login-history.ts +101 -0
- package/client/components/ownership-transfer-popup.ts +110 -0
- package/client/components/partner-info-card.ts +89 -0
- package/client/components/partner-role-editor.ts +153 -0
- package/client/components/profile-component.ts +332 -0
- package/client/components/role-edit-form.ts +92 -0
- package/client/components/role-privilege-editor.ts +267 -0
- package/client/components/role-selector.ts +102 -0
- package/client/components/user-role-editor.ts +499 -0
- package/client/constants/application.ts +9 -0
- package/client/constants/index.ts +1 -0
- package/client/entries/auth/activate.ts +272 -0
- package/client/entries/auth/checkin.ts +190 -0
- package/client/entries/auth/forgot-password.ts +103 -0
- package/client/entries/auth/reset-password.ts +22 -0
- package/client/entries/auth/result.ts +193 -0
- package/client/entries/auth/signin.ts +18 -0
- package/client/entries/auth/signup.ts +109 -0
- package/client/entries/auth/unlock-user.ts +22 -0
- package/client/entries/oauth2/oauth2-decision-error-page.ts +50 -0
- package/client/entries/oauth2/oauth2-decision-page.ts +196 -0
- package/client/entries/public/home.ts +246 -0
- package/client/index.ts +124 -0
- package/client/pages/app-binding/app-binding.ts +423 -0
- package/client/pages/app-binding/app-bindings.ts +171 -0
- package/client/pages/appliance/appliance.ts +452 -0
- package/client/pages/appliance/home.ts +177 -0
- package/client/pages/appliance/register.ts +183 -0
- package/client/pages/application/application.ts +428 -0
- package/client/pages/application/applications.ts +182 -0
- package/client/pages/application/register.ts +211 -0
- package/client/pages/attribute/attribute-set-item-list.ts +237 -0
- package/client/pages/attribute/attribute-set-management.ts +282 -0
- package/client/pages/auth-provider/auth-provider-management.ts +381 -0
- package/client/pages/domain/domain-management.ts +410 -0
- package/client/pages/partner/partner-management.ts +112 -0
- package/client/pages/profile.ts +32 -0
- package/client/pages/role/role-management.ts +134 -0
- package/client/pages/user/user-management.ts +224 -0
- package/client/route.ts +67 -0
- package/client/themes/auth-theme.css +65 -0
- package/client/utils/password-rule.ts +37 -0
- package/dist-client/components/abstract-auth-page.js +10 -10
- package/dist-client/components/abstract-auth-page.js.map +1 -1
- package/dist-client/components/abstract-password-reset.d.ts +2 -1
- package/dist-client/components/abstract-password-reset.js +14 -7
- package/dist-client/components/abstract-password-reset.js.map +1 -1
- package/dist-client/components/abstract-sign.js +11 -12
- package/dist-client/components/abstract-sign.js.map +1 -1
- package/dist-client/components/contact-us.d.ts +1 -1
- package/dist-client/components/contact-us.js +7 -10
- package/dist-client/components/contact-us.js.map +1 -1
- package/dist-client/components/create-user.js +5 -28
- package/dist-client/components/create-user.js.map +1 -1
- package/dist-client/components/invite-user.js +11 -19
- package/dist-client/components/invite-user.js.map +1 -1
- package/dist-client/components/ownership-transfer-popup.js +3 -3
- package/dist-client/components/ownership-transfer-popup.js.map +1 -1
- package/dist-client/components/profile-component.d.ts +1 -5
- package/dist-client/components/profile-component.js +4 -64
- package/dist-client/components/profile-component.js.map +1 -1
- package/dist-client/components/role-privilege-editor.js +1 -2
- package/dist-client/components/role-privilege-editor.js.map +1 -1
- package/dist-client/components/user-role-editor.js +18 -18
- package/dist-client/components/user-role-editor.js.map +1 -1
- package/dist-client/entries/auth/checkin.js +1 -1
- package/dist-client/entries/auth/checkin.js.map +1 -1
- package/dist-client/entries/auth/forgot-password.js +2 -11
- package/dist-client/entries/auth/forgot-password.js.map +1 -1
- package/dist-client/entries/auth/signup.js +7 -13
- package/dist-client/entries/auth/signup.js.map +1 -1
- package/dist-client/index.js +1 -1
- package/dist-client/index.js.map +1 -1
- package/dist-client/pages/user/user-management.d.ts +1 -5
- package/dist-client/pages/user/user-management.js +7 -6
- package/dist-client/pages/user/user-management.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +12 -12
- package/server/index.ts +0 -0
- package/translations/en.json +2 -6
- package/translations/ja.json +2 -6
- package/translations/ko.json +2 -6
- package/translations/ms.json +2 -6
- package/translations/zh.json +2 -6
|
@@ -0,0 +1,452 @@
|
|
|
1
|
+
import '@material/web/icon/icon.js'
|
|
2
|
+
|
|
3
|
+
import Clipboard from 'clipboard'
|
|
4
|
+
import gql from 'graphql-tag'
|
|
5
|
+
import { css, html } from 'lit'
|
|
6
|
+
import { customElement, property, queryAll } from 'lit/decorators.js'
|
|
7
|
+
import { asyncReplace } from 'lit/directives/async-replace.js'
|
|
8
|
+
import { connect } from 'pwa-helpers/connect-mixin.js'
|
|
9
|
+
|
|
10
|
+
import { client } from '@operato/graphql'
|
|
11
|
+
import { navigate, PageView, store } from '@operato/shell'
|
|
12
|
+
import { parseJwt, sleep } from '@operato/utils'
|
|
13
|
+
import { i18next } from '@operato/i18n'
|
|
14
|
+
|
|
15
|
+
@customElement('appliance-page')
|
|
16
|
+
class Appliance extends connect(store)(PageView) {
|
|
17
|
+
static styles = [
|
|
18
|
+
css`
|
|
19
|
+
:host {
|
|
20
|
+
display: flex;
|
|
21
|
+
flex-direction: column;
|
|
22
|
+
overflow-y: auto;
|
|
23
|
+
position: relative;
|
|
24
|
+
|
|
25
|
+
background-color: var(--md-sys-color-background);
|
|
26
|
+
padding: var(--spacing-large);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
h2 {
|
|
30
|
+
margin: var(--title-margin);
|
|
31
|
+
font: var(--title-font);
|
|
32
|
+
color: var(--title-text-color);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
[page-description] {
|
|
36
|
+
margin: var(--page-description-margin);
|
|
37
|
+
font: var(--page-description-font);
|
|
38
|
+
color: var(--page-description-color);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
[icon] {
|
|
42
|
+
position: absolute;
|
|
43
|
+
top: 10px;
|
|
44
|
+
right: 10px;
|
|
45
|
+
max-width: 80px;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
[icon] img {
|
|
49
|
+
max-width: 100%;
|
|
50
|
+
max-height: 100%;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
[button-primary] {
|
|
54
|
+
background-color: var(--button-primary-background-color);
|
|
55
|
+
border: var(--button-border);
|
|
56
|
+
border-radius: var(--button-border-radius);
|
|
57
|
+
margin: var(--button-margin);
|
|
58
|
+
padding: var(--button-primary-padding);
|
|
59
|
+
color: var(--button-primary-color);
|
|
60
|
+
font: var(--button-primary-font);
|
|
61
|
+
text-transform: var(--button-text-transform);
|
|
62
|
+
|
|
63
|
+
text-decoration: none;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
[button-primary]:hover {
|
|
67
|
+
background-color: var(--button-primary-active-background-color);
|
|
68
|
+
box-shadow: var(--button-active-box-shadow);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
[fieldset-container] {
|
|
72
|
+
background-color: var(--md-sys-color-surface);
|
|
73
|
+
margin: var(--spacing-large) 0 var(--spacing-medium) 0;
|
|
74
|
+
padding: var(--spacing-medium);
|
|
75
|
+
border-radius: var(--border-radius);
|
|
76
|
+
box-shadow: var(--box-shadow);
|
|
77
|
+
|
|
78
|
+
label {
|
|
79
|
+
font: var(--label-font);
|
|
80
|
+
color: var(--label-color, var(--md-sys-color-on-surface));
|
|
81
|
+
text-transform: var(--label-text-transform);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
input,
|
|
85
|
+
select {
|
|
86
|
+
border: var(--border-dim-color);
|
|
87
|
+
border-radius: var(--border-radius);
|
|
88
|
+
margin: var(--input-margin);
|
|
89
|
+
padding: var(--input-padding);
|
|
90
|
+
font: var(--input-font);
|
|
91
|
+
|
|
92
|
+
flex: 1;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
select:focus,
|
|
96
|
+
input:focus,
|
|
97
|
+
button {
|
|
98
|
+
outline: none;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
form {
|
|
102
|
+
max-width: var(--content-container-max-width);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
[fieldset-container] fieldset {
|
|
107
|
+
margin: 0;
|
|
108
|
+
margin-top: -15px;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
fieldset {
|
|
112
|
+
border-radius: var(--border-radius);
|
|
113
|
+
border: var(--border-dim-color);
|
|
114
|
+
margin: var(--fieldset-margin);
|
|
115
|
+
padding: var(--fieldset-padding);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
legend {
|
|
119
|
+
padding: var(--legend-padding);
|
|
120
|
+
font-weight: bold;
|
|
121
|
+
color: var(--legend-color);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
[field-2column] {
|
|
125
|
+
display: grid;
|
|
126
|
+
grid-template-columns: 1fr 1fr;
|
|
127
|
+
grid-gap: 15px;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
[field] {
|
|
131
|
+
display: flex;
|
|
132
|
+
flex-direction: column;
|
|
133
|
+
position: relative;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
[grid-span] {
|
|
137
|
+
grid-column: span 2;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
button {
|
|
141
|
+
display: flex;
|
|
142
|
+
align-items: center;
|
|
143
|
+
gap: var(--spacing-small);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
button,
|
|
147
|
+
input[type='submit'],
|
|
148
|
+
[button-in-field] {
|
|
149
|
+
background-color: var(--button-background-color);
|
|
150
|
+
border: var(--button-border);
|
|
151
|
+
border-radius: var(--button-border-radius);
|
|
152
|
+
padding: var(--button-padding);
|
|
153
|
+
color: var(--button-color);
|
|
154
|
+
font: var(--button-font);
|
|
155
|
+
text-transform: var(--button-text-transform);
|
|
156
|
+
|
|
157
|
+
margin: var(--spacing-medium) 0 var(--spacing-medium) var(--spacing-medium);
|
|
158
|
+
float: right;
|
|
159
|
+
text-decoration: none;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
button:hover,
|
|
163
|
+
input[type='submit']:hover {
|
|
164
|
+
border: var(--button-activ-border);
|
|
165
|
+
box-shadow: var(--button-active-box-shadow);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
[button-in-field] {
|
|
169
|
+
border-radius: 0 var(--button-border-radius) var(--button-border-radius) 0;
|
|
170
|
+
position: absolute;
|
|
171
|
+
top: 12px;
|
|
172
|
+
right: 0;
|
|
173
|
+
max-height: 36px;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
[input-hint] {
|
|
177
|
+
font: var(--input-hint-font);
|
|
178
|
+
color: var(--input-hint-color);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
@media screen and (max-width: 480px) {
|
|
182
|
+
[field] {
|
|
183
|
+
grid-column: span 2;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
`
|
|
187
|
+
]
|
|
188
|
+
|
|
189
|
+
@property({ type: Object }) appliance: any
|
|
190
|
+
@property({ type: String }) accessToken?: string
|
|
191
|
+
@property({ type: Object }) _accessTokenInfo: any
|
|
192
|
+
|
|
193
|
+
@queryAll('[clipboard-copy]') copybuttons
|
|
194
|
+
|
|
195
|
+
private clipboard?: Clipboard
|
|
196
|
+
|
|
197
|
+
get context() {
|
|
198
|
+
return {
|
|
199
|
+
title: {
|
|
200
|
+
icon: 'devices',
|
|
201
|
+
text: this.appliance.name
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
render() {
|
|
207
|
+
var appliance = this.appliance || {}
|
|
208
|
+
var accessTokenExp = this._accessTokenInfo?.exp
|
|
209
|
+
|
|
210
|
+
return html`
|
|
211
|
+
<div>
|
|
212
|
+
<h2><md-icon>devices</md-icon> ${appliance.name}</h2>
|
|
213
|
+
<p page-description>${appliance.description}</p>
|
|
214
|
+
</div>
|
|
215
|
+
|
|
216
|
+
<form>
|
|
217
|
+
<div fieldset-container>
|
|
218
|
+
<fieldset>
|
|
219
|
+
<legend>${i18next.t('text.appliance')}</legend>
|
|
220
|
+
<div field-2column>
|
|
221
|
+
<div field grid-span>
|
|
222
|
+
<label for="name">${i18next.t('field.name')}</label>
|
|
223
|
+
<input id="name" type="text" name="name" .value=${appliance.name} />
|
|
224
|
+
</div>
|
|
225
|
+
|
|
226
|
+
<div field grid-span>
|
|
227
|
+
<label for="description">${i18next.t('field.description')}</label>
|
|
228
|
+
<input id="description" type="text" name="description" .value=${appliance.description} />
|
|
229
|
+
</div>
|
|
230
|
+
|
|
231
|
+
<div field>
|
|
232
|
+
<label for="brand">${i18next.t('field.brand')}</label>
|
|
233
|
+
<input id="brand" type="text" name="brand" .value=${appliance.brand} />
|
|
234
|
+
</div>
|
|
235
|
+
|
|
236
|
+
<div field>
|
|
237
|
+
<label for="serial-no">${i18next.t('field.serial-no')}</label>
|
|
238
|
+
<input id="serial-no" type="text" name="serialNo" .value=${appliance.serialNo} />
|
|
239
|
+
</div>
|
|
240
|
+
|
|
241
|
+
<div field>
|
|
242
|
+
<label for="model">${i18next.t('field.model')}</label>
|
|
243
|
+
<input id="model" type="text" name="model" .value=${appliance.model} />
|
|
244
|
+
</div>
|
|
245
|
+
|
|
246
|
+
<div field>
|
|
247
|
+
<label for="netmask">${i18next.t('field.netmask')}</label>
|
|
248
|
+
<input id="netmask" type="text" name="netmask" .value=${appliance.netmask} />
|
|
249
|
+
</div>
|
|
250
|
+
</div>
|
|
251
|
+
</fieldset>
|
|
252
|
+
</div>
|
|
253
|
+
|
|
254
|
+
<div fieldset-container>
|
|
255
|
+
<fieldset>
|
|
256
|
+
<legend>${i18next.t('text.appliance credential')}</legend>
|
|
257
|
+
<div field-2column>
|
|
258
|
+
<div field grid-span>
|
|
259
|
+
<label for="access-token">${i18next.t('label.access token')}</label>
|
|
260
|
+
<input id="access-token" type="text" .value=${appliance.accessToken} readonly />
|
|
261
|
+
<button button-in-field clipboard-copy @click=${e => e.preventDefault()}>
|
|
262
|
+
${i18next.t('button.copy')}
|
|
263
|
+
</button>
|
|
264
|
+
${accessTokenExp
|
|
265
|
+
? html`<div input-hint>
|
|
266
|
+
${i18next.t('text.token expiry time')} ${new Date(accessTokenExp * 1000).toLocaleString()} :
|
|
267
|
+
${asyncReplace(this.expTimer(accessTokenExp))}
|
|
268
|
+
</div>`
|
|
269
|
+
: html``}
|
|
270
|
+
</div>
|
|
271
|
+
</div>
|
|
272
|
+
</fieldset>
|
|
273
|
+
</div>
|
|
274
|
+
|
|
275
|
+
<button @click=${this.deleteAppliance.bind(this)}>${i18next.t('button.delete this appliance')}</button>
|
|
276
|
+
<button @click=${this.generateApplianceSecret.bind(this)}>
|
|
277
|
+
${i18next.t('button.generate new access token')}
|
|
278
|
+
</button>
|
|
279
|
+
<button @click=${this.updateAppliance.bind(this)}>${i18next.t('button.update')}</button>
|
|
280
|
+
</form>
|
|
281
|
+
`
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
firstUpdated() {
|
|
285
|
+
this.clipboard = new Clipboard(this.copybuttons, {
|
|
286
|
+
target: (trigger => trigger.parentElement.querySelector('input')) as any
|
|
287
|
+
})
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
updated(changes) {
|
|
291
|
+
/*
|
|
292
|
+
* If this page properties are changed, this callback will be invoked.
|
|
293
|
+
* This callback will be called back only when this page is activated.
|
|
294
|
+
*/
|
|
295
|
+
if (changes.has('appliance')) {
|
|
296
|
+
const { accessToken } = this.appliance || {}
|
|
297
|
+
this.accessToken = accessToken
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
if (changes.has('accessToken')) {
|
|
301
|
+
this._accessTokenInfo = this.accessToken ? parseJwt(this.accessToken) : {}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
async pageUpdated(changes, lifecycle, before) {
|
|
306
|
+
if (this.active) {
|
|
307
|
+
await this.fetchAppliance()
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
async fetchAppliance() {
|
|
312
|
+
const response = await client.query({
|
|
313
|
+
query: gql`
|
|
314
|
+
query ($id: String!) {
|
|
315
|
+
appliance(id: $id) {
|
|
316
|
+
id
|
|
317
|
+
name
|
|
318
|
+
description
|
|
319
|
+
serialNo
|
|
320
|
+
brand
|
|
321
|
+
model
|
|
322
|
+
netmask
|
|
323
|
+
accessToken
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
`,
|
|
327
|
+
variables: {
|
|
328
|
+
id: this.lifecycle.resourceId
|
|
329
|
+
}
|
|
330
|
+
})
|
|
331
|
+
|
|
332
|
+
this.appliance = response.data.appliance
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
async updateAppliance(e) {
|
|
336
|
+
e.preventDefault()
|
|
337
|
+
|
|
338
|
+
const form = this.renderRoot.querySelector('form') as HTMLFormElement
|
|
339
|
+
const formData = new FormData(form)
|
|
340
|
+
|
|
341
|
+
const patch = Array.from(formData.entries()).reduce((patch, [key, value]) => {
|
|
342
|
+
patch[key] = value
|
|
343
|
+
return patch
|
|
344
|
+
}, {})
|
|
345
|
+
|
|
346
|
+
const id = this.lifecycle.resourceId
|
|
347
|
+
|
|
348
|
+
const response = await client.mutate({
|
|
349
|
+
mutation: gql`
|
|
350
|
+
mutation ($id: String!, $patch: AppliancePatch!) {
|
|
351
|
+
updateAppliance(id: $id, patch: $patch) {
|
|
352
|
+
id
|
|
353
|
+
name
|
|
354
|
+
description
|
|
355
|
+
serialNo
|
|
356
|
+
brand
|
|
357
|
+
model
|
|
358
|
+
netmask
|
|
359
|
+
accessToken
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
`,
|
|
363
|
+
variables: {
|
|
364
|
+
id,
|
|
365
|
+
patch
|
|
366
|
+
}
|
|
367
|
+
})
|
|
368
|
+
|
|
369
|
+
if (response.errors) {
|
|
370
|
+
console.error('update fail')
|
|
371
|
+
} else {
|
|
372
|
+
this.appliance = response.data.updateAppliance
|
|
373
|
+
console.log('update sucess')
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
async deleteAppliance(e) {
|
|
378
|
+
e.preventDefault()
|
|
379
|
+
|
|
380
|
+
const id = this.lifecycle.resourceId
|
|
381
|
+
|
|
382
|
+
const response = await client.mutate({
|
|
383
|
+
mutation: gql`
|
|
384
|
+
mutation ($id: String!) {
|
|
385
|
+
deleteAppliance(id: $id)
|
|
386
|
+
}
|
|
387
|
+
`,
|
|
388
|
+
variables: {
|
|
389
|
+
id
|
|
390
|
+
}
|
|
391
|
+
})
|
|
392
|
+
|
|
393
|
+
if (response.errors) {
|
|
394
|
+
console.error('delete fail')
|
|
395
|
+
} else {
|
|
396
|
+
navigate('appliance-home')
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
async generateApplianceSecret(e) {
|
|
401
|
+
e.preventDefault()
|
|
402
|
+
|
|
403
|
+
const id = this.lifecycle.resourceId
|
|
404
|
+
|
|
405
|
+
const response = await client.mutate({
|
|
406
|
+
mutation: gql`
|
|
407
|
+
mutation ($id: String!) {
|
|
408
|
+
generateApplianceSecret(id: $id) {
|
|
409
|
+
id
|
|
410
|
+
name
|
|
411
|
+
description
|
|
412
|
+
serialNo
|
|
413
|
+
brand
|
|
414
|
+
model
|
|
415
|
+
netmask
|
|
416
|
+
accessToken
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
`,
|
|
420
|
+
variables: {
|
|
421
|
+
id
|
|
422
|
+
}
|
|
423
|
+
})
|
|
424
|
+
|
|
425
|
+
if (response.errors) {
|
|
426
|
+
console.error('generate-appliance-secret fail')
|
|
427
|
+
} else {
|
|
428
|
+
this.appliance = response.data.generateApplianceSecret
|
|
429
|
+
console.log('generate-appliance-secret sucess')
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
async *expTimer(exp) {
|
|
434
|
+
const DAY = 24 * 60 * 60
|
|
435
|
+
const HOUR = 60 * 60
|
|
436
|
+
const MIN = 60
|
|
437
|
+
|
|
438
|
+
while (this.active) {
|
|
439
|
+
var remain = Math.floor(Number(exp) - Date.now() / 1000)
|
|
440
|
+
const days = Math.floor(remain / DAY)
|
|
441
|
+
remain -= days * DAY
|
|
442
|
+
const hours = Math.floor(remain / HOUR)
|
|
443
|
+
remain -= hours * HOUR
|
|
444
|
+
const mins = Math.floor(remain / MIN)
|
|
445
|
+
const secs = remain - mins * MIN
|
|
446
|
+
|
|
447
|
+
yield i18next.t('text.remaining time', { days, hours, mins, secs })
|
|
448
|
+
|
|
449
|
+
await sleep(1000)
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import '@material/web/button/elevated-button.js'
|
|
2
|
+
import '@material/web/button/outlined-button.js'
|
|
3
|
+
|
|
4
|
+
import gql from 'graphql-tag'
|
|
5
|
+
import { css, html } from 'lit'
|
|
6
|
+
import { customElement, property } from 'lit/decorators.js'
|
|
7
|
+
import { connect } from 'pwa-helpers/connect-mixin.js'
|
|
8
|
+
|
|
9
|
+
import { client } from '@operato/graphql'
|
|
10
|
+
import { navigate, PageView, store } from '@operato/shell'
|
|
11
|
+
|
|
12
|
+
@customElement('appliance-home')
|
|
13
|
+
class Appliances extends connect(store)(PageView) {
|
|
14
|
+
static styles = [
|
|
15
|
+
css`
|
|
16
|
+
:host {
|
|
17
|
+
background-color: var(--md-sys-color-background);
|
|
18
|
+
padding: var(--spacing-large);
|
|
19
|
+
|
|
20
|
+
overflow: auto;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
md-elevated-button {
|
|
24
|
+
text-transform: capitalize;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
md-outlined-button {
|
|
28
|
+
float: right;
|
|
29
|
+
margin-top: var(--spacing-medium);
|
|
30
|
+
text-transform: capitalize;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
h2 {
|
|
34
|
+
margin: var(--title-margin);
|
|
35
|
+
font: var(--title-font);
|
|
36
|
+
color: var(--title-text-color);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
[page-description] {
|
|
40
|
+
margin: var(--page-description-margin);
|
|
41
|
+
font: var(--page-description-font);
|
|
42
|
+
color: var(--page-description-color);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
table {
|
|
46
|
+
width: 100%;
|
|
47
|
+
margin: var(--spacing-large) 0;
|
|
48
|
+
border-collapse: collapse;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
tr {
|
|
52
|
+
background-color: var(--tr-background-color);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
tr:nth-child(odd) {
|
|
56
|
+
background-color: var(--tr-background-odd-color);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
tr:hover {
|
|
60
|
+
background-color: var(--tr-background-hover-color);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
th {
|
|
64
|
+
border-top: var(--th-border-top);
|
|
65
|
+
border-bottom: var(--td-border-bottom);
|
|
66
|
+
padding: var(--th-padding);
|
|
67
|
+
|
|
68
|
+
font: var(--th-font);
|
|
69
|
+
color: var(--th-color);
|
|
70
|
+
text-transform: var(--th-text-transform);
|
|
71
|
+
text-align: left;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
td {
|
|
75
|
+
padding: var(--td-padding);
|
|
76
|
+
border-bottom: var(--td-border-bottom);
|
|
77
|
+
font: var(--td-font);
|
|
78
|
+
color: var(--td-color);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
td a {
|
|
82
|
+
color: var(--md-sys-color-primary);
|
|
83
|
+
font: bold 16px var(--theme-font);
|
|
84
|
+
|
|
85
|
+
display: block;
|
|
86
|
+
text-decoration: none;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.text-align-center {
|
|
90
|
+
text-align: center;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.text-align-right {
|
|
94
|
+
text-align: right;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
@media screen and (max-width: 480px) {
|
|
98
|
+
:host {
|
|
99
|
+
padding: var(--spacing-medium);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
`
|
|
103
|
+
]
|
|
104
|
+
|
|
105
|
+
@property({ type: Array }) appliances: any[] = []
|
|
106
|
+
|
|
107
|
+
get context() {
|
|
108
|
+
return {
|
|
109
|
+
title: `appliance home`,
|
|
110
|
+
help: 'auth/appliance'
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
render() {
|
|
115
|
+
var appliances = this.appliances || []
|
|
116
|
+
|
|
117
|
+
return html`
|
|
118
|
+
<div>
|
|
119
|
+
<h2>Registered Appliances</h2>
|
|
120
|
+
<p page-description>
|
|
121
|
+
What type of appliance are you building?<br />Choose the app type that best suits the audience you’re building
|
|
122
|
+
for. The appliance type can’t be changed after it’s created.
|
|
123
|
+
</p>
|
|
124
|
+
<md-elevated-button @click=${e => navigate('appliance-register')}>register new appliance</md-elevated-button>
|
|
125
|
+
</div>
|
|
126
|
+
|
|
127
|
+
<table>
|
|
128
|
+
<tr>
|
|
129
|
+
<th>appliance name</th>
|
|
130
|
+
<th>API health</th>
|
|
131
|
+
<th>Installs</th>
|
|
132
|
+
<th>status</th>
|
|
133
|
+
</tr>
|
|
134
|
+
${appliances.map(
|
|
135
|
+
appliance => html`
|
|
136
|
+
<tr>
|
|
137
|
+
<td>
|
|
138
|
+
<a href=${`appliance/${appliance.id}`}>${appliance.name}</a>
|
|
139
|
+
${appliance.description}
|
|
140
|
+
</td>
|
|
141
|
+
<td>OK</td>
|
|
142
|
+
<td class="text-align-center">1</td>
|
|
143
|
+
<td>draft</td>
|
|
144
|
+
</tr>
|
|
145
|
+
`
|
|
146
|
+
)}
|
|
147
|
+
</table>
|
|
148
|
+
`
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
async pageUpdated() {
|
|
152
|
+
if (this.active) {
|
|
153
|
+
this.appliances = (await this.fetchAppliances()).items
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
async fetchAppliances() {
|
|
158
|
+
const response = await client.query({
|
|
159
|
+
query: gql`
|
|
160
|
+
query {
|
|
161
|
+
appliances {
|
|
162
|
+
items {
|
|
163
|
+
id
|
|
164
|
+
name
|
|
165
|
+
description
|
|
166
|
+
}
|
|
167
|
+
total
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
`
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
if (!response.errors) {
|
|
174
|
+
return response.data.appliances
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|