@things-factory/dashboard 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/dashboard",
3
- "version": "8.0.0-beta.9",
3
+ "version": "8.0.0",
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.9",
30
- "@things-factory/board-service": "^8.0.0-beta.9",
31
- "@things-factory/board-ui": "^8.0.0-beta.9",
32
- "@things-factory/setting-base": "^8.0.0-beta.9"
29
+ "@things-factory/auth-base": "^8.0.0",
30
+ "@things-factory/board-service": "^8.0.0",
31
+ "@things-factory/board-ui": "^8.0.0",
32
+ "@things-factory/setting-base": "^8.0.0"
33
33
  },
34
- "gitHead": "86b1dfa26292926a2d5447fdc23bfa5a9e983245"
34
+ "gitHead": "07ef27d272dd9a067a9648ac7013748510556a18"
35
35
  }
@@ -0,0 +1 @@
1
+ export * from './service'
@@ -0,0 +1,17 @@
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
+ }
@@ -0,0 +1,54 @@
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
+ }
@@ -0,0 +1,4 @@
1
+ import { BoardSettingsQuery } from './board-settings-query'
2
+
3
+ export const entities = []
4
+ export const resolvers = [BoardSettingsQuery]
@@ -0,0 +1,17 @@
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
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "../../tsconfig-base.json",
3
+ "compilerOptions": {
4
+ "strict": false,
5
+ "module": "commonjs",
6
+ "outDir": "../dist-server",
7
+ "baseUrl": "./"
8
+ },
9
+ "include": ["./**/*"]
10
+ }