@things-factory/edge 8.0.0-beta.9 → 8.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.
@@ -0,0 +1 @@
1
+ export default function bootstrap() {}
File without changes
@@ -0,0 +1,173 @@
1
+ import '@operato/data-grist'
2
+ import '@operato/context/ox-context-page-toolbar.js'
3
+ import '@operato/input/ox-input-select-buttons.js'
4
+
5
+ import { PropertyValues, css, html } from 'lit'
6
+ import { customElement, property, query, state } from 'lit/decorators.js'
7
+ import { connect } from 'pwa-helpers/connect-mixin.js'
8
+ import gql from 'graphql-tag'
9
+
10
+ import { store, PageView } from '@operato/shell'
11
+ import { client } from '@operato/graphql'
12
+ import { DataGrist, FetchOption, GristRecord } from '@operato/data-grist'
13
+ import { i18next, localize } from '@operato/i18n'
14
+ import { openPopup } from '@operato/layout'
15
+ import { CommonHeaderStyles, ScrollbarStyles } from '@operato/styles'
16
+ import { isMobileDevice } from '@operato/utils'
17
+
18
+ @customElement('edge-status-page')
19
+ export class EdgeStatusPage extends connect(store)(localize(i18next)(PageView)) {
20
+ static styles = [
21
+ ScrollbarStyles,
22
+ CommonHeaderStyles,
23
+ css`
24
+ :host {
25
+ display: flex;
26
+ flex-direction: column;
27
+
28
+ overflow: hidden;
29
+
30
+ --grid-header-padding: 2px 0 2px 9px;
31
+ }
32
+
33
+ ox-grist {
34
+ overflow-y: auto;
35
+ flex: 1;
36
+ }
37
+ `
38
+ ]
39
+
40
+ @state() private gristConfig: any
41
+ @state() private mode: 'CARD' | 'GRID' | 'LIST' = isMobileDevice() ? 'CARD' : 'GRID'
42
+ @state() private state?: string[]
43
+
44
+ @query('ox-grist') private grist!: DataGrist
45
+
46
+ get context() {
47
+ return {
48
+ title: i18next.t('title.edge-status'),
49
+ search: {
50
+ handler: (search: string) => {
51
+ this.grist.searchText = search
52
+ },
53
+ value: this.grist?.searchText || ''
54
+ },
55
+ filter: {
56
+ handler: () => {
57
+ this.grist.toggleHeadroom()
58
+ }
59
+ },
60
+ help: 'edge/edge-status',
61
+ actions: [],
62
+ toolbar: false
63
+ }
64
+ }
65
+
66
+ render() {
67
+ const mode = this.mode || (isMobileDevice() ? 'LIST' : 'GRID')
68
+
69
+ return html`
70
+ <ox-grist .mode=${mode} .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)}>
71
+ <div slot="headroom" class="header">
72
+ <div class="title">${i18next.t('label.connections')}</div>
73
+
74
+ <ox-context-page-toolbar class="actions" .context=${this.context}></ox-context-page-toolbar>
75
+ </div>
76
+ </ox-grist>
77
+ `
78
+ }
79
+
80
+ async pageInitialized(lifecycle) {
81
+ this.gristConfig = {
82
+ list: {
83
+ fields: ['name', 'description'],
84
+ details: ['active', 'updatedAt']
85
+ },
86
+ columns: [
87
+ { type: 'gutter', gutterName: 'sequence' },
88
+ {
89
+ type: 'string',
90
+ name: 'domain',
91
+ header: i18next.t('field.domain'),
92
+ record: {
93
+ renderer: value => value.name
94
+ },
95
+ width: 200
96
+ },
97
+ {
98
+ type: 'string',
99
+ name: 'type',
100
+ header: i18next.t('field.type'),
101
+ width: 150
102
+ },
103
+ {
104
+ type: 'string',
105
+ name: 'name',
106
+ header: i18next.t('field.name'),
107
+ width: 150
108
+ },
109
+ {
110
+ type: 'string',
111
+ name: 'description',
112
+ header: i18next.t('field.description'),
113
+ width: 200
114
+ },
115
+ {
116
+ type: 'checkbox',
117
+ name: 'active',
118
+ label: true,
119
+ header: i18next.t('field.active'),
120
+ width: 60
121
+ },
122
+ {
123
+ type: 'string',
124
+ name: 'state',
125
+ label: true,
126
+ header: i18next.t('field.status'),
127
+ width: 100
128
+ }
129
+ ],
130
+ rows: {
131
+ appendable: false,
132
+ selectable: false,
133
+ handlers: {}
134
+ },
135
+ pagination: { infinite: true },
136
+ sorters: []
137
+ }
138
+ }
139
+
140
+ async pageUpdated(changes: any, lifecycle: any) {
141
+ if (this.active) {
142
+ // do something here when this page just became as active
143
+ }
144
+ }
145
+
146
+ async fetchHandler() {
147
+ const response = await client.query({
148
+ query: gql`
149
+ query {
150
+ responses: connectionsOnEdge {
151
+ domain {
152
+ id
153
+ name
154
+ subdomain
155
+ }
156
+ id
157
+ type
158
+ name
159
+ description
160
+ endpoint
161
+ active
162
+ state
163
+ }
164
+ }
165
+ `
166
+ })
167
+
168
+ return {
169
+ total: response.data.responses.length || 0,
170
+ records: response.data.responses || []
171
+ }
172
+ }
173
+ }
@@ -0,0 +1,7 @@
1
+ export default function route(page: string) {
2
+ switch (page) {
3
+ case 'edge-status-page':
4
+ import('./pages/edge-status-page')
5
+ return page
6
+ }
7
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "extends": "../../tsconfig-base.json",
3
+ "compilerOptions": {
4
+ "strict": true,
5
+ "declaration": true,
6
+ "module": "esnext",
7
+ "outDir": "../dist-client",
8
+ "baseUrl": "./"
9
+ },
10
+ "include": ["./**/*"]
11
+ }