@things-factory/auth-ui 10.1.16 → 10.1.18
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/dist-client/components/app-binding-detail.d.ts +46 -0
- package/dist-client/components/app-binding-detail.js +384 -0
- package/dist-client/components/app-binding-detail.js.map +1 -0
- package/dist-client/components/appliance-editor.d.ts +37 -0
- package/dist-client/components/appliance-editor.js +489 -0
- package/dist-client/components/appliance-editor.js.map +1 -0
- package/dist-client/components/application-editor.d.ts +31 -0
- package/dist-client/components/application-editor.js +491 -0
- package/dist-client/components/application-editor.js.map +1 -0
- package/dist-client/components/profile-component.js +28 -11
- package/dist-client/components/profile-component.js.map +1 -1
- package/dist-client/components/secret-field.d.ts +35 -0
- package/dist-client/components/secret-field.js +149 -0
- package/dist-client/components/secret-field.js.map +1 -0
- package/dist-client/constants/application-type-parity.test.js +62 -0
- package/dist-client/constants/application-type-parity.test.js.map +1 -0
- package/dist-client/constants/application.d.ts +17 -7
- package/dist-client/constants/application.js +18 -8
- package/dist-client/constants/application.js.map +1 -1
- package/dist-client/pages/app-binding/app-binding-list-query.test.js +46 -0
- package/dist-client/pages/app-binding/app-binding-list-query.test.js.map +1 -0
- package/dist-client/pages/app-binding/app-bindings.d.ts +65 -2
- package/dist-client/pages/app-binding/app-bindings.js +217 -117
- package/dist-client/pages/app-binding/app-bindings.js.map +1 -1
- package/dist-client/pages/appliance/appliance-list-query.test.d.ts +1 -0
- package/dist-client/pages/appliance/appliance-list-query.test.js +58 -0
- package/dist-client/pages/appliance/appliance-list-query.test.js.map +1 -0
- package/dist-client/pages/appliance/home.d.ts +63 -2
- package/dist-client/pages/appliance/home.js +219 -123
- package/dist-client/pages/appliance/home.js.map +1 -1
- package/dist-client/pages/application/applications.d.ts +63 -2
- package/dist-client/pages/application/applications.js +212 -129
- package/dist-client/pages/application/applications.js.map +1 -1
- package/dist-client/pages/auth-provider/auth-provider-management.d.ts +4 -2
- package/dist-client/pages/auth-provider/auth-provider-management.js +35 -6
- package/dist-client/pages/auth-provider/auth-provider-management.js.map +1 -1
- package/dist-client/pages/domain-owner/domain-owner-management.d.ts +2 -0
- package/dist-client/pages/domain-owner/domain-owner-management.js +34 -7
- package/dist-client/pages/domain-owner/domain-owner-management.js.map +1 -1
- package/dist-client/pages/secrets-are-not-printed.test.d.ts +1 -0
- package/dist-client/pages/secrets-are-not-printed.test.js +88 -0
- package/dist-client/pages/secrets-are-not-printed.test.js.map +1 -0
- package/dist-client/route.js +0 -15
- package/dist-client/route.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-client/utils/application-status.d.ts +32 -0
- package/dist-client/utils/application-status.js +45 -0
- package/dist-client/utils/application-status.js.map +1 -0
- package/dist-client/utils/application-status.test.d.ts +1 -0
- package/dist-client/utils/application-status.test.js +45 -0
- package/dist-client/utils/application-status.test.js.map +1 -0
- package/dist-client/utils/form-values.d.ts +71 -0
- package/dist-client/utils/form-values.js +102 -0
- package/dist-client/utils/form-values.js.map +1 -0
- package/dist-client/utils/form-values.test.d.ts +1 -0
- package/dist-client/utils/form-values.test.js +120 -0
- package/dist-client/utils/form-values.test.js.map +1 -0
- package/dist-client/utils/list-result.d.ts +62 -0
- package/dist-client/utils/list-result.js +92 -0
- package/dist-client/utils/list-result.js.map +1 -0
- package/dist-client/utils/list-result.test.d.ts +1 -0
- package/dist-client/utils/list-result.test.js +160 -0
- package/dist-client/utils/list-result.test.js.map +1 -0
- package/dist-client/utils/secret-display.d.ts +51 -0
- package/dist-client/utils/secret-display.js +61 -0
- package/dist-client/utils/secret-display.js.map +1 -0
- package/dist-client/utils/secret-display.test.d.ts +1 -0
- package/dist-client/utils/secret-display.test.js +59 -0
- package/dist-client/utils/secret-display.test.js.map +1 -0
- package/dist-client/utils/webauthn-verification.d.ts +56 -0
- package/dist-client/utils/webauthn-verification.js +79 -0
- package/dist-client/utils/webauthn-verification.js.map +1 -0
- package/dist-client/utils/webauthn-verification.test.d.ts +1 -0
- package/dist-client/utils/webauthn-verification.test.js +79 -0
- package/dist-client/utils/webauthn-verification.test.js.map +1 -0
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/things-factory.config.js +0 -5
- package/translations/en.json +56 -0
- package/translations/ja.json +57 -0
- package/translations/ko.json +56 -0
- package/translations/ms.json +57 -0
- package/translations/zh.json +57 -0
- package/dist-client/pages/app-binding/app-binding.d.ts +0 -1
- package/dist-client/pages/app-binding/app-binding.js +0 -371
- package/dist-client/pages/app-binding/app-binding.js.map +0 -1
- package/dist-client/pages/appliance/appliance.d.ts +0 -1
- package/dist-client/pages/appliance/appliance.js +0 -392
- package/dist-client/pages/appliance/appliance.js.map +0 -1
- package/dist-client/pages/appliance/register.js +0 -166
- package/dist-client/pages/appliance/register.js.map +0 -1
- package/dist-client/pages/application/application.d.ts +0 -1
- package/dist-client/pages/application/application.js +0 -377
- package/dist-client/pages/application/application.js.map +0 -1
- package/dist-client/pages/application/register.js +0 -192
- package/dist-client/pages/application/register.js.map +0 -1
- /package/dist-client/{pages/appliance/register.d.ts → constants/application-type-parity.test.d.ts} +0 -0
- /package/dist-client/pages/{application/register.d.ts → app-binding/app-binding-list-query.test.d.ts} +0 -0
|
@@ -1,392 +0,0 @@
|
|
|
1
|
-
import { __decorate, __metadata } from "tslib";
|
|
2
|
-
import '@material/web/icon/icon.js';
|
|
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 { client } from '@operato/graphql';
|
|
9
|
-
import { navigate, PageView } from '@operato/shell';
|
|
10
|
-
import { parseJwt, sleep } from '@operato/utils';
|
|
11
|
-
import { i18next } from '@operato/i18n';
|
|
12
|
-
let Appliance = class Appliance extends PageView {
|
|
13
|
-
static { this.styles = [
|
|
14
|
-
css `
|
|
15
|
-
:host { display: flex;
|
|
16
|
-
flex-direction: column;
|
|
17
|
-
overflow-y: auto;
|
|
18
|
-
position: relative;
|
|
19
|
-
|
|
20
|
-
background-color: var(--md-sys-color-background);
|
|
21
|
-
padding: var(--spacing-large);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
h2 { margin: var(--title-margin);
|
|
25
|
-
font: var(--title-font);
|
|
26
|
-
color: var(--title-text-color);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
[page-description] { margin: var(--page-description-margin);
|
|
30
|
-
font: var(--page-description-font);
|
|
31
|
-
color: var(--page-description-color);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
[icon] { position: absolute;
|
|
35
|
-
top: 10px;
|
|
36
|
-
right: 10px;
|
|
37
|
-
max-width: 80px;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
[icon] img { max-width: 100%;
|
|
41
|
-
max-height: 100%;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
[button-primary] { background-color: var(--button-primary-background-color);
|
|
45
|
-
border: var(--button-border);
|
|
46
|
-
border-radius: var(--button-border-radius);
|
|
47
|
-
margin: var(--button-margin);
|
|
48
|
-
padding: var(--button-primary-padding);
|
|
49
|
-
color: var(--button-primary-color);
|
|
50
|
-
font: var(--button-primary-font);
|
|
51
|
-
text-transform: var(--button-text-transform);
|
|
52
|
-
|
|
53
|
-
text-decoration: none;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
[button-primary]:hover { background-color: var(--button-primary-active-background-color);
|
|
57
|
-
box-shadow: var(--button-active-box-shadow);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
[fieldset-container] { background-color: var(--md-sys-color-surface);
|
|
61
|
-
margin: var(--spacing-large) 0 var(--spacing-medium) 0;
|
|
62
|
-
padding: var(--spacing-medium);
|
|
63
|
-
border-radius: var(--border-radius);
|
|
64
|
-
box-shadow: var(--box-shadow);
|
|
65
|
-
|
|
66
|
-
label { font: var(--label-font);
|
|
67
|
-
color: var(--label-color, var(--md-sys-color-on-surface));
|
|
68
|
-
text-transform: var(--label-text-transform);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
input,
|
|
72
|
-
select {
|
|
73
|
-
background-color: var(--input-field-background, var(--md-sys-color-surface-container-highest));
|
|
74
|
-
color: var(--input-field-color, var(--md-sys-color-on-surface));
|
|
75
|
-
border: var(--border-dim-color);
|
|
76
|
-
border-radius: var(--border-radius);
|
|
77
|
-
margin: var(--input-margin);
|
|
78
|
-
padding: var(--input-padding);
|
|
79
|
-
font: var(--input-font);
|
|
80
|
-
|
|
81
|
-
flex: 1;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
select:focus,
|
|
85
|
-
input:focus,
|
|
86
|
-
button { outline: none;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
form { max-width: var(--content-container-max-width);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
[fieldset-container] fieldset { margin: 0;
|
|
94
|
-
margin-top: -15px;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
fieldset { border-radius: var(--border-radius);
|
|
98
|
-
border: var(--border-dim-color);
|
|
99
|
-
margin: var(--fieldset-margin);
|
|
100
|
-
padding: var(--fieldset-padding);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
legend { padding: var(--legend-padding);
|
|
104
|
-
font-weight: bold;
|
|
105
|
-
color: var(--legend-color);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
[field-2column] { display: grid;
|
|
109
|
-
grid-template-columns: 1fr 1fr;
|
|
110
|
-
grid-gap: 15px;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
[field] { display: flex;
|
|
114
|
-
flex-direction: column;
|
|
115
|
-
position: relative;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
[grid-span] { grid-column: span 2;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
button { display: flex;
|
|
122
|
-
align-items: center;
|
|
123
|
-
gap: var(--spacing-small);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
button,
|
|
127
|
-
input[type='submit'],
|
|
128
|
-
[button-in-field] { background-color: var(--button-background-color);
|
|
129
|
-
border: var(--button-border);
|
|
130
|
-
border-radius: var(--button-border-radius);
|
|
131
|
-
padding: var(--button-padding);
|
|
132
|
-
color: var(--button-color);
|
|
133
|
-
font: var(--button-font);
|
|
134
|
-
text-transform: var(--button-text-transform);
|
|
135
|
-
|
|
136
|
-
margin: var(--spacing-medium) 0 var(--spacing-medium) var(--spacing-medium);
|
|
137
|
-
float: right;
|
|
138
|
-
text-decoration: none;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
button:hover,
|
|
142
|
-
input[type='submit']:hover { border: var(--button-activ-border);
|
|
143
|
-
box-shadow: var(--button-active-box-shadow);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
[button-in-field] { border-radius: 0 var(--button-border-radius) var(--button-border-radius) 0;
|
|
147
|
-
position: absolute;
|
|
148
|
-
top: 12px;
|
|
149
|
-
right: 0;
|
|
150
|
-
max-height: 36px;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
[input-hint] { font: var(--input-hint-font);
|
|
154
|
-
color: var(--input-hint-color);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
@media screen and (max-width: 480px) { [field] { grid-column: span 2;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
`
|
|
161
|
-
]; }
|
|
162
|
-
get context() {
|
|
163
|
-
return { title: { icon: 'devices',
|
|
164
|
-
text: this.appliance.name
|
|
165
|
-
}
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
render() {
|
|
169
|
-
var appliance = this.appliance || {};
|
|
170
|
-
var accessTokenExp = this._accessTokenInfo?.exp;
|
|
171
|
-
return html `
|
|
172
|
-
<div>
|
|
173
|
-
<h2><md-icon>devices</md-icon> ${appliance.name}</h2>
|
|
174
|
-
<p page-description>${appliance.description}</p>
|
|
175
|
-
</div>
|
|
176
|
-
|
|
177
|
-
<form>
|
|
178
|
-
<div fieldset-container>
|
|
179
|
-
<fieldset>
|
|
180
|
-
<legend>${i18next.t('text.appliance')}</legend>
|
|
181
|
-
<div field-2column>
|
|
182
|
-
<div field grid-span>
|
|
183
|
-
<label for="name">${i18next.t('field.name')}</label>
|
|
184
|
-
<input id="name" type="text" name="name" .value=${appliance.name} />
|
|
185
|
-
</div>
|
|
186
|
-
|
|
187
|
-
<div field grid-span>
|
|
188
|
-
<label for="description">${i18next.t('field.description')}</label>
|
|
189
|
-
<input id="description" type="text" name="description" .value=${appliance.description} />
|
|
190
|
-
</div>
|
|
191
|
-
|
|
192
|
-
<div field>
|
|
193
|
-
<label for="brand">${i18next.t('field.brand')}</label>
|
|
194
|
-
<input id="brand" type="text" name="brand" .value=${appliance.brand} />
|
|
195
|
-
</div>
|
|
196
|
-
|
|
197
|
-
<div field>
|
|
198
|
-
<label for="serial-no">${i18next.t('field.serial-no')}</label>
|
|
199
|
-
<input id="serial-no" type="text" name="serialNo" .value=${appliance.serialNo} />
|
|
200
|
-
</div>
|
|
201
|
-
|
|
202
|
-
<div field>
|
|
203
|
-
<label for="model">${i18next.t('field.model')}</label>
|
|
204
|
-
<input id="model" type="text" name="model" .value=${appliance.model} />
|
|
205
|
-
</div>
|
|
206
|
-
|
|
207
|
-
<div field>
|
|
208
|
-
<label for="netmask">${i18next.t('field.netmask')}</label>
|
|
209
|
-
<input id="netmask" type="text" name="netmask" .value=${appliance.netmask} />
|
|
210
|
-
</div>
|
|
211
|
-
</div>
|
|
212
|
-
</fieldset>
|
|
213
|
-
</div>
|
|
214
|
-
|
|
215
|
-
<div fieldset-container>
|
|
216
|
-
<fieldset>
|
|
217
|
-
<legend>${i18next.t('text.appliance credential')}</legend>
|
|
218
|
-
<div field-2column>
|
|
219
|
-
<div field grid-span>
|
|
220
|
-
<label for="access-token">${i18next.t('label.access token')}</label>
|
|
221
|
-
<input id="access-token" type="text" .value=${appliance.accessToken} readonly />
|
|
222
|
-
<button button-in-field clipboard-copy @click=${e => e.preventDefault()}>
|
|
223
|
-
${i18next.t('button.copy')}
|
|
224
|
-
</button>
|
|
225
|
-
${accessTokenExp
|
|
226
|
-
? html `<div input-hint>
|
|
227
|
-
${i18next.t('text.token expiry time')} ${new Date(accessTokenExp * 1000).toLocaleString()} :
|
|
228
|
-
${asyncReplace(this.expTimer(accessTokenExp))}
|
|
229
|
-
</div>`
|
|
230
|
-
: html ``}
|
|
231
|
-
</div>
|
|
232
|
-
</div>
|
|
233
|
-
</fieldset>
|
|
234
|
-
</div>
|
|
235
|
-
|
|
236
|
-
<button @click=${this.deleteAppliance.bind(this)}>${i18next.t('button.delete this appliance')}</button>
|
|
237
|
-
<button @click=${this.generateApplianceSecret.bind(this)}>
|
|
238
|
-
${i18next.t('button.generate new access token')}
|
|
239
|
-
</button>
|
|
240
|
-
<button @click=${this.updateAppliance.bind(this)}>${i18next.t('button.update')}</button>
|
|
241
|
-
</form>
|
|
242
|
-
`;
|
|
243
|
-
}
|
|
244
|
-
firstUpdated() {
|
|
245
|
-
this.clipboard = new Clipboard(this.copybuttons, { target: (trigger => trigger.parentElement.querySelector('input'))
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
updated(changes) {
|
|
249
|
-
if (changes.has('appliance')) {
|
|
250
|
-
const { accessToken } = this.appliance || {};
|
|
251
|
-
this.accessToken = accessToken;
|
|
252
|
-
}
|
|
253
|
-
if (changes.has('accessToken')) {
|
|
254
|
-
this._accessTokenInfo = this.accessToken ? parseJwt(this.accessToken) : {};
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
async pageUpdated(changes, lifecycle, before) {
|
|
258
|
-
if (this.active) {
|
|
259
|
-
await this.fetchAppliance();
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
async fetchAppliance() {
|
|
263
|
-
const response = await client.query({ query: gql `
|
|
264
|
-
query ($id: String!) { appliance(id: $id) { id
|
|
265
|
-
name
|
|
266
|
-
description
|
|
267
|
-
serialNo
|
|
268
|
-
brand
|
|
269
|
-
model
|
|
270
|
-
netmask
|
|
271
|
-
accessToken
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
`,
|
|
275
|
-
variables: { id: this.lifecycle.resourceId
|
|
276
|
-
}
|
|
277
|
-
});
|
|
278
|
-
this.appliance = response.data.appliance;
|
|
279
|
-
}
|
|
280
|
-
async updateAppliance(e) {
|
|
281
|
-
e.preventDefault();
|
|
282
|
-
const form = this.renderRoot.querySelector('form');
|
|
283
|
-
const formData = new FormData(form);
|
|
284
|
-
const patch = Array.from(formData.entries()).reduce((patch, [key, value]) => {
|
|
285
|
-
patch[key] = value;
|
|
286
|
-
return patch;
|
|
287
|
-
}, {});
|
|
288
|
-
const id = this.lifecycle.resourceId;
|
|
289
|
-
const response = await client.mutate({ mutation: gql `
|
|
290
|
-
mutation ($id: String!, $patch: AppliancePatch!) { updateAppliance(id: $id, patch: $patch) { id
|
|
291
|
-
name
|
|
292
|
-
description
|
|
293
|
-
serialNo
|
|
294
|
-
brand
|
|
295
|
-
model
|
|
296
|
-
netmask
|
|
297
|
-
accessToken
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
`,
|
|
301
|
-
variables: { id,
|
|
302
|
-
patch
|
|
303
|
-
}
|
|
304
|
-
});
|
|
305
|
-
if (response.errors) {
|
|
306
|
-
console.error('update fail');
|
|
307
|
-
}
|
|
308
|
-
else {
|
|
309
|
-
this.appliance = response.data.updateAppliance;
|
|
310
|
-
console.log('update sucess');
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
async deleteAppliance(e) {
|
|
314
|
-
e.preventDefault();
|
|
315
|
-
const id = this.lifecycle.resourceId;
|
|
316
|
-
const response = await client.mutate({ mutation: gql `
|
|
317
|
-
mutation ($id: String!) { deleteAppliance(id: $id)
|
|
318
|
-
}
|
|
319
|
-
`,
|
|
320
|
-
variables: { id
|
|
321
|
-
}
|
|
322
|
-
});
|
|
323
|
-
if (response.errors) {
|
|
324
|
-
console.error('delete fail');
|
|
325
|
-
}
|
|
326
|
-
else {
|
|
327
|
-
navigate('appliance-home');
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
async generateApplianceSecret(e) {
|
|
331
|
-
e.preventDefault();
|
|
332
|
-
const id = this.lifecycle.resourceId;
|
|
333
|
-
const response = await client.mutate({ mutation: gql `
|
|
334
|
-
mutation ($id: String!) { generateApplianceSecret(id: $id) { id
|
|
335
|
-
name
|
|
336
|
-
description
|
|
337
|
-
serialNo
|
|
338
|
-
brand
|
|
339
|
-
model
|
|
340
|
-
netmask
|
|
341
|
-
accessToken
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
`,
|
|
345
|
-
variables: { id
|
|
346
|
-
}
|
|
347
|
-
});
|
|
348
|
-
if (response.errors) {
|
|
349
|
-
console.error('generate-appliance-secret fail');
|
|
350
|
-
}
|
|
351
|
-
else {
|
|
352
|
-
this.appliance = response.data.generateApplianceSecret;
|
|
353
|
-
console.log('generate-appliance-secret sucess');
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
async *expTimer(exp) {
|
|
357
|
-
const DAY = 24 * 60 * 60;
|
|
358
|
-
const HOUR = 60 * 60;
|
|
359
|
-
const MIN = 60;
|
|
360
|
-
while (this.active) {
|
|
361
|
-
var remain = Math.floor(Number(exp) - Date.now() / 1000);
|
|
362
|
-
const days = Math.floor(remain / DAY);
|
|
363
|
-
remain -= days * DAY;
|
|
364
|
-
const hours = Math.floor(remain / HOUR);
|
|
365
|
-
remain -= hours * HOUR;
|
|
366
|
-
const mins = Math.floor(remain / MIN);
|
|
367
|
-
const secs = remain - mins * MIN;
|
|
368
|
-
yield i18next.t('text.remaining time', { days, hours, mins, secs });
|
|
369
|
-
await sleep(1000);
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
};
|
|
373
|
-
__decorate([
|
|
374
|
-
property({ type: Object }),
|
|
375
|
-
__metadata("design:type", Object)
|
|
376
|
-
], Appliance.prototype, "appliance", void 0);
|
|
377
|
-
__decorate([
|
|
378
|
-
property({ type: String }),
|
|
379
|
-
__metadata("design:type", String)
|
|
380
|
-
], Appliance.prototype, "accessToken", void 0);
|
|
381
|
-
__decorate([
|
|
382
|
-
property({ type: Object }),
|
|
383
|
-
__metadata("design:type", Object)
|
|
384
|
-
], Appliance.prototype, "_accessTokenInfo", void 0);
|
|
385
|
-
__decorate([
|
|
386
|
-
queryAll('[clipboard-copy]'),
|
|
387
|
-
__metadata("design:type", Object)
|
|
388
|
-
], Appliance.prototype, "copybuttons", void 0);
|
|
389
|
-
Appliance = __decorate([
|
|
390
|
-
customElement('appliance-page')
|
|
391
|
-
], Appliance);
|
|
392
|
-
//# sourceMappingURL=appliance.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"appliance.js","sourceRoot":"","sources":["../../../client/pages/appliance/appliance.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AAEnC,OAAO,SAAS,MAAM,WAAW,CAAA;AACjC,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACnD,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAGvC,IAAM,SAAS,GAAf,MAAM,SAAU,SAAQ,QAAQ;aAAY,WAAM,GAAG;QACjD,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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IADd,aAAa,CAAC,gBAAgB,CAAC;GAC1B,SAAS,CAsXd","sourcesContent":["import '@material/web/icon/icon.js'\n\nimport Clipboard from 'clipboard'\nimport gql from 'graphql-tag'\nimport { css, html } from 'lit'\nimport { customElement, property, queryAll } from 'lit/decorators.js'\nimport { asyncReplace } from 'lit/directives/async-replace.js'\nimport { client } from '@operato/graphql'\nimport { navigate, PageView } from '@operato/shell'\nimport { parseJwt, sleep } from '@operato/utils'\nimport { i18next } from '@operato/i18n'\n\n@customElement('appliance-page')\nclass Appliance extends PageView { static styles = [\n css`\n :host { display: flex;\n flex-direction: column;\n overflow-y: auto;\n position: relative;\n\n background-color: var(--md-sys-color-background);\n padding: var(--spacing-large);\n }\n\n h2 { margin: var(--title-margin);\n font: var(--title-font);\n color: var(--title-text-color);\n }\n\n [page-description] { margin: var(--page-description-margin);\n font: var(--page-description-font);\n color: var(--page-description-color);\n }\n\n [icon] { position: absolute;\n top: 10px;\n right: 10px;\n max-width: 80px;\n }\n\n [icon] img { max-width: 100%;\n max-height: 100%;\n }\n\n [button-primary] { background-color: var(--button-primary-background-color);\n border: var(--button-border);\n border-radius: var(--button-border-radius);\n margin: var(--button-margin);\n padding: var(--button-primary-padding);\n color: var(--button-primary-color);\n font: var(--button-primary-font);\n text-transform: var(--button-text-transform);\n\n text-decoration: none;\n }\n\n [button-primary]:hover { background-color: var(--button-primary-active-background-color);\n box-shadow: var(--button-active-box-shadow);\n }\n\n [fieldset-container] { background-color: var(--md-sys-color-surface);\n margin: var(--spacing-large) 0 var(--spacing-medium) 0;\n padding: var(--spacing-medium);\n border-radius: var(--border-radius);\n box-shadow: var(--box-shadow);\n\n label { font: var(--label-font);\n color: var(--label-color, var(--md-sys-color-on-surface));\n text-transform: var(--label-text-transform);\n }\n\n input,\n select {\n background-color: var(--input-field-background, var(--md-sys-color-surface-container-highest));\n color: var(--input-field-color, var(--md-sys-color-on-surface));\n border: var(--border-dim-color);\n border-radius: var(--border-radius);\n margin: var(--input-margin);\n padding: var(--input-padding);\n font: var(--input-font);\n\n flex: 1;\n }\n\n select:focus,\n input:focus,\n button { outline: none;\n }\n\n form { max-width: var(--content-container-max-width);\n }\n }\n\n [fieldset-container] fieldset { margin: 0;\n margin-top: -15px;\n }\n\n fieldset { border-radius: var(--border-radius);\n border: var(--border-dim-color);\n margin: var(--fieldset-margin);\n padding: var(--fieldset-padding);\n }\n\n legend { padding: var(--legend-padding);\n font-weight: bold;\n color: var(--legend-color);\n }\n\n [field-2column] { display: grid;\n grid-template-columns: 1fr 1fr;\n grid-gap: 15px;\n }\n\n [field] { display: flex;\n flex-direction: column;\n position: relative;\n }\n\n [grid-span] { grid-column: span 2;\n }\n\n button { display: flex;\n align-items: center;\n gap: var(--spacing-small);\n }\n\n button,\n input[type='submit'],\n [button-in-field] { background-color: var(--button-background-color);\n border: var(--button-border);\n border-radius: var(--button-border-radius);\n padding: var(--button-padding);\n color: var(--button-color);\n font: var(--button-font);\n text-transform: var(--button-text-transform);\n\n margin: var(--spacing-medium) 0 var(--spacing-medium) var(--spacing-medium);\n float: right;\n text-decoration: none;\n }\n\n button:hover,\n input[type='submit']:hover { border: var(--button-activ-border);\n box-shadow: var(--button-active-box-shadow);\n }\n\n [button-in-field] { border-radius: 0 var(--button-border-radius) var(--button-border-radius) 0;\n position: absolute;\n top: 12px;\n right: 0;\n max-height: 36px;\n }\n\n [input-hint] { font: var(--input-hint-font);\n color: var(--input-hint-color);\n }\n\n @media screen and (max-width: 480px) { [field] { grid-column: span 2;\n }\n }\n `\n ]\n\n @property({ type: Object }) appliance: any\n @property({ type: String }) accessToken?: string\n @property({ type: Object }) _accessTokenInfo: any\n\n @queryAll('[clipboard-copy]') copybuttons\n\n private clipboard?: Clipboard\n\n get context() { return { title: { icon: 'devices',\n text: this.appliance.name\n }\n }\n }\n\n render() { var appliance = this.appliance || {}\n var accessTokenExp = this._accessTokenInfo?.exp\n\n return html`\n <div>\n <h2><md-icon>devices</md-icon> ${appliance.name}</h2>\n <p page-description>${appliance.description}</p>\n </div>\n\n <form>\n <div fieldset-container>\n <fieldset>\n <legend>${i18next.t('text.appliance')}</legend>\n <div field-2column>\n <div field grid-span>\n <label for=\"name\">${i18next.t('field.name')}</label>\n <input id=\"name\" type=\"text\" name=\"name\" .value=${appliance.name} />\n </div>\n\n <div field grid-span>\n <label for=\"description\">${i18next.t('field.description')}</label>\n <input id=\"description\" type=\"text\" name=\"description\" .value=${appliance.description} />\n </div>\n\n <div field>\n <label for=\"brand\">${i18next.t('field.brand')}</label>\n <input id=\"brand\" type=\"text\" name=\"brand\" .value=${appliance.brand} />\n </div>\n\n <div field>\n <label for=\"serial-no\">${i18next.t('field.serial-no')}</label>\n <input id=\"serial-no\" type=\"text\" name=\"serialNo\" .value=${appliance.serialNo} />\n </div>\n\n <div field>\n <label for=\"model\">${i18next.t('field.model')}</label>\n <input id=\"model\" type=\"text\" name=\"model\" .value=${appliance.model} />\n </div>\n\n <div field>\n <label for=\"netmask\">${i18next.t('field.netmask')}</label>\n <input id=\"netmask\" type=\"text\" name=\"netmask\" .value=${appliance.netmask} />\n </div>\n </div>\n </fieldset>\n </div>\n\n <div fieldset-container>\n <fieldset>\n <legend>${i18next.t('text.appliance credential')}</legend>\n <div field-2column>\n <div field grid-span>\n <label for=\"access-token\">${i18next.t('label.access token')}</label>\n <input id=\"access-token\" type=\"text\" .value=${appliance.accessToken} readonly />\n <button button-in-field clipboard-copy @click=${e => e.preventDefault()}>\n ${i18next.t('button.copy')}\n </button>\n ${accessTokenExp\n ? html`<div input-hint>\n ${i18next.t('text.token expiry time')} ${new Date(accessTokenExp * 1000).toLocaleString()} :\n ${asyncReplace(this.expTimer(accessTokenExp))}\n </div>`\n : html``}\n </div>\n </div>\n </fieldset>\n </div>\n\n <button @click=${this.deleteAppliance.bind(this)}>${i18next.t('button.delete this appliance')}</button>\n <button @click=${this.generateApplianceSecret.bind(this)}>\n ${i18next.t('button.generate new access token')}\n </button>\n <button @click=${this.updateAppliance.bind(this)}>${i18next.t('button.update')}</button>\n </form>\n `\n }\n\n firstUpdated() { this.clipboard = new Clipboard(this.copybuttons, { target: (trigger => trigger.parentElement.querySelector('input')) as any\n })\n }\n\n updated(changes) { /*\n * If this page properties are changed, this callback will be invoked.\n * This callback will be called back only when this page is activated.\n */\n if (changes.has('appliance')) { const { accessToken } = this.appliance || {}\n this.accessToken = accessToken\n }\n\n if (changes.has('accessToken')) { this._accessTokenInfo = this.accessToken ? parseJwt(this.accessToken) : {}\n }\n }\n\n async pageUpdated(changes, lifecycle, before) { if (this.active) { await this.fetchAppliance()\n }\n }\n\n async fetchAppliance() { const response = await client.query({ query: gql`\n query ($id: String!) { appliance(id: $id) { id\n name\n description\n serialNo\n brand\n model\n netmask\n accessToken\n }\n }\n `,\n variables: { id: this.lifecycle.resourceId\n }\n })\n\n this.appliance = response.data.appliance\n }\n\n async updateAppliance(e) { e.preventDefault()\n\n const form = this.renderRoot.querySelector('form') as HTMLFormElement\n const formData = new FormData(form)\n\n const patch = Array.from(formData.entries()).reduce((patch, [key, value]) => { patch[key] = value\n return patch\n }, {})\n\n const id = this.lifecycle.resourceId\n\n const response = await client.mutate({ mutation: gql`\n mutation ($id: String!, $patch: AppliancePatch!) { updateAppliance(id: $id, patch: $patch) { id\n name\n description\n serialNo\n brand\n model\n netmask\n accessToken\n }\n }\n `,\n variables: { id,\n patch\n }\n })\n\n if (response.errors) { console.error('update fail')\n } else { this.appliance = response.data.updateAppliance\n console.log('update sucess')\n }\n }\n\n async deleteAppliance(e) { e.preventDefault()\n\n const id = this.lifecycle.resourceId\n\n const response = await client.mutate({ mutation: gql`\n mutation ($id: String!) { deleteAppliance(id: $id)\n }\n `,\n variables: { id\n }\n })\n\n if (response.errors) { console.error('delete fail')\n } else { navigate('appliance-home')\n }\n }\n\n async generateApplianceSecret(e) { e.preventDefault()\n\n const id = this.lifecycle.resourceId\n\n const response = await client.mutate({ mutation: gql`\n mutation ($id: String!) { generateApplianceSecret(id: $id) { id\n name\n description\n serialNo\n brand\n model\n netmask\n accessToken\n }\n }\n `,\n variables: { id\n }\n })\n\n if (response.errors) { console.error('generate-appliance-secret fail')\n } else { this.appliance = response.data.generateApplianceSecret\n console.log('generate-appliance-secret sucess')\n }\n }\n\n async *expTimer(exp) { const DAY = 24 * 60 * 60\n const HOUR = 60 * 60\n const MIN = 60\n\n while (this.active) { var remain = Math.floor(Number(exp) - Date.now() / 1000)\n const days = Math.floor(remain / DAY)\n remain -= days * DAY\n const hours = Math.floor(remain / HOUR)\n remain -= hours * HOUR\n const mins = Math.floor(remain / MIN)\n const secs = remain - mins * MIN\n\n yield i18next.t('text.remaining time', { days, hours, mins, secs })\n\n await sleep(1000)\n }\n }\n}\n"]}
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import { __decorate, __metadata } from "tslib";
|
|
2
|
-
import gql from 'graphql-tag';
|
|
3
|
-
import { css, html } from 'lit';
|
|
4
|
-
import { customElement, property, query } from 'lit/decorators.js';
|
|
5
|
-
import { client } from '@operato/graphql';
|
|
6
|
-
import { navigate, PageView } from '@operato/shell';
|
|
7
|
-
let ApplianceRegister = class ApplianceRegister extends PageView {
|
|
8
|
-
static get styles() {
|
|
9
|
-
return [
|
|
10
|
-
css `
|
|
11
|
-
:host { background-color: var(--md-sys-color-background);
|
|
12
|
-
padding: var(--spacing-large);
|
|
13
|
-
|
|
14
|
-
display: flex;
|
|
15
|
-
flex-direction: column;
|
|
16
|
-
|
|
17
|
-
align-items: center;
|
|
18
|
-
|
|
19
|
-
overflow: auto;
|
|
20
|
-
}
|
|
21
|
-
h2 { margin: var(--title-margin);
|
|
22
|
-
font: var(--title-font);
|
|
23
|
-
color: var(--title-text-color);
|
|
24
|
-
}
|
|
25
|
-
[page-description] { margin: var(--page-description-margin);
|
|
26
|
-
font: var(--page-description-font);
|
|
27
|
-
color: var(--page-description-color);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
[form-container] { background-color: var(--md-sys-color-surface);
|
|
31
|
-
padding: var(--spacing-large);
|
|
32
|
-
border-radius: var(--border-radius);
|
|
33
|
-
box-shadow: var(--box-shadow);
|
|
34
|
-
min-width: 60%;
|
|
35
|
-
max-width: var(--input-container-max-width);
|
|
36
|
-
position: relative;
|
|
37
|
-
clear: both;
|
|
38
|
-
}
|
|
39
|
-
label { font: var(--label-font);
|
|
40
|
-
color: var(--label-color, var(--md-sys-color-on-surface));
|
|
41
|
-
text-transform: var(--label-text-transform);
|
|
42
|
-
}
|
|
43
|
-
input {
|
|
44
|
-
background-color: var(--input-field-background, var(--md-sys-color-surface-container-highest));
|
|
45
|
-
color: var(--input-field-color, var(--md-sys-color-on-surface));
|
|
46
|
-
border: var(--border-dim-color);
|
|
47
|
-
border-radius: var(--border-radius);
|
|
48
|
-
margin: var(--input-margin);
|
|
49
|
-
padding: var(--input-padding);
|
|
50
|
-
font: var(--input-font);
|
|
51
|
-
|
|
52
|
-
flex: 1;
|
|
53
|
-
}
|
|
54
|
-
select:focus,
|
|
55
|
-
input:focus { outline: none;
|
|
56
|
-
}
|
|
57
|
-
[field-2column] { display: grid;
|
|
58
|
-
grid-template-columns: 1fr 1fr;
|
|
59
|
-
grid-gap: 15px;
|
|
60
|
-
max-width: var(--content-container-max-width);
|
|
61
|
-
}
|
|
62
|
-
[field] { display: flex;
|
|
63
|
-
flex-direction: column;
|
|
64
|
-
}
|
|
65
|
-
[grid-span] { grid-column: span 2;
|
|
66
|
-
}
|
|
67
|
-
@media screen and (max-width: 480px) { [form-container] { position: initial;
|
|
68
|
-
width: 100%;
|
|
69
|
-
}
|
|
70
|
-
[field] { grid-column: span 2;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
`
|
|
74
|
-
];
|
|
75
|
-
}
|
|
76
|
-
get context() {
|
|
77
|
-
return { title: `appliance registration`,
|
|
78
|
-
help: 'auth/appliance'
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
render() {
|
|
82
|
-
return html `
|
|
83
|
-
<h2>Register new appliance</h2>
|
|
84
|
-
<p page-description>You can register new appliance here</p>
|
|
85
|
-
|
|
86
|
-
<div form-container>
|
|
87
|
-
<form>
|
|
88
|
-
<div field-2column>
|
|
89
|
-
<div field grid-span>
|
|
90
|
-
<label for="name">name</label>
|
|
91
|
-
<input id="name" type="text" name="name" />
|
|
92
|
-
</div>
|
|
93
|
-
|
|
94
|
-
<div field grid-span>
|
|
95
|
-
<label for="description">description</label>
|
|
96
|
-
<input id="description" type="text" name="description" />
|
|
97
|
-
</div>
|
|
98
|
-
|
|
99
|
-
<div field>
|
|
100
|
-
<label for="brand">brand</label>
|
|
101
|
-
<input id="brand" type="text" name="brand" />
|
|
102
|
-
</div>
|
|
103
|
-
|
|
104
|
-
<div field>
|
|
105
|
-
<label for="serial-no">serial #</label>
|
|
106
|
-
<input id="serial-no" type="text" name="serialNo" />
|
|
107
|
-
</div>
|
|
108
|
-
|
|
109
|
-
<div field>
|
|
110
|
-
<label for="model">model</label>
|
|
111
|
-
<input id="model" type="text" name="model" />
|
|
112
|
-
</div>
|
|
113
|
-
|
|
114
|
-
<div field>
|
|
115
|
-
<label for="netmask">netmask</label>
|
|
116
|
-
<input id="netmask" type="text" name="netmask" />
|
|
117
|
-
</div>
|
|
118
|
-
|
|
119
|
-
<md-elevated-button grid-span @click=${this.createAppliance.bind(this)}>register</md-elevated-button>
|
|
120
|
-
</div>
|
|
121
|
-
</form>
|
|
122
|
-
</div>
|
|
123
|
-
`;
|
|
124
|
-
}
|
|
125
|
-
async createAppliance(e) {
|
|
126
|
-
e.preventDefault();
|
|
127
|
-
const form = this.renderRoot.querySelector('form');
|
|
128
|
-
const formData = new FormData(form);
|
|
129
|
-
const appliance = Array.from(formData.entries()).reduce((appliance, [key, value]) => {
|
|
130
|
-
appliance[key] = value;
|
|
131
|
-
return appliance;
|
|
132
|
-
}, {});
|
|
133
|
-
const response = await client.mutate({ mutation: gql `
|
|
134
|
-
mutation ($appliance: NewAppliance!) { createAppliance(appliance: $appliance) { id
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
`,
|
|
138
|
-
variables: { appliance
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
if (response.errors) {
|
|
142
|
-
console.log('creation fail.');
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
const id = response.data.createAppliance.id;
|
|
146
|
-
navigate(`appliance/${id}`);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
pageUpdated(changes, lifecycle, before) {
|
|
150
|
-
if (this.active) {
|
|
151
|
-
this.form.reset();
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
__decorate([
|
|
156
|
-
property({ type: Object }),
|
|
157
|
-
__metadata("design:type", Object)
|
|
158
|
-
], ApplianceRegister.prototype, "appliance", void 0);
|
|
159
|
-
__decorate([
|
|
160
|
-
query('form'),
|
|
161
|
-
__metadata("design:type", HTMLFormElement)
|
|
162
|
-
], ApplianceRegister.prototype, "form", void 0);
|
|
163
|
-
ApplianceRegister = __decorate([
|
|
164
|
-
customElement('appliance-register')
|
|
165
|
-
], ApplianceRegister);
|
|
166
|
-
//# sourceMappingURL=register.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"register.js","sourceRoot":"","sources":["../../../client/pages/appliance/register.ts"],"names":[],"mappings":";AAAA,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,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,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAGnD,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,QAAQ;IAAK,MAAM,KAAK,MAAM;QAAS,OAAO;YACxE,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,CAAC;IAEA,WAAW,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM;QAAQ,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAAO,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAA;QACzF,CAAC;IACD,CAAC;CACD,CAAA;AAhF6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;oDAAe;AAE3B;IAAd,KAAK,CAAC,MAAM,CAAC;8BAAQ,eAAe;+CAAA;AAtEjC,iBAAiB;IADtB,aAAa,CAAC,oBAAoB,CAAC;GAC9B,iBAAiB,CAoJtB","sourcesContent":["import gql from 'graphql-tag'\nimport { css, html } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\nimport { client } from '@operato/graphql'\nimport { navigate, PageView } from '@operato/shell'\n\n@customElement('appliance-register')\nclass ApplianceRegister extends PageView { static get styles() { return [\n css`\n :host { background-color: var(--md-sys-color-background);\n padding: var(--spacing-large);\n\n display: flex;\n flex-direction: column;\n\n align-items: center;\n\n overflow: auto;\n }\n h2 { margin: var(--title-margin);\n font: var(--title-font);\n color: var(--title-text-color);\n }\n [page-description] { margin: var(--page-description-margin);\n font: var(--page-description-font);\n color: var(--page-description-color);\n }\n\n [form-container] { background-color: var(--md-sys-color-surface);\n padding: var(--spacing-large);\n border-radius: var(--border-radius);\n box-shadow: var(--box-shadow);\n min-width: 60%;\n max-width: var(--input-container-max-width);\n position: relative;\n clear: both;\n }\n label { font: var(--label-font);\n color: var(--label-color, var(--md-sys-color-on-surface));\n text-transform: var(--label-text-transform);\n }\n input {\n background-color: var(--input-field-background, var(--md-sys-color-surface-container-highest));\n color: var(--input-field-color, var(--md-sys-color-on-surface));\n border: var(--border-dim-color);\n border-radius: var(--border-radius);\n margin: var(--input-margin);\n padding: var(--input-padding);\n font: var(--input-font);\n\n flex: 1;\n }\n select:focus,\n input:focus { outline: none;\n }\n [field-2column] { display: grid;\n grid-template-columns: 1fr 1fr;\n grid-gap: 15px;\n max-width: var(--content-container-max-width);\n }\n [field] { display: flex;\n flex-direction: column;\n }\n [grid-span] { grid-column: span 2;\n }\n @media screen and (max-width: 480px) { [form-container] { position: initial;\n width: 100%;\n }\n [field] { grid-column: span 2;\n }\n }\n `\n ]\n }\n\n @property({ type: Object }) appliance: any\n\n @query('form') form!: HTMLFormElement\n\n get context() { return { title: `appliance registration`,\n help: 'auth/appliance'\n }\n }\n\n render() { return html`\n <h2>Register new appliance</h2>\n <p page-description>You can register new appliance here</p>\n\n <div form-container>\n <form>\n <div field-2column>\n <div field grid-span>\n <label for=\"name\">name</label>\n <input id=\"name\" type=\"text\" name=\"name\" />\n </div>\n\n <div field grid-span>\n <label for=\"description\">description</label>\n <input id=\"description\" type=\"text\" name=\"description\" />\n </div>\n\n <div field>\n <label for=\"brand\">brand</label>\n <input id=\"brand\" type=\"text\" name=\"brand\" />\n </div>\n\n <div field>\n <label for=\"serial-no\">serial #</label>\n <input id=\"serial-no\" type=\"text\" name=\"serialNo\" />\n </div>\n\n <div field>\n <label for=\"model\">model</label>\n <input id=\"model\" type=\"text\" name=\"model\" />\n </div>\n\n <div field>\n <label for=\"netmask\">netmask</label>\n <input id=\"netmask\" type=\"text\" name=\"netmask\" />\n </div>\n\n <md-elevated-button grid-span @click=${this.createAppliance.bind(this)}>register</md-elevated-button>\n </div>\n </form>\n </div>\n `\n }\n\n async createAppliance(e) { e.preventDefault()\n\n const form = this.renderRoot.querySelector('form') as HTMLFormElement\n const formData = new FormData(form)\n\n const appliance = Array.from(formData.entries()).reduce((appliance, [key, value]) => { appliance[key] = value\n return appliance\n }, {})\n\n const response = await client.mutate({ mutation: gql`\n mutation ($appliance: NewAppliance!) { createAppliance(appliance: $appliance) { id\n }\n }\n `,\n variables: { appliance\n }\n })\n\n if (response.errors) { console.log('creation fail.')\n } else { const id = response.data.createAppliance.id\n navigate(`appliance/${id}`)\n }\n }\n\n pageUpdated(changes, lifecycle, before) { if (this.active) { this.form.reset()\n }\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import '@material/web/icon/icon.js';
|