@things-factory/dashboard 8.0.0-beta.1 → 8.0.0-beta.2
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 +6 -6
- package/client/actions/board-settings.ts +0 -31
- package/client/actions/index.ts +0 -1
- package/client/bootstrap.ts +0 -37
- package/client/const.ts +0 -5
- package/client/index.ts +0 -1
- package/client/pages/dashboard.ts +0 -112
- package/client/reducers/board-settings.ts +0 -21
- package/client/route.ts +0 -10
- package/client/tsconfig.json +0 -11
- package/client/viewparts/dashboard-setting-let.ts +0 -237
- package/server/index.ts +0 -1
- package/server/service/board-settings/board-setting.ts +0 -17
- package/server/service/board-settings/board-settings-query.ts +0 -54
- package/server/service/board-settings/index.ts +0 -4
- package/server/service/index.ts +0 -17
- package/server/tsconfig.json +0 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/dashboard",
|
|
3
|
-
"version": "8.0.0-beta.
|
|
3
|
+
"version": "8.0.0-beta.2",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "dist-client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
"clean": "npm run clean:server && npm run clean:client"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@things-factory/auth-base": "^8.0.0-beta.
|
|
30
|
-
"@things-factory/board-service": "^8.0.0-beta.
|
|
31
|
-
"@things-factory/board-ui": "^8.0.0-beta.
|
|
32
|
-
"@things-factory/setting-base": "^8.0.0-beta.
|
|
29
|
+
"@things-factory/auth-base": "^8.0.0-beta.2",
|
|
30
|
+
"@things-factory/board-service": "^8.0.0-beta.2",
|
|
31
|
+
"@things-factory/board-ui": "^8.0.0-beta.2",
|
|
32
|
+
"@things-factory/setting-base": "^8.0.0-beta.2"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "f03431a09435511b2595515658f9cb8f78ba4ebb"
|
|
35
35
|
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import gql from 'graphql-tag'
|
|
2
|
-
|
|
3
|
-
import { client } from '@operato/graphql'
|
|
4
|
-
|
|
5
|
-
export const UPDATE_BOARD_SETTINGS = 'UPDATE_BOARD_SETTINGS'
|
|
6
|
-
export const CLEAR_BOARD_SETTINGS = 'CLEAR_BOARD_SETTINGS'
|
|
7
|
-
|
|
8
|
-
export async function fetchBoardSettings(names) {
|
|
9
|
-
var response = await client.query({
|
|
10
|
-
query: gql`
|
|
11
|
-
query ($names: [String!]) {
|
|
12
|
-
boardSettings(names: $names) {
|
|
13
|
-
name
|
|
14
|
-
value
|
|
15
|
-
board {
|
|
16
|
-
id
|
|
17
|
-
name
|
|
18
|
-
description
|
|
19
|
-
thumbnail
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
`,
|
|
24
|
-
variables: {
|
|
25
|
-
names
|
|
26
|
-
}
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
if (!response || !response.data) return
|
|
30
|
-
return response.data.boardSettings
|
|
31
|
-
}
|
package/client/actions/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './board-settings'
|
package/client/bootstrap.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
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
|
-
|
|
6
|
-
import { UPDATE_BOARD_SETTINGS, fetchBoardSettings } from './actions/board-settings'
|
|
7
|
-
import boardSetting from './reducers/board-settings'
|
|
8
|
-
|
|
9
|
-
import './viewparts/dashboard-setting-let'
|
|
10
|
-
|
|
11
|
-
import { FALLBACK_HOME_BOARD, DASHBOARD, DASHBOARD_MOBILE } from './const'
|
|
12
|
-
|
|
13
|
-
export default function bootstrap() {
|
|
14
|
-
store.addReducers({ boardSetting })
|
|
15
|
-
|
|
16
|
-
auth.on('profile', async () => {
|
|
17
|
-
var settings = await fetchBoardSettings([FALLBACK_HOME_BOARD, DASHBOARD, DASHBOARD_MOBILE])
|
|
18
|
-
|
|
19
|
-
store.dispatch({
|
|
20
|
-
type: UPDATE_BOARD_SETTINGS,
|
|
21
|
-
settings: settings.reduce((settings, setting) => {
|
|
22
|
-
settings[setting.name] = setting
|
|
23
|
-
return settings
|
|
24
|
-
}, {})
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
if (await hasPrivilege({ privilege: 'mutation', category: 'setting' })) {
|
|
28
|
-
store.dispatch({
|
|
29
|
-
type: ADD_SETTING,
|
|
30
|
-
setting: {
|
|
31
|
-
seq: 20,
|
|
32
|
-
template: html` <dashboard-setting-let></dashboard-setting-let> `
|
|
33
|
-
}
|
|
34
|
-
})
|
|
35
|
-
}
|
|
36
|
-
})
|
|
37
|
-
}
|
package/client/const.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
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'
|
package/client/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './actions'
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import '@operato/board/ox-board-selector.js'
|
|
2
|
-
|
|
3
|
-
import gql from 'graphql-tag'
|
|
4
|
-
import { html } from 'lit'
|
|
5
|
-
import { customElement } from 'lit/decorators.js'
|
|
6
|
-
|
|
7
|
-
import { store } from '@operato/shell'
|
|
8
|
-
import { client } from '@operato/graphql'
|
|
9
|
-
import { i18next } from '@operato/i18n'
|
|
10
|
-
import { openPopup } from '@operato/layout'
|
|
11
|
-
import { isMobileDevice } from '@operato/utils'
|
|
12
|
-
import { BoardViewerPage } from '@things-factory/board-ui/dist-client'
|
|
13
|
-
|
|
14
|
-
import { fetchBoardSettings, UPDATE_BOARD_SETTINGS } from '../actions/board-settings'
|
|
15
|
-
import { DASHBOARD, DASHBOARD_MOBILE, FALLBACK_HOME_BOARD } from '../const'
|
|
16
|
-
|
|
17
|
-
const HOME_DESCRIPTION = 'home dashboard'
|
|
18
|
-
|
|
19
|
-
const FALLBACK_ORDER = isMobileDevice()
|
|
20
|
-
? [DASHBOARD_MOBILE, DASHBOARD, FALLBACK_HOME_BOARD]
|
|
21
|
-
: [DASHBOARD, FALLBACK_HOME_BOARD]
|
|
22
|
-
const HOME_BOARD = isMobileDevice() ? DASHBOARD_MOBILE : DASHBOARD
|
|
23
|
-
|
|
24
|
-
@customElement('dashboard-home')
|
|
25
|
-
export class DashboardHome extends BoardViewerPage {
|
|
26
|
-
stateChanged(state) {
|
|
27
|
-
super.stateChanged(state)
|
|
28
|
-
|
|
29
|
-
const dashboard = state?.boardSetting
|
|
30
|
-
const homeBoard = dashboard && dashboard[FALLBACK_ORDER.find(name => dashboard[name]) || 'maybe notfound']
|
|
31
|
-
this._boardId = homeBoard?.value
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
get oopsNote() {
|
|
35
|
-
return {
|
|
36
|
-
icon: 'insert_chart',
|
|
37
|
-
title: 'HOME DASHBOARD',
|
|
38
|
-
description: 'There are no home dashboard setting. Pls, click to setting home dashboard.',
|
|
39
|
-
click: e => this.onClickDashboardSetting(HOME_BOARD, HOME_DESCRIPTION)
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
get context() {
|
|
44
|
-
return {
|
|
45
|
-
title: HOME_DESCRIPTION
|
|
46
|
-
} as any
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
onClickDashboardSetting(name, description) {
|
|
50
|
-
var popup = openPopup(
|
|
51
|
-
html`
|
|
52
|
-
<ox-board-selector
|
|
53
|
-
.creatable=${true}
|
|
54
|
-
.value=${this._boardId}
|
|
55
|
-
@board-selected=${async e => {
|
|
56
|
-
var board = e.detail.board
|
|
57
|
-
|
|
58
|
-
await this.saveSettings({
|
|
59
|
-
name,
|
|
60
|
-
value: board.id,
|
|
61
|
-
category: 'board',
|
|
62
|
-
description
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
var settings = await fetchBoardSettings([FALLBACK_HOME_BOARD, DASHBOARD, DASHBOARD_MOBILE])
|
|
66
|
-
store.dispatch({
|
|
67
|
-
type: UPDATE_BOARD_SETTINGS,
|
|
68
|
-
settings: settings.reduce((settings, setting) => {
|
|
69
|
-
settings[setting.name] = setting
|
|
70
|
-
return settings
|
|
71
|
-
}, {})
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
popup.close()
|
|
75
|
-
this.requestUpdate()
|
|
76
|
-
}}
|
|
77
|
-
></ox-board-selector>
|
|
78
|
-
`,
|
|
79
|
-
{
|
|
80
|
-
backdrop: true,
|
|
81
|
-
size: 'large',
|
|
82
|
-
title: i18next.t('title.dashboard setting')
|
|
83
|
-
}
|
|
84
|
-
)
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
async saveSettings({ name, value, category, description }) {
|
|
88
|
-
if (!(name && value)) {
|
|
89
|
-
return
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
await client.query({
|
|
93
|
-
query: gql`
|
|
94
|
-
mutation UpdateSetting($patch: SettingPatch!, $name: String!) {
|
|
95
|
-
updateSetting(patch: $patch, name: $name) {
|
|
96
|
-
name
|
|
97
|
-
value
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
`,
|
|
101
|
-
variables: {
|
|
102
|
-
name,
|
|
103
|
-
patch: {
|
|
104
|
-
name,
|
|
105
|
-
description,
|
|
106
|
-
category,
|
|
107
|
-
value
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
})
|
|
111
|
-
}
|
|
112
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { UPDATE_BOARD_SETTINGS, CLEAR_BOARD_SETTINGS } from '../actions/board-settings'
|
|
2
|
-
|
|
3
|
-
const INITIAL_STATE = {}
|
|
4
|
-
|
|
5
|
-
const boardSetting = (state = INITIAL_STATE, action) => {
|
|
6
|
-
switch (action.type) {
|
|
7
|
-
case UPDATE_BOARD_SETTINGS:
|
|
8
|
-
return {
|
|
9
|
-
...state,
|
|
10
|
-
...action.settings
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
case CLEAR_BOARD_SETTINGS:
|
|
14
|
-
return {}
|
|
15
|
-
|
|
16
|
-
default:
|
|
17
|
-
return state
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export default boardSetting
|
package/client/route.ts
DELETED
package/client/tsconfig.json
DELETED
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
import '@material/web/icon/icon.js'
|
|
2
|
-
import '@operato/board/ox-board-selector.js'
|
|
3
|
-
import '@operato/i18n/ox-i18n.js'
|
|
4
|
-
|
|
5
|
-
import gql from 'graphql-tag'
|
|
6
|
-
import { css, html, LitElement } from 'lit'
|
|
7
|
-
import { customElement, state } from 'lit/decorators.js'
|
|
8
|
-
import { connect } from 'pwa-helpers'
|
|
9
|
-
|
|
10
|
-
import { openPopup } from '@operato/layout'
|
|
11
|
-
import { i18next, localize } from '@operato/i18n'
|
|
12
|
-
import { store } from '@operato/shell'
|
|
13
|
-
import { client } from '@operato/graphql'
|
|
14
|
-
|
|
15
|
-
import { fetchBoardSettings, UPDATE_BOARD_SETTINGS } from '../actions/board-settings'
|
|
16
|
-
import {
|
|
17
|
-
DASHBOARD,
|
|
18
|
-
DASHBOARD_DESCRIPTION,
|
|
19
|
-
DASHBOARD_MOBILE,
|
|
20
|
-
DASHBOARD_MOBILE_DESCRIPTION,
|
|
21
|
-
FALLBACK_HOME_BOARD
|
|
22
|
-
} from '../const'
|
|
23
|
-
|
|
24
|
-
@customElement('dashboard-setting-let')
|
|
25
|
-
export class DashboardSettingLet extends connect(store)(localize(i18next)(LitElement)) {
|
|
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
|
-
}
|
|
35
|
-
|
|
36
|
-
div.field > * {
|
|
37
|
-
flex: none;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
div.field > div {
|
|
41
|
-
flex: 1;
|
|
42
|
-
display: flex;
|
|
43
|
-
flex-direction: column;
|
|
44
|
-
align-items: flex-start;
|
|
45
|
-
}
|
|
46
|
-
|
|
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
|
-
}
|
|
55
|
-
|
|
56
|
-
div.field img {
|
|
57
|
-
max-height: 250px;
|
|
58
|
-
max-width: 100%;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
.name {
|
|
62
|
-
color: var(--md-sys-color-on-secondary-container);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
.description {
|
|
66
|
-
font-size: 0.7rem;
|
|
67
|
-
opacity: 0.7;
|
|
68
|
-
color: var(--md-sys-color-on-secondary-container);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
label {
|
|
72
|
-
width: 80px;
|
|
73
|
-
padding-right: var(--spacing-medium);
|
|
74
|
-
font: bold 0.9em var(--theme-font);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
setting-let > form {
|
|
78
|
-
display: grid;
|
|
79
|
-
grid-template-columns: 1fr 1fr;
|
|
80
|
-
}
|
|
81
|
-
|
|
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
|
-
}
|
|
91
|
-
|
|
92
|
-
md-icon:hover,
|
|
93
|
-
md-icon:active {
|
|
94
|
-
background-color: var(--button-active-background-color, #22a6a7);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
@media screen and (max-width: 460px) {
|
|
98
|
-
setting-let > form {
|
|
99
|
-
display: flex;
|
|
100
|
-
flex-direction: column;
|
|
101
|
-
}
|
|
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
|
-
|
|
113
|
-
@state() private dashboard: any
|
|
114
|
-
@state() private dashboardMobile: any
|
|
115
|
-
|
|
116
|
-
render() {
|
|
117
|
-
return html`
|
|
118
|
-
<setting-let>
|
|
119
|
-
<ox-i18n slot="title" msgid="title.dashboard setting"></ox-i18n>
|
|
120
|
-
|
|
121
|
-
<form slot="content">
|
|
122
|
-
${[
|
|
123
|
-
{
|
|
124
|
-
title: i18next.t('label.dashboard for desktop'),
|
|
125
|
-
board: this.dashboard,
|
|
126
|
-
key: DASHBOARD,
|
|
127
|
-
description: DASHBOARD_DESCRIPTION
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
title: i18next.t('label.dashboard for mobile'),
|
|
131
|
-
board: this.dashboardMobile,
|
|
132
|
-
key: DASHBOARD_MOBILE,
|
|
133
|
-
description: DASHBOARD_MOBILE_DESCRIPTION
|
|
134
|
-
}
|
|
135
|
-
].map(
|
|
136
|
-
field => html`
|
|
137
|
-
<div class="field">
|
|
138
|
-
<label>${field.title}</ox-i18n></label>
|
|
139
|
-
<div>
|
|
140
|
-
<div class="name">${field.board.name}</div>
|
|
141
|
-
<span class="description">${field.board.description}</span>
|
|
142
|
-
<md-icon @click=${e => this.onClickBoardSelector(field.key, field.description)}>
|
|
143
|
-
more_horiz
|
|
144
|
-
</md-icon>
|
|
145
|
-
${
|
|
146
|
-
field.board.id
|
|
147
|
-
? html`
|
|
148
|
-
<a href=${`board-modeller/${field.board.id}`}>
|
|
149
|
-
<img
|
|
150
|
-
src=${field.board.thumbnail ||
|
|
151
|
-
'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'}
|
|
152
|
-
/>
|
|
153
|
-
</a>
|
|
154
|
-
`
|
|
155
|
-
: html``
|
|
156
|
-
}
|
|
157
|
-
</div>
|
|
158
|
-
</div>
|
|
159
|
-
`
|
|
160
|
-
)}
|
|
161
|
-
</form>
|
|
162
|
-
</setting-let>
|
|
163
|
-
`
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
stateChanged(state: any) {
|
|
167
|
-
var dashboard = state.boardSetting[DASHBOARD] || state.boardSetting[FALLBACK_HOME_BOARD]
|
|
168
|
-
var dashboardMobile = state.boardSetting[DASHBOARD_MOBILE] || dashboard
|
|
169
|
-
|
|
170
|
-
this.dashboard = (dashboard ? dashboard.board : {}) || {}
|
|
171
|
-
this.dashboardMobile = (dashboardMobile ? dashboardMobile.board : {}) || {}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
onClickBoardSelector(name: string, description: string) {
|
|
175
|
-
var popup = openPopup(
|
|
176
|
-
html`
|
|
177
|
-
<ox-board-selector
|
|
178
|
-
.creatable=${true}
|
|
179
|
-
.value=${name == DASHBOARD ? this.dashboard?.id : this.dashboardMobile?.id}
|
|
180
|
-
@board-selected=${async e => {
|
|
181
|
-
var board = e.detail.board
|
|
182
|
-
|
|
183
|
-
await this.saveSettings({
|
|
184
|
-
name,
|
|
185
|
-
value: board.id,
|
|
186
|
-
category: 'board',
|
|
187
|
-
description
|
|
188
|
-
})
|
|
189
|
-
|
|
190
|
-
var settings = await fetchBoardSettings([FALLBACK_HOME_BOARD, DASHBOARD, DASHBOARD_MOBILE])
|
|
191
|
-
store.dispatch({
|
|
192
|
-
type: UPDATE_BOARD_SETTINGS,
|
|
193
|
-
settings: settings.reduce((settings, setting) => {
|
|
194
|
-
settings[setting.name] = setting
|
|
195
|
-
return settings
|
|
196
|
-
}, {})
|
|
197
|
-
})
|
|
198
|
-
|
|
199
|
-
popup.close()
|
|
200
|
-
this.requestUpdate()
|
|
201
|
-
}}
|
|
202
|
-
></ox-board-selector>
|
|
203
|
-
`,
|
|
204
|
-
{
|
|
205
|
-
backdrop: true,
|
|
206
|
-
size: 'large',
|
|
207
|
-
title: i18next.t('title.dashboard setting')
|
|
208
|
-
}
|
|
209
|
-
)
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
async saveSettings({ name, value, category, description }) {
|
|
213
|
-
if (!(name && value)) {
|
|
214
|
-
return
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
await client.query({
|
|
218
|
-
query: gql`
|
|
219
|
-
mutation UpdateSetting($patch: SettingPatch!, $name: String!) {
|
|
220
|
-
updateSetting(patch: $patch, name: $name) {
|
|
221
|
-
name
|
|
222
|
-
value
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
`,
|
|
226
|
-
variables: {
|
|
227
|
-
name,
|
|
228
|
-
patch: {
|
|
229
|
-
name,
|
|
230
|
-
description,
|
|
231
|
-
category,
|
|
232
|
-
value
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
})
|
|
236
|
-
}
|
|
237
|
-
}
|
package/server/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './service'
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { ObjectType, Field, ID } from 'type-graphql'
|
|
2
|
-
import { Board } from '@things-factory/board-service'
|
|
3
|
-
|
|
4
|
-
@ObjectType()
|
|
5
|
-
export class BoardSetting {
|
|
6
|
-
@Field(type => ID)
|
|
7
|
-
id: string
|
|
8
|
-
|
|
9
|
-
@Field()
|
|
10
|
-
name: string
|
|
11
|
-
|
|
12
|
-
@Field()
|
|
13
|
-
value: string
|
|
14
|
-
|
|
15
|
-
@Field(type => Board)
|
|
16
|
-
board: Board
|
|
17
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { Arg, Ctx, Query, Resolver } from 'type-graphql'
|
|
2
|
-
|
|
3
|
-
import { Board } from '@things-factory/board-service'
|
|
4
|
-
import { Setting } from '@things-factory/setting-base'
|
|
5
|
-
import { getRepository } from '@things-factory/shell'
|
|
6
|
-
|
|
7
|
-
import { BoardSetting } from './board-setting'
|
|
8
|
-
|
|
9
|
-
@Resolver(BoardSetting)
|
|
10
|
-
export class BoardSettingsQuery {
|
|
11
|
-
@Query(returns => [BoardSetting], { description: 'To fetch a BoardSettings' })
|
|
12
|
-
async boardSettings(@Arg('names', type => [String], { nullable: true }) names: string[], @Ctx() context: any): Promise<BoardSetting[]> {
|
|
13
|
-
const { domain } = context.state
|
|
14
|
-
const queryBuilder = getRepository(Setting).createQueryBuilder()
|
|
15
|
-
|
|
16
|
-
var qb = queryBuilder
|
|
17
|
-
.innerJoin(Board, 'Board', 'Setting.value = CAST(Board.id AS char(36))')
|
|
18
|
-
.select([
|
|
19
|
-
'Setting.id as id',
|
|
20
|
-
'Setting.name as name',
|
|
21
|
-
'Setting.value as value',
|
|
22
|
-
'Board.id as boardId',
|
|
23
|
-
'Board.name as boardName',
|
|
24
|
-
'Board.description as boardDescription',
|
|
25
|
-
'Board.thumbnail as boardThumbnail'
|
|
26
|
-
])
|
|
27
|
-
.where('Setting.domain.id = :domain and Setting.category = :category', {
|
|
28
|
-
domain: domain.id,
|
|
29
|
-
category: 'board'
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
if (names && names.length) qb.andWhere('Setting.name IN (:...names)', { names })
|
|
33
|
-
|
|
34
|
-
var boardSettingList = await qb.getRawMany()
|
|
35
|
-
|
|
36
|
-
return boardSettingList.map(boardSetting => {
|
|
37
|
-
var setting: any = {
|
|
38
|
-
board: {}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
for (let key in boardSetting) {
|
|
42
|
-
if (key.includes('board')) {
|
|
43
|
-
let originKey = key
|
|
44
|
-
key = key.replace('board', '').toLowerCase()
|
|
45
|
-
setting.board[key] = boardSetting[originKey]
|
|
46
|
-
} else {
|
|
47
|
-
setting[key] = boardSetting[key]
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return setting
|
|
52
|
-
})
|
|
53
|
-
}
|
|
54
|
-
}
|
package/server/service/index.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/* EXPORT ENTITY TYPES */
|
|
2
|
-
export * from './board-settings/board-setting'
|
|
3
|
-
|
|
4
|
-
/* IMPORT ENTITIES AND RESOLVERS */
|
|
5
|
-
import { entities as BoardSettingsEntities, resolvers as BoardSettingsResolvers } from './board-settings'
|
|
6
|
-
|
|
7
|
-
export const entities = [
|
|
8
|
-
/* ENTITIES */
|
|
9
|
-
...BoardSettingsEntities
|
|
10
|
-
]
|
|
11
|
-
|
|
12
|
-
export const schema = {
|
|
13
|
-
resolverClasses: [
|
|
14
|
-
/* RESOLVER CLASSES */
|
|
15
|
-
...BoardSettingsResolvers
|
|
16
|
-
]
|
|
17
|
-
}
|