@things-factory/auth-ui 8.0.38 → 9.0.0-9.0.0-beta.59.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/dist-client/components/abstract-auth-page.d.ts +1 -1
  2. package/dist-client/components/abstract-auth-page.js +2 -0
  3. package/dist-client/components/abstract-auth-page.js.map +1 -1
  4. package/dist-client/components/abstract-password-reset.d.ts +2 -2
  5. package/dist-client/components/abstract-password-reset.js +5 -5
  6. package/dist-client/components/abstract-password-reset.js.map +1 -1
  7. package/dist-client/components/change-password.js +1 -1
  8. package/dist-client/components/change-password.js.map +1 -1
  9. package/dist-client/components/invite-user.d.ts +1 -1
  10. package/dist-client/components/invite-user.js +1 -2
  11. package/dist-client/components/invite-user.js.map +1 -1
  12. package/dist-client/components/partner-role-editor.js +1 -1
  13. package/dist-client/components/partner-role-editor.js.map +1 -1
  14. package/dist-client/components/profile-component.d.ts +3 -3
  15. package/dist-client/components/profile-component.js +3 -3
  16. package/dist-client/components/profile-component.js.map +1 -1
  17. package/dist-client/components/role-privilege-editor.js +2 -1
  18. package/dist-client/components/role-privilege-editor.js.map +1 -1
  19. package/dist-client/components/user-role-editor.d.ts +2 -2
  20. package/dist-client/components/user-role-editor.js +2 -2
  21. package/dist-client/components/user-role-editor.js.map +1 -1
  22. package/dist-client/constants/index.d.ts +1 -1
  23. package/dist-client/constants/index.js +1 -1
  24. package/dist-client/constants/index.js.map +1 -1
  25. package/dist-client/entries/auth/activate.d.ts +1 -1
  26. package/dist-client/entries/auth/activate.js +1 -1
  27. package/dist-client/entries/auth/activate.js.map +1 -1
  28. package/dist-client/entries/auth/checkin.js +2 -2
  29. package/dist-client/entries/auth/checkin.js.map +1 -1
  30. package/dist-client/entries/auth/forgot-password.d.ts +2 -2
  31. package/dist-client/entries/auth/forgot-password.js +11 -3
  32. package/dist-client/entries/auth/forgot-password.js.map +1 -1
  33. package/dist-client/entries/auth/reset-password.d.ts +1 -1
  34. package/dist-client/entries/auth/reset-password.js +1 -1
  35. package/dist-client/entries/auth/reset-password.js.map +1 -1
  36. package/dist-client/entries/auth/result.d.ts +1 -1
  37. package/dist-client/entries/auth/result.js +1 -1
  38. package/dist-client/entries/auth/result.js.map +1 -1
  39. package/dist-client/entries/auth/signin.d.ts +1 -1
  40. package/dist-client/entries/auth/signin.js +1 -1
  41. package/dist-client/entries/auth/signin.js.map +1 -1
  42. package/dist-client/entries/auth/signup.d.ts +3 -1
  43. package/dist-client/entries/auth/signup.js +32 -2
  44. package/dist-client/entries/auth/signup.js.map +1 -1
  45. package/dist-client/entries/auth/unlock-user.d.ts +1 -1
  46. package/dist-client/entries/auth/unlock-user.js +1 -1
  47. package/dist-client/entries/auth/unlock-user.js.map +1 -1
  48. package/dist-client/entries/oauth2/oauth2-decision-page.d.ts +1 -1
  49. package/dist-client/entries/oauth2/oauth2-decision-page.js +1 -1
  50. package/dist-client/entries/oauth2/oauth2-decision-page.js.map +1 -1
  51. package/dist-client/entries/public/home.js +2 -2
  52. package/dist-client/entries/public/home.js.map +1 -1
  53. package/dist-client/pages/application/application.js +1 -1
  54. package/dist-client/pages/application/application.js.map +1 -1
  55. package/dist-client/pages/domain/domain-management.d.ts +1 -1
  56. package/dist-client/pages/domain/domain-management.js +1 -1
  57. package/dist-client/pages/domain/domain-management.js.map +1 -1
  58. package/dist-client/pages/domain-link/domain-link-management.d.ts +53 -0
  59. package/dist-client/pages/domain-link/domain-link-management.js +353 -0
  60. package/dist-client/pages/domain-link/domain-link-management.js.map +1 -0
  61. package/dist-client/pages/partner/partner-management.d.ts +3 -3
  62. package/dist-client/pages/partner/partner-management.js +3 -3
  63. package/dist-client/pages/partner/partner-management.js.map +1 -1
  64. package/dist-client/pages/profile.d.ts +1 -1
  65. package/dist-client/pages/profile.js +1 -1
  66. package/dist-client/pages/profile.js.map +1 -1
  67. package/dist-client/pages/role/role-management.d.ts +3 -3
  68. package/dist-client/pages/role/role-management.js +3 -3
  69. package/dist-client/pages/role/role-management.js.map +1 -1
  70. package/dist-client/pages/user/user-management.d.ts +4 -4
  71. package/dist-client/pages/user/user-management.js +4 -4
  72. package/dist-client/pages/user/user-management.js.map +1 -1
  73. package/dist-client/route.js +3 -0
  74. package/dist-client/route.js.map +1 -1
  75. package/dist-client/tsconfig.tsbuildinfo +1 -1
  76. package/dist-server/tsconfig.tsbuildinfo +1 -1
  77. package/helps/auth/domain-link.md +178 -0
  78. package/package.json +12 -12
  79. package/things-factory.config.js +2 -1
  80. package/translations/en.json +7 -0
  81. package/translations/ja.json +7 -0
  82. package/translations/ko.json +7 -0
  83. package/translations/ms.json +7 -0
  84. package/translations/zh.json +7 -0
  85. package/client/auth-style-sign.ts +0 -194
  86. package/client/bootstrap.ts +0 -55
  87. package/client/components/abstract-auth-page.ts +0 -301
  88. package/client/components/abstract-password-reset.ts +0 -163
  89. package/client/components/abstract-sign.ts +0 -127
  90. package/client/components/change-password.ts +0 -153
  91. package/client/components/contact-us.ts +0 -116
  92. package/client/components/create-domain-popup.ts +0 -141
  93. package/client/components/create-role.ts +0 -123
  94. package/client/components/create-user.ts +0 -117
  95. package/client/components/credential-manager.ts +0 -64
  96. package/client/components/delete-user-popup.ts +0 -117
  97. package/client/components/domain-switch.ts +0 -127
  98. package/client/components/invite-customer.ts +0 -104
  99. package/client/components/invite-user.ts +0 -104
  100. package/client/components/my-login-history.ts +0 -101
  101. package/client/components/ownership-transfer-popup.ts +0 -110
  102. package/client/components/partner-info-card.ts +0 -89
  103. package/client/components/partner-role-editor.ts +0 -153
  104. package/client/components/profile-component.ts +0 -392
  105. package/client/components/role-edit-form.ts +0 -92
  106. package/client/components/role-privilege-editor.ts +0 -267
  107. package/client/components/role-selector.ts +0 -102
  108. package/client/components/user-role-editor.ts +0 -499
  109. package/client/constants/application.ts +0 -9
  110. package/client/constants/index.ts +0 -1
  111. package/client/entries/auth/activate.ts +0 -272
  112. package/client/entries/auth/checkin.ts +0 -183
  113. package/client/entries/auth/forgot-password.ts +0 -104
  114. package/client/entries/auth/reset-password.ts +0 -22
  115. package/client/entries/auth/result.ts +0 -193
  116. package/client/entries/auth/signin.ts +0 -18
  117. package/client/entries/auth/signup.ts +0 -115
  118. package/client/entries/auth/unlock-user.ts +0 -22
  119. package/client/entries/oauth2/oauth2-decision-error-page.ts +0 -50
  120. package/client/entries/oauth2/oauth2-decision-page.ts +0 -196
  121. package/client/entries/public/home.ts +0 -246
  122. package/client/index.ts +0 -124
  123. package/client/pages/app-binding/app-binding.ts +0 -423
  124. package/client/pages/app-binding/app-bindings.ts +0 -171
  125. package/client/pages/appliance/appliance.ts +0 -452
  126. package/client/pages/appliance/home.ts +0 -177
  127. package/client/pages/appliance/register.ts +0 -183
  128. package/client/pages/application/application.ts +0 -428
  129. package/client/pages/application/applications.ts +0 -182
  130. package/client/pages/application/register.ts +0 -211
  131. package/client/pages/attribute/attribute-set-item-list.ts +0 -237
  132. package/client/pages/attribute/attribute-set-management.ts +0 -282
  133. package/client/pages/auth-provider/auth-provider-management.ts +0 -381
  134. package/client/pages/domain/domain-management.ts +0 -431
  135. package/client/pages/partner/partner-management.ts +0 -112
  136. package/client/pages/profile.ts +0 -32
  137. package/client/pages/role/role-management.ts +0 -134
  138. package/client/pages/user/user-management.ts +0 -223
  139. package/client/route.ts +0 -67
  140. package/client/themes/auth-theme.css +0 -65
  141. package/client/utils/password-rule.ts +0 -37
  142. package/server/index.ts +0 -0
@@ -1,127 +0,0 @@
1
- import '@operato/i18n/ox-i18n.js'
2
-
3
- import { html, nothing } from 'lit'
4
- import { startAuthentication } from '@simplewebauthn/browser'
5
-
6
- import { i18next } from '@operato/i18n'
7
- import { notify } from '@operato/layout'
8
-
9
- import { AbstractAuthPage } from './abstract-auth-page.js'
10
-
11
- const isAvailableWebauthn = 'PublicKeyCredential' in window
12
-
13
- interface AssertionResponse {
14
- id: string
15
- rawId?: number[]
16
- response: {
17
- authenticatorData: string
18
- clientDataJSON: string
19
- signature: string
20
- userHandle: string | null
21
- }
22
- type: PublicKeyCredentialType
23
- authenticatorAttachment?: AuthenticatorAttachment
24
- }
25
-
26
- export abstract class AbstractSign extends AbstractAuthPage {
27
- async submit() {
28
- this.formEl.submit()
29
- }
30
-
31
- updated(changed) {
32
- super.updated(changed)
33
-
34
- if (changed.has('message')) {
35
- if (!this.message) {
36
- this.hideSnackbar()
37
- } else {
38
- this.showSnackbar({
39
- level: 'error',
40
- timer: -1
41
- })
42
- }
43
- }
44
- }
45
-
46
- get formfields() {
47
- const username = this.data?.username || ''
48
- const autocompletable = this.autocompletable
49
-
50
- return html`
51
- <input id="redirectTo" type="hidden" name="redirectTo" .value=${this.redirectTo || '/'} />
52
-
53
- <div class="field">
54
- <md-filled-text-field
55
- name="username"
56
- type="text"
57
- label=${String(i18next.t('field.user-id or email'))}
58
- required
59
- .value=${username}
60
- autocomplete=${autocompletable ? 'username' : 'off'}
61
- autocapitalize="off"
62
- pattern="^(?:[A-Za-z0-9]*|[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+.[A-Za-z]{2,})$"
63
- @input=${(e: Event) => {
64
- const target = e.target as HTMLInputElement
65
- if (target.validity.typeMismatch) {
66
- target.setCustomValidity(i18next.t('text.invalid-username'))
67
- } else {
68
- target.setCustomValidity('')
69
- }
70
- }}
71
- ><md-icon slot="leading-icon">id_card</md-icon></md-filled-text-field
72
- >
73
- </div>
74
- <div class="field">
75
- <md-filled-text-field
76
- name="password"
77
- type="password"
78
- label=${String(i18next.t('field.password'))}
79
- autocomplete=${autocompletable ? 'current-password' : 'off'}
80
- required
81
- ><md-icon slot="leading-icon">password</md-icon></md-filled-text-field
82
- >
83
- </div>
84
-
85
- <div class="submit-buttons-container">
86
- <md-elevated-button class="submit-button" type="button" raised @click=${e => this._onSubmit(e)}>
87
- <ox-i18n msgid="field.${this.pageName}"> </ox-i18n>
88
- </md-elevated-button>
89
- ${isAvailableWebauthn
90
- ? html` <md-icon class="fingerprint" raised @click=${e => this.authenticateUser()}> fingerprint </md-icon>`
91
- : nothing}
92
- </div>
93
- `
94
- }
95
-
96
- async authenticateUser() {
97
- try {
98
- const options = await fetch('/auth/signin-webauthn/challenge').then(res => res.json())
99
- const assertionResp = await startAuthentication(options)
100
- const verification = await fetch('/auth/signin-webauthn', {
101
- method: 'POST',
102
- headers: {
103
- 'Content-Type': 'application/json'
104
- },
105
- body: JSON.stringify(assertionResp)
106
- }).then(res => res.json())
107
-
108
- if (verification.verified) {
109
- const { redirectURL } = verification
110
-
111
- if (redirectURL) {
112
- window.location.href = redirectURL
113
- }
114
- } else {
115
- notify({
116
- level: 'error',
117
- message: verification.message
118
- })
119
- }
120
- } catch (error) {
121
- notify({
122
- level: 'error',
123
- message: i18next.t('error.authn verification failed')
124
- })
125
- }
126
- }
127
- }
@@ -1,153 +0,0 @@
1
- import { css, html, LitElement, PropertyValues } from 'lit'
2
- import { customElement, property, query } from 'lit/decorators.js'
3
-
4
- import { i18next, localize } from '@operato/i18n'
5
- import { auth } from '@things-factory/auth-base/dist-client/auth.js'
6
- import { generatePasswordPatternHelp, generatePasswordPatternRegExp } from '../utils/password-rule'
7
-
8
- @customElement('change-password')
9
- export class ChangePassword extends localize(i18next)(LitElement) {
10
- static styles = [
11
- css`
12
- * {
13
- box-sizing: border-box;
14
- }
15
-
16
- *:focus {
17
- outline: none;
18
- }
19
-
20
- form {
21
- display: flex;
22
- flex-direction: column;
23
- }
24
-
25
- input {
26
- border: var(--change-password-field-border);
27
- border-radius: var(--change-password-field-border-radius);
28
- margin: var(--change-password-field-margin);
29
- padding: var(--change-password-field-padding);
30
-
31
- font: var(--change-password-field-font);
32
- width: var(--change-password-field-width);
33
- }
34
-
35
- input:focus {
36
- border: 1px solid var(--focus-background-color);
37
- }
38
-
39
- ::placeholder {
40
- font-size: 0.8rem;
41
- text-transform: capitalize;
42
- }
43
-
44
- md-elevated-button {
45
- margin: var(--spacing-small) auto var(--spacing-medium) auto;
46
- text-transform: capitalize;
47
- }
48
-
49
- button {
50
- background-color: var(--secondary-color, #394e64);
51
- margin: 2px 2px 10px 2px;
52
- height: var(--button-height, 28px);
53
- color: var(--button-color, #fff);
54
- font: var(--button-font);
55
- border-radius: var(--button-radius, 5px);
56
- border: var(--button-border, 1px solid transparent);
57
- line-height: 1.5;
58
- }
59
-
60
- button:hover,
61
- button:active {
62
- background-color: var(--button-active-background-color, #22a6a7);
63
- border: var(--button-active-border);
64
- }
65
-
66
- .helper-text {
67
- font-size: 12px;
68
- color: var(--md-sys-color-) #6c757d;
69
- margin-top: 4px;
70
- display: block; /* 텍스트를 입력 필드 아래에 배치 */
71
- line-height: 1.5; /* 텍스트 줄 간격 조절 */
72
- }
73
- `
74
- ]
75
-
76
- @property({ type: Object }) passwordRule: {
77
- lowerCase?: boolean
78
- upperCase?: boolean
79
- digit?: boolean
80
- specialCharacter?: boolean
81
- allowRepeat?: boolean
82
- useTightPattern?: boolean
83
- useLoosePattern?: boolean
84
- tightCharacterLength?: number
85
- looseCharacterLength?: number
86
- } = {}
87
-
88
- @query('form') form!: HTMLFormElement
89
-
90
- private passwordPattern: string = ''
91
- private passwordHelp: string = ''
92
-
93
- render() {
94
- return html`
95
- <form>
96
- <div class="field">
97
- <input type="password" name="current_pass" placeholder=${i18next.t('text.current password')} required />
98
- </div>
99
- <span id="password-helper" class="helper-text">${this.passwordHelp}</span>
100
- <div class="field">
101
- <input
102
- type="password"
103
- name="new_pass"
104
- placeholder=${i18next.t('text.new password')}
105
- required
106
- pattern=${this.passwordPattern}
107
- aria-describedby="password-helper"
108
- />
109
- </div>
110
- <div class="field">
111
- <input type="password" name="confirm_pass" placeholder=${i18next.t('text.confirm password')} required />
112
- </div>
113
-
114
- <md-elevated-button @click=${this.submit.bind(this)}>${i18next.t('text.change password')}</md-elevated-button>
115
- </form>
116
- `
117
- }
118
-
119
- updated(changes: PropertyValues<this>) {
120
- if (changes.has('passwordRule')) {
121
- this.passwordPattern = generatePasswordPatternRegExp(this.passwordRule).source
122
- this.passwordHelp = generatePasswordPatternHelp(this.passwordRule)
123
- }
124
- }
125
-
126
- languageUpdated() {
127
- this.passwordPattern = generatePasswordPatternRegExp(this.passwordRule).source
128
- this.passwordHelp = generatePasswordPatternHelp(this.passwordRule)
129
- }
130
-
131
- async submit() {
132
- const formData = new FormData(this.form)
133
- let params = {}
134
- for (const [key, value] of formData.entries()) {
135
- if (!value) {
136
- const placeholder = (this.form.querySelector(`[name=${key}]`) as HTMLInputElement)?.placeholder
137
- return this.showToast(i18next.t('error.value is empty', { value: placeholder || key }))
138
- }
139
- params[key] = value
140
- }
141
-
142
- if (params['new_pass'] !== params['confirm_pass']) {
143
- return this.showToast(i18next.t('error.new-password-and-confirm-password-do-not-match'))
144
- }
145
-
146
- auth.changePassword(params)
147
- this.form.reset()
148
- }
149
-
150
- showToast(message) {
151
- document.dispatchEvent(new CustomEvent('notify', { detail: { message } }))
152
- }
153
- }
@@ -1,116 +0,0 @@
1
- import '@material/web/button/text-button.js'
2
- import '@material/web/button/elevated-button.js'
3
- import '@material/web/textfield/filled-text-field.js'
4
- import '@material/web/dialog/dialog.js'
5
-
6
- import '@operato/i18n'
7
-
8
- import { css, html, LitElement } from 'lit'
9
- import { customElement, query } from 'lit/decorators.js'
10
-
11
- import { i18next, localize } from '@operato/i18n'
12
- import { auth } from '@things-factory/auth-base/dist-client/auth.js'
13
-
14
- @customElement('contact-us')
15
- export class ContactUs extends localize(i18next)(LitElement) {
16
- static get styles() {
17
- return [
18
- css`
19
- * {
20
- box-sizing: border-box;
21
- }
22
-
23
- *:focus {
24
- outline: none;
25
- }
26
-
27
- #input-form {
28
- display: grid;
29
- grid-template-rows: 1fr 1fr 3fr;
30
- grid-gap: 10px 0;
31
- }
32
- `
33
- ]
34
- }
35
-
36
- @query('#dialog') dialog!: HTMLElement & { show: () => void }
37
- @query('#subject-input') subjectInput!: HTMLInputElement
38
- @query('#sender-input') senderInput!: HTMLInputElement
39
- @query('#content-input') contentInput!: HTMLInputElement
40
-
41
- render() {
42
- return html`
43
- <md-elevated-button @click=${e => this.dialog.show()}>${i18next.t('button.need help')}</md-elevated-button>
44
-
45
- <md-dialog id="dialog" heading=${i18next.t('title.need help')}>
46
- <form action="" method="post">
47
- <input id="subject-input" name="subject" type="hidden" />
48
- <input id="sender-input" name="sender" type="hidden" />
49
- <input id="content-input" name="content" type="hidden" />
50
- </form>
51
-
52
- <div id="input-form" slot="content">
53
- <md-filled-text-field
54
- type="text"
55
- label=${i18next.t('label.subject')}
56
- dialogInitialFocus
57
- required
58
- @input=${e => {
59
- const val = e.target.value
60
- this.subjectInput.value = val
61
- }}
62
- ></md-filled-text-field>
63
-
64
- <md-filled-text-field
65
- type="text"
66
- name="sender"
67
- label=${i18next.t('label.email')}
68
- required
69
- @input=${e => {
70
- const val = e.target.value
71
- this.senderInput.value = val
72
- }}
73
- ></md-filled-text-field>
74
-
75
- <md-filled-text-field
76
- name="content"
77
- type="textarea"
78
- label=${i18next.t('label.content')}
79
- required
80
- @keydown=${e => e.stopPropagation()}
81
- @input=${e => {
82
- const val = e.target.value
83
- this.contentInput.value = val
84
- }}
85
- ></md-filled-text-field>
86
-
87
- <md-elevated-button slot="primaryAction" type="button" @click=${e => this._submit(e)}
88
- >${i18next.t('button.submit')}</md-elevated-button
89
- >
90
- </div>
91
- </md-dialog>
92
- `
93
- }
94
-
95
- _checkValidity(): boolean {
96
- return false
97
- }
98
-
99
- _submit(e: MouseEvent) {
100
- if (!this._checkValidity()) return
101
-
102
- const form = e.target as HTMLFormElement
103
-
104
- const formData = new FormData(form)
105
- let json = {}
106
-
107
- //convert form into json
108
- for (const [key, value] of formData.entries()) {
109
- json[key] = value
110
- }
111
-
112
- auth.changePassword(json)
113
-
114
- form.reset()
115
- }
116
- }
@@ -1,141 +0,0 @@
1
- import '@material/web/icon/icon.js'
2
-
3
- import gql from 'graphql-tag'
4
- import { css, html, LitElement } from 'lit'
5
- import { customElement, query } from 'lit/decorators.js'
6
-
7
- import { client } from '@operato/graphql'
8
- import { i18next, localize } from '@operato/i18n'
9
- import { OxPrompt } from '@operato/popup/ox-prompt.js'
10
- import { CommonHeaderStyles } from '@operato/styles'
11
-
12
- @customElement('create-domain-popup')
13
- class CreateDomainPopup extends localize(i18next)(LitElement) {
14
- static styles = [
15
- CommonHeaderStyles,
16
- css`
17
- :host {
18
- display: flex;
19
- flex-direction: column;
20
- background-color: var(--md-sys-color-background);
21
- overflow: auto;
22
- }
23
-
24
- form {
25
- flex: 1;
26
- padding: var(--spacing-large);
27
- }
28
-
29
- input.checkValidName {
30
- background-color: #fce6e6;
31
- }
32
-
33
- label {
34
- display: flex;
35
- flex-direction: column;
36
-
37
- font: var(--label-font);
38
- color: var(--label-color, var(--md-sys-color-on-surface));
39
- text-transform: var(--label-text-transform);
40
- }
41
-
42
- input {
43
- border: var(--border-dim-color);
44
- border-radius: var(--border-radius);
45
- margin: var(--input-margin);
46
- padding: var(--input-padding);
47
- background-color: var(--md-sys-color-surface);
48
- font: var(--input-font);
49
- }
50
-
51
- [field] {
52
- grid-column: span 2;
53
- }
54
- `
55
- ]
56
-
57
- @query('input[name="name"]') nameInput!: HTMLInputElement
58
-
59
- render() {
60
- return html`
61
- <form>
62
- <div field grid-span>
63
- <label
64
- >${i18next.t('label.x name', { x: i18next.t('label.domain') })}<input
65
- type="text"
66
- name="name"
67
- @input=${this.checkValidation}
68
- autofocus
69
- /></label>
70
- </div>
71
-
72
- <div field grid-span>
73
- <label>${i18next.t('label.description')}<input type="text" name="description" /></label>
74
- </div>
75
- </form>
76
-
77
- <div class="footer">
78
- <div filler></div>
79
- <button @click=${e => this.onCreateDomain()} done><md-icon>add</md-icon>${i18next.t('button.create')}</button>
80
- </div>
81
- `
82
- }
83
-
84
- firstUpdated() {
85
- this.nameInput.focus() // autofocus
86
- }
87
-
88
- get inputData() {
89
- return this.renderRoot.querySelectorAll('input')
90
- }
91
-
92
- checkValidation(e) {
93
- const currentInput = e.currentTarget
94
- const regExp = /^[a-zA-Z ]+$/
95
-
96
- if (!regExp.test(currentInput.value)) {
97
- currentInput.classList.add('checkValidName')
98
- } else {
99
- currentInput.classList.remove('checkValidName')
100
- }
101
- }
102
-
103
- async onCreateDomain() {
104
- const domainInput: { [prop: string]: string } = {}
105
- this.inputData.forEach(data => (domainInput[data.name] = data.value))
106
- const regExp = /^[a-zA-z0-9- ]+$/
107
-
108
- if (!regExp.test(domainInput.name)) {
109
- return this.showToast(i18next.t('error: domain name should consist only of letters or dashes'))
110
- }
111
-
112
- const response = await client.mutate({
113
- mutation: gql`
114
- mutation domainRegister($domainInput: DomainGeneratorInput!) {
115
- domainRegister(domainInput: $domainInput) {
116
- id
117
- name
118
- }
119
- }
120
- `,
121
- variables: { domainInput }
122
- })
123
-
124
- if (!response.errors) {
125
- await OxPrompt.open({
126
- type: 'success',
127
- title: i18next.t('text.completed'),
128
- text: i18next.t('text.x_created_successfully', { x: i18next.t('label.domain') }),
129
- confirmButton: { text: i18next.t('button.confirm') }
130
- })
131
-
132
- history.back()
133
-
134
- this.dispatchEvent(new CustomEvent('fetch-data'))
135
- }
136
- }
137
-
138
- showToast(message) {
139
- document.dispatchEvent(new CustomEvent('notify', { detail: { message } }))
140
- }
141
- }
@@ -1,123 +0,0 @@
1
- import '@material/web/textfield/filled-text-field.js'
2
-
3
- import gql from 'graphql-tag'
4
- import { css, html, LitElement } from 'lit'
5
- import { customElement, query } from 'lit/decorators.js'
6
-
7
- import { client, gqlContext } from '@operato/graphql'
8
- import { i18next, localize } from '@operato/i18n'
9
- import { OxPrompt } from '@operato/popup/ox-prompt.js'
10
-
11
- @customElement('create-role')
12
- class CreateRole extends localize(i18next)(LitElement) {
13
- static styles = css`
14
- :host {
15
- --md-text-field-fill-color: var(--md-sys-color-on-primary);
16
- background-color: var(--md-sys-color-surface);
17
- margin: var(--spacing-large) 0;
18
- padding: var(--spacing-large);
19
- border-radius: var(--border-radius);
20
- box-shadow: var(--box-shadow);
21
-
22
- display: grid;
23
- grid-template-columns: 1fr 2fr auto;
24
- gap: 5px 15px;
25
- clear: both;
26
- max-width: var(--input-container-max-width);
27
-
28
- align-items: center;
29
- }
30
-
31
- md-outlined-button {
32
- margin: var(--input-margin);
33
- text-transform: capitalize;
34
- }
35
-
36
- @media screen and (max-width: 480px) {
37
- :host {
38
- grid-template-columns: 1fr 1fr;
39
- }
40
-
41
- md-outlined-button {
42
- grid-column: span 2;
43
-
44
- margin: var(--input-margin);
45
- }
46
- }
47
- `
48
-
49
- @query('[name=name]') nameInput!: HTMLInputElement
50
- @query('[name=description]') descriptionInput!: HTMLInputElement
51
-
52
- render() {
53
- return html`
54
- <md-filled-text-field
55
- type="text"
56
- name="name"
57
- label=${String(i18next.t('label.x name', { x: i18next.t('label.role') }))}
58
- ></md-filled-text-field>
59
- <md-filled-text-field
60
- type="text"
61
- name="description"
62
- label=${String(i18next.t('label.x description', { x: i18next.t('label.role') }))}
63
- ></md-filled-text-field>
64
-
65
- <md-outlined-button @click=${this.onCreateRole.bind(this)}
66
- >${String(i18next.t('button.create'))}</md-outlined-button
67
- >
68
- `
69
- }
70
-
71
- async onCreateRole() {
72
- let role: { name?: string; description?: string } = {}
73
-
74
- const name = this.nameInput.value.trim()
75
- const description = this.descriptionInput.value
76
-
77
- if (!name) {
78
- return this.showToast(i18next.t('error.value is empty', { value: i18next.t('field.name') }))
79
- }
80
-
81
- role.name = name
82
- role.description = description
83
-
84
- if (
85
- await OxPrompt.open({
86
- title: i18next.t('text.are_you_sure'),
87
- text: i18next.t('text.do_you_want_to_create_x', { x: i18next.t('label.role') }),
88
- confirmButton: { text: i18next.t('button.confirm') },
89
- cancelButton: { text: i18next.t('button.cancel') }
90
- })
91
- ) {
92
- const response = await client.mutate({
93
- mutation: gql`
94
- mutation createRole($role: NewRole!) {
95
- createRole(role: $role) {
96
- name
97
- }
98
- }
99
- `,
100
- variables: { role },
101
- context: gqlContext()
102
- })
103
-
104
- if (!response.errors) {
105
- await this.dispatchEvent(new CustomEvent('fetch-roles'))
106
-
107
- await OxPrompt.open({
108
- type: 'success',
109
- title: i18next.t('text.completed'),
110
- text: i18next.t('text.data_uploaded_successfully'),
111
- confirmButton: { text: i18next.t('button.confirm') }
112
- })
113
-
114
- this.nameInput.value = ''
115
- this.descriptionInput.value = ''
116
- }
117
- }
118
- }
119
-
120
- showToast(message) {
121
- document.dispatchEvent(new CustomEvent('notify', { detail: { message, option: { timer: 1000 } } }))
122
- }
123
- }