@things-factory/shell 4.0.28 → 4.0.33
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/elements/oops-progress.js +3 -2
- package/client/entries/public/home.js +2 -1
- package/client/index.js +1 -6
- package/package.json +9 -7
- package/client/gql-context.js +0 -15
- package/client/graphql-client.js +0 -161
- package/client/mixins/index.js +0 -1
- package/client/mixins/infinite-scrollable.js +0 -32
@@ -1,5 +1,6 @@
|
|
1
|
-
import {
|
2
|
-
|
1
|
+
import { html, LitElement } from 'lit-element'
|
2
|
+
|
3
|
+
import { subscribe } from '@operato/graphql'
|
3
4
|
|
4
5
|
export class OopsProgress extends LitElement {
|
5
6
|
static get properties() {
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import '@material/mwc-icon-button'
|
2
2
|
import '@material/mwc-button'
|
3
|
+
|
3
4
|
import { css, html, LitElement } from 'lit-element'
|
4
5
|
|
5
6
|
export class HomePage extends LitElement {
|
@@ -66,7 +67,7 @@ export class HomePage extends LitElement {
|
|
66
67
|
var { icon, title, description } = this.applicationMeta
|
67
68
|
|
68
69
|
return html`
|
69
|
-
<mwc-icon-button home icon="home" @click=${e => (window.location = '/')}></mwc-icon-button>
|
70
|
+
<mwc-icon-button home icon="home" @click=${e => (window.location.href = '/')}></mwc-icon-button>
|
70
71
|
|
71
72
|
<div message>
|
72
73
|
<strong>${title}</strong>
|
package/client/index.js
CHANGED
@@ -19,19 +19,14 @@ export * from './actions'
|
|
19
19
|
export * from './app/pages/page-view'
|
20
20
|
|
21
21
|
// graphql-client
|
22
|
-
export * from '
|
22
|
+
export * from '@operato/graphql'
|
23
23
|
|
24
24
|
// indexdb-store
|
25
25
|
export * from './indexdb'
|
26
26
|
|
27
|
-
// mixins
|
28
|
-
export * from './mixins'
|
29
|
-
|
30
27
|
// elements
|
31
28
|
export * from './elements'
|
32
29
|
|
33
30
|
// Redux assumes `process.env.NODE_ENV` exists in the ES module build.
|
34
31
|
// https://github.com/reactjs/redux/issues/2907
|
35
32
|
window.process = { env: { NODE_ENV: 'production' } }
|
36
|
-
|
37
|
-
export * from './gql-context'
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@things-factory/shell",
|
3
|
-
"version": "4.0.
|
3
|
+
"version": "4.0.33",
|
4
4
|
"description": "Core module for framework",
|
5
5
|
"bin": {
|
6
6
|
"things-factory": "bin/things-factory",
|
@@ -44,11 +44,13 @@
|
|
44
44
|
"@material/mwc-icon-button": "^0.25.3",
|
45
45
|
"@material/mwc-slider": "^0.25.3",
|
46
46
|
"@material/mwc-textfield": "^0.25.3",
|
47
|
-
"@operato/board": "^0.3.
|
48
|
-
"@
|
49
|
-
"@
|
50
|
-
"@things-factory/
|
51
|
-
"@things-factory/
|
47
|
+
"@operato/board": "^0.3.14",
|
48
|
+
"@operato/graphql": "^0.3.14",
|
49
|
+
"@operato/utils": "^0.3.14",
|
50
|
+
"@things-factory/ejs-remote": "^4.0.33",
|
51
|
+
"@things-factory/env": "^4.0.33",
|
52
|
+
"@things-factory/styles": "^4.0.33",
|
53
|
+
"@things-factory/utils": "^4.0.33",
|
52
54
|
"@webcomponents/webcomponentsjs": "^2.6.0",
|
53
55
|
"@webpack-contrib/schema-utils": "^1.0.0-beta.0",
|
54
56
|
"apollo-server-core": "^3.5.0",
|
@@ -122,5 +124,5 @@
|
|
122
124
|
"resolutions": {
|
123
125
|
"core-js": "^3.16.0"
|
124
126
|
},
|
125
|
-
"gitHead": "
|
127
|
+
"gitHead": "0cd5e3b224feb8d526dd5ebc0ee838ff55e2c91c"
|
126
128
|
}
|
package/client/gql-context.js
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
export const CONTEXT_KEY = '__context__'
|
2
|
-
|
3
|
-
export function gqlContext() {
|
4
|
-
const search = new URLSearchParams(location.search)
|
5
|
-
return JSON.parse(search.get(CONTEXT_KEY)) || ''
|
6
|
-
}
|
7
|
-
|
8
|
-
export function buildGqlContext(context) {
|
9
|
-
if (!context) throw new Error('context is not passed')
|
10
|
-
if (typeof context !== 'string') {
|
11
|
-
context = JSON.stringify(context)
|
12
|
-
}
|
13
|
-
|
14
|
-
return new URLSearchParams({ [CONTEXT_KEY]: context }).toString()
|
15
|
-
}
|
package/client/graphql-client.js
DELETED
@@ -1,161 +0,0 @@
|
|
1
|
-
import { ApolloClient, ApolloLink, HttpLink, InMemoryCache, from } from '@apollo/client/core'
|
2
|
-
|
3
|
-
import { SubscriptionClient } from 'subscriptions-transport-ws'
|
4
|
-
import { createUploadLink } from 'apollo-upload-client'
|
5
|
-
import { onError } from '@apollo/client/link/error'
|
6
|
-
|
7
|
-
// import { persistCache } from 'apollo-cache-persist'
|
8
|
-
|
9
|
-
export const GRAPHQL_URI = '/graphql'
|
10
|
-
|
11
|
-
const defaultOptions = {
|
12
|
-
watchQuery: {
|
13
|
-
fetchPolicy: 'no-cache',
|
14
|
-
errorPolicy: 'ignore'
|
15
|
-
},
|
16
|
-
query: {
|
17
|
-
fetchPolicy: 'no-cache', //'network-only'
|
18
|
-
errorPolicy: 'all'
|
19
|
-
},
|
20
|
-
mutate: {
|
21
|
-
errorPolicy: 'all'
|
22
|
-
}
|
23
|
-
}
|
24
|
-
|
25
|
-
const ERROR_HANDLER = ({ operation, graphQLErrors, networkError }) => {
|
26
|
-
if (graphQLErrors) {
|
27
|
-
document.dispatchEvent(
|
28
|
-
new CustomEvent('notify', {
|
29
|
-
detail: {
|
30
|
-
level: 'error',
|
31
|
-
message: graphQLErrors[0].message,
|
32
|
-
ex: graphQLErrors
|
33
|
-
}
|
34
|
-
})
|
35
|
-
)
|
36
|
-
}
|
37
|
-
|
38
|
-
if (networkError) {
|
39
|
-
switch (networkError.statusCode) {
|
40
|
-
case 401:
|
41
|
-
/* 401 에러가 리턴되면, 인증이 필요하다는 메시지를 dispatch 한다. 이 auth 모듈 등에서 이 메시지를 받아서 signin 프로세스를 진행할 수 있다. */
|
42
|
-
document.dispatchEvent(new CustomEvent('auth-required'))
|
43
|
-
break
|
44
|
-
case 403:
|
45
|
-
/* 403 에러가 리턴되면, 도메인 정보가 필요하다는 메시지를 dispatch 한다. 이 auth 모듈 등에서 이 메시지를 받아서 domain-register 프로세스 등을 진행할 수 있다. */
|
46
|
-
document.dispatchEvent(new CustomEvent('domain-required'))
|
47
|
-
break
|
48
|
-
default:
|
49
|
-
var { name, response, statusCode, bodyText, message } = networkError
|
50
|
-
if (name == 'ServerParseError') {
|
51
|
-
message = `[ ${statusCode || ''} : ${response.statusText} ] ${bodyText}`
|
52
|
-
} else {
|
53
|
-
message = `[ ${statusCode || ''} : ${response.statusText} ] ${message}`
|
54
|
-
}
|
55
|
-
|
56
|
-
document.dispatchEvent(
|
57
|
-
new CustomEvent('notify', {
|
58
|
-
detail: {
|
59
|
-
level: 'error',
|
60
|
-
message,
|
61
|
-
ex: networkError
|
62
|
-
}
|
63
|
-
})
|
64
|
-
)
|
65
|
-
}
|
66
|
-
}
|
67
|
-
}
|
68
|
-
|
69
|
-
const cache = new InMemoryCache({
|
70
|
-
addTypename: false
|
71
|
-
// dataIdFromObject: object => object.key
|
72
|
-
})
|
73
|
-
|
74
|
-
const httpOptions = {
|
75
|
-
GRAPHQL_URI,
|
76
|
-
credentials: 'include'
|
77
|
-
}
|
78
|
-
|
79
|
-
const httpLink = ApolloLink.split(
|
80
|
-
operation => operation.getContext().hasUpload,
|
81
|
-
createUploadLink(httpOptions),
|
82
|
-
new HttpLink(httpOptions)
|
83
|
-
)
|
84
|
-
|
85
|
-
// const initPersistCache = async () => {
|
86
|
-
// persistCache({
|
87
|
-
// cache,
|
88
|
-
// storage: window.localStorage
|
89
|
-
// })
|
90
|
-
// }
|
91
|
-
|
92
|
-
// initPersistCache()
|
93
|
-
|
94
|
-
export const client = new ApolloClient({
|
95
|
-
defaultOptions,
|
96
|
-
cache,
|
97
|
-
link: from([onError(ERROR_HANDLER), httpLink])
|
98
|
-
})
|
99
|
-
|
100
|
-
/* SubscriptionClient */
|
101
|
-
var subscriptionClient
|
102
|
-
|
103
|
-
const getSubscriptionClient = async () => {
|
104
|
-
if (!subscriptionClient) {
|
105
|
-
subscriptionClient = new Promise((resolve, reject) => {
|
106
|
-
var client = new SubscriptionClient(location.origin.replace(/^http/, 'ws') + '/subscriptions', {
|
107
|
-
reconnect: true,
|
108
|
-
connectionParams: {
|
109
|
-
headers: {
|
110
|
-
/*
|
111
|
-
특정 도메인의 데이타만 받고자 하는 경우에, referer 정보를 제공해서 서버에서 서브도메인 정보를 취득하도록 한다.
|
112
|
-
referer: location.href
|
113
|
-
또는, 이미 서브도메인 정보를 알고 있다면,
|
114
|
-
'x-things-factory-domain': '[subdomain]'
|
115
|
-
을 보낼 수 있다.
|
116
|
-
관련 정보를 보내지 않는다면, 사용자가 권한을 가진 모든 도메인의 데이타를 수신하게 된다.
|
117
|
-
*/
|
118
|
-
referer: location.href
|
119
|
-
}
|
120
|
-
}
|
121
|
-
})
|
122
|
-
|
123
|
-
client.onError(err => {
|
124
|
-
//readyState === 3 인 경우 url을 잘 못 입력했거나, 서버에 문제가 있는 경우이므로 reconnect = false로 변경한다.
|
125
|
-
if (client.status === 3) {
|
126
|
-
client.reconnect = false
|
127
|
-
}
|
128
|
-
reject(err)
|
129
|
-
})
|
130
|
-
|
131
|
-
client.onConnected(() => {
|
132
|
-
resolve(client)
|
133
|
-
})
|
134
|
-
})
|
135
|
-
}
|
136
|
-
|
137
|
-
return await subscriptionClient
|
138
|
-
}
|
139
|
-
|
140
|
-
var subscriptions = []
|
141
|
-
|
142
|
-
export const subscribe = async (request, subscribe) => {
|
143
|
-
var client = await getSubscriptionClient()
|
144
|
-
var { unsubscribe } = client.request(request).subscribe(subscribe)
|
145
|
-
|
146
|
-
subscriptions.push(unsubscribe)
|
147
|
-
|
148
|
-
return {
|
149
|
-
unsubscribe() {
|
150
|
-
subscriptions.splice(subscriptions.indexOf(unsubscribe), 1)
|
151
|
-
unsubscribe()
|
152
|
-
|
153
|
-
if (subscriptions.length == 0) {
|
154
|
-
client.unsubscribeAll()
|
155
|
-
client.close(true)
|
156
|
-
|
157
|
-
subscriptionClient = null
|
158
|
-
}
|
159
|
-
}
|
160
|
-
}
|
161
|
-
}
|
package/client/mixins/index.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export { default as InfiniteScrollable } from './infinite-scrollable'
|
@@ -1,32 +0,0 @@
|
|
1
|
-
import debounce from 'lodash/debounce'
|
2
|
-
export default superclass => {
|
3
|
-
return class A extends superclass {
|
4
|
-
constructor() {
|
5
|
-
super()
|
6
|
-
|
7
|
-
this._infiniteScrollOptions = {
|
8
|
-
threshold: 20,
|
9
|
-
limit: 30,
|
10
|
-
totalProp: '_total',
|
11
|
-
pageProp: '_page'
|
12
|
-
}
|
13
|
-
|
14
|
-
this.onScroll = debounce(e => {
|
15
|
-
var el = this.scrollTargetEl
|
16
|
-
var { threshold = 0, limit, totalProp, pageProp } = this._infiniteScrollOptions
|
17
|
-
|
18
|
-
if (this[pageProp] < this[totalProp] / limit && el.scrollHeight - el.clientHeight <= el.scrollTop + threshold) {
|
19
|
-
this.scrollAction()
|
20
|
-
}
|
21
|
-
}, 300)
|
22
|
-
}
|
23
|
-
|
24
|
-
get scrollTargetEl() {
|
25
|
-
console.warn('scroll target element is not defined.')
|
26
|
-
}
|
27
|
-
|
28
|
-
async scrollAction() {
|
29
|
-
console.warn('scroll action not implemented.')
|
30
|
-
}
|
31
|
-
}
|
32
|
-
}
|