@things-factory/auth-ui 7.0.1-alpha.77 → 7.0.1-alpha.79

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.
@@ -1,5 +1,3 @@
1
- import '@things-factory/auth-ui'
2
-
3
1
  import gql from 'graphql-tag'
4
2
  import { css, html, LitElement } from 'lit'
5
3
  import { customElement, property, query } from 'lit/decorators.js'
@@ -1,5 +1,5 @@
1
1
  import '@material/mwc-icon'
2
- import '@things-factory/auth-ui'
2
+ import './role-selector.js'
3
3
 
4
4
  import gql from 'graphql-tag'
5
5
  import { css, html, LitElement } from 'lit'
package/client/index.ts CHANGED
@@ -11,85 +11,114 @@ export * from './components/role-selector.js'
11
11
  export * from './components/domain-switch.js'
12
12
  export * from './components/invite-user.js'
13
13
 
14
- export async function setAuthManagementMenus() {
15
- if (await hasPrivilege({ privilege: 'mutation', category: 'user', domainOwnerGranted: true, superUserGranted: true })) {
16
- store.dispatch({
17
- type: ADD_MORENDA,
18
- morenda: {
19
- icon: html` <md-icon>how_to_reg</md-icon> `,
20
- name: html` <ox-i18n msgid="text.role_management"></ox-i18n> `,
21
- action: () => {
22
- navigate('roles')
14
+ export type AuthManagementMenuOptions = {
15
+ role?: boolean
16
+ appliance?: boolean
17
+ application?: boolean
18
+ user?: boolean
19
+ authProvider?: boolean
20
+ domain?: boolean
21
+ attribute?: boolean
22
+ }
23
+
24
+ export async function setAuthManagementMenus(options?: any) {
25
+ const {
26
+ role = true,
27
+ appliance = true,
28
+ application = true,
29
+ user = true,
30
+ authProvider = true,
31
+ domain = true,
32
+ attribute = true
33
+ } = options || {}
34
+
35
+ if (
36
+ await hasPrivilege({ privilege: 'mutation', category: 'user', domainOwnerGranted: true, superUserGranted: true })
37
+ ) {
38
+ role &&
39
+ store.dispatch({
40
+ type: ADD_MORENDA,
41
+ morenda: {
42
+ icon: html` <md-icon>how_to_reg</md-icon> `,
43
+ name: html` <ox-i18n msgid="text.role_management"></ox-i18n> `,
44
+ action: () => {
45
+ navigate('roles')
46
+ }
23
47
  }
24
- }
25
- })
48
+ })
26
49
 
27
- store.dispatch({
28
- type: ADD_MORENDA,
29
- morenda: {
30
- icon: html` <md-icon>devices</md-icon> `,
31
- name: html` <ox-i18n msgid="text.appliance"></ox-i18n> `,
32
- action: () => {
33
- navigate('appliance-home')
50
+ appliance &&
51
+ store.dispatch({
52
+ type: ADD_MORENDA,
53
+ morenda: {
54
+ icon: html` <md-icon>devices</md-icon> `,
55
+ name: html` <ox-i18n msgid="text.appliance"></ox-i18n> `,
56
+ action: () => {
57
+ navigate('appliance-home')
58
+ }
34
59
  }
35
- }
36
- })
60
+ })
37
61
 
38
- store.dispatch({
39
- type: ADD_MORENDA,
40
- morenda: {
41
- icon: html` <md-icon>apps</md-icon> `,
42
- name: html` <ox-i18n msgid="text.application management"></ox-i18n> `,
43
- action: () => {
44
- navigate('applications')
62
+ application &&
63
+ store.dispatch({
64
+ type: ADD_MORENDA,
65
+ morenda: {
66
+ icon: html` <md-icon>apps</md-icon> `,
67
+ name: html` <ox-i18n msgid="text.application management"></ox-i18n> `,
68
+ action: () => {
69
+ navigate('applications')
70
+ }
45
71
  }
46
- }
47
- })
72
+ })
48
73
 
49
- store.dispatch({
50
- type: ADD_MORENDA,
51
- morenda: {
52
- icon: html` <md-icon>people</md-icon> `,
53
- name: html` <ox-i18n msgid="text.user management"></ox-i18n> `,
54
- action: () => {
55
- navigate('users')
74
+ user &&
75
+ store.dispatch({
76
+ type: ADD_MORENDA,
77
+ morenda: {
78
+ icon: html` <md-icon>people</md-icon> `,
79
+ name: html` <ox-i18n msgid="text.user management"></ox-i18n> `,
80
+ action: () => {
81
+ navigate('users')
82
+ }
56
83
  }
57
- }
58
- })
84
+ })
59
85
 
60
- store.dispatch({
61
- type: ADD_MORENDA,
62
- morenda: {
63
- icon: html` <md-icon>badge</md-icon> `,
64
- name: html` <ox-i18n msgid="text.auth-provider management"></ox-i18n> `,
65
- action: () => {
66
- navigate('auth-providers')
86
+ authProvider &&
87
+ store.dispatch({
88
+ type: ADD_MORENDA,
89
+ morenda: {
90
+ icon: html` <md-icon>badge</md-icon> `,
91
+ name: html` <ox-i18n msgid="text.auth-provider management"></ox-i18n> `,
92
+ action: () => {
93
+ navigate('auth-providers')
94
+ }
67
95
  }
68
- }
69
- })
96
+ })
70
97
  }
71
98
 
72
99
  if (await hasPrivilege({ superUserGranted: true })) {
73
- store.dispatch({
74
- type: ADD_MORENDA,
75
- morenda: {
76
- icon: html` <md-icon>business</md-icon> `,
77
- name: html` <ox-i18n msgid="text.domain management"></ox-i18n> `,
78
- action: () => {
79
- navigate('domains')
100
+ domain &&
101
+ store.dispatch({
102
+ type: ADD_MORENDA,
103
+ morenda: {
104
+ icon: html` <md-icon>business</md-icon> `,
105
+ name: html` <ox-i18n msgid="text.domain management"></ox-i18n> `,
106
+ action: () => {
107
+ navigate('domains')
108
+ }
80
109
  }
81
- }
82
- })
110
+ })
83
111
 
84
- store.dispatch({
85
- type: ADD_MORENDA,
86
- morenda: {
87
- icon: html` <md-icon>dataset</md-icon> `,
88
- name: html` <ox-i18n msgid="text.attribute management"></ox-i18n> `,
89
- action: () => {
90
- navigate('attributes')
112
+ attribute &&
113
+ store.dispatch({
114
+ type: ADD_MORENDA,
115
+ morenda: {
116
+ icon: html` <md-icon>dataset</md-icon> `,
117
+ name: html` <ox-i18n msgid="text.attribute management"></ox-i18n> `,
118
+ action: () => {
119
+ navigate('attributes')
120
+ }
91
121
  }
92
- }
93
- })
122
+ })
94
123
  }
95
124
  }
@@ -1 +1 @@
1
- import '@things-factory/auth-ui';
1
+ export {};
@@ -1,5 +1,4 @@
1
1
  import { __decorate, __metadata } from "tslib";
2
- import '@things-factory/auth-ui';
3
2
  import gql from 'graphql-tag';
4
3
  import { css, html, LitElement } from 'lit';
5
4
  import { customElement, property, query } from 'lit/decorators.js';
@@ -1 +1 @@
1
- {"version":3,"file":"invite-customer.js","sourceRoot":"","sources":["../../client/components/invite-customer.ts"],"names":[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AG,EAAE,CAAA;iBAClC;aACF;SACF;QAAC,OAAO,CAAM,EAAE;YACf,QAAQ,CAAC,aAAa,CACpB,IAAI,WAAW,CAAC,QAAQ,EAAE;gBACxB,MAAM,EAAE;oBACN,KAAK,EAAE,OAAO;oBACd,OAAO,EAAE,SAAS,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;iBACxC;aACF,CAAC,CACH,CAAA;SACF;IACH,CAAC;;AA9FM,qBAAM,GAAG;IACd,GAAG,CAAA;;;;;;;;;;;;;;;;;KAiBF;CACF,CAAA;AAED;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;iDAAsB;AAEhD;IAAC,KAAK,CAAC,qBAAqB,CAAC;8BAAqB,gBAAgB;yDAAA;AAxB9D,cAAc;IADnB,aAAa,CAAC,iBAAiB,CAAC;GAC3B,cAAc,CAgGnB","sourcesContent":["import '@things-factory/auth-ui'\n\nimport gql from 'graphql-tag'\nimport { css, html, LitElement } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\n\nimport { client, gqlContext } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { OxPrompt } from '@operato/popup/ox-prompt.js'\n\n@customElement('invite-customer')\nclass InviteCustomer extends localize(i18next)(LitElement) {\n static styles = [\n css`\n input {\n border: var(--border-dark-color);\n border-radius: var(--border-radius);\n margin: var(--input-margin);\n padding: var(--input-padding);\n min-width: 250px;\n font: var(--input-font);\n }\n mwc-button {\n margin: var(--input-margin);\n }\n @media screen and (max-width: 480px) {\n div {\n display: grid;\n }\n }\n `\n ]\n\n @property({ type: Array }) customers: any[] = []\n\n @query('input#customer-name') customerNameInput!: HTMLInputElement\n\n render() {\n return html`\n <div>\n <input id=\"customer-name\" required />\n <mwc-button\n @click=${this.invite.bind(this)}\n outlined\n icon=\"group_add\"\n label=${String(i18next.t('label.invite customer'))}\n ></mwc-button>\n </div>\n `\n }\n\n async invite() {\n try {\n if (!this.customerNameInput.value)\n throw new Error(i18next.t('error.value is empty', { value: i18next.t('field.name') }))\n\n if (this.customers.find(c => c.name?.toLowerCase() === this.customerNameInput.value.toLowerCase())) {\n throw new Error(\n i18next.t('error.x already exists in y', { x: this.customerNameInput.value, y: i18next.t('field.customer') })\n )\n }\n\n if (\n await OxPrompt.open({\n title: i18next.t('text.are_you_sure'),\n text: i18next.t('text.do_you_want_to_invite_x', { x: i18next.t(`label.partner`) }),\n confirmButton: { text: i18next.t('button.confirm') },\n cancelButton: { text: i18next.t('button.cancel') }\n })\n ) {\n const customerDomainName = this.customerNameInput.value\n\n const response = await client.mutate({\n mutation: gql`\n mutation inviteCustomer($customerDomainName: String!) {\n inviteCustomer(customerDomainName: $customerDomainName)\n }\n `,\n variables: { customerDomainName },\n context: gqlContext()\n })\n\n if (!response.errors) {\n const answer = this.dispatchEvent(new CustomEvent('invitationCompleted'))\n\n if (answer) {\n await OxPrompt.open({\n type: 'success',\n title: i18next.t('text.completed'),\n confirmButton: { text: i18next.t('button.confirm') }\n })\n }\n\n this.customerNameInput.value = ''\n }\n }\n } catch (e: any) {\n document.dispatchEvent(\n new CustomEvent('notify', {\n detail: {\n level: 'error',\n message: 'message' in e ? e.message : e\n }\n })\n )\n }\n }\n}\n"]}
1
+ {"version":3,"file":"invite-customer.js","sourceRoot":"","sources":["../../client/components/invite-customer.ts"],"names":[],"mappings":";AAAA,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAElE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA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AAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;iDAAsB;AAEhD;IAAC,KAAK,CAAC,qBAAqB,CAAC;8BAAqB,gBAAgB;yDAAA;AAxB9D,cAAc;IADnB,aAAa,CAAC,iBAAiB,CAAC;GAC3B,cAAc,CAgGnB","sourcesContent":["import gql from 'graphql-tag'\nimport { css, html, LitElement } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\n\nimport { client, gqlContext } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { OxPrompt } from '@operato/popup/ox-prompt.js'\n\n@customElement('invite-customer')\nclass InviteCustomer extends localize(i18next)(LitElement) {\n static styles = [\n css`\n input {\n border: var(--border-dark-color);\n border-radius: var(--border-radius);\n margin: var(--input-margin);\n padding: var(--input-padding);\n min-width: 250px;\n font: var(--input-font);\n }\n mwc-button {\n margin: var(--input-margin);\n }\n @media screen and (max-width: 480px) {\n div {\n display: grid;\n }\n }\n `\n ]\n\n @property({ type: Array }) customers: any[] = []\n\n @query('input#customer-name') customerNameInput!: HTMLInputElement\n\n render() {\n return html`\n <div>\n <input id=\"customer-name\" required />\n <mwc-button\n @click=${this.invite.bind(this)}\n outlined\n icon=\"group_add\"\n label=${String(i18next.t('label.invite customer'))}\n ></mwc-button>\n </div>\n `\n }\n\n async invite() {\n try {\n if (!this.customerNameInput.value)\n throw new Error(i18next.t('error.value is empty', { value: i18next.t('field.name') }))\n\n if (this.customers.find(c => c.name?.toLowerCase() === this.customerNameInput.value.toLowerCase())) {\n throw new Error(\n i18next.t('error.x already exists in y', { x: this.customerNameInput.value, y: i18next.t('field.customer') })\n )\n }\n\n if (\n await OxPrompt.open({\n title: i18next.t('text.are_you_sure'),\n text: i18next.t('text.do_you_want_to_invite_x', { x: i18next.t(`label.partner`) }),\n confirmButton: { text: i18next.t('button.confirm') },\n cancelButton: { text: i18next.t('button.cancel') }\n })\n ) {\n const customerDomainName = this.customerNameInput.value\n\n const response = await client.mutate({\n mutation: gql`\n mutation inviteCustomer($customerDomainName: String!) {\n inviteCustomer(customerDomainName: $customerDomainName)\n }\n `,\n variables: { customerDomainName },\n context: gqlContext()\n })\n\n if (!response.errors) {\n const answer = this.dispatchEvent(new CustomEvent('invitationCompleted'))\n\n if (answer) {\n await OxPrompt.open({\n type: 'success',\n title: i18next.t('text.completed'),\n confirmButton: { text: i18next.t('button.confirm') }\n })\n }\n\n this.customerNameInput.value = ''\n }\n }\n } catch (e: any) {\n document.dispatchEvent(\n new CustomEvent('notify', {\n detail: {\n level: 'error',\n message: 'message' in e ? e.message : e\n }\n })\n )\n }\n }\n}\n"]}
@@ -1,2 +1,2 @@
1
1
  import '@material/mwc-icon';
2
- import '@things-factory/auth-ui';
2
+ import './role-selector.js';
@@ -1,6 +1,6 @@
1
1
  import { __decorate, __metadata } from "tslib";
2
2
  import '@material/mwc-icon';
3
- import '@things-factory/auth-ui';
3
+ import './role-selector.js';
4
4
  import gql from 'graphql-tag';
5
5
  import { css, html, LitElement } from 'lit';
6
6
  import { customElement, property, query } from 'lit/decorators.js';
@@ -1 +1 @@
1
- {"version":3,"file":"partner-role-editor.js","sourceRoot":"","sources":["../../client/components/partner-role-editor.ts"],"names":[],"mappings":";AAAA,OAAO,oBAAoB,CAAA;AAC3B,OAAO,yBAAyB,CAAA;AAEhC,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAElE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AAEtD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAG9C,IAAM,iBAAiB,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;gBAC5B,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,oBAAoB,CAAC,CAAC,CAAA;gBAExE,IAAI,MAAM,EAAE;oBACV,MAAM,QAAQ,CAAC,IAAI,CAAC;wBAClB,IAAI,EAAE,SAAS;wBACf,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,gBAAgB,CAAC;wBAClC,aAAa,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,gBAAgB,CAAC,EAAE;qBACrD,CAAC,CAAA;iBACH;aACF;SACF;IACH,CAAC;IAED,SAAS,CAAC,OAAO;QACf,QAAQ,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,CAAA;IACrG,CAAC;;AAhJM,wBAAM,GAAG;IACd,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;KAqBF;CACF,CAAA;AAED;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;mDAAc;AACzC;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;gDAAkB;AAC5C;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;wDAA0B;AAEpD;IAAC,KAAK,CAAC,eAAe,CAAC;8BAAgB,YAAY;uDAAA;AA9B/C,iBAAiB;IADtB,aAAa,CAAC,qBAAqB,CAAC;GAC/B,iBAAiB,CAkJtB","sourcesContent":["import '@material/mwc-icon'\nimport '@things-factory/auth-ui'\n\nimport gql from 'graphql-tag'\nimport { css, html, LitElement } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\n\nimport { client, gqlContext } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { OxPrompt } from '@operato/popup/ox-prompt.js'\n\nimport { RoleSelector } from './role-selector'\n\n@customElement('partner-role-editor')\nclass PartnerRoleEditor extends localize(i18next)(LitElement) {\n static styles = [\n css`\n :host {\n display: flex;\n flex-direction: column;\n\n border: 1px solid var(--primary-color);\n padding: var(--padding-default);\n font: normal 15px var(--theme-font);\n color: var(--secondary-color);\n }\n [buttons] {\n margin: 0;\n padding: var(--padding-default);\n background-color: rgba(var(--primary-color-rgb), 0.2);\n }\n mwc-button {\n margin-right: var(--padding-narrow);\n }\n [danger] {\n --mdc-theme-primary: var(--mdc-danger-button-primary-color);\n }\n `\n ]\n\n @property({ type: Object }) customer: any\n @property({ type: Array }) roles: any[] = []\n @property({ type: Array }) grantingRoles: any[] = []\n\n @query('role-selector') roleSelector!: RoleSelector\n\n render() {\n const roles = this.roles || []\n const grantingRoles = this.grantingRoles || []\n\n return html`\n <role-selector .roles=\"${roles}\" .userRoles=\"${grantingRoles}\"></role-selector>\n\n <div buttons>\n <mwc-button @click=${this.onSave} raised label=\"${i18next.t('button.save')}\"></mwc-button>\n <mwc-button\n @click=${this.onTerminateContract}\n raised\n danger\n label=\"${i18next.t('button.terminate contract')}\"\n ></mwc-button>\n </div>\n `\n }\n\n updated(changes) {\n if (changes.has('customer')) {\n this.refreshRoles()\n }\n }\n\n async refreshRoles() {\n const response = await client.query({\n query: gql`\n query roles($customerId: String!) {\n roles {\n items {\n id\n name\n description\n }\n total\n }\n grantingRoles(customerId: $customerId) {\n id\n role {\n id\n name\n description\n }\n }\n }\n `,\n variables: { customerId: this.customer.id },\n context: gqlContext()\n })\n\n if (!response.errors?.length) {\n this.roles = response.data.roles.items\n this.grantingRoles = response.data.grantingRoles.map(grantingRole => grantingRole.role)\n } else {\n this.roles = []\n this.grantingRoles = []\n }\n }\n\n async onSave() {\n const roles = this.roleSelector.selectedRoles()\n\n const response = await client.mutate({\n mutation: gql`\n mutation grantRoles($customerId: String!, $roles: [RolePatch!]!) {\n grantRoles(customerId: $customerId, roles: $roles)\n }\n `,\n variables: { customerId: this.customer.id, roles },\n context: gqlContext()\n })\n\n if (!response.errors?.length) {\n this.showToast(i18next.t('text.data_updated_successfully'))\n }\n }\n\n async onTerminateContract() {\n if (\n await OxPrompt.open({\n title: i18next.t('text.are_you_sure'),\n text: i18next.t('text.are_you_sure_to_terminate_contract'),\n confirmButton: { text: i18next.t('button.terminate contract') },\n cancelButton: { text: i18next.t('button.cancel') }\n })\n ) {\n const response = await client.mutate({\n mutation: gql`\n mutation terminateContract($partnerName: String!) {\n terminateContract(partnerName: $partnerName)\n }\n `,\n variables: { partnerName: this.customer.name },\n context: gqlContext()\n })\n\n if (!response.errors?.length) {\n const answer = this.dispatchEvent(new CustomEvent('contractTerminated'))\n\n if (answer) {\n await OxPrompt.open({\n type: 'success',\n title: i18next.t('text.completed'),\n confirmButton: { text: i18next.t('button.confirm') }\n })\n }\n }\n }\n }\n\n showToast(message) {\n document.dispatchEvent(new CustomEvent('notify', { detail: { message, option: { timer: 1000 } } }))\n }\n}\n"]}
1
+ {"version":3,"file":"partner-role-editor.js","sourceRoot":"","sources":["../../client/components/partner-role-editor.ts"],"names":[],"mappings":";AAAA,OAAO,oBAAoB,CAAA;AAC3B,OAAO,oBAAoB,CAAA;AAE3B,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAElE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AAEtD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAG9C,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,QAAQ,CAAC,OAAO,CAAC,CAAC,UAAU,CAAC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BAAoB,CAAC,CAAC,CAAA;gBAExE,IAAI,MAAM,EAAE;oBACV,MAAM,QAAQ,CAAC,IAAI,CAAC;wBAClB,IAAI,EAAE,SAAS;wBACf,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,gBAAgB,CAAC;wBAClC,aAAa,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,gBAAgB,CAAC,EAAE;qBACrD,CAAC,CAAA;iBACH;aACF;SACF;IACH,CAAC;IAED,SAAS,CAAC,OAAO;QACf,QAAQ,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,CAAA;IACrG,CAAC;;AAhJM,wBAAM,GAAG;IACd,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;KAqBF;CACF,CAAA;AAED;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;mDAAc;AACzC;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;gDAAkB;AAC5C;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;wDAA0B;AAEpD;IAAC,KAAK,CAAC,eAAe,CAAC;8BAAgB,YAAY;uDAAA;AA9B/C,iBAAiB;IADtB,aAAa,CAAC,qBAAqB,CAAC;GAC/B,iBAAiB,CAkJtB","sourcesContent":["import '@material/mwc-icon'\nimport './role-selector.js'\n\nimport gql from 'graphql-tag'\nimport { css, html, LitElement } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\n\nimport { client, gqlContext } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { OxPrompt } from '@operato/popup/ox-prompt.js'\n\nimport { RoleSelector } from './role-selector'\n\n@customElement('partner-role-editor')\nclass PartnerRoleEditor extends localize(i18next)(LitElement) {\n static styles = [\n css`\n :host {\n display: flex;\n flex-direction: column;\n\n border: 1px solid var(--primary-color);\n padding: var(--padding-default);\n font: normal 15px var(--theme-font);\n color: var(--secondary-color);\n }\n [buttons] {\n margin: 0;\n padding: var(--padding-default);\n background-color: rgba(var(--primary-color-rgb), 0.2);\n }\n mwc-button {\n margin-right: var(--padding-narrow);\n }\n [danger] {\n --mdc-theme-primary: var(--mdc-danger-button-primary-color);\n }\n `\n ]\n\n @property({ type: Object }) customer: any\n @property({ type: Array }) roles: any[] = []\n @property({ type: Array }) grantingRoles: any[] = []\n\n @query('role-selector') roleSelector!: RoleSelector\n\n render() {\n const roles = this.roles || []\n const grantingRoles = this.grantingRoles || []\n\n return html`\n <role-selector .roles=\"${roles}\" .userRoles=\"${grantingRoles}\"></role-selector>\n\n <div buttons>\n <mwc-button @click=${this.onSave} raised label=\"${i18next.t('button.save')}\"></mwc-button>\n <mwc-button\n @click=${this.onTerminateContract}\n raised\n danger\n label=\"${i18next.t('button.terminate contract')}\"\n ></mwc-button>\n </div>\n `\n }\n\n updated(changes) {\n if (changes.has('customer')) {\n this.refreshRoles()\n }\n }\n\n async refreshRoles() {\n const response = await client.query({\n query: gql`\n query roles($customerId: String!) {\n roles {\n items {\n id\n name\n description\n }\n total\n }\n grantingRoles(customerId: $customerId) {\n id\n role {\n id\n name\n description\n }\n }\n }\n `,\n variables: { customerId: this.customer.id },\n context: gqlContext()\n })\n\n if (!response.errors?.length) {\n this.roles = response.data.roles.items\n this.grantingRoles = response.data.grantingRoles.map(grantingRole => grantingRole.role)\n } else {\n this.roles = []\n this.grantingRoles = []\n }\n }\n\n async onSave() {\n const roles = this.roleSelector.selectedRoles()\n\n const response = await client.mutate({\n mutation: gql`\n mutation grantRoles($customerId: String!, $roles: [RolePatch!]!) {\n grantRoles(customerId: $customerId, roles: $roles)\n }\n `,\n variables: { customerId: this.customer.id, roles },\n context: gqlContext()\n })\n\n if (!response.errors?.length) {\n this.showToast(i18next.t('text.data_updated_successfully'))\n }\n }\n\n async onTerminateContract() {\n if (\n await OxPrompt.open({\n title: i18next.t('text.are_you_sure'),\n text: i18next.t('text.are_you_sure_to_terminate_contract'),\n confirmButton: { text: i18next.t('button.terminate contract') },\n cancelButton: { text: i18next.t('button.cancel') }\n })\n ) {\n const response = await client.mutate({\n mutation: gql`\n mutation terminateContract($partnerName: String!) {\n terminateContract(partnerName: $partnerName)\n }\n `,\n variables: { partnerName: this.customer.name },\n context: gqlContext()\n })\n\n if (!response.errors?.length) {\n const answer = this.dispatchEvent(new CustomEvent('contractTerminated'))\n\n if (answer) {\n await OxPrompt.open({\n type: 'success',\n title: i18next.t('text.completed'),\n confirmButton: { text: i18next.t('button.confirm') }\n })\n }\n }\n }\n }\n\n showToast(message) {\n document.dispatchEvent(new CustomEvent('notify', { detail: { message, option: { timer: 1000 } } }))\n }\n}\n"]}
@@ -3,4 +3,13 @@ import '@operato/i18n/ox-i18n.js';
3
3
  export * from './components/role-selector.js';
4
4
  export * from './components/domain-switch.js';
5
5
  export * from './components/invite-user.js';
6
- export declare function setAuthManagementMenus(): Promise<void>;
6
+ export type AuthManagementMenuOptions = {
7
+ role?: boolean;
8
+ appliance?: boolean;
9
+ application?: boolean;
10
+ user?: boolean;
11
+ authProvider?: boolean;
12
+ domain?: boolean;
13
+ attribute?: boolean;
14
+ };
15
+ export declare function setAuthManagementMenus(options?: any): Promise<void>;
@@ -7,80 +7,88 @@ import { hasPrivilege } from '@things-factory/auth-base/dist-client';
7
7
  export * from './components/role-selector.js';
8
8
  export * from './components/domain-switch.js';
9
9
  export * from './components/invite-user.js';
10
- export async function setAuthManagementMenus() {
10
+ export async function setAuthManagementMenus(options) {
11
+ const { role = true, appliance = true, application = true, user = true, authProvider = true, domain = true, attribute = true } = options || {};
11
12
  if (await hasPrivilege({ privilege: 'mutation', category: 'user', domainOwnerGranted: true, superUserGranted: true })) {
12
- store.dispatch({
13
- type: ADD_MORENDA,
14
- morenda: {
15
- icon: html ` <md-icon>how_to_reg</md-icon> `,
16
- name: html ` <ox-i18n msgid="text.role_management"></ox-i18n> `,
17
- action: () => {
18
- navigate('roles');
13
+ role &&
14
+ store.dispatch({
15
+ type: ADD_MORENDA,
16
+ morenda: {
17
+ icon: html ` <md-icon>how_to_reg</md-icon> `,
18
+ name: html ` <ox-i18n msgid="text.role_management"></ox-i18n> `,
19
+ action: () => {
20
+ navigate('roles');
21
+ }
19
22
  }
20
- }
21
- });
22
- store.dispatch({
23
- type: ADD_MORENDA,
24
- morenda: {
25
- icon: html ` <md-icon>devices</md-icon> `,
26
- name: html ` <ox-i18n msgid="text.appliance"></ox-i18n> `,
27
- action: () => {
28
- navigate('appliance-home');
23
+ });
24
+ appliance &&
25
+ store.dispatch({
26
+ type: ADD_MORENDA,
27
+ morenda: {
28
+ icon: html ` <md-icon>devices</md-icon> `,
29
+ name: html ` <ox-i18n msgid="text.appliance"></ox-i18n> `,
30
+ action: () => {
31
+ navigate('appliance-home');
32
+ }
29
33
  }
30
- }
31
- });
32
- store.dispatch({
33
- type: ADD_MORENDA,
34
- morenda: {
35
- icon: html ` <md-icon>apps</md-icon> `,
36
- name: html ` <ox-i18n msgid="text.application management"></ox-i18n> `,
37
- action: () => {
38
- navigate('applications');
34
+ });
35
+ application &&
36
+ store.dispatch({
37
+ type: ADD_MORENDA,
38
+ morenda: {
39
+ icon: html ` <md-icon>apps</md-icon> `,
40
+ name: html ` <ox-i18n msgid="text.application management"></ox-i18n> `,
41
+ action: () => {
42
+ navigate('applications');
43
+ }
39
44
  }
40
- }
41
- });
42
- store.dispatch({
43
- type: ADD_MORENDA,
44
- morenda: {
45
- icon: html ` <md-icon>people</md-icon> `,
46
- name: html ` <ox-i18n msgid="text.user management"></ox-i18n> `,
47
- action: () => {
48
- navigate('users');
45
+ });
46
+ user &&
47
+ store.dispatch({
48
+ type: ADD_MORENDA,
49
+ morenda: {
50
+ icon: html ` <md-icon>people</md-icon> `,
51
+ name: html ` <ox-i18n msgid="text.user management"></ox-i18n> `,
52
+ action: () => {
53
+ navigate('users');
54
+ }
49
55
  }
50
- }
51
- });
52
- store.dispatch({
53
- type: ADD_MORENDA,
54
- morenda: {
55
- icon: html ` <md-icon>badge</md-icon> `,
56
- name: html ` <ox-i18n msgid="text.auth-provider management"></ox-i18n> `,
57
- action: () => {
58
- navigate('auth-providers');
56
+ });
57
+ authProvider &&
58
+ store.dispatch({
59
+ type: ADD_MORENDA,
60
+ morenda: {
61
+ icon: html ` <md-icon>badge</md-icon> `,
62
+ name: html ` <ox-i18n msgid="text.auth-provider management"></ox-i18n> `,
63
+ action: () => {
64
+ navigate('auth-providers');
65
+ }
59
66
  }
60
- }
61
- });
67
+ });
62
68
  }
63
69
  if (await hasPrivilege({ superUserGranted: true })) {
64
- store.dispatch({
65
- type: ADD_MORENDA,
66
- morenda: {
67
- icon: html ` <md-icon>business</md-icon> `,
68
- name: html ` <ox-i18n msgid="text.domain management"></ox-i18n> `,
69
- action: () => {
70
- navigate('domains');
70
+ domain &&
71
+ store.dispatch({
72
+ type: ADD_MORENDA,
73
+ morenda: {
74
+ icon: html ` <md-icon>business</md-icon> `,
75
+ name: html ` <ox-i18n msgid="text.domain management"></ox-i18n> `,
76
+ action: () => {
77
+ navigate('domains');
78
+ }
71
79
  }
72
- }
73
- });
74
- store.dispatch({
75
- type: ADD_MORENDA,
76
- morenda: {
77
- icon: html ` <md-icon>dataset</md-icon> `,
78
- name: html ` <ox-i18n msgid="text.attribute management"></ox-i18n> `,
79
- action: () => {
80
- navigate('attributes');
80
+ });
81
+ attribute &&
82
+ store.dispatch({
83
+ type: ADD_MORENDA,
84
+ morenda: {
85
+ icon: html ` <md-icon>dataset</md-icon> `,
86
+ name: html ` <ox-i18n msgid="text.attribute management"></ox-i18n> `,
87
+ action: () => {
88
+ navigate('attributes');
89
+ }
81
90
  }
82
- }
83
- });
91
+ });
84
92
  }
85
93
  }
86
94
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../client/index.ts"],"names":[],"mappings":"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/i18n/ox-i18n.js'\n\nimport { html } from 'lit-html'\n\nimport { navigate, store } from '@operato/shell'\nimport { ADD_MORENDA } from '@things-factory/more-base/client'\nimport { hasPrivilege } from '@things-factory/auth-base/dist-client'\n\nexport * from './components/role-selector.js'\nexport * from './components/domain-switch.js'\nexport * from './components/invite-user.js'\n\nexport async function setAuthManagementMenus() {\n if (await hasPrivilege({ privilege: 'mutation', category: 'user', domainOwnerGranted: true, superUserGranted: true })) {\n store.dispatch({\n type: ADD_MORENDA,\n morenda: {\n icon: html` <md-icon>how_to_reg</md-icon> `,\n name: html` <ox-i18n msgid=\"text.role_management\"></ox-i18n> `,\n action: () => {\n navigate('roles')\n }\n }\n })\n\n store.dispatch({\n type: ADD_MORENDA,\n morenda: {\n icon: html` <md-icon>devices</md-icon> `,\n name: html` <ox-i18n msgid=\"text.appliance\"></ox-i18n> `,\n action: () => {\n navigate('appliance-home')\n }\n }\n })\n\n store.dispatch({\n type: ADD_MORENDA,\n morenda: {\n icon: html` <md-icon>apps</md-icon> `,\n name: html` <ox-i18n msgid=\"text.application management\"></ox-i18n> `,\n action: () => {\n navigate('applications')\n }\n }\n })\n\n store.dispatch({\n type: ADD_MORENDA,\n morenda: {\n icon: html` <md-icon>people</md-icon> `,\n name: html` <ox-i18n msgid=\"text.user management\"></ox-i18n> `,\n action: () => {\n navigate('users')\n }\n }\n })\n\n store.dispatch({\n type: ADD_MORENDA,\n morenda: {\n icon: html` <md-icon>badge</md-icon> `,\n name: html` <ox-i18n msgid=\"text.auth-provider management\"></ox-i18n> `,\n action: () => {\n navigate('auth-providers')\n }\n }\n })\n }\n\n if (await hasPrivilege({ superUserGranted: true })) {\n store.dispatch({\n type: ADD_MORENDA,\n morenda: {\n icon: html` <md-icon>business</md-icon> `,\n name: html` <ox-i18n msgid=\"text.domain management\"></ox-i18n> `,\n action: () => {\n navigate('domains')\n }\n }\n })\n\n store.dispatch({\n type: ADD_MORENDA,\n morenda: {\n icon: html` <md-icon>dataset</md-icon> `,\n name: html` <ox-i18n msgid=\"text.attribute management\"></ox-i18n> `,\n action: () => {\n navigate('attributes')\n }\n }\n })\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../client/index.ts"],"names":[],"mappings":"AAAA,OAAO,4BAA4B,CAAA;AACnC,OAAO,0BAA0B,CAAA;AAEjC,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAE/B,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAA;AAEpE,cAAc,+BAA+B,CAAA;AAC7C,cAAc,+BAA+B,CAAA;AAC7C,cAAc,6BAA6B,CAAA;AAY3C,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,OAAa;IACxD,MAAM,EACJ,IAAI,GAAG,IAAI,EACX,SAAS,GAAG,IAAI,EAChB,WAAW,GAAG,IAAI,EAClB,IAAI,GAAG,IAAI,EACX,YAAY,GAAG,IAAI,EACnB,MAAM,GAAG,IAAI,EACb,SAAS,GAAG,IAAI,EACjB,GAAG,OAAO,IAAI,EAAE,CAAA;IAEjB,IACE,MAAM,YAAY,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,kBAAkB,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC,EACjH;QACA,IAAI;YACF,KAAK,CAAC,QAAQ,CAAC;gBACb,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE;oBACP,IAAI,EAAE,IAAI,CAAA,iCAAiC;oBAC3C,IAAI,EAAE,IAAI,CAAA,oDAAoD;oBAC9D,MAAM,EAAE,GAAG,EAAE;wBACX,QAAQ,CAAC,OAAO,CAAC,CAAA;oBACnB,CAAC;iBACF;aACF,CAAC,CAAA;QAEJ,SAAS;YACP,KAAK,CAAC,QAAQ,CAAC;g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CAAA,+BAA+B;oBACzC,IAAI,EAAE,IAAI,CAAA,sDAAsD;oBAChE,MAAM,EAAE,GAAG,EAAE;wBACX,QAAQ,CAAC,SAAS,CAAC,CAAA;oBACrB,CAAC;iBACF;aACF,CAAC,CAAA;QAEJ,SAAS;YACP,KAAK,CAAC,QAAQ,CAAC;gBACb,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE;oBACP,IAAI,EAAE,IAAI,CAAA,8BAA8B;oBACxC,IAAI,EAAE,IAAI,CAAA,yDAAyD;oBACnE,MAAM,EAAE,GAAG,EAAE;wBACX,QAAQ,CAAC,YAAY,CAAC,CAAA;oBACxB,CAAC;iBACF;aACF,CAAC,CAAA;KACL;AACH,CAAC","sourcesContent":["import '@material/web/icon/icon.js'\nimport '@operato/i18n/ox-i18n.js'\n\nimport { html } from 'lit-html'\n\nimport { navigate, store } from '@operato/shell'\nimport { ADD_MORENDA } from '@things-factory/more-base/client'\nimport { hasPrivilege } from '@things-factory/auth-base/dist-client'\n\nexport * from './components/role-selector.js'\nexport * from './components/domain-switch.js'\nexport * from './components/invite-user.js'\n\nexport type AuthManagementMenuOptions = {\n role?: boolean\n appliance?: boolean\n application?: boolean\n user?: boolean\n authProvider?: boolean\n domain?: boolean\n attribute?: boolean\n}\n\nexport async function setAuthManagementMenus(options?: any) {\n const {\n role = true,\n appliance = true,\n application = true,\n user = true,\n authProvider = true,\n domain = true,\n attribute = true\n } = options || {}\n\n if (\n await hasPrivilege({ privilege: 'mutation', category: 'user', domainOwnerGranted: true, superUserGranted: true })\n ) {\n role &&\n store.dispatch({\n type: ADD_MORENDA,\n morenda: {\n icon: html` <md-icon>how_to_reg</md-icon> `,\n name: html` <ox-i18n msgid=\"text.role_management\"></ox-i18n> `,\n action: () => {\n navigate('roles')\n }\n }\n })\n\n appliance &&\n store.dispatch({\n type: ADD_MORENDA,\n morenda: {\n icon: html` <md-icon>devices</md-icon> `,\n name: html` <ox-i18n msgid=\"text.appliance\"></ox-i18n> `,\n action: () => {\n navigate('appliance-home')\n }\n }\n })\n\n application &&\n store.dispatch({\n type: ADD_MORENDA,\n morenda: {\n icon: html` <md-icon>apps</md-icon> `,\n name: html` <ox-i18n msgid=\"text.application management\"></ox-i18n> `,\n action: () => {\n navigate('applications')\n }\n }\n })\n\n user &&\n store.dispatch({\n type: ADD_MORENDA,\n morenda: {\n icon: html` <md-icon>people</md-icon> `,\n name: html` <ox-i18n msgid=\"text.user management\"></ox-i18n> `,\n action: () => {\n navigate('users')\n }\n }\n })\n\n authProvider &&\n store.dispatch({\n type: ADD_MORENDA,\n morenda: {\n icon: html` <md-icon>badge</md-icon> `,\n name: html` <ox-i18n msgid=\"text.auth-provider management\"></ox-i18n> `,\n action: () => {\n navigate('auth-providers')\n }\n }\n })\n }\n\n if (await hasPrivilege({ superUserGranted: true })) {\n domain &&\n store.dispatch({\n type: ADD_MORENDA,\n morenda: {\n icon: html` <md-icon>business</md-icon> `,\n name: html` <ox-i18n msgid=\"text.domain management\"></ox-i18n> `,\n action: () => {\n navigate('domains')\n }\n }\n })\n\n attribute &&\n store.dispatch({\n type: ADD_MORENDA,\n morenda: {\n icon: html` <md-icon>dataset</md-icon> `,\n name: html` <ox-i18n msgid=\"text.attribute management\"></ox-i18n> `,\n action: () => {\n navigate('attributes')\n }\n }\n })\n }\n}\n"]}