@things-factory/notification 6.1.1 → 6.1.4

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.
@@ -1,5 +1,7 @@
1
+ import gql from 'graphql-tag'
1
2
  import { LitElement, html, css } from 'lit'
2
3
  import '@material/mwc-icon'
4
+ import { client } from '@operato/graphql'
3
5
 
4
6
  function isOriginSameAsLocation(url) {
5
7
  function defaultPort(protocol) {
@@ -137,13 +139,16 @@ export class NotificationItem extends LitElement {
137
139
  reflect: true
138
140
  },
139
141
  notification: Object,
140
- target: String
142
+ target: String,
143
+ detail: String
141
144
  }
142
145
  }
143
146
 
144
147
  render() {
145
148
  const { title, url, image, timestamp, body } = this.notification
146
149
  const target = this.target
150
+ const detail = this.detail
151
+ const type = this.type
147
152
 
148
153
  return html`
149
154
  <div titler>
@@ -164,6 +169,17 @@ export class NotificationItem extends LitElement {
164
169
  : html`<img src=${image} />`
165
170
  : html``}
166
171
  <div message>${body}</div>
172
+ ${type == 'ERROR'
173
+ ? html`<div
174
+ @click=${() => {
175
+ this.decipherErrorCode()
176
+ }}
177
+ >
178
+ more...
179
+ </div>`
180
+ : html``}
181
+ ${detail ? html`<div detail>${detail.message}</div>` : html``}
182
+
167
183
  <div timestamp>${new Date(Number(timestamp)).toLocaleString()}</div>
168
184
  `
169
185
  }
@@ -178,6 +194,36 @@ export class NotificationItem extends LitElement {
178
194
  const url = this.notification?.url
179
195
  this.target = url && !isOriginSameAsLocation(url) && '_blank'
180
196
  }
197
+
198
+ async decipherErrorCode() {
199
+ if (this.type != 'ERROR' || !this.notification) {
200
+ return
201
+ }
202
+
203
+ const { title, body } = this.notification
204
+ var code = `${title}`
205
+ if (body) {
206
+ code += `: ${body}`
207
+ }
208
+
209
+ const response = await client.query({
210
+ query: gql`
211
+ query ($input: CodeDecipherInput!) {
212
+ decipherErrorCode(input: $input) {
213
+ message
214
+ }
215
+ }
216
+ `,
217
+ variables: {
218
+ input: {
219
+ code,
220
+ system: ''
221
+ }
222
+ }
223
+ })
224
+
225
+ this.detail = response.data.decipherErrorCode
226
+ }
181
227
  }
182
228
 
183
229
  customElements.define('notification-item', NotificationItem)
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./service"), exports);
5
- tslib_1.__exportStar(require("./migrations"), exports);
6
5
  tslib_1.__exportStar(require("./middlewares"), exports);
7
6
  tslib_1.__exportStar(require("./controllers"), exports);
8
7
  require("./routes");
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":";;;AAAA,oDAAyB;AACzB,uDAA4B;AAC5B,wDAA6B;AAC7B,wDAA6B;AAE7B,oBAAiB","sourcesContent":["export * from './service'\nexport * from './migrations'\nexport * from './middlewares'\nexport * from './controllers'\n\nimport './routes'\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":";;;AAAA,oDAAyB;AACzB,wDAA6B;AAC7B,wDAA6B;AAE7B,oBAAiB","sourcesContent":["export * from './service'\nexport * from './middlewares'\nexport * from './controllers'\n\nimport './routes'\n"]}