@things-factory/dataset 5.0.0-alpha.40 → 5.0.0-alpha.41
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/pages/data-ooc/data-ooc-list-page.js +43 -48
- package/client/pages/data-report/data-report-list-page.js +3 -3
- package/client/pages/data-report/jasper-report-oocs-page.js +115 -0
- package/client/pages/data-report/jasper-report-samples-page.js +115 -0
- package/client/pages/data-sample/data-sample-list-page.js +43 -48
- package/client/pages/data-sensor/data-sensor-list-page.js +37 -53
- package/client/pages/data-set/data-set-list-page.js +28 -43
- package/client/route.js +8 -0
- package/config/config.development.js +13 -0
- package/config/config.production.js +1 -0
- package/dist-server/controllers/jasper-report.js +129 -0
- package/dist-server/controllers/jasper-report.js.map +1 -0
- package/dist-server/routes.js +4 -0
- package/dist-server/routes.js.map +1 -1
- package/dist-server/service/data-set/data-set-mutation.js +27 -4
- package/dist-server/service/data-set/data-set-mutation.js.map +1 -1
- package/dist-server/service/data-set/data-set-query.js +23 -0
- package/dist-server/service/data-set/data-set-query.js.map +1 -1
- package/dist-server/service/data-set/data-set-type.js +13 -4
- package/dist-server/service/data-set/data-set-type.js.map +1 -1
- package/dist-server/service/data-set/data-set.js +4 -0
- package/dist-server/service/data-set/data-set.js.map +1 -1
- package/package.json +17 -16
- package/server/controllers/jasper-report.ts +130 -0
- package/server/routes.ts +4 -0
- package/server/service/data-set/data-set-mutation.ts +41 -4
- package/server/service/data-set/data-set-query.ts +21 -0
- package/server/service/data-set/data-set-type.ts +7 -0
- package/server/service/data-set/data-set.ts +3 -0
- package/things-factory.config.js +8 -0
- package/translations/en.json +1 -0
- package/translations/ko.json +1 -0
@@ -9,20 +9,22 @@ import { client } from '@operato/graphql'
|
|
9
9
|
import { i18next, localize } from '@operato/i18n'
|
10
10
|
import { openPopup } from '@operato/layout'
|
11
11
|
import { PageView, store } from '@operato/shell'
|
12
|
-
import { ScrollbarStyles } from '@operato/styles'
|
12
|
+
import { CommonGristStyles, ScrollbarStyles } from '@operato/styles'
|
13
13
|
import { isMobileDevice } from '@operato/utils'
|
14
14
|
|
15
15
|
export class DataOocListPage extends connect(store)(localize(i18next)(PageView)) {
|
16
16
|
static get properties() {
|
17
17
|
return {
|
18
18
|
active: String,
|
19
|
-
gristConfig: Object
|
19
|
+
gristConfig: Object,
|
20
|
+
mode: String
|
20
21
|
}
|
21
22
|
}
|
22
23
|
|
23
24
|
static get styles() {
|
24
25
|
return [
|
25
26
|
ScrollbarStyles,
|
27
|
+
CommonGristStyles,
|
26
28
|
css`
|
27
29
|
:host {
|
28
30
|
display: flex;
|
@@ -35,18 +37,6 @@ export class DataOocListPage extends connect(store)(localize(i18next)(PageView))
|
|
35
37
|
overflow-y: auto;
|
36
38
|
flex: 1;
|
37
39
|
}
|
38
|
-
|
39
|
-
#filters {
|
40
|
-
display: flex;
|
41
|
-
flex-direction: row;
|
42
|
-
justify-content: space-between;
|
43
|
-
|
44
|
-
background-color: white;
|
45
|
-
}
|
46
|
-
|
47
|
-
#filters > * {
|
48
|
-
padding: var(--padding-default) var(--padding-wide);
|
49
|
-
}
|
50
40
|
`
|
51
41
|
]
|
52
42
|
}
|
@@ -70,14 +60,42 @@ export class DataOocListPage extends connect(store)(localize(i18next)(PageView))
|
|
70
60
|
}
|
71
61
|
|
72
62
|
render() {
|
63
|
+
const mode = this.mode || (isMobileDevice() ? 'LIST' : 'GRID')
|
64
|
+
|
73
65
|
return html`
|
74
66
|
<ox-grist
|
75
|
-
.mode=${
|
67
|
+
.mode=${mode}
|
76
68
|
.config=${this.gristConfig}
|
77
69
|
.fetchHandler=${this.fetchHandler.bind(this)}
|
70
|
+
url-params-sensitive
|
78
71
|
>
|
79
|
-
<div slot="headroom"
|
80
|
-
<
|
72
|
+
<div slot="headroom">
|
73
|
+
<div id="filters">
|
74
|
+
<ox-filters-form></ox-filters-form>
|
75
|
+
</div>
|
76
|
+
|
77
|
+
<div id="sorters">
|
78
|
+
Sort
|
79
|
+
<mwc-icon
|
80
|
+
@click=${e => {
|
81
|
+
const target = e.currentTarget
|
82
|
+
this.renderRoot.querySelector('#sorter-control').open({
|
83
|
+
right: 0,
|
84
|
+
top: target.offsetTop + target.offsetHeight
|
85
|
+
})
|
86
|
+
}}
|
87
|
+
>expand_more</mwc-icon
|
88
|
+
>
|
89
|
+
<ox-popup id="sorter-control">
|
90
|
+
<ox-sorters-control> </ox-sorters-control>
|
91
|
+
</ox-popup>
|
92
|
+
</div>
|
93
|
+
|
94
|
+
<div id="modes">
|
95
|
+
<mwc-icon @click=${() => (this.mode = 'GRID')} ?active=${mode == 'GRID'}>grid_on</mwc-icon>
|
96
|
+
<mwc-icon @click=${() => (this.mode = 'LIST')} ?active=${mode == 'LIST'}>format_list_bulleted</mwc-icon>
|
97
|
+
<mwc-icon @click=${() => (this.mode = 'CARD')} ?active=${mode == 'CARD'}>apps</mwc-icon>
|
98
|
+
</div>
|
81
99
|
</div>
|
82
100
|
</ox-grist>
|
83
101
|
`
|
@@ -87,30 +105,7 @@ export class DataOocListPage extends connect(store)(localize(i18next)(PageView))
|
|
87
105
|
return this.renderRoot.querySelector('ox-grist')
|
88
106
|
}
|
89
107
|
|
90
|
-
// update with url params value
|
91
|
-
_updateSearchConfig(lifecycle) {
|
92
|
-
// this.searchConfig = this.searchConfig.map(conf => {
|
93
|
-
// if (conf.name in lifecycle.params) {
|
94
|
-
// conf.value = lifecycle.params[conf.name]
|
95
|
-
// } else {
|
96
|
-
// delete conf.value
|
97
|
-
// }
|
98
|
-
// return conf
|
99
|
-
// })
|
100
|
-
}
|
101
|
-
|
102
|
-
// set default field value to record with searchConfig
|
103
|
-
_setDefaultFieldsValue(fields) {
|
104
|
-
// this.searchConfig.forEach(conf => {
|
105
|
-
// if (!fields[conf.name] && conf.value) {
|
106
|
-
// fields[conf.name] = conf.value
|
107
|
-
// }
|
108
|
-
// })
|
109
|
-
}
|
110
|
-
|
111
108
|
async pageInitialized(lifecycle) {
|
112
|
-
this._updateSearchConfig(lifecycle)
|
113
|
-
|
114
109
|
this.gristConfig = {
|
115
110
|
list: {
|
116
111
|
fields: ['dataSet', 'data', 'spec', 'correctiveAction', 'corrector', 'correctedAt', 'collectedAt', 'creator']
|
@@ -321,15 +316,15 @@ export class DataOocListPage extends connect(store)(localize(i18next)(PageView))
|
|
321
316
|
this.grist.fetch()
|
322
317
|
}
|
323
318
|
|
324
|
-
async pageUpdated(changes, lifecycle) {
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
319
|
+
// async pageUpdated(changes, lifecycle) {
|
320
|
+
// if (this.active) {
|
321
|
+
// // update with url params value
|
322
|
+
// this._updateSearchConfig(lifecycle)
|
323
|
+
// await this.updateComplete
|
329
324
|
|
330
|
-
|
331
|
-
|
332
|
-
}
|
325
|
+
// this.grist.fetch()
|
326
|
+
// }
|
327
|
+
// }
|
333
328
|
|
334
329
|
async fetchHandler({ page, limit, sortings = [], filters = [] }) {
|
335
330
|
const response = await client.query({
|
@@ -25,7 +25,7 @@ const USECASE_OPTIONS = () => {
|
|
25
25
|
}
|
26
26
|
|
27
27
|
const showMonitorView = (columns, data, column, record, rowIndex) => {
|
28
|
-
const { name, monitorType, monitorView } = record
|
28
|
+
const { id, name, monitorType, monitorView } = record
|
29
29
|
const title = `${name} - ${i18next.t('title.data-monitor-view')}`
|
30
30
|
|
31
31
|
switch (monitorType) {
|
@@ -73,7 +73,7 @@ const showMonitorView = (columns, data, column, record, rowIndex) => {
|
|
73
73
|
}
|
74
74
|
|
75
75
|
const showReportView = (columns, data, column, record, rowIndex) => {
|
76
|
-
const { name, reportType, reportView } = record
|
76
|
+
const { id, name, reportType, reportView } = record
|
77
77
|
const title = `${name} - ${i18next.t('title.data-report-view')}`
|
78
78
|
|
79
79
|
switch (reportType) {
|
@@ -99,7 +99,7 @@ const showReportView = (columns, data, column, record, rowIndex) => {
|
|
99
99
|
break
|
100
100
|
|
101
101
|
case 'page':
|
102
|
-
navigate(reportView)
|
102
|
+
navigate(reportView + `/${id}`)
|
103
103
|
break
|
104
104
|
|
105
105
|
case 'external':
|
@@ -0,0 +1,115 @@
|
|
1
|
+
import { css, html } from 'lit'
|
2
|
+
import '@operato/data-grist'
|
3
|
+
import '@things-factory/form-ui'
|
4
|
+
|
5
|
+
import { i18next, localize } from '@operato/i18n'
|
6
|
+
import { CommonButtonStyles, ScrollbarStyles } from '@operato/styles'
|
7
|
+
import { PageView } from '@things-factory/shell'
|
8
|
+
import { throws } from 'assert'
|
9
|
+
|
10
|
+
class JasperReportOocsPage extends localize(i18next)(PageView) {
|
11
|
+
static get properties() {
|
12
|
+
return {
|
13
|
+
_grnNo: String,
|
14
|
+
_status: String,
|
15
|
+
searchFields: Array,
|
16
|
+
resourceId: String,
|
17
|
+
params: Object
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
21
|
+
static get styles() {
|
22
|
+
return [
|
23
|
+
ScrollbarStyles,
|
24
|
+
css`
|
25
|
+
:host {
|
26
|
+
display: flex;
|
27
|
+
flex-direction: column;
|
28
|
+
padding: 0;
|
29
|
+
}
|
30
|
+
|
31
|
+
#container {
|
32
|
+
flex: 1;
|
33
|
+
padding: 0;
|
34
|
+
margin: 0;
|
35
|
+
border: 0;
|
36
|
+
}
|
37
|
+
`
|
38
|
+
]
|
39
|
+
}
|
40
|
+
|
41
|
+
get context() {
|
42
|
+
this.searchFields = [
|
43
|
+
{
|
44
|
+
label: i18next.t('field.from'),
|
45
|
+
name: 'fromDate',
|
46
|
+
type: 'date',
|
47
|
+
props: {
|
48
|
+
searchOper: 'eq'
|
49
|
+
}
|
50
|
+
},
|
51
|
+
{
|
52
|
+
label: i18next.t('field.to'),
|
53
|
+
name: 'toDate',
|
54
|
+
type: 'date',
|
55
|
+
props: {
|
56
|
+
searchOper: 'eq'
|
57
|
+
}
|
58
|
+
}
|
59
|
+
]
|
60
|
+
var actions = [
|
61
|
+
{
|
62
|
+
title: i18next.t('button.print'),
|
63
|
+
action: () => {
|
64
|
+
this.renderRoot.querySelector('iframe').contentWindow.print()
|
65
|
+
},
|
66
|
+
...CommonButtonStyles.print
|
67
|
+
}
|
68
|
+
]
|
69
|
+
return {
|
70
|
+
title: 'jasper-report',
|
71
|
+
actions
|
72
|
+
}
|
73
|
+
}
|
74
|
+
render() {
|
75
|
+
return html`
|
76
|
+
<search-form
|
77
|
+
.fields=${this.searchFields}
|
78
|
+
@submit=${() => {
|
79
|
+
this._reportTemplate()
|
80
|
+
}}
|
81
|
+
></search-form>
|
82
|
+
<iframe id="container"></iframe>
|
83
|
+
`
|
84
|
+
}
|
85
|
+
|
86
|
+
get searchForm() {
|
87
|
+
return this.renderRoot.querySelector('search-form')
|
88
|
+
}
|
89
|
+
async pageUpdated(changes, lifecycle) {
|
90
|
+
if (this.active) {
|
91
|
+
this.updateContext()
|
92
|
+
}
|
93
|
+
}
|
94
|
+
|
95
|
+
async _reportTemplate() {
|
96
|
+
const params = await this.searchForm.getQueryFilters()
|
97
|
+
|
98
|
+
/** urlencoded params including test values */
|
99
|
+
const urlParams = {
|
100
|
+
table: 'oocs',
|
101
|
+
dataSetId: this.lifecycle.resourceId,
|
102
|
+
fromWorkDate: params[0].value,
|
103
|
+
toWorkDate: params[1].value,
|
104
|
+
workShift: 'NA'
|
105
|
+
}
|
106
|
+
|
107
|
+
const encodedUrlParams = Object.keys(urlParams).map(key =>
|
108
|
+
`${key}=${encodeURIComponent(urlParams[key])}`
|
109
|
+
).join('&')
|
110
|
+
|
111
|
+
this.shadowRoot.querySelector('#container').src = `/data-report/jasper?${encodedUrlParams}`
|
112
|
+
}
|
113
|
+
}
|
114
|
+
|
115
|
+
window.customElements.define('jasper-report-oocs-page', JasperReportOocsPage)
|
@@ -0,0 +1,115 @@
|
|
1
|
+
import { css, html } from 'lit'
|
2
|
+
import '@operato/data-grist'
|
3
|
+
import '@things-factory/form-ui'
|
4
|
+
|
5
|
+
import { i18next, localize } from '@operato/i18n'
|
6
|
+
import { CommonButtonStyles, ScrollbarStyles } from '@operato/styles'
|
7
|
+
import { PageView } from '@things-factory/shell'
|
8
|
+
import { throws } from 'assert'
|
9
|
+
|
10
|
+
class JasperReportSamplesPage extends localize(i18next)(PageView) {
|
11
|
+
static get properties() {
|
12
|
+
return {
|
13
|
+
_grnNo: String,
|
14
|
+
_status: String,
|
15
|
+
searchFields: Array,
|
16
|
+
resourceId: String,
|
17
|
+
params: Object
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
21
|
+
static get styles() {
|
22
|
+
return [
|
23
|
+
ScrollbarStyles,
|
24
|
+
css`
|
25
|
+
:host {
|
26
|
+
display: flex;
|
27
|
+
flex-direction: column;
|
28
|
+
padding: 0;
|
29
|
+
}
|
30
|
+
|
31
|
+
#container {
|
32
|
+
flex: 1;
|
33
|
+
padding: 0;
|
34
|
+
margin: 0;
|
35
|
+
border: 0;
|
36
|
+
}
|
37
|
+
`
|
38
|
+
]
|
39
|
+
}
|
40
|
+
|
41
|
+
get context() {
|
42
|
+
this.searchFields = [
|
43
|
+
{
|
44
|
+
label: i18next.t('field.from'),
|
45
|
+
name: 'fromDate',
|
46
|
+
type: 'date',
|
47
|
+
props: {
|
48
|
+
searchOper: 'eq'
|
49
|
+
}
|
50
|
+
},
|
51
|
+
{
|
52
|
+
label: i18next.t('field.to'),
|
53
|
+
name: 'toDate',
|
54
|
+
type: 'date',
|
55
|
+
props: {
|
56
|
+
searchOper: 'eq'
|
57
|
+
}
|
58
|
+
}
|
59
|
+
]
|
60
|
+
var actions = [
|
61
|
+
{
|
62
|
+
title: i18next.t('button.print'),
|
63
|
+
action: () => {
|
64
|
+
this.renderRoot.querySelector('iframe').contentWindow.print()
|
65
|
+
},
|
66
|
+
...CommonButtonStyles.print
|
67
|
+
}
|
68
|
+
]
|
69
|
+
return {
|
70
|
+
title: 'jasper-report',
|
71
|
+
actions
|
72
|
+
}
|
73
|
+
}
|
74
|
+
render() {
|
75
|
+
return html`
|
76
|
+
<search-form
|
77
|
+
.fields=${this.searchFields}
|
78
|
+
@submit=${() => {
|
79
|
+
this._reportTemplate()
|
80
|
+
}}
|
81
|
+
></search-form>
|
82
|
+
<iframe id="container"></iframe>
|
83
|
+
`
|
84
|
+
}
|
85
|
+
|
86
|
+
get searchForm() {
|
87
|
+
return this.renderRoot.querySelector('search-form')
|
88
|
+
}
|
89
|
+
async pageUpdated(changes, lifecycle) {
|
90
|
+
if (this.active) {
|
91
|
+
this.updateContext()
|
92
|
+
}
|
93
|
+
}
|
94
|
+
|
95
|
+
async _reportTemplate() {
|
96
|
+
const params = await this.searchForm.getQueryFilters()
|
97
|
+
|
98
|
+
/** urlencoded params including test values */
|
99
|
+
const urlParams = {
|
100
|
+
table: 'samples',
|
101
|
+
dataSetId: this.lifecycle.resourceId,
|
102
|
+
fromWorkDate: params[0].value,
|
103
|
+
toWorkDate: params[1].value,
|
104
|
+
workShift: 'NA'
|
105
|
+
}
|
106
|
+
|
107
|
+
const encodedUrlParams = Object.keys(urlParams).map(key =>
|
108
|
+
`${key}=${encodeURIComponent(urlParams[key])}`
|
109
|
+
).join('&')
|
110
|
+
|
111
|
+
this.shadowRoot.querySelector('#container').src = `/data-report/jasper?${encodedUrlParams}`
|
112
|
+
}
|
113
|
+
}
|
114
|
+
|
115
|
+
window.customElements.define('jasper-report-samples-page', JasperReportSamplesPage)
|
@@ -9,20 +9,22 @@ import { client } from '@operato/graphql'
|
|
9
9
|
import { i18next, localize } from '@operato/i18n'
|
10
10
|
import { openPopup } from '@operato/layout'
|
11
11
|
import { PageView, store } from '@operato/shell'
|
12
|
-
import { ScrollbarStyles } from '@operato/styles'
|
12
|
+
import { CommonGristStyles, ScrollbarStyles } from '@operato/styles'
|
13
13
|
import { isMobileDevice } from '@operato/utils'
|
14
14
|
|
15
15
|
export class DataSampleListPage extends connect(store)(localize(i18next)(PageView)) {
|
16
16
|
static get properties() {
|
17
17
|
return {
|
18
18
|
active: String,
|
19
|
-
gristConfig: Object
|
19
|
+
gristConfig: Object,
|
20
|
+
mode: String
|
20
21
|
}
|
21
22
|
}
|
22
23
|
|
23
24
|
static get styles() {
|
24
25
|
return [
|
25
26
|
ScrollbarStyles,
|
27
|
+
CommonGristStyles,
|
26
28
|
css`
|
27
29
|
:host {
|
28
30
|
display: flex;
|
@@ -35,18 +37,6 @@ export class DataSampleListPage extends connect(store)(localize(i18next)(PageVie
|
|
35
37
|
overflow-y: auto;
|
36
38
|
flex: 1;
|
37
39
|
}
|
38
|
-
|
39
|
-
#filters {
|
40
|
-
display: flex;
|
41
|
-
flex-direction: row;
|
42
|
-
justify-content: space-between;
|
43
|
-
|
44
|
-
background-color: white;
|
45
|
-
}
|
46
|
-
|
47
|
-
#filters > * {
|
48
|
-
padding: var(--padding-default) var(--padding-wide);
|
49
|
-
}
|
50
40
|
`
|
51
41
|
]
|
52
42
|
}
|
@@ -64,14 +54,42 @@ export class DataSampleListPage extends connect(store)(localize(i18next)(PageVie
|
|
64
54
|
}
|
65
55
|
|
66
56
|
render() {
|
57
|
+
const mode = this.mode || (isMobileDevice() ? 'LIST' : 'GRID')
|
58
|
+
|
67
59
|
return html`
|
68
60
|
<ox-grist
|
69
|
-
.mode=${
|
61
|
+
.mode=${mode}
|
70
62
|
.config=${this.gristConfig}
|
71
63
|
.fetchHandler=${this.fetchHandler.bind(this)}
|
64
|
+
url-params-sensitive
|
72
65
|
>
|
73
|
-
<div slot="headroom"
|
74
|
-
<
|
66
|
+
<div slot="headroom">
|
67
|
+
<div id="filters">
|
68
|
+
<ox-filters-form></ox-filters-form>
|
69
|
+
</div>
|
70
|
+
|
71
|
+
<div id="sorters">
|
72
|
+
Sort
|
73
|
+
<mwc-icon
|
74
|
+
@click=${e => {
|
75
|
+
const target = e.currentTarget
|
76
|
+
this.renderRoot.querySelector('#sorter-control').open({
|
77
|
+
right: 0,
|
78
|
+
top: target.offsetTop + target.offsetHeight
|
79
|
+
})
|
80
|
+
}}
|
81
|
+
>expand_more</mwc-icon
|
82
|
+
>
|
83
|
+
<ox-popup id="sorter-control">
|
84
|
+
<ox-sorters-control> </ox-sorters-control>
|
85
|
+
</ox-popup>
|
86
|
+
</div>
|
87
|
+
|
88
|
+
<div id="modes">
|
89
|
+
<mwc-icon @click=${() => (this.mode = 'GRID')} ?active=${mode == 'GRID'}>grid_on</mwc-icon>
|
90
|
+
<mwc-icon @click=${() => (this.mode = 'LIST')} ?active=${mode == 'LIST'}>format_list_bulleted</mwc-icon>
|
91
|
+
<mwc-icon @click=${() => (this.mode = 'CARD')} ?active=${mode == 'CARD'}>apps</mwc-icon>
|
92
|
+
</div>
|
75
93
|
</div>
|
76
94
|
</ox-grist>
|
77
95
|
`
|
@@ -81,30 +99,7 @@ export class DataSampleListPage extends connect(store)(localize(i18next)(PageVie
|
|
81
99
|
return this.renderRoot.querySelector('ox-grist')
|
82
100
|
}
|
83
101
|
|
84
|
-
// update with url params value
|
85
|
-
_updateSearchConfig(lifecycle) {
|
86
|
-
// this.searchConfig = this.searchConfig.map(conf => {
|
87
|
-
// if (conf.name in lifecycle.params) {
|
88
|
-
// conf.value = lifecycle.params[conf.name]
|
89
|
-
// } else {
|
90
|
-
// delete conf.value
|
91
|
-
// }
|
92
|
-
// return conf
|
93
|
-
// })
|
94
|
-
}
|
95
|
-
|
96
|
-
// set default field value to record with searchConfig
|
97
|
-
_setDefaultFieldsValue(fields) {
|
98
|
-
// this.searchConfig.forEach(conf => {
|
99
|
-
// if (!fields[conf.name] && conf.value) {
|
100
|
-
// fields[conf.name] = conf.value
|
101
|
-
// }
|
102
|
-
// })
|
103
|
-
}
|
104
|
-
|
105
102
|
async pageInitialized(lifecycle) {
|
106
|
-
this._updateSearchConfig(lifecycle)
|
107
|
-
|
108
103
|
this.gristConfig = {
|
109
104
|
list: { fields: ['dataSet', 'data', 'spec', 'updater', 'updatedAt'] },
|
110
105
|
columns: [
|
@@ -292,15 +287,15 @@ export class DataSampleListPage extends connect(store)(localize(i18next)(PageVie
|
|
292
287
|
this.grist.fetch()
|
293
288
|
}
|
294
289
|
|
295
|
-
async pageUpdated(changes, lifecycle) {
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
290
|
+
// async pageUpdated(changes, lifecycle) {
|
291
|
+
// if (this.active) {
|
292
|
+
// // update with url params value
|
293
|
+
// this._updateSearchConfig(lifecycle)
|
294
|
+
// await this.updateComplete
|
300
295
|
|
301
|
-
|
302
|
-
|
303
|
-
}
|
296
|
+
// this.grist.fetch()
|
297
|
+
// }
|
298
|
+
// }
|
304
299
|
|
305
300
|
async fetchHandler({ page, limit, sortings = [], filters = [] }) {
|
306
301
|
const response = await client.query({
|
@@ -8,20 +8,22 @@ import { client } from '@operato/graphql'
|
|
8
8
|
import { i18next, localize } from '@operato/i18n'
|
9
9
|
import { notify } from '@operato/layout'
|
10
10
|
import { PageView, store } from '@operato/shell'
|
11
|
-
import { CommonButtonStyles, ScrollbarStyles } from '@operato/styles'
|
11
|
+
import { CommonButtonStyles, CommonGristStyles, ScrollbarStyles } from '@operato/styles'
|
12
12
|
import { isMobileDevice } from '@operato/utils'
|
13
13
|
|
14
14
|
export class DataSensorListPage extends connect(store)(localize(i18next)(PageView)) {
|
15
15
|
static get properties() {
|
16
16
|
return {
|
17
17
|
active: String,
|
18
|
-
gristConfig: Object
|
18
|
+
gristConfig: Object,
|
19
|
+
mode: String
|
19
20
|
}
|
20
21
|
}
|
21
22
|
|
22
23
|
static get styles() {
|
23
24
|
return [
|
24
25
|
ScrollbarStyles,
|
26
|
+
CommonGristStyles,
|
25
27
|
css`
|
26
28
|
:host {
|
27
29
|
display: flex;
|
@@ -34,18 +36,6 @@ export class DataSensorListPage extends connect(store)(localize(i18next)(PageVie
|
|
34
36
|
overflow-y: auto;
|
35
37
|
flex: 1;
|
36
38
|
}
|
37
|
-
|
38
|
-
#filters {
|
39
|
-
display: flex;
|
40
|
-
flex-direction: row;
|
41
|
-
justify-content: space-between;
|
42
|
-
|
43
|
-
background-color: white;
|
44
|
-
}
|
45
|
-
|
46
|
-
#filters > * {
|
47
|
-
padding: var(--padding-default) var(--padding-wide);
|
48
|
-
}
|
49
39
|
`
|
50
40
|
]
|
51
41
|
}
|
@@ -75,14 +65,42 @@ export class DataSensorListPage extends connect(store)(localize(i18next)(PageVie
|
|
75
65
|
}
|
76
66
|
|
77
67
|
render() {
|
68
|
+
const mode = this.mode || (isMobileDevice() ? 'LIST' : 'GRID')
|
69
|
+
|
78
70
|
return html`
|
79
71
|
<ox-grist
|
80
|
-
.mode=${
|
72
|
+
.mode=${mode}
|
81
73
|
.config=${this.gristConfig}
|
82
74
|
.fetchHandler=${this.fetchHandler.bind(this)}
|
75
|
+
url-params-sensitive
|
83
76
|
>
|
84
|
-
<div slot="headroom"
|
85
|
-
<
|
77
|
+
<div slot="headroom">
|
78
|
+
<div id="filters">
|
79
|
+
<ox-filters-form></ox-filters-form>
|
80
|
+
</div>
|
81
|
+
|
82
|
+
<div id="sorters">
|
83
|
+
Sort
|
84
|
+
<mwc-icon
|
85
|
+
@click=${e => {
|
86
|
+
const target = e.currentTarget
|
87
|
+
this.renderRoot.querySelector('#sorter-control').open({
|
88
|
+
right: 0,
|
89
|
+
top: target.offsetTop + target.offsetHeight
|
90
|
+
})
|
91
|
+
}}
|
92
|
+
>expand_more</mwc-icon
|
93
|
+
>
|
94
|
+
<ox-popup id="sorter-control">
|
95
|
+
<ox-sorters-control> </ox-sorters-control>
|
96
|
+
</ox-popup>
|
97
|
+
</div>
|
98
|
+
|
99
|
+
<div id="modes">
|
100
|
+
<mwc-icon @click=${() => (this.mode = 'GRID')} ?active=${mode == 'GRID'}>grid_on</mwc-icon>
|
101
|
+
<mwc-icon @click=${() => (this.mode = 'LIST')} ?active=${mode == 'LIST'}>format_list_bulleted</mwc-icon>
|
102
|
+
<mwc-icon @click=${() => (this.mode = 'CARD')} ?active=${mode == 'CARD'}>apps</mwc-icon>
|
103
|
+
</div>
|
86
104
|
</div>
|
87
105
|
</ox-grist>
|
88
106
|
`
|
@@ -92,30 +110,7 @@ export class DataSensorListPage extends connect(store)(localize(i18next)(PageVie
|
|
92
110
|
return this.renderRoot.querySelector('ox-grist')
|
93
111
|
}
|
94
112
|
|
95
|
-
// update with url params value
|
96
|
-
_updateSearchConfig(lifecycle) {
|
97
|
-
// this.searchConfig = this.searchConfig.map(conf => {
|
98
|
-
// if (conf.name in lifecycle.params) {
|
99
|
-
// conf.value = lifecycle.params[conf.name]
|
100
|
-
// } else {
|
101
|
-
// delete conf.value
|
102
|
-
// }
|
103
|
-
// return conf
|
104
|
-
// })
|
105
|
-
}
|
106
|
-
|
107
|
-
// set default field value to record with searchConfig
|
108
|
-
_setDefaultFieldsValue(fields) {
|
109
|
-
// this.searchConfig.forEach(conf => {
|
110
|
-
// if (!fields[conf.name] && conf.value) {
|
111
|
-
// fields[conf.name] = conf.value
|
112
|
-
// }
|
113
|
-
// })
|
114
|
-
}
|
115
|
-
|
116
113
|
async pageInitialized(lifecycle) {
|
117
|
-
this._updateSearchConfig(lifecycle)
|
118
|
-
|
119
114
|
this.gristConfig = {
|
120
115
|
list: { fields: ['name', 'description', 'active'] },
|
121
116
|
columns: [
|
@@ -273,8 +268,8 @@ export class DataSensorListPage extends connect(store)(localize(i18next)(PageVie
|
|
273
268
|
},
|
274
269
|
{
|
275
270
|
type: 'datetime',
|
276
|
-
name: '
|
277
|
-
header: i18next.t('field.
|
271
|
+
name: 'updatedAt',
|
272
|
+
header: i18next.t('field.updated-at'),
|
278
273
|
record: {
|
279
274
|
editable: false
|
280
275
|
},
|
@@ -299,16 +294,6 @@ export class DataSensorListPage extends connect(store)(localize(i18next)(PageVie
|
|
299
294
|
this.grist.fetch()
|
300
295
|
}
|
301
296
|
|
302
|
-
async pageUpdated(changes, lifecycle) {
|
303
|
-
if (this.active) {
|
304
|
-
// update with url params value
|
305
|
-
this._updateSearchConfig(lifecycle)
|
306
|
-
await this.updateComplete
|
307
|
-
|
308
|
-
this.grist.fetch()
|
309
|
-
}
|
310
|
-
}
|
311
|
-
|
312
297
|
async fetchHandler({ page, limit, sortings = [], filters = [] }) {
|
313
298
|
const response = await client.query({
|
314
299
|
query: gql`
|
@@ -414,7 +399,6 @@ export class DataSensorListPage extends connect(store)(localize(i18next)(PageVie
|
|
414
399
|
for (let key in dirtyFields) {
|
415
400
|
patchField[key] = dirtyFields[key].after
|
416
401
|
}
|
417
|
-
this._setDefaultFieldsValue(patchField)
|
418
402
|
patchField.cuFlag = patch.__dirty__
|
419
403
|
|
420
404
|
return patchField
|