@things-factory/dataset 5.0.0-alpha.1 → 5.0.0-alpha.10
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/bootstrap.js +11 -2
- package/client/pages/data-entry-form.js +75 -0
- package/client/pages/data-item-list.js +65 -16
- package/client/pages/data-sample.js +45 -10
- package/client/pages/data-sensor.js +446 -0
- package/client/pages/data-set.js +47 -8
- package/client/route.js +4 -0
- package/dist-server/index.js +1 -0
- package/dist-server/index.js.map +1 -1
- package/dist-server/routes.js +64 -0
- package/dist-server/routes.js.map +1 -1
- package/dist-server/service/data-item/data-item-mutation.js +5 -1
- package/dist-server/service/data-item/data-item-mutation.js.map +1 -1
- package/dist-server/service/data-item/data-item-type.js +15 -6
- package/dist-server/service/data-item/data-item-type.js.map +1 -1
- package/dist-server/service/data-item/data-item.js +26 -6
- package/dist-server/service/data-item/data-item.js.map +1 -1
- package/dist-server/service/data-sample/data-sample-mutation.js +41 -7
- package/dist-server/service/data-sample/data-sample-mutation.js.map +1 -1
- package/dist-server/service/data-sample/data-sample-type.js +23 -2
- package/dist-server/service/data-sample/data-sample-type.js.map +1 -1
- package/dist-server/service/data-sample/data-sample.js +44 -5
- package/dist-server/service/data-sample/data-sample.js.map +1 -1
- package/dist-server/service/data-sensor/data-sensor-mutation.js +120 -0
- package/dist-server/service/data-sensor/data-sensor-mutation.js.map +1 -0
- package/dist-server/service/data-sensor/data-sensor-query.js +108 -0
- package/dist-server/service/data-sensor/data-sensor-query.js.map +1 -0
- package/dist-server/service/data-sensor/data-sensor-type.js +147 -0
- package/dist-server/service/data-sensor/data-sensor-type.js.map +1 -0
- package/dist-server/service/data-sensor/data-sensor.js +168 -0
- package/dist-server/service/data-sensor/data-sensor.js.map +1 -0
- package/dist-server/service/data-sensor/index.js +9 -0
- package/dist-server/service/data-sensor/index.js.map +1 -0
- package/dist-server/service/data-set/data-set-type.js +18 -0
- package/dist-server/service/data-set/data-set-type.js.map +1 -1
- package/dist-server/service/data-set/data-set.js +22 -3
- package/dist-server/service/data-set/data-set.js.map +1 -1
- package/dist-server/service/data-spec/data-spec-manager.js +20 -0
- package/dist-server/service/data-spec/data-spec-manager.js.map +1 -0
- package/dist-server/service/data-spec/data-spec-query.js +48 -0
- package/dist-server/service/data-spec/data-spec-query.js.map +1 -0
- package/dist-server/service/data-spec/data-spec.js +78 -0
- package/dist-server/service/data-spec/data-spec.js.map +1 -0
- package/dist-server/service/data-spec/index.js +8 -0
- package/dist-server/service/data-spec/index.js.map +1 -0
- package/dist-server/service/index.js +10 -2
- package/dist-server/service/index.js.map +1 -1
- package/package.json +13 -11
- package/server/index.ts +2 -0
- package/server/routes.ts +76 -0
- package/server/service/data-item/data-item-mutation.ts +6 -1
- package/server/service/data-item/data-item-type.ts +11 -6
- package/server/service/data-item/data-item.ts +21 -5
- package/server/service/data-sample/data-sample-mutation.ts +51 -5
- package/server/service/data-sample/data-sample-type.ts +17 -2
- package/server/service/data-sample/data-sample.ts +37 -2
- package/server/service/data-sensor/data-sensor-mutation.ts +110 -0
- package/server/service/data-sensor/data-sensor-query.ts +56 -0
- package/server/service/data-sensor/data-sensor-type.ts +98 -0
- package/server/service/data-sensor/data-sensor.ts +139 -0
- package/server/service/data-sensor/index.ts +6 -0
- package/server/service/data-set/data-set-type.ts +14 -0
- package/server/service/data-set/data-set.ts +17 -1
- package/server/service/data-spec/data-spec-manager.ts +21 -0
- package/server/service/data-spec/data-spec-query.ts +21 -0
- package/server/service/data-spec/data-spec.ts +44 -0
- package/server/service/data-spec/index.ts +5 -0
- package/server/service/index.ts +12 -4
- package/things-factory.config.js +4 -0
- package/translations/en.json +18 -4
- package/translations/ko.json +17 -3
- package/translations/ms.json +18 -4
- package/translations/zh.json +18 -4
@@ -0,0 +1,110 @@
|
|
1
|
+
import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'
|
2
|
+
import { In } from 'typeorm'
|
3
|
+
|
4
|
+
import { DataSensor } from './data-sensor'
|
5
|
+
import { DataSensorPatch, NewDataSensor } from './data-sensor-type'
|
6
|
+
|
7
|
+
@Resolver(DataSensor)
|
8
|
+
export class DataSensorMutation {
|
9
|
+
@Directive('@transaction')
|
10
|
+
@Mutation(returns => DataSensor, { description: 'To create new DataSensor' })
|
11
|
+
async createDataSensor(@Arg('dataSensor') dataSensor: NewDataSensor, @Ctx() context: any): Promise<DataSensor> {
|
12
|
+
const { domain, user, tx } = context.state
|
13
|
+
|
14
|
+
return await tx.getRepository(DataSensor).save({
|
15
|
+
...dataSensor,
|
16
|
+
domain,
|
17
|
+
creator: user,
|
18
|
+
updater: user
|
19
|
+
})
|
20
|
+
}
|
21
|
+
|
22
|
+
@Directive('@transaction')
|
23
|
+
@Mutation(returns => DataSensor, { description: 'To modify DataSensor information' })
|
24
|
+
async updateDataSensor(
|
25
|
+
@Arg('id') id: string,
|
26
|
+
@Arg('patch') patch: DataSensorPatch,
|
27
|
+
@Ctx() context: any
|
28
|
+
): Promise<DataSensor> {
|
29
|
+
const { domain, user, tx } = context.state
|
30
|
+
|
31
|
+
const repository = tx.getRepository(DataSensor)
|
32
|
+
const dataSensor = await repository.findOne({
|
33
|
+
where: { domain, id }
|
34
|
+
})
|
35
|
+
|
36
|
+
return await repository.save({
|
37
|
+
...dataSensor,
|
38
|
+
...patch,
|
39
|
+
updater: user
|
40
|
+
})
|
41
|
+
}
|
42
|
+
|
43
|
+
@Directive('@transaction')
|
44
|
+
@Mutation(returns => [DataSensor], { description: "To modify multiple DataSensors' information" })
|
45
|
+
async updateMultipleDataSensor(
|
46
|
+
@Arg('patches', type => [DataSensorPatch]) patches: DataSensorPatch[],
|
47
|
+
@Ctx() context: any
|
48
|
+
): Promise<DataSensor[]> {
|
49
|
+
const { domain, user, tx } = context.state
|
50
|
+
|
51
|
+
let results = []
|
52
|
+
const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')
|
53
|
+
const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')
|
54
|
+
const dataSensorRepo = tx.getRepository(DataSensor)
|
55
|
+
|
56
|
+
if (_createRecords.length > 0) {
|
57
|
+
for (let i = 0; i < _createRecords.length; i++) {
|
58
|
+
const newRecord = _createRecords[i]
|
59
|
+
|
60
|
+
const result = await dataSensorRepo.save({
|
61
|
+
...newRecord,
|
62
|
+
domain,
|
63
|
+
creator: user,
|
64
|
+
updater: user
|
65
|
+
})
|
66
|
+
|
67
|
+
results.push({ ...result, cuFlag: '+' })
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
if (_updateRecords.length > 0) {
|
72
|
+
for (let i = 0; i < _updateRecords.length; i++) {
|
73
|
+
const newRecord = _updateRecords[i]
|
74
|
+
const dataSensor = await dataSensorRepo.findOne(newRecord.id)
|
75
|
+
|
76
|
+
const result = await dataSensorRepo.save({
|
77
|
+
...dataSensor,
|
78
|
+
...newRecord,
|
79
|
+
updater: user
|
80
|
+
})
|
81
|
+
|
82
|
+
results.push({ ...result, cuFlag: 'M' })
|
83
|
+
}
|
84
|
+
}
|
85
|
+
|
86
|
+
return results
|
87
|
+
}
|
88
|
+
|
89
|
+
@Directive('@transaction')
|
90
|
+
@Mutation(returns => Boolean, { description: 'To delete DataSensor' })
|
91
|
+
async deleteDataSensor(@Arg('id') id: string, @Ctx() context: any): Promise<boolean> {
|
92
|
+
const { domain, tx } = context.state
|
93
|
+
|
94
|
+
await tx.getRepository(DataSensor).delete({ domain, id })
|
95
|
+
return true
|
96
|
+
}
|
97
|
+
|
98
|
+
@Directive('@transaction')
|
99
|
+
@Mutation(returns => Boolean, { description: 'To delete multiple dataSensors' })
|
100
|
+
async deleteDataSensors(@Arg('ids', type => [String]) ids: string[], @Ctx() context: any): Promise<boolean> {
|
101
|
+
const { domain, tx } = context.state
|
102
|
+
|
103
|
+
await tx.getRepository(DataSensor).delete({
|
104
|
+
domain,
|
105
|
+
id: In(ids)
|
106
|
+
})
|
107
|
+
|
108
|
+
return true
|
109
|
+
}
|
110
|
+
}
|
@@ -0,0 +1,56 @@
|
|
1
|
+
import { Arg, Args, Ctx, FieldResolver, Query, Resolver, Root } from 'type-graphql'
|
2
|
+
import { getRepository } from 'typeorm'
|
3
|
+
|
4
|
+
import { Appliance, User } from '@things-factory/auth-base'
|
5
|
+
import { convertListParams, Domain, ListParam } from '@things-factory/shell'
|
6
|
+
|
7
|
+
import { DataSet } from '../data-set/data-set'
|
8
|
+
import { DataSensor } from './data-sensor'
|
9
|
+
import { DataSensorList } from './data-sensor-type'
|
10
|
+
|
11
|
+
@Resolver(DataSensor)
|
12
|
+
export class DataSensorQuery {
|
13
|
+
@Query(returns => DataSensor, { description: 'To fetch a DataSensor' })
|
14
|
+
async dataSensor(@Arg('id') id: string, @Ctx() context: any): Promise<DataSensor> {
|
15
|
+
const { domain } = context.state
|
16
|
+
|
17
|
+
return await getRepository(DataSensor).findOne({
|
18
|
+
where: { domain, id }
|
19
|
+
})
|
20
|
+
}
|
21
|
+
|
22
|
+
@Query(returns => DataSensorList, { description: 'To fetch multiple DataSensors' })
|
23
|
+
async dataSensors(@Args() params: ListParam, @Ctx() context: any): Promise<DataSensorList> {
|
24
|
+
const { domain } = context.state
|
25
|
+
|
26
|
+
const convertedParams = convertListParams(params, domain.id)
|
27
|
+
const [items, total] = await getRepository(DataSensor).findAndCount(convertedParams)
|
28
|
+
|
29
|
+
return { items, total }
|
30
|
+
}
|
31
|
+
|
32
|
+
@FieldResolver(type => Appliance)
|
33
|
+
async appliance(@Root() dataSensor: DataSensor): Promise<Appliance> {
|
34
|
+
return await getRepository(Appliance).findOne(dataSensor.applianceId || '')
|
35
|
+
}
|
36
|
+
|
37
|
+
@FieldResolver(type => Appliance)
|
38
|
+
async dataSet(@Root() dataSensor: DataSensor): Promise<DataSet> {
|
39
|
+
return await getRepository(DataSet).findOne(dataSensor.dataSetId || '')
|
40
|
+
}
|
41
|
+
|
42
|
+
@FieldResolver(type => Domain)
|
43
|
+
async domain(@Root() dataSensor: DataSensor): Promise<Domain> {
|
44
|
+
return await getRepository(Domain).findOne(dataSensor.domainId)
|
45
|
+
}
|
46
|
+
|
47
|
+
@FieldResolver(type => User)
|
48
|
+
async updater(@Root() dataSensor: DataSensor): Promise<User> {
|
49
|
+
return await getRepository(User).findOne(dataSensor.updaterId)
|
50
|
+
}
|
51
|
+
|
52
|
+
@FieldResolver(type => User)
|
53
|
+
async creator(@Root() dataSensor: DataSensor): Promise<User> {
|
54
|
+
return await getRepository(User).findOne(dataSensor.creatorId)
|
55
|
+
}
|
56
|
+
}
|
@@ -0,0 +1,98 @@
|
|
1
|
+
import { Field, ID, InputType, Int, ObjectType } from 'type-graphql'
|
2
|
+
|
3
|
+
import { ObjectRef } from '@things-factory/shell'
|
4
|
+
|
5
|
+
import { DataSensor } from './data-sensor'
|
6
|
+
|
7
|
+
@InputType()
|
8
|
+
export class NewDataSensor {
|
9
|
+
@Field()
|
10
|
+
name: string
|
11
|
+
|
12
|
+
@Field({ nullable: true })
|
13
|
+
description?: string
|
14
|
+
|
15
|
+
@Field({ nullable: true })
|
16
|
+
active?: boolean
|
17
|
+
|
18
|
+
@Field({ nullable: true })
|
19
|
+
deviceId?: string
|
20
|
+
|
21
|
+
@Field({ nullable: true })
|
22
|
+
serialNo?: string
|
23
|
+
|
24
|
+
@Field({ nullable: true })
|
25
|
+
brand?: string
|
26
|
+
|
27
|
+
@Field({ nullable: true })
|
28
|
+
model?: string
|
29
|
+
|
30
|
+
@Field({ nullable: true })
|
31
|
+
netmask?: string
|
32
|
+
|
33
|
+
@Field({ nullable: true })
|
34
|
+
tag?: string
|
35
|
+
|
36
|
+
@Field({ nullable: true })
|
37
|
+
refBy?: String
|
38
|
+
|
39
|
+
@Field(type => ObjectRef, { nullable: true })
|
40
|
+
appliance?: ObjectRef
|
41
|
+
|
42
|
+
@Field(type => ObjectRef, { nullable: true })
|
43
|
+
dataSet?: ObjectRef
|
44
|
+
}
|
45
|
+
|
46
|
+
@InputType()
|
47
|
+
export class DataSensorPatch {
|
48
|
+
@Field(type => ID, { nullable: true })
|
49
|
+
id?: string
|
50
|
+
|
51
|
+
@Field({ nullable: true })
|
52
|
+
name?: string
|
53
|
+
|
54
|
+
@Field({ nullable: true })
|
55
|
+
description?: string
|
56
|
+
|
57
|
+
@Field({ nullable: true })
|
58
|
+
active?: boolean
|
59
|
+
|
60
|
+
@Field({ nullable: true })
|
61
|
+
deviceId?: string
|
62
|
+
|
63
|
+
@Field({ nullable: true })
|
64
|
+
serialNo?: string
|
65
|
+
|
66
|
+
@Field({ nullable: true })
|
67
|
+
brand?: string
|
68
|
+
|
69
|
+
@Field({ nullable: true })
|
70
|
+
model?: string
|
71
|
+
|
72
|
+
@Field({ nullable: true })
|
73
|
+
netmask?: string
|
74
|
+
|
75
|
+
@Field({ nullable: true })
|
76
|
+
tag?: string
|
77
|
+
|
78
|
+
@Field({ nullable: true })
|
79
|
+
refBy?: String
|
80
|
+
|
81
|
+
@Field(type => ObjectRef, { nullable: true })
|
82
|
+
appliance: ObjectRef
|
83
|
+
|
84
|
+
@Field(type => ObjectRef, { nullable: true })
|
85
|
+
dataSet?: ObjectRef
|
86
|
+
|
87
|
+
@Field()
|
88
|
+
cuFlag: string
|
89
|
+
}
|
90
|
+
|
91
|
+
@ObjectType()
|
92
|
+
export class DataSensorList {
|
93
|
+
@Field(type => [DataSensor])
|
94
|
+
items: DataSensor[]
|
95
|
+
|
96
|
+
@Field(type => Int)
|
97
|
+
total: number
|
98
|
+
}
|
@@ -0,0 +1,139 @@
|
|
1
|
+
import { Field, ID, ObjectType } from 'type-graphql'
|
2
|
+
import {
|
3
|
+
Column,
|
4
|
+
CreateDateColumn,
|
5
|
+
Entity,
|
6
|
+
Index,
|
7
|
+
ManyToOne,
|
8
|
+
PrimaryGeneratedColumn,
|
9
|
+
RelationId,
|
10
|
+
UpdateDateColumn
|
11
|
+
} from 'typeorm'
|
12
|
+
|
13
|
+
import { Appliance, User } from '@things-factory/auth-base'
|
14
|
+
import { Domain } from '@things-factory/shell'
|
15
|
+
|
16
|
+
import { DataSet } from '../data-set/data-set'
|
17
|
+
|
18
|
+
@Entity()
|
19
|
+
@Index('ix_data_sensor_0', (dataSensor: DataSensor) => [dataSensor.domain, dataSensor.name], { unique: true })
|
20
|
+
@Index('ix_data_sensor_1', (dataSensor: DataSensor) => [dataSensor.deviceId], { unique: true })
|
21
|
+
@Index('ix_data_sensor_2', (dataSensor: DataSensor) => [dataSensor.domain, dataSensor.refBy], {
|
22
|
+
unique: false
|
23
|
+
})
|
24
|
+
@Index('ix_data_sensor_3', (dataSensor: DataSensor) => [dataSensor.domain, dataSensor.serialNo], {
|
25
|
+
unique: false
|
26
|
+
})
|
27
|
+
@ObjectType({ description: 'Entity for DataSensor' })
|
28
|
+
export class DataSensor {
|
29
|
+
@PrimaryGeneratedColumn('uuid')
|
30
|
+
@Field(type => ID)
|
31
|
+
readonly id: string
|
32
|
+
|
33
|
+
@ManyToOne(type => Domain)
|
34
|
+
@Field({ nullable: true })
|
35
|
+
domain?: Domain
|
36
|
+
|
37
|
+
@RelationId((dataSensor: DataSensor) => dataSensor.domain)
|
38
|
+
domainId?: string
|
39
|
+
|
40
|
+
@Column()
|
41
|
+
@Field()
|
42
|
+
name: string
|
43
|
+
|
44
|
+
@Column({
|
45
|
+
nullable: true
|
46
|
+
})
|
47
|
+
@Field({ nullable: true })
|
48
|
+
description?: string
|
49
|
+
|
50
|
+
@Column({
|
51
|
+
nullable: true
|
52
|
+
})
|
53
|
+
@Field({ nullable: true })
|
54
|
+
active?: boolean
|
55
|
+
|
56
|
+
@Column({
|
57
|
+
nullable: true
|
58
|
+
})
|
59
|
+
@Field({ nullable: true })
|
60
|
+
deviceId?: string
|
61
|
+
|
62
|
+
@Column({
|
63
|
+
nullable: true
|
64
|
+
})
|
65
|
+
@Field({ nullable: true })
|
66
|
+
serialNo?: string
|
67
|
+
|
68
|
+
@Column({
|
69
|
+
nullable: true
|
70
|
+
})
|
71
|
+
@Field({ nullable: true })
|
72
|
+
brand?: string
|
73
|
+
|
74
|
+
@Column({
|
75
|
+
nullable: true
|
76
|
+
})
|
77
|
+
@Field({ nullable: true })
|
78
|
+
model?: string
|
79
|
+
|
80
|
+
@Column({
|
81
|
+
nullable: true
|
82
|
+
})
|
83
|
+
@Field({ nullable: true })
|
84
|
+
netmask?: string
|
85
|
+
|
86
|
+
@Column({
|
87
|
+
nullable: true
|
88
|
+
})
|
89
|
+
@Field({ nullable: true })
|
90
|
+
tag?: string
|
91
|
+
|
92
|
+
@Column({ nullable: true })
|
93
|
+
@Field({ nullable: true })
|
94
|
+
refBy?: String
|
95
|
+
|
96
|
+
@ManyToOne(type => Appliance, {
|
97
|
+
nullable: true
|
98
|
+
})
|
99
|
+
@Field({ nullable: true })
|
100
|
+
appliance?: Appliance
|
101
|
+
|
102
|
+
@RelationId((dataSensor: DataSensor) => dataSensor.appliance)
|
103
|
+
applianceId?: string
|
104
|
+
|
105
|
+
@ManyToOne(type => DataSet, {
|
106
|
+
nullable: true
|
107
|
+
})
|
108
|
+
@Field({ nullable: true })
|
109
|
+
dataSet?: DataSet
|
110
|
+
|
111
|
+
@RelationId((dataSensor: DataSensor) => dataSensor.dataSet)
|
112
|
+
dataSetId?: string
|
113
|
+
|
114
|
+
@CreateDateColumn()
|
115
|
+
@Field({ nullable: true })
|
116
|
+
createdAt?: Date
|
117
|
+
|
118
|
+
@UpdateDateColumn()
|
119
|
+
@Field({ nullable: true })
|
120
|
+
updatedAt?: Date
|
121
|
+
|
122
|
+
@ManyToOne(type => User, {
|
123
|
+
nullable: true
|
124
|
+
})
|
125
|
+
@Field({ nullable: true })
|
126
|
+
creator?: User
|
127
|
+
|
128
|
+
@RelationId((dataSensor: DataSensor) => dataSensor.creator)
|
129
|
+
creatorId?: string
|
130
|
+
|
131
|
+
@ManyToOne(type => User, {
|
132
|
+
nullable: true
|
133
|
+
})
|
134
|
+
@Field({ nullable: true })
|
135
|
+
updater?: User
|
136
|
+
|
137
|
+
@RelationId((dataSensor: DataSensor) => dataSensor.creator)
|
138
|
+
updaterId?: string
|
139
|
+
}
|
@@ -1,5 +1,7 @@
|
|
1
1
|
import { Field, ID, InputType, Int, ObjectType } from 'type-graphql'
|
2
2
|
|
3
|
+
import { ScalarObject } from '@things-factory/shell'
|
4
|
+
|
3
5
|
import { DataSet } from './data-set'
|
4
6
|
|
5
7
|
@InputType()
|
@@ -13,6 +15,12 @@ export class NewDataSet {
|
|
13
15
|
@Field({ nullable: true })
|
14
16
|
active?: boolean
|
15
17
|
|
18
|
+
@Field({ nullable: true })
|
19
|
+
type?: string
|
20
|
+
|
21
|
+
@Field(type => ScalarObject, { nullable: true })
|
22
|
+
partitionKeys?: ScalarObject
|
23
|
+
|
16
24
|
@Field({ nullable: true })
|
17
25
|
schedule?: string
|
18
26
|
|
@@ -34,6 +42,12 @@ export class DataSetPatch {
|
|
34
42
|
@Field({ nullable: true })
|
35
43
|
active?: boolean
|
36
44
|
|
45
|
+
@Field({ nullable: true })
|
46
|
+
type?: string
|
47
|
+
|
48
|
+
@Field(type => ScalarObject, { nullable: true })
|
49
|
+
partitionKeys?: ScalarObject
|
50
|
+
|
37
51
|
@Field({ nullable: true })
|
38
52
|
schedule?: string
|
39
53
|
|
@@ -12,7 +12,7 @@ import {
|
|
12
12
|
} from 'typeorm'
|
13
13
|
|
14
14
|
import { User } from '@things-factory/auth-base'
|
15
|
-
import { Domain } from '@things-factory/shell'
|
15
|
+
import { Domain, ScalarObject } from '@things-factory/shell'
|
16
16
|
|
17
17
|
import { DataItem } from '../data-item/data-item'
|
18
18
|
import { DataSample } from '../data-sample/data-sample'
|
@@ -48,6 +48,22 @@ export class DataSet {
|
|
48
48
|
@Field({ nullable: true })
|
49
49
|
active?: boolean
|
50
50
|
|
51
|
+
@Column({
|
52
|
+
nullable: true
|
53
|
+
})
|
54
|
+
@Field({ nullable: true })
|
55
|
+
type?: string
|
56
|
+
|
57
|
+
@Column('simple-json', { nullable: true })
|
58
|
+
@Field(type => ScalarObject, { nullable: true })
|
59
|
+
partitionKeys?: ScalarObject
|
60
|
+
|
61
|
+
@Column({
|
62
|
+
nullable: true
|
63
|
+
})
|
64
|
+
@Field({ nullable: true })
|
65
|
+
slugger?: string
|
66
|
+
|
51
67
|
@OneToMany(type => DataItem, dataItem => dataItem.dataSet)
|
52
68
|
@Field(type => [DataItem], { nullable: true })
|
53
69
|
dataItems: DataItem[]
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { DataSpec } from './data-spec'
|
2
|
+
|
3
|
+
export class DataSpecManager {
|
4
|
+
static specRegistry: { [type: string]: DataSpec } = {}
|
5
|
+
|
6
|
+
static getDataSpec(type: string): DataSpec {
|
7
|
+
return DataSpecManager.specRegistry[type]
|
8
|
+
}
|
9
|
+
|
10
|
+
static registerDataSpec(type: string, dataSpec: DataSpec) {
|
11
|
+
DataSpecManager.specRegistry[type] = dataSpec
|
12
|
+
}
|
13
|
+
|
14
|
+
static unregisterDataSpec(type: string) {
|
15
|
+
delete DataSpecManager.specRegistry[type]
|
16
|
+
}
|
17
|
+
|
18
|
+
static getDataSpecs(): DataSpec[] {
|
19
|
+
return Object.values(DataSpecManager.specRegistry)
|
20
|
+
}
|
21
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { Resolver, Query, Arg } from 'type-graphql'
|
2
|
+
import { DataSpec, DataSpecList } from './data-spec'
|
3
|
+
import { DataSpecManager } from './data-spec-manager'
|
4
|
+
|
5
|
+
@Resolver(DataSpec)
|
6
|
+
export class DataSpecQuery {
|
7
|
+
@Query(returns => DataSpec, { description: 'To fetch a data-spec' })
|
8
|
+
dataSpec(@Arg('name') name: string): DataSpec {
|
9
|
+
return DataSpecManager.getDataSpec(name)
|
10
|
+
}
|
11
|
+
|
12
|
+
@Query(returns => DataSpecList, { description: 'To fetch all data-specs' })
|
13
|
+
dataSpecs(): DataSpecList {
|
14
|
+
const items = DataSpecManager.getDataSpecs()
|
15
|
+
|
16
|
+
return {
|
17
|
+
items,
|
18
|
+
total: items.length
|
19
|
+
}
|
20
|
+
}
|
21
|
+
}
|
@@ -0,0 +1,44 @@
|
|
1
|
+
import { ObjectType, Field, Int } from 'type-graphql'
|
2
|
+
import { ScalarObject } from '@things-factory/shell'
|
3
|
+
|
4
|
+
@ObjectType()
|
5
|
+
export class DataSpecItem {
|
6
|
+
@Field()
|
7
|
+
type: string
|
8
|
+
|
9
|
+
@Field()
|
10
|
+
label: string
|
11
|
+
|
12
|
+
@Field()
|
13
|
+
name: string
|
14
|
+
|
15
|
+
@Field({ nullable: true })
|
16
|
+
placeholder?: string
|
17
|
+
|
18
|
+
@Field(type => ScalarObject, { nullable: true })
|
19
|
+
property?: ScalarObject
|
20
|
+
}
|
21
|
+
|
22
|
+
@ObjectType()
|
23
|
+
export class DataSpec {
|
24
|
+
@Field()
|
25
|
+
name: string
|
26
|
+
|
27
|
+
@Field({ nullable: true })
|
28
|
+
description: string
|
29
|
+
|
30
|
+
@Field({ nullable: true })
|
31
|
+
help: string
|
32
|
+
|
33
|
+
@Field(type => [DataSpecItem], { nullable: true })
|
34
|
+
specItems: DataSpecItem[]
|
35
|
+
}
|
36
|
+
|
37
|
+
@ObjectType()
|
38
|
+
export class DataSpecList {
|
39
|
+
@Field(type => [DataSpec])
|
40
|
+
items: DataSpec[]
|
41
|
+
|
42
|
+
@Field(type => Int)
|
43
|
+
total: number
|
44
|
+
}
|
package/server/service/index.ts
CHANGED
@@ -1,25 +1,33 @@
|
|
1
1
|
/* IMPORT ENTITIES AND RESOLVERS */
|
2
|
+
import { entities as DataSensorEntities, resolvers as DataSensorResolvers } from './data-sensor'
|
2
3
|
import { entities as DataSampleEntities, resolvers as DataSampleResolvers } from './data-sample'
|
3
4
|
import { entities as DataItemEntities, resolvers as DataItemResolvers } from './data-item'
|
4
5
|
import { entities as DataSetEntities, resolvers as DataSetResolvers } from './data-set'
|
6
|
+
import { entities as DataSpecEntities, resolvers as DataSpecResolvers } from './data-spec'
|
5
7
|
|
6
8
|
/* EXPORT ENTITY TYPES */
|
9
|
+
export * from './data-sensor/data-sensor'
|
7
10
|
export * from './data-sample/data-sample'
|
8
11
|
export * from './data-item/data-item'
|
9
12
|
export * from './data-set/data-set'
|
13
|
+
export * from './data-spec/data-spec'
|
10
14
|
|
11
15
|
export const entities = [
|
12
16
|
/* ENTITIES */
|
13
|
-
|
17
|
+
...DataSensorEntities,
|
18
|
+
...DataSampleEntities,
|
14
19
|
...DataItemEntities,
|
15
|
-
...DataSetEntities
|
20
|
+
...DataSetEntities,
|
21
|
+
...DataSpecEntities
|
16
22
|
]
|
17
23
|
|
18
24
|
export const schema = {
|
19
25
|
resolverClasses: [
|
20
26
|
/* RESOLVER CLASSES */
|
21
|
-
|
27
|
+
...DataSensorResolvers,
|
28
|
+
...DataSampleResolvers,
|
22
29
|
...DataItemResolvers,
|
23
|
-
...DataSetResolvers
|
30
|
+
...DataSetResolvers,
|
31
|
+
...DataSpecResolvers
|
24
32
|
]
|
25
33
|
}
|
package/things-factory.config.js
CHANGED
package/translations/en.json
CHANGED
@@ -1,8 +1,22 @@
|
|
1
1
|
{
|
2
|
-
"field.
|
3
|
-
"field.
|
2
|
+
"field.appliance": "appliance",
|
3
|
+
"field.collected_at": "collected at",
|
4
4
|
"field.data": "data",
|
5
|
+
"field.dataSet": "data set",
|
6
|
+
"field.device-id": "device id",
|
7
|
+
"field.netmask": "network mask",
|
8
|
+
"field.options": "options",
|
9
|
+
"field.partitionKeys": "partition keys",
|
10
|
+
"field.quota": "sampling #",
|
11
|
+
"field.raw-data": "raw data",
|
12
|
+
"field.ref-by": "ref. by",
|
13
|
+
"field.serial-no": "serial #",
|
14
|
+
"field.spec": "spec",
|
15
|
+
"field.tag": "tag name",
|
16
|
+
"field.unit": "unit",
|
17
|
+
"title.data-entry-form": "data entry form",
|
5
18
|
"title.data-item list": "data item list",
|
6
|
-
"title.data-
|
7
|
-
"title.data-
|
19
|
+
"title.data-sample list": "data sample list",
|
20
|
+
"title.data-sensor list": "data sensor list",
|
21
|
+
"title.data-set list": "data set list"
|
8
22
|
}
|
package/translations/ko.json
CHANGED
@@ -1,8 +1,22 @@
|
|
1
1
|
{
|
2
|
+
"field.appliance": "어플라이언스",
|
3
|
+
"field.collected_at": "수집일시",
|
4
|
+
"field.data": "데이타",
|
5
|
+
"field.dataSet": "데이타셋",
|
6
|
+
"field.device-id": "디바이스 아이디",
|
7
|
+
"field.netmask": "네트워크마스크",
|
8
|
+
"field.options": "선택옵션",
|
9
|
+
"field.partitionKeys": "파티션 키",
|
2
10
|
"field.quota": "샘플수",
|
11
|
+
"field.raw-data": "데이타 원본",
|
12
|
+
"field.ref-by": "참조아이템",
|
13
|
+
"field.serial-no": "시리얼번호",
|
3
14
|
"field.spec": "명세",
|
4
|
-
"field.
|
15
|
+
"field.tag": "태그이름",
|
16
|
+
"field.unit": "단위",
|
17
|
+
"title.data-entry-form": "데이타 입력",
|
5
18
|
"title.data-item list": "데이타 아이템 조회",
|
6
|
-
"title.data-
|
7
|
-
"title.data-
|
19
|
+
"title.data-sample list": "데이타 샘플 조회",
|
20
|
+
"title.data-sensor list": "데이타 센서 조회",
|
21
|
+
"title.data-set list": "데이타 셋 조회"
|
8
22
|
}
|