@things-factory/auth-ui 8.0.0-beta.1 → 8.0.0-beta.4
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/package.json +4 -4
- package/client/auth-style-sign.ts +0 -194
- package/client/bootstrap.ts +0 -51
- package/client/components/abstract-auth-page.ts +0 -301
- package/client/components/abstract-password-reset.ts +0 -163
- package/client/components/abstract-sign.ts +0 -127
- package/client/components/change-password.ts +0 -153
- package/client/components/contact-us.ts +0 -116
- package/client/components/create-domain-popup.ts +0 -141
- package/client/components/create-role.ts +0 -123
- package/client/components/create-user.ts +0 -117
- package/client/components/credential-manager.ts +0 -64
- package/client/components/delete-user-popup.ts +0 -117
- package/client/components/domain-switch.ts +0 -127
- package/client/components/invite-customer.ts +0 -104
- package/client/components/invite-user.ts +0 -104
- package/client/components/my-login-history.ts +0 -101
- package/client/components/ownership-transfer-popup.ts +0 -110
- package/client/components/partner-info-card.ts +0 -89
- package/client/components/partner-role-editor.ts +0 -153
- package/client/components/profile-component.ts +0 -392
- package/client/components/role-edit-form.ts +0 -92
- package/client/components/role-privilege-editor.ts +0 -268
- package/client/components/role-selector.ts +0 -102
- package/client/components/user-role-editor.ts +0 -499
- package/client/constants/application.ts +0 -9
- package/client/constants/index.ts +0 -1
- package/client/entries/auth/activate.ts +0 -272
- package/client/entries/auth/checkin.ts +0 -190
- package/client/entries/auth/forgot-password.ts +0 -112
- package/client/entries/auth/reset-password.ts +0 -22
- package/client/entries/auth/result.ts +0 -193
- package/client/entries/auth/signin.ts +0 -18
- package/client/entries/auth/signup.ts +0 -115
- package/client/entries/auth/unlock-user.ts +0 -22
- package/client/entries/oauth2/oauth2-decision-error-page.ts +0 -50
- package/client/entries/oauth2/oauth2-decision-page.ts +0 -196
- package/client/entries/public/home.ts +0 -246
- package/client/index.ts +0 -124
- package/client/pages/app-binding/app-binding.ts +0 -423
- package/client/pages/app-binding/app-bindings.ts +0 -171
- package/client/pages/appliance/appliance.ts +0 -452
- package/client/pages/appliance/home.ts +0 -177
- package/client/pages/appliance/register.ts +0 -183
- package/client/pages/application/application.ts +0 -428
- package/client/pages/application/applications.ts +0 -182
- package/client/pages/application/register.ts +0 -211
- package/client/pages/attribute/attribute-set-item-list.ts +0 -237
- package/client/pages/attribute/attribute-set-management.ts +0 -282
- package/client/pages/auth-provider/auth-provider-management.ts +0 -381
- package/client/pages/domain/domain-management.ts +0 -410
- package/client/pages/partner/partner-management.ts +0 -112
- package/client/pages/profile.ts +0 -32
- package/client/pages/role/role-management.ts +0 -134
- package/client/pages/user/user-management.ts +0 -223
- package/client/route.ts +0 -67
- package/client/themes/auth-theme.css +0 -65
- package/client/utils/password-rule.ts +0 -37
- package/server/index.ts +0 -0
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import './user-role-editor'
|
|
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('invite-user')
|
|
12
|
-
class InviteUser extends localize(i18next)(LitElement) {
|
|
13
|
-
static styles = css`
|
|
14
|
-
:host {
|
|
15
|
-
display: grid;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
input {
|
|
19
|
-
flex: 1;
|
|
20
|
-
|
|
21
|
-
border: var(--border-dim-color);
|
|
22
|
-
border-radius: var(--border-radius);
|
|
23
|
-
margin: var(--input-margin);
|
|
24
|
-
padding: var(--input-padding);
|
|
25
|
-
min-width: 250px;
|
|
26
|
-
font: var(--input-font);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
md-outlined-button {
|
|
30
|
-
margin: var(--input-margin);
|
|
31
|
-
text-transform: capitalize;
|
|
32
|
-
}
|
|
33
|
-
`
|
|
34
|
-
|
|
35
|
-
@query('input[name=username]') userIdInput!: HTMLInputElement
|
|
36
|
-
|
|
37
|
-
render() {
|
|
38
|
-
return html`
|
|
39
|
-
<input
|
|
40
|
-
name="username"
|
|
41
|
-
type="text"
|
|
42
|
-
required
|
|
43
|
-
name="username"
|
|
44
|
-
autocapitalize="off"
|
|
45
|
-
placeholder=${String(i18next.t('text.user invitation prompt'))}
|
|
46
|
-
pattern="^(?:[A-Za-z0-9]*|[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+.[A-Za-z]{2,})$"
|
|
47
|
-
/>
|
|
48
|
-
<md-outlined-button @click=${this.invite.bind(this)}>
|
|
49
|
-
<md-icon slot="icon">group_add</md-icon>${String(i18next.t('label.invite user'))}
|
|
50
|
-
</md-outlined-button>
|
|
51
|
-
`
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
async invite() {
|
|
55
|
-
try {
|
|
56
|
-
if (!this.userIdInput.checkValidity()) {
|
|
57
|
-
throw new Error(i18next.t('error.not valid pattern of type', { type: 'user-id or email' }))
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (
|
|
61
|
-
await OxPrompt.open({
|
|
62
|
-
title: i18next.t('text.are_you_sure'),
|
|
63
|
-
text: i18next.t('text.do_you_want_to_invite_x', { x: i18next.t(`label.user`) }),
|
|
64
|
-
confirmButton: { text: i18next.t('button.confirm') },
|
|
65
|
-
cancelButton: { text: i18next.t('button.cancel') }
|
|
66
|
-
})
|
|
67
|
-
) {
|
|
68
|
-
await this.inviteUser(this.userIdInput.value)
|
|
69
|
-
|
|
70
|
-
this.dispatchEvent(new CustomEvent('invitationCompleted'))
|
|
71
|
-
}
|
|
72
|
-
} catch (e: any) {
|
|
73
|
-
document.dispatchEvent(
|
|
74
|
-
new CustomEvent('notify', {
|
|
75
|
-
detail: {
|
|
76
|
-
level: 'error',
|
|
77
|
-
message: 'message' in e ? e.message : e
|
|
78
|
-
}
|
|
79
|
-
})
|
|
80
|
-
)
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
async inviteUser(username) {
|
|
85
|
-
const response = await client.mutate({
|
|
86
|
-
mutation: gql`
|
|
87
|
-
mutation inviteUser($username: String!) {
|
|
88
|
-
inviteUser(username: $username)
|
|
89
|
-
}
|
|
90
|
-
`,
|
|
91
|
-
variables: { username },
|
|
92
|
-
context: gqlContext()
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
if (!response.errors) {
|
|
96
|
-
await OxPrompt.open({
|
|
97
|
-
title: i18next.t('text.completed'),
|
|
98
|
-
confirmButton: { text: i18next.t('button.confirm') }
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
this.userIdInput.value = ''
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import '@operato/data-grist'
|
|
2
|
-
|
|
3
|
-
import gql from 'graphql-tag'
|
|
4
|
-
import { css, html, LitElement } from 'lit'
|
|
5
|
-
import { customElement, property } from 'lit/decorators.js'
|
|
6
|
-
|
|
7
|
-
import { client } from '@operato/graphql'
|
|
8
|
-
import { i18next } from '@operato/i18n'
|
|
9
|
-
import { isMobileDevice } from '@operato/utils'
|
|
10
|
-
|
|
11
|
-
@customElement('my-login-history')
|
|
12
|
-
class MyLoginHistory extends LitElement {
|
|
13
|
-
static styles = css`
|
|
14
|
-
:host {
|
|
15
|
-
display: flex;
|
|
16
|
-
flex-direction: column;
|
|
17
|
-
background-color: var(--md-sys-color-background);
|
|
18
|
-
padding: var(--spacing-large);
|
|
19
|
-
overflow: auto;
|
|
20
|
-
}
|
|
21
|
-
ox-grist {
|
|
22
|
-
flex: 1;
|
|
23
|
-
}
|
|
24
|
-
`
|
|
25
|
-
|
|
26
|
-
@property({ type: Array }) histories: any[] = []
|
|
27
|
-
@property({ type: Number }) limit?: number
|
|
28
|
-
|
|
29
|
-
render() {
|
|
30
|
-
if (!this.histories?.length) return html``
|
|
31
|
-
|
|
32
|
-
const config = {
|
|
33
|
-
rows: { appendable: false },
|
|
34
|
-
pagination: { infinite: true },
|
|
35
|
-
columns: [
|
|
36
|
-
{ type: 'gutter', gutterName: 'sequence' },
|
|
37
|
-
{
|
|
38
|
-
type: 'object',
|
|
39
|
-
name: 'accessDomain',
|
|
40
|
-
header: i18next.t('field.domain'),
|
|
41
|
-
record: { editable: false },
|
|
42
|
-
width: 200
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
type: 'datetime',
|
|
46
|
-
name: 'accessedAt',
|
|
47
|
-
header: i18next.t('field.accessed-at'),
|
|
48
|
-
record: { editable: false },
|
|
49
|
-
width: 200
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
type: 'string',
|
|
53
|
-
name: 'accessorIp',
|
|
54
|
-
header: i18next.t('field.ip_address'),
|
|
55
|
-
record: { editable: false },
|
|
56
|
-
width: 200
|
|
57
|
-
}
|
|
58
|
-
]
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return html`
|
|
62
|
-
<ox-grist
|
|
63
|
-
.mode=${isMobileDevice() ? 'LIST' : 'GRID'}
|
|
64
|
-
.config=${config}
|
|
65
|
-
.data="${{ records: this.histories }}"
|
|
66
|
-
></ox-grist>
|
|
67
|
-
`
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
firstUpdated() {
|
|
71
|
-
this.fetchLoginHistories()
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
async fetchLoginHistories() {
|
|
75
|
-
try {
|
|
76
|
-
const response = await client.query({
|
|
77
|
-
query: gql`
|
|
78
|
-
query myLoginHistories($limit: Float!) {
|
|
79
|
-
myLoginHistories(limit: $limit) {
|
|
80
|
-
accessDomain {
|
|
81
|
-
name
|
|
82
|
-
}
|
|
83
|
-
accessorIp
|
|
84
|
-
accessedAt
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
`,
|
|
88
|
-
variables: { limit: this.limit || 10 }
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
if (response.errors?.length) return
|
|
92
|
-
this.histories = response.data.myLoginHistories
|
|
93
|
-
} catch (e: any) {
|
|
94
|
-
this.showToast('message' in e ? e.message : e)
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
showToast(message) {
|
|
99
|
-
document.dispatchEvent(new CustomEvent('notify', { detail: { message } }))
|
|
100
|
-
}
|
|
101
|
-
}
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import '@material/web/button/elevated-button.js'
|
|
2
|
-
|
|
3
|
-
import gql from 'graphql-tag'
|
|
4
|
-
import { css, html, LitElement } from 'lit'
|
|
5
|
-
import { customElement, property, 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('ownership-transfer-popup')
|
|
12
|
-
class OwnershipTransferPopup extends localize(i18next)(LitElement) {
|
|
13
|
-
static styles = [
|
|
14
|
-
css`
|
|
15
|
-
:host {
|
|
16
|
-
display: flex;
|
|
17
|
-
flex-direction: column;
|
|
18
|
-
background-color: var(--md-sys-color-background);
|
|
19
|
-
padding: var(--spacing-large);
|
|
20
|
-
overflow: auto;
|
|
21
|
-
}
|
|
22
|
-
.container {
|
|
23
|
-
display: flex;
|
|
24
|
-
flex-direction: column;
|
|
25
|
-
flex: 1;
|
|
26
|
-
}
|
|
27
|
-
input {
|
|
28
|
-
border: var(--border-dim-color);
|
|
29
|
-
border-radius: var(--border-radius);
|
|
30
|
-
margin: var(--input-margin);
|
|
31
|
-
padding: var(--input-padding);
|
|
32
|
-
min-width: 250px;
|
|
33
|
-
font: var(--input-font);
|
|
34
|
-
}
|
|
35
|
-
.input-container {
|
|
36
|
-
margin: auto;
|
|
37
|
-
display: flex;
|
|
38
|
-
}
|
|
39
|
-
.input-container md-elevated-button {
|
|
40
|
-
margin: auto 0px auto var(--spacing-large);
|
|
41
|
-
}
|
|
42
|
-
`
|
|
43
|
-
]
|
|
44
|
-
|
|
45
|
-
@property({ type: Object }) user: any
|
|
46
|
-
|
|
47
|
-
@query('input[name=email]') emailInput!: HTMLInputElement
|
|
48
|
-
|
|
49
|
-
render() {
|
|
50
|
-
return html`
|
|
51
|
-
<div class="container">
|
|
52
|
-
<div>${i18next.t('text.please enter the email of the user you want to transfer owner')}</div>
|
|
53
|
-
<div class="input-container">
|
|
54
|
-
<input name="email" />
|
|
55
|
-
<md-elevated-button @click=${this.transferOwnership}>${i18next.t('button.confirm')}</md-elevated-button>
|
|
56
|
-
</div>
|
|
57
|
-
</div>
|
|
58
|
-
`
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
async transferOwnership() {
|
|
62
|
-
if (!this.doubleCheckEmail()) {
|
|
63
|
-
this.showToast(i18next.t('text.email is not matched'))
|
|
64
|
-
|
|
65
|
-
return
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (
|
|
69
|
-
await OxPrompt.open({
|
|
70
|
-
title: i18next.t('text.are_you_sure'),
|
|
71
|
-
text: i18next.t('text.are_you_sure_to_transfer_owner'),
|
|
72
|
-
confirmButton: { text: i18next.t('button.confirm') },
|
|
73
|
-
cancelButton: { text: i18next.t('button.cancel') }
|
|
74
|
-
})
|
|
75
|
-
) {
|
|
76
|
-
const response = await client.mutate({
|
|
77
|
-
mutation: gql`
|
|
78
|
-
mutation transferOwner($username: String!) {
|
|
79
|
-
transferOwner(username: $username)
|
|
80
|
-
}
|
|
81
|
-
`,
|
|
82
|
-
variables: { username: this.user.username || this.user.email },
|
|
83
|
-
context: gqlContext()
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
if (!response.errors?.length) {
|
|
87
|
-
await OxPrompt.open({
|
|
88
|
-
type: 'success',
|
|
89
|
-
title: i18next.t('text.completed'),
|
|
90
|
-
text: i18next.t('text.owner_transfer_completed'),
|
|
91
|
-
confirmButton: { text: i18next.t('button.confirm') }
|
|
92
|
-
})
|
|
93
|
-
|
|
94
|
-
history.back()
|
|
95
|
-
|
|
96
|
-
this.dispatchEvent(new CustomEvent('ownershipTransferred', { bubbles: true, composed: true }))
|
|
97
|
-
}
|
|
98
|
-
} else {
|
|
99
|
-
history.back()
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
doubleCheckEmail() {
|
|
104
|
-
return this.emailInput.value === this.user.email
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
showToast(message) {
|
|
108
|
-
document.dispatchEvent(new CustomEvent('notify', { detail: { message, option: { timer: 1000 } } }))
|
|
109
|
-
}
|
|
110
|
-
}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { css, html, LitElement } from 'lit'
|
|
2
|
-
import { customElement, property } from 'lit/decorators.js'
|
|
3
|
-
|
|
4
|
-
import { i18next } from '@operato/i18n'
|
|
5
|
-
|
|
6
|
-
@customElement('partner-info-card')
|
|
7
|
-
export class PartnerInfoCard extends LitElement {
|
|
8
|
-
static styles = [
|
|
9
|
-
css`
|
|
10
|
-
input {
|
|
11
|
-
border: var(--border-dim-color);
|
|
12
|
-
border-radius: var(--border-radius);
|
|
13
|
-
margin: var(--input-margin);
|
|
14
|
-
padding: var(--input-padding);
|
|
15
|
-
background-color: transparent;
|
|
16
|
-
font: var(--input-font);
|
|
17
|
-
|
|
18
|
-
flex: 1;
|
|
19
|
-
}
|
|
20
|
-
#vendors {
|
|
21
|
-
display: flex;
|
|
22
|
-
max-height: 45vh;
|
|
23
|
-
flex-direction: row;
|
|
24
|
-
background-color: var(--md-sys-color-surface-variant);
|
|
25
|
-
margin: 0;
|
|
26
|
-
padding: 0;
|
|
27
|
-
border-radius: var(--border-radius);
|
|
28
|
-
box-shadow: var(--box-shadow);
|
|
29
|
-
overflow: hidden;
|
|
30
|
-
}
|
|
31
|
-
[field-2column] {
|
|
32
|
-
overflow: auto;
|
|
33
|
-
flex: 1;
|
|
34
|
-
background-color: var(--md-sys-color-surface-variant);
|
|
35
|
-
padding: var(--spacing-medium);
|
|
36
|
-
border-radius: var(--border-radius);
|
|
37
|
-
display: grid;
|
|
38
|
-
grid-template-columns: 1fr 1fr;
|
|
39
|
-
gap: 5px 15px;
|
|
40
|
-
clear: both;
|
|
41
|
-
max-width: var(--input-container-max-width);
|
|
42
|
-
}
|
|
43
|
-
[field] {
|
|
44
|
-
display: flex;
|
|
45
|
-
flex-direction: column;
|
|
46
|
-
padding-bottom: var(--spacing-medium);
|
|
47
|
-
}
|
|
48
|
-
label {
|
|
49
|
-
display: flex;
|
|
50
|
-
flex-direction: column;
|
|
51
|
-
|
|
52
|
-
font: var(--label-font);
|
|
53
|
-
color: var(--label-color, var(--md-sys-color-on-surface));
|
|
54
|
-
text-transform: var(--label-text-transform);
|
|
55
|
-
}
|
|
56
|
-
@media screen and (max-width: 480px) {
|
|
57
|
-
[field] {
|
|
58
|
-
grid-column: span 2;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
`
|
|
62
|
-
]
|
|
63
|
-
|
|
64
|
-
@property({ type: Object }) partner: any
|
|
65
|
-
|
|
66
|
-
render() {
|
|
67
|
-
const partner = this.partner || {}
|
|
68
|
-
|
|
69
|
-
return html`
|
|
70
|
-
<div id="vendors">
|
|
71
|
-
<div field-2column>
|
|
72
|
-
<div field>
|
|
73
|
-
<label
|
|
74
|
-
>${i18next.t('label.name')}
|
|
75
|
-
<input type="text" name="name" readonly .value=${partner.name || ''} />
|
|
76
|
-
</label>
|
|
77
|
-
</div>
|
|
78
|
-
|
|
79
|
-
<div field>
|
|
80
|
-
<label
|
|
81
|
-
>${i18next.t('label.description')}
|
|
82
|
-
<input type="text" name="description" readonly .value=${partner.description || ''} />
|
|
83
|
-
</label>
|
|
84
|
-
</div>
|
|
85
|
-
</div>
|
|
86
|
-
</div>
|
|
87
|
-
`
|
|
88
|
-
}
|
|
89
|
-
}
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import '@material/web/button/elevated-button.js'
|
|
2
|
-
import './role-selector.js'
|
|
3
|
-
|
|
4
|
-
import gql from 'graphql-tag'
|
|
5
|
-
import { css, html, LitElement } from 'lit'
|
|
6
|
-
import { customElement, property, query } from 'lit/decorators.js'
|
|
7
|
-
|
|
8
|
-
import { client, gqlContext } from '@operato/graphql'
|
|
9
|
-
import { i18next, localize } from '@operato/i18n'
|
|
10
|
-
import { OxPrompt } from '@operato/popup/ox-prompt.js'
|
|
11
|
-
import { ButtonContainerStyles } from '@operato/styles'
|
|
12
|
-
|
|
13
|
-
import { RoleSelector } from './role-selector'
|
|
14
|
-
|
|
15
|
-
@customElement('partner-role-editor')
|
|
16
|
-
class PartnerRoleEditor extends localize(i18next)(LitElement) {
|
|
17
|
-
static styles = [
|
|
18
|
-
ButtonContainerStyles,
|
|
19
|
-
css`
|
|
20
|
-
:host {
|
|
21
|
-
display: flex;
|
|
22
|
-
flex-direction: column;
|
|
23
|
-
|
|
24
|
-
border: 1px solid var(--md-sys-color-primary);
|
|
25
|
-
padding: var(--spacing-medium);
|
|
26
|
-
font: normal 15px var(--theme-font);
|
|
27
|
-
color: var(--md-sys-color-secondary);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
md-elevated-button {
|
|
31
|
-
margin-right: var(--spacing-small);
|
|
32
|
-
}
|
|
33
|
-
`
|
|
34
|
-
]
|
|
35
|
-
|
|
36
|
-
@property({ type: Object }) customer: any
|
|
37
|
-
@property({ type: Array }) roles: any[] = []
|
|
38
|
-
@property({ type: Array }) grantingRoles: any[] = []
|
|
39
|
-
|
|
40
|
-
@query('role-selector') roleSelector!: RoleSelector
|
|
41
|
-
|
|
42
|
-
render() {
|
|
43
|
-
const roles = this.roles || []
|
|
44
|
-
const grantingRoles = this.grantingRoles || []
|
|
45
|
-
|
|
46
|
-
return html`
|
|
47
|
-
<role-selector .roles="${roles}" .userRoles="${grantingRoles}"></role-selector>
|
|
48
|
-
|
|
49
|
-
<div class="button-container">
|
|
50
|
-
<md-elevated-button @click=${this.onSave}>${i18next.t('button.save')}</md-elevated-button>
|
|
51
|
-
<md-elevated-button @click=${this.onTerminateContract} danger
|
|
52
|
-
>${i18next.t('button.terminate contract')}</md-elevated-button
|
|
53
|
-
>
|
|
54
|
-
</div>
|
|
55
|
-
`
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
updated(changes) {
|
|
59
|
-
if (changes.has('customer')) {
|
|
60
|
-
this.refreshRoles()
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
async refreshRoles() {
|
|
65
|
-
const response = await client.query({
|
|
66
|
-
query: gql`
|
|
67
|
-
query roles($customerId: String!) {
|
|
68
|
-
roles {
|
|
69
|
-
items {
|
|
70
|
-
id
|
|
71
|
-
name
|
|
72
|
-
description
|
|
73
|
-
}
|
|
74
|
-
total
|
|
75
|
-
}
|
|
76
|
-
grantingRoles(customerId: $customerId) {
|
|
77
|
-
id
|
|
78
|
-
role {
|
|
79
|
-
id
|
|
80
|
-
name
|
|
81
|
-
description
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
`,
|
|
86
|
-
variables: { customerId: this.customer.id },
|
|
87
|
-
context: gqlContext()
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
if (!response.errors?.length) {
|
|
91
|
-
this.roles = response.data.roles.items
|
|
92
|
-
this.grantingRoles = response.data.grantingRoles.map(grantingRole => grantingRole.role)
|
|
93
|
-
} else {
|
|
94
|
-
this.roles = []
|
|
95
|
-
this.grantingRoles = []
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
async onSave() {
|
|
100
|
-
const roles = this.roleSelector.selectedRoles()
|
|
101
|
-
|
|
102
|
-
const response = await client.mutate({
|
|
103
|
-
mutation: gql`
|
|
104
|
-
mutation grantRoles($customerId: String!, $roles: [RolePatch!]!) {
|
|
105
|
-
grantRoles(customerId: $customerId, roles: $roles)
|
|
106
|
-
}
|
|
107
|
-
`,
|
|
108
|
-
variables: { customerId: this.customer.id, roles },
|
|
109
|
-
context: gqlContext()
|
|
110
|
-
})
|
|
111
|
-
|
|
112
|
-
if (!response.errors?.length) {
|
|
113
|
-
this.showToast(i18next.t('text.data_updated_successfully'))
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
async onTerminateContract() {
|
|
118
|
-
if (
|
|
119
|
-
await OxPrompt.open({
|
|
120
|
-
title: i18next.t('text.are_you_sure'),
|
|
121
|
-
text: i18next.t('text.are_you_sure_to_terminate_contract'),
|
|
122
|
-
confirmButton: { text: i18next.t('button.terminate contract') },
|
|
123
|
-
cancelButton: { text: i18next.t('button.cancel') }
|
|
124
|
-
})
|
|
125
|
-
) {
|
|
126
|
-
const response = await client.mutate({
|
|
127
|
-
mutation: gql`
|
|
128
|
-
mutation terminateContract($partnerName: String!) {
|
|
129
|
-
terminateContract(partnerName: $partnerName)
|
|
130
|
-
}
|
|
131
|
-
`,
|
|
132
|
-
variables: { partnerName: this.customer.name },
|
|
133
|
-
context: gqlContext()
|
|
134
|
-
})
|
|
135
|
-
|
|
136
|
-
if (!response.errors?.length) {
|
|
137
|
-
const answer = this.dispatchEvent(new CustomEvent('contractTerminated'))
|
|
138
|
-
|
|
139
|
-
if (answer) {
|
|
140
|
-
await OxPrompt.open({
|
|
141
|
-
type: 'success',
|
|
142
|
-
title: i18next.t('text.completed'),
|
|
143
|
-
confirmButton: { text: i18next.t('button.confirm') }
|
|
144
|
-
})
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
showToast(message) {
|
|
151
|
-
document.dispatchEvent(new CustomEvent('notify', { detail: { message, option: { timer: 1000 } } }))
|
|
152
|
-
}
|
|
153
|
-
}
|