@things-factory/dashboard 7.0.0-alpha.9 → 7.0.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.
- package/client/actions/{board-settings.js → board-settings.ts} +3 -2
- package/client/{bootstrap.js → bootstrap.ts} +2 -2
- package/client/{const.js → const.ts} +1 -1
- package/client/index.ts +1 -0
- package/client/pages/{dashboard.js → dashboard.ts} +25 -22
- package/client/tsconfig.json +11 -0
- package/client/viewparts/{dashboard-setting-let.js → dashboard-setting-let.ts} +102 -104
- package/dist-client/actions/board-settings.d.ts +3 -0
- package/dist-client/actions/board-settings.js +29 -0
- package/dist-client/actions/board-settings.js.map +1 -0
- package/dist-client/actions/index.d.ts +1 -0
- package/dist-client/actions/index.js +2 -0
- package/dist-client/actions/index.js.map +1 -0
- package/dist-client/bootstrap.d.ts +2 -0
- package/dist-client/bootstrap.js +31 -0
- package/dist-client/bootstrap.js.map +1 -0
- package/dist-client/const.d.ts +5 -0
- package/dist-client/const.js +6 -0
- package/dist-client/const.js.map +1 -0
- package/dist-client/index.d.ts +1 -0
- package/dist-client/index.js +2 -0
- package/dist-client/index.js.map +1 -0
- package/dist-client/pages/dashboard.d.ts +21 -0
- package/dist-client/pages/dashboard.js +97 -0
- package/dist-client/pages/dashboard.js.map +1 -0
- package/dist-client/reducers/board-settings.d.ts +2 -0
- package/dist-client/reducers/board-settings.js +14 -0
- package/dist-client/reducers/board-settings.js.map +1 -0
- package/dist-client/route.d.ts +1 -0
- package/dist-client/route.js +10 -0
- package/dist-client/route.js.map +1 -0
- package/dist-client/tsconfig.tsbuildinfo +1 -0
- package/dist-client/viewparts/dashboard-setting-let.d.ts +26 -0
- package/dist-client/viewparts/dashboard-setting-let.js +222 -0
- package/dist-client/viewparts/dashboard-setting-let.js.map +1 -0
- package/dist-server/index.d.ts +1 -0
- package/dist-server/index.js +0 -1
- package/dist-server/index.js.map +1 -1
- package/dist-server/service/board-settings/board-setting.d.ts +7 -0
- package/dist-server/service/board-settings/board-setting.js +3 -4
- package/dist-server/service/board-settings/board-setting.js.map +1 -1
- package/dist-server/service/board-settings/board-settings-query.d.ts +4 -0
- package/dist-server/service/board-settings/board-settings-query.js +2 -2
- package/dist-server/service/board-settings/board-settings-query.js.map +1 -1
- package/dist-server/service/board-settings/index.d.ts +3 -0
- package/dist-server/service/index.d.ts +5 -0
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +14 -12
- package/server/index.ts +0 -1
- package/server/tsconfig.json +10 -0
- package/things-factory.config.js +2 -2
- package/client/index.js +0 -1
- package/dist-server/migrations/index.js +0 -12
- package/dist-server/migrations/index.js.map +0 -1
- package/server/migrations/index.ts +0 -9
- package/tsconfig.json +0 -9
- /package/client/actions/{index.js → index.ts} +0 -0
- /package/client/reducers/{board-settings.js → board-settings.ts} +0 -0
- /package/client/{route.js → route.ts} +0 -0
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { client } from '@things-factory/shell'
|
|
2
1
|
import gql from 'graphql-tag'
|
|
3
2
|
|
|
3
|
+
import { client } from '@operato/graphql'
|
|
4
|
+
|
|
4
5
|
export const UPDATE_BOARD_SETTINGS = 'UPDATE_BOARD_SETTINGS'
|
|
5
6
|
export const CLEAR_BOARD_SETTINGS = 'CLEAR_BOARD_SETTINGS'
|
|
6
7
|
|
|
7
8
|
export async function fetchBoardSettings(names) {
|
|
8
9
|
var response = await client.query({
|
|
9
10
|
query: gql`
|
|
10
|
-
query($names: [String!]) {
|
|
11
|
+
query ($names: [String!]) {
|
|
11
12
|
boardSettings(names: $names) {
|
|
12
13
|
name
|
|
13
14
|
value
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { html } from 'lit'
|
|
2
|
-
import { store } from '@
|
|
2
|
+
import { store } from '@operato/shell'
|
|
3
3
|
import { auth, hasPrivilege } from '@things-factory/auth-base/dist-client'
|
|
4
|
-
import { ADD_SETTING } from '@things-factory/setting-base'
|
|
4
|
+
import { ADD_SETTING } from '@things-factory/setting-base/dist-client'
|
|
5
5
|
|
|
6
6
|
import { UPDATE_BOARD_SETTINGS, fetchBoardSettings } from './actions/board-settings'
|
|
7
7
|
import boardSetting from './reducers/board-settings'
|
|
@@ -2,4 +2,4 @@ export const FALLBACK_HOME_BOARD = 'home' /* for backward compatibility */
|
|
|
2
2
|
export const DASHBOARD = 'dashboard'
|
|
3
3
|
export const DASHBOARD_MOBILE = 'dashboard-mobile'
|
|
4
4
|
export const DASHBOARD_DESCRIPTION = 'dashboard'
|
|
5
|
-
export const DASHBOARD_MOBILE_DESCRIPTION = 'dashboard mobile'
|
|
5
|
+
export const DASHBOARD_MOBILE_DESCRIPTION = 'dashboard mobile'
|
package/client/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './actions'
|
|
@@ -2,29 +2,30 @@ import '@operato/board/ox-board-selector.js'
|
|
|
2
2
|
|
|
3
3
|
import gql from 'graphql-tag'
|
|
4
4
|
import { html } from 'lit'
|
|
5
|
+
import { customElement } from 'lit/decorators.js'
|
|
5
6
|
|
|
7
|
+
import { store } from '@operato/shell'
|
|
8
|
+
import { client } from '@operato/graphql'
|
|
9
|
+
import { i18next } from '@operato/i18n'
|
|
6
10
|
import { openPopup } from '@operato/layout'
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { client, store } from '@things-factory/shell'
|
|
10
|
-
import { gqlBuilder, isMobileDevice } from '@things-factory/utils'
|
|
11
|
+
import { isMobileDevice } from '@operato/utils'
|
|
12
|
+
import { BoardViewerPage } from '@things-factory/board-ui/dist-client'
|
|
11
13
|
|
|
12
14
|
import { fetchBoardSettings, UPDATE_BOARD_SETTINGS } from '../actions/board-settings'
|
|
13
15
|
import { DASHBOARD, DASHBOARD_MOBILE, FALLBACK_HOME_BOARD } from '../const'
|
|
14
16
|
|
|
15
17
|
const HOME_DESCRIPTION = 'home dashboard'
|
|
16
18
|
|
|
17
|
-
const FALLBACK_ORDER = isMobileDevice()
|
|
18
|
-
? [DASHBOARD_MOBILE, DASHBOARD, FALLBACK_HOME_BOARD]
|
|
19
|
-
: [DASHBOARD, FALLBACK_HOME_BOARD]
|
|
19
|
+
const FALLBACK_ORDER = isMobileDevice() ? [DASHBOARD_MOBILE, DASHBOARD, FALLBACK_HOME_BOARD] : [DASHBOARD, FALLBACK_HOME_BOARD]
|
|
20
20
|
const HOME_BOARD = isMobileDevice() ? DASHBOARD_MOBILE : DASHBOARD
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
@customElement('dashboard-home')
|
|
23
|
+
export class DashboardHome extends BoardViewerPage {
|
|
23
24
|
stateChanged(state) {
|
|
24
25
|
super.stateChanged(state)
|
|
25
26
|
|
|
26
27
|
const dashboard = state?.boardSetting
|
|
27
|
-
const homeBoard = dashboard && dashboard[FALLBACK_ORDER.find(name => dashboard[name])]
|
|
28
|
+
const homeBoard = dashboard && dashboard[FALLBACK_ORDER.find(name => dashboard[name]) || 'maybe notfound']
|
|
28
29
|
this._boardId = homeBoard?.value
|
|
29
30
|
}
|
|
30
31
|
|
|
@@ -82,26 +83,28 @@ class DashboardHome extends BoardViewerPage {
|
|
|
82
83
|
}
|
|
83
84
|
|
|
84
85
|
async saveSettings({ name, value, category, description }) {
|
|
85
|
-
if (!(name && value))
|
|
86
|
+
if (!(name && value)) {
|
|
87
|
+
return
|
|
88
|
+
}
|
|
86
89
|
|
|
87
90
|
await client.query({
|
|
88
91
|
query: gql`
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
patch: {
|
|
93
|
-
name,
|
|
94
|
-
description,
|
|
95
|
-
category,
|
|
92
|
+
mutation UpdateSetting($patch: SettingPatch!, $name: String!) {
|
|
93
|
+
updateSetting(patch: $patch, name: $name) {
|
|
94
|
+
name
|
|
96
95
|
value
|
|
97
96
|
}
|
|
98
|
-
}
|
|
99
|
-
|
|
97
|
+
}
|
|
98
|
+
`,
|
|
99
|
+
variables: {
|
|
100
|
+
name,
|
|
101
|
+
patch: {
|
|
102
|
+
name,
|
|
103
|
+
description,
|
|
104
|
+
category,
|
|
100
105
|
value
|
|
101
106
|
}
|
|
102
|
-
}
|
|
107
|
+
}
|
|
103
108
|
})
|
|
104
109
|
}
|
|
105
110
|
}
|
|
106
|
-
|
|
107
|
-
customElements.define('dashboard-home', DashboardHome)
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
+
import '@material/web/icon/icon.js'
|
|
1
2
|
import '@operato/board/ox-board-selector.js'
|
|
2
3
|
import '@operato/i18n/ox-i18n.js'
|
|
3
4
|
|
|
4
5
|
import gql from 'graphql-tag'
|
|
5
6
|
import { css, html, LitElement } from 'lit'
|
|
7
|
+
import { customElement, state } from 'lit/decorators.js'
|
|
6
8
|
import { connect } from 'pwa-helpers'
|
|
7
9
|
|
|
8
10
|
import { openPopup } from '@operato/layout'
|
|
9
|
-
import { i18next, localize } from '@
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
11
|
+
import { i18next, localize } from '@operato/i18n'
|
|
12
|
+
import { store } from '@operato/shell'
|
|
13
|
+
import { client } from '@operato/graphql'
|
|
12
14
|
|
|
13
15
|
import { fetchBoardSettings, UPDATE_BOARD_SETTINGS } from '../actions/board-settings'
|
|
14
16
|
import {
|
|
@@ -19,110 +21,104 @@ import {
|
|
|
19
21
|
FALLBACK_HOME_BOARD
|
|
20
22
|
} from '../const'
|
|
21
23
|
|
|
24
|
+
@customElement('dashboard-setting-let')
|
|
22
25
|
export class DashboardSettingLet extends connect(store)(localize(i18next)(LitElement)) {
|
|
23
|
-
static
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
26
|
+
static styles = [
|
|
27
|
+
css`
|
|
28
|
+
div.field {
|
|
29
|
+
display: flex;
|
|
30
|
+
flex-direction: row;
|
|
31
|
+
align-items: flex-start;
|
|
32
|
+
max-width: 100%;
|
|
33
|
+
overflow: hidden;
|
|
34
|
+
}
|
|
33
35
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
div.field > * {
|
|
37
|
+
flex: none;
|
|
38
|
+
}
|
|
37
39
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
div.field > div {
|
|
41
|
+
flex: 1;
|
|
42
|
+
display: flex;
|
|
43
|
+
flex-direction: column;
|
|
44
|
+
align-items: flex-start;
|
|
45
|
+
}
|
|
44
46
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
div.field a {
|
|
48
|
+
overflow: hidden;
|
|
49
|
+
border: var(--border-dim-color);
|
|
50
|
+
border-radius: var(--border-radius);
|
|
51
|
+
background-color: rgba(0, 0, 0, 0.1);
|
|
52
|
+
min-width: 50px;
|
|
53
|
+
min-height: 50px;
|
|
54
|
+
}
|
|
53
55
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
div.field img {
|
|
57
|
+
max-height: 250px;
|
|
58
|
+
max-width: 100%;
|
|
59
|
+
}
|
|
58
60
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
61
|
+
.name {
|
|
62
|
+
color: var(--md-sys-color-on-secondary-container);
|
|
63
|
+
}
|
|
62
64
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
.description {
|
|
66
|
+
font-size: 0.7rem;
|
|
67
|
+
opacity: 0.7;
|
|
68
|
+
color: var(--md-sys-color-on-secondary-container);
|
|
69
|
+
}
|
|
68
70
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
label {
|
|
72
|
+
width: 80px;
|
|
73
|
+
padding-right: var(--spacing-medium);
|
|
74
|
+
font: bold 0.9em var(--theme-font);
|
|
75
|
+
}
|
|
74
76
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
setting-let > form {
|
|
78
|
+
display: grid;
|
|
79
|
+
grid-template-columns: 1fr 1fr;
|
|
80
|
+
}
|
|
79
81
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
82
|
+
md-icon {
|
|
83
|
+
--md-icon-size: 18px;
|
|
84
|
+
margin: 2px 2px 5px 2px;
|
|
85
|
+
padding: 0 var(--spacing-medium);
|
|
86
|
+
color: var(--md-sys-on-secondary-container, #fff);
|
|
87
|
+
background-color: var(--md-sys-secondary-container, #394e64);
|
|
88
|
+
border-radius: var(--border-radius, 5px);
|
|
89
|
+
border: var(--button-border, 1px solid transparent);
|
|
90
|
+
}
|
|
89
91
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
92
|
+
md-icon:hover,
|
|
93
|
+
md-icon:active {
|
|
94
|
+
background-color: var(--button-active-background-color, #22a6a7);
|
|
95
|
+
}
|
|
95
96
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
div.field {
|
|
102
|
-
border-bottom: var(--border-dark-color);
|
|
103
|
-
padding: var(--padding-default);
|
|
104
|
-
}
|
|
105
|
-
mwc-icon {
|
|
106
|
-
padding: var(--padding-narrow) var(--padding-default);
|
|
107
|
-
}
|
|
97
|
+
@media screen and (max-width: 460px) {
|
|
98
|
+
setting-let > form {
|
|
99
|
+
display: flex;
|
|
100
|
+
flex-direction: column;
|
|
108
101
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
102
|
+
div.field {
|
|
103
|
+
border-bottom: var(--border-dim-color);
|
|
104
|
+
padding: var(--spacing-medium);
|
|
105
|
+
}
|
|
106
|
+
md-icon {
|
|
107
|
+
padding: var(--spacing-small) var(--spacing-medium);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
`
|
|
111
|
+
]
|
|
112
112
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
dashboard: Object,
|
|
116
|
-
dashboardMobile: Object
|
|
117
|
-
}
|
|
118
|
-
}
|
|
113
|
+
@state() private dashboard: any
|
|
114
|
+
@state() private dashboardMobile: any
|
|
119
115
|
|
|
120
116
|
render() {
|
|
121
117
|
return html`
|
|
122
118
|
<setting-let>
|
|
123
119
|
<ox-i18n slot="title" msgid="title.dashboard setting"></ox-i18n>
|
|
124
120
|
|
|
125
|
-
<form slot="content"
|
|
121
|
+
<form slot="content">
|
|
126
122
|
${[
|
|
127
123
|
{
|
|
128
124
|
title: i18next.t('label.dashboard for desktop'),
|
|
@@ -143,9 +139,9 @@ export class DashboardSettingLet extends connect(store)(localize(i18next)(LitEle
|
|
|
143
139
|
<div>
|
|
144
140
|
<div class="name">${field.board.name}</div>
|
|
145
141
|
<span class="description">${field.board.description}</span>
|
|
146
|
-
<
|
|
142
|
+
<md-icon @click=${e => this.onClickBoardSelector(field.key, field.description)}>
|
|
147
143
|
more_horiz
|
|
148
|
-
</
|
|
144
|
+
</md-icon>
|
|
149
145
|
${
|
|
150
146
|
field.board.id
|
|
151
147
|
? html`
|
|
@@ -167,7 +163,7 @@ export class DashboardSettingLet extends connect(store)(localize(i18next)(LitEle
|
|
|
167
163
|
`
|
|
168
164
|
}
|
|
169
165
|
|
|
170
|
-
stateChanged(state) {
|
|
166
|
+
stateChanged(state: any) {
|
|
171
167
|
var dashboard = state.boardSetting[DASHBOARD] || state.boardSetting[FALLBACK_HOME_BOARD]
|
|
172
168
|
var dashboardMobile = state.boardSetting[DASHBOARD_MOBILE] || dashboard
|
|
173
169
|
|
|
@@ -175,7 +171,7 @@ export class DashboardSettingLet extends connect(store)(localize(i18next)(LitEle
|
|
|
175
171
|
this.dashboardMobile = (dashboardMobile ? dashboardMobile.board : {}) || {}
|
|
176
172
|
}
|
|
177
173
|
|
|
178
|
-
onClickBoardSelector(name, description) {
|
|
174
|
+
onClickBoardSelector(name: string, description: string) {
|
|
179
175
|
var popup = openPopup(
|
|
180
176
|
html`
|
|
181
177
|
<ox-board-selector
|
|
@@ -214,26 +210,28 @@ export class DashboardSettingLet extends connect(store)(localize(i18next)(LitEle
|
|
|
214
210
|
}
|
|
215
211
|
|
|
216
212
|
async saveSettings({ name, value, category, description }) {
|
|
217
|
-
if (!(name && value))
|
|
213
|
+
if (!(name && value)) {
|
|
214
|
+
return
|
|
215
|
+
}
|
|
218
216
|
|
|
219
217
|
await client.query({
|
|
220
218
|
query: gql`
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
patch: {
|
|
225
|
-
name,
|
|
226
|
-
description,
|
|
227
|
-
category,
|
|
219
|
+
mutation UpdateSetting($patch: SettingPatch!, $name: String!) {
|
|
220
|
+
updateSetting(patch: $patch, name: $name) {
|
|
221
|
+
name
|
|
228
222
|
value
|
|
229
223
|
}
|
|
230
|
-
}
|
|
231
|
-
|
|
224
|
+
}
|
|
225
|
+
`,
|
|
226
|
+
variables: {
|
|
227
|
+
name,
|
|
228
|
+
patch: {
|
|
229
|
+
name,
|
|
230
|
+
description,
|
|
231
|
+
category,
|
|
232
232
|
value
|
|
233
233
|
}
|
|
234
|
-
}
|
|
234
|
+
}
|
|
235
235
|
})
|
|
236
236
|
}
|
|
237
237
|
}
|
|
238
|
-
|
|
239
|
-
customElements.define('dashboard-setting-let', DashboardSettingLet)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import gql from 'graphql-tag';
|
|
2
|
+
import { client } from '@operato/graphql';
|
|
3
|
+
export const UPDATE_BOARD_SETTINGS = 'UPDATE_BOARD_SETTINGS';
|
|
4
|
+
export const CLEAR_BOARD_SETTINGS = 'CLEAR_BOARD_SETTINGS';
|
|
5
|
+
export async function fetchBoardSettings(names) {
|
|
6
|
+
var response = await client.query({
|
|
7
|
+
query: gql `
|
|
8
|
+
query ($names: [String!]) {
|
|
9
|
+
boardSettings(names: $names) {
|
|
10
|
+
name
|
|
11
|
+
value
|
|
12
|
+
board {
|
|
13
|
+
id
|
|
14
|
+
name
|
|
15
|
+
description
|
|
16
|
+
thumbnail
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
`,
|
|
21
|
+
variables: {
|
|
22
|
+
names
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
if (!response || !response.data)
|
|
26
|
+
return;
|
|
27
|
+
return response.data.boardSettings;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=board-settings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"board-settings.js","sourceRoot":"","sources":["../../client/actions/board-settings.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,aAAa,CAAA;AAE7B,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAEzC,MAAM,CAAC,MAAM,qBAAqB,GAAG,uBAAuB,CAAA;AAC5D,MAAM,CAAC,MAAM,oBAAoB,GAAG,sBAAsB,CAAA;AAE1D,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,KAAK;IAC5C,IAAI,QAAQ,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC;QAChC,KAAK,EAAE,GAAG,CAAA;;;;;;;;;;;;;KAaT;QACD,SAAS,EAAE;YACT,KAAK;SACN;KACF,CAAC,CAAA;IAEF,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ,CAAC,IAAI;QAAE,OAAM;IACvC,OAAO,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAA;AACpC,CAAC","sourcesContent":["import gql from 'graphql-tag'\n\nimport { client } from '@operato/graphql'\n\nexport const UPDATE_BOARD_SETTINGS = 'UPDATE_BOARD_SETTINGS'\nexport const CLEAR_BOARD_SETTINGS = 'CLEAR_BOARD_SETTINGS'\n\nexport async function fetchBoardSettings(names) {\n var response = await client.query({\n query: gql`\n query ($names: [String!]) {\n boardSettings(names: $names) {\n name\n value\n board {\n id\n name\n description\n thumbnail\n }\n }\n }\n `,\n variables: {\n names\n }\n })\n\n if (!response || !response.data) return\n return response.data.boardSettings\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './board-settings';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../client/actions/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA","sourcesContent":["export * from './board-settings'\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { html } from 'lit';
|
|
2
|
+
import { store } from '@operato/shell';
|
|
3
|
+
import { auth, hasPrivilege } from '@things-factory/auth-base/dist-client';
|
|
4
|
+
import { ADD_SETTING } from '@things-factory/setting-base/dist-client';
|
|
5
|
+
import { UPDATE_BOARD_SETTINGS, fetchBoardSettings } from './actions/board-settings';
|
|
6
|
+
import boardSetting from './reducers/board-settings';
|
|
7
|
+
import './viewparts/dashboard-setting-let';
|
|
8
|
+
import { FALLBACK_HOME_BOARD, DASHBOARD, DASHBOARD_MOBILE } from './const';
|
|
9
|
+
export default function bootstrap() {
|
|
10
|
+
store.addReducers({ boardSetting });
|
|
11
|
+
auth.on('profile', async () => {
|
|
12
|
+
var settings = await fetchBoardSettings([FALLBACK_HOME_BOARD, DASHBOARD, DASHBOARD_MOBILE]);
|
|
13
|
+
store.dispatch({
|
|
14
|
+
type: UPDATE_BOARD_SETTINGS,
|
|
15
|
+
settings: settings.reduce((settings, setting) => {
|
|
16
|
+
settings[setting.name] = setting;
|
|
17
|
+
return settings;
|
|
18
|
+
}, {})
|
|
19
|
+
});
|
|
20
|
+
if (await hasPrivilege({ privilege: 'mutation', category: 'setting' })) {
|
|
21
|
+
store.dispatch({
|
|
22
|
+
type: ADD_SETTING,
|
|
23
|
+
setting: {
|
|
24
|
+
seq: 20,
|
|
25
|
+
template: html ` <dashboard-setting-let></dashboard-setting-let> `
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=bootstrap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../client/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC1B,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AACtC,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAA;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAA;AAEtE,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AACpF,OAAO,YAAY,MAAM,2BAA2B,CAAA;AAEpD,OAAO,mCAAmC,CAAA;AAE1C,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE1E,MAAM,CAAC,OAAO,UAAU,SAAS;IAC/B,KAAK,CAAC,WAAW,CAAC,EAAE,YAAY,EAAE,CAAC,CAAA;IAEnC,IAAI,CAAC,EAAE,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE;QAC5B,IAAI,QAAQ,GAAG,MAAM,kBAAkB,CAAC,CAAC,mBAAmB,EAAE,SAAS,EAAE,gBAAgB,CAAC,CAAC,CAAA;QAE3F,KAAK,CAAC,QAAQ,CAAC;YACb,IAAI,EAAE,qBAAqB;YAC3B,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE;gBAC9C,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAA;gBAChC,OAAO,QAAQ,CAAA;YACjB,CAAC,EAAE,EAAE,CAAC;SACP,CAAC,CAAA;QAEF,IAAI,MAAM,YAAY,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;YACvE,KAAK,CAAC,QAAQ,CAAC;gBACb,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE;oBACP,GAAG,EAAE,EAAE;oBACP,QAAQ,EAAE,IAAI,CAAA,mDAAmD;iBAClE;aACF,CAAC,CAAA;QACJ,CAAC;IACH,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import { html } from 'lit'\nimport { store } from '@operato/shell'\nimport { auth, hasPrivilege } from '@things-factory/auth-base/dist-client'\nimport { ADD_SETTING } from '@things-factory/setting-base/dist-client'\n\nimport { UPDATE_BOARD_SETTINGS, fetchBoardSettings } from './actions/board-settings'\nimport boardSetting from './reducers/board-settings'\n\nimport './viewparts/dashboard-setting-let'\n\nimport { FALLBACK_HOME_BOARD, DASHBOARD, DASHBOARD_MOBILE } from './const'\n\nexport default function bootstrap() {\n store.addReducers({ boardSetting })\n\n auth.on('profile', async () => {\n var settings = await fetchBoardSettings([FALLBACK_HOME_BOARD, DASHBOARD, DASHBOARD_MOBILE])\n\n store.dispatch({\n type: UPDATE_BOARD_SETTINGS,\n settings: settings.reduce((settings, setting) => {\n settings[setting.name] = setting\n return settings\n }, {})\n })\n\n if (await hasPrivilege({ privilege: 'mutation', category: 'setting' })) {\n store.dispatch({\n type: ADD_SETTING,\n setting: {\n seq: 20,\n template: html` <dashboard-setting-let></dashboard-setting-let> `\n }\n })\n }\n })\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const FALLBACK_HOME_BOARD = "home";
|
|
2
|
+
export declare const DASHBOARD = "dashboard";
|
|
3
|
+
export declare const DASHBOARD_MOBILE = "dashboard-mobile";
|
|
4
|
+
export declare const DASHBOARD_DESCRIPTION = "dashboard";
|
|
5
|
+
export declare const DASHBOARD_MOBILE_DESCRIPTION = "dashboard mobile";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export const FALLBACK_HOME_BOARD = 'home'; /* for backward compatibility */
|
|
2
|
+
export const DASHBOARD = 'dashboard';
|
|
3
|
+
export const DASHBOARD_MOBILE = 'dashboard-mobile';
|
|
4
|
+
export const DASHBOARD_DESCRIPTION = 'dashboard';
|
|
5
|
+
export const DASHBOARD_MOBILE_DESCRIPTION = 'dashboard mobile';
|
|
6
|
+
//# sourceMappingURL=const.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"const.js","sourceRoot":"","sources":["../client/const.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAA,CAAC,gCAAgC;AAC1E,MAAM,CAAC,MAAM,SAAS,GAAG,WAAW,CAAA;AACpC,MAAM,CAAC,MAAM,gBAAgB,GAAG,kBAAkB,CAAA;AAClD,MAAM,CAAC,MAAM,qBAAqB,GAAG,WAAW,CAAA;AAChD,MAAM,CAAC,MAAM,4BAA4B,GAAG,kBAAkB,CAAA","sourcesContent":["export const FALLBACK_HOME_BOARD = 'home' /* for backward compatibility */\nexport const DASHBOARD = 'dashboard'\nexport const DASHBOARD_MOBILE = 'dashboard-mobile'\nexport const DASHBOARD_DESCRIPTION = 'dashboard'\nexport const DASHBOARD_MOBILE_DESCRIPTION = 'dashboard mobile'\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './actions';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../client/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA","sourcesContent":["export * from './actions'\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import '@operato/board/ox-board-selector.js';
|
|
2
|
+
import { BoardViewerPage } from '@things-factory/board-ui/dist-client';
|
|
3
|
+
export declare class DashboardHome extends BoardViewerPage {
|
|
4
|
+
stateChanged(state: any): void;
|
|
5
|
+
get oopsNote(): {
|
|
6
|
+
icon: string;
|
|
7
|
+
title: string;
|
|
8
|
+
description: string;
|
|
9
|
+
click: (e: any) => void;
|
|
10
|
+
};
|
|
11
|
+
get context(): {
|
|
12
|
+
title: string;
|
|
13
|
+
};
|
|
14
|
+
onClickDashboardSetting(name: any, description: any): void;
|
|
15
|
+
saveSettings({ name, value, category, description }: {
|
|
16
|
+
name: any;
|
|
17
|
+
value: any;
|
|
18
|
+
category: any;
|
|
19
|
+
description: any;
|
|
20
|
+
}): Promise<void>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import '@operato/board/ox-board-selector.js';
|
|
3
|
+
import gql from 'graphql-tag';
|
|
4
|
+
import { html } from 'lit';
|
|
5
|
+
import { customElement } from 'lit/decorators.js';
|
|
6
|
+
import { store } from '@operato/shell';
|
|
7
|
+
import { client } from '@operato/graphql';
|
|
8
|
+
import { i18next } from '@operato/i18n';
|
|
9
|
+
import { openPopup } from '@operato/layout';
|
|
10
|
+
import { isMobileDevice } from '@operato/utils';
|
|
11
|
+
import { BoardViewerPage } from '@things-factory/board-ui/dist-client';
|
|
12
|
+
import { fetchBoardSettings, UPDATE_BOARD_SETTINGS } from '../actions/board-settings';
|
|
13
|
+
import { DASHBOARD, DASHBOARD_MOBILE, FALLBACK_HOME_BOARD } from '../const';
|
|
14
|
+
const HOME_DESCRIPTION = 'home dashboard';
|
|
15
|
+
const FALLBACK_ORDER = isMobileDevice() ? [DASHBOARD_MOBILE, DASHBOARD, FALLBACK_HOME_BOARD] : [DASHBOARD, FALLBACK_HOME_BOARD];
|
|
16
|
+
const HOME_BOARD = isMobileDevice() ? DASHBOARD_MOBILE : DASHBOARD;
|
|
17
|
+
let DashboardHome = class DashboardHome extends BoardViewerPage {
|
|
18
|
+
stateChanged(state) {
|
|
19
|
+
super.stateChanged(state);
|
|
20
|
+
const dashboard = state === null || state === void 0 ? void 0 : state.boardSetting;
|
|
21
|
+
const homeBoard = dashboard && dashboard[FALLBACK_ORDER.find(name => dashboard[name]) || 'maybe notfound'];
|
|
22
|
+
this._boardId = homeBoard === null || homeBoard === void 0 ? void 0 : homeBoard.value;
|
|
23
|
+
}
|
|
24
|
+
get oopsNote() {
|
|
25
|
+
return {
|
|
26
|
+
icon: 'insert_chart',
|
|
27
|
+
title: 'HOME DASHBOARD',
|
|
28
|
+
description: 'There are no home dashboard setting. Pls, click to setting home dashboard.',
|
|
29
|
+
click: e => this.onClickDashboardSetting(HOME_BOARD, HOME_DESCRIPTION)
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
get context() {
|
|
33
|
+
return {
|
|
34
|
+
title: HOME_DESCRIPTION
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
onClickDashboardSetting(name, description) {
|
|
38
|
+
var popup = openPopup(html `
|
|
39
|
+
<ox-board-selector
|
|
40
|
+
.creatable=${true}
|
|
41
|
+
.value=${this._boardId}
|
|
42
|
+
@board-selected=${async (e) => {
|
|
43
|
+
var board = e.detail.board;
|
|
44
|
+
await this.saveSettings({
|
|
45
|
+
name,
|
|
46
|
+
value: board.id,
|
|
47
|
+
category: 'board',
|
|
48
|
+
description
|
|
49
|
+
});
|
|
50
|
+
var settings = await fetchBoardSettings([FALLBACK_HOME_BOARD, DASHBOARD, DASHBOARD_MOBILE]);
|
|
51
|
+
store.dispatch({
|
|
52
|
+
type: UPDATE_BOARD_SETTINGS,
|
|
53
|
+
settings: settings.reduce((settings, setting) => {
|
|
54
|
+
settings[setting.name] = setting;
|
|
55
|
+
return settings;
|
|
56
|
+
}, {})
|
|
57
|
+
});
|
|
58
|
+
popup.close();
|
|
59
|
+
this.requestUpdate();
|
|
60
|
+
}}
|
|
61
|
+
></ox-board-selector>
|
|
62
|
+
`, {
|
|
63
|
+
backdrop: true,
|
|
64
|
+
size: 'large',
|
|
65
|
+
title: i18next.t('title.dashboard setting')
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
async saveSettings({ name, value, category, description }) {
|
|
69
|
+
if (!(name && value)) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
await client.query({
|
|
73
|
+
query: gql `
|
|
74
|
+
mutation UpdateSetting($patch: SettingPatch!, $name: String!) {
|
|
75
|
+
updateSetting(patch: $patch, name: $name) {
|
|
76
|
+
name
|
|
77
|
+
value
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
`,
|
|
81
|
+
variables: {
|
|
82
|
+
name,
|
|
83
|
+
patch: {
|
|
84
|
+
name,
|
|
85
|
+
description,
|
|
86
|
+
category,
|
|
87
|
+
value
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
DashboardHome = __decorate([
|
|
94
|
+
customElement('dashboard-home')
|
|
95
|
+
], DashboardHome);
|
|
96
|
+
export { DashboardHome };
|
|
97
|
+
//# sourceMappingURL=dashboard.js.map
|