@dssp/supervision 0.0.2
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/CHANGELOG.md +8 -0
- package/assets/images/hatiolab-logo.png +0 -0
- package/client/actions/main.ts +1 -0
- package/client/bootstrap.ts +8 -0
- package/client/index.ts +1 -0
- package/client/pages/action-plan/action-plan-importer.ts +96 -0
- package/client/pages/action-plan/action-plan-list-page.ts +355 -0
- package/client/pages/check-item/check-item-importer.ts +96 -0
- package/client/pages/check-item/check-item-list-page.ts +355 -0
- package/client/pages/issue/issue-importer.ts +96 -0
- package/client/pages/issue/issue-list-page.ts +355 -0
- package/client/pages/main.ts +25 -0
- package/client/pages/project-report/project-report-importer.ts +96 -0
- package/client/pages/project-report/project-report-list-page.ts +355 -0
- package/client/pages/supervisor/supervisor-importer.ts +96 -0
- package/client/pages/supervisor/supervisor-list-page.ts +355 -0
- package/client/reducers/main.ts +17 -0
- package/client/route.ts +27 -0
- package/client/tsconfig.json +11 -0
- package/dist-client/actions/main.d.ts +1 -0
- package/dist-client/actions/main.js +2 -0
- package/dist-client/actions/main.js.map +1 -0
- package/dist-client/bootstrap.d.ts +1 -0
- package/dist-client/bootstrap.js +8 -0
- package/dist-client/bootstrap.js.map +1 -0
- package/dist-client/index.d.ts +1 -0
- package/dist-client/index.js +2 -0
- package/dist-client/index.js.map +1 -0
- package/dist-client/pages/action-plan/action-plan-importer.d.ts +9 -0
- package/dist-client/pages/action-plan/action-plan-importer.js +100 -0
- package/dist-client/pages/action-plan/action-plan-importer.js.map +1 -0
- package/dist-client/pages/action-plan/action-plan-list-page.d.ts +62 -0
- package/dist-client/pages/action-plan/action-plan-list-page.js +331 -0
- package/dist-client/pages/action-plan/action-plan-list-page.js.map +1 -0
- package/dist-client/pages/check-item/check-item-importer.d.ts +9 -0
- package/dist-client/pages/check-item/check-item-importer.js +100 -0
- package/dist-client/pages/check-item/check-item-importer.js.map +1 -0
- package/dist-client/pages/check-item/check-item-list-page.d.ts +62 -0
- package/dist-client/pages/check-item/check-item-list-page.js +331 -0
- package/dist-client/pages/check-item/check-item-list-page.js.map +1 -0
- package/dist-client/pages/issue/issue-importer.d.ts +9 -0
- package/dist-client/pages/issue/issue-importer.js +100 -0
- package/dist-client/pages/issue/issue-importer.js.map +1 -0
- package/dist-client/pages/issue/issue-list-page.d.ts +62 -0
- package/dist-client/pages/issue/issue-list-page.js +331 -0
- package/dist-client/pages/issue/issue-list-page.js.map +1 -0
- package/dist-client/pages/main.d.ts +1 -0
- package/dist-client/pages/main.js +27 -0
- package/dist-client/pages/main.js.map +1 -0
- package/dist-client/pages/project-report/project-report-importer.d.ts +9 -0
- package/dist-client/pages/project-report/project-report-importer.js +100 -0
- package/dist-client/pages/project-report/project-report-importer.js.map +1 -0
- package/dist-client/pages/project-report/project-report-list-page.d.ts +62 -0
- package/dist-client/pages/project-report/project-report-list-page.js +331 -0
- package/dist-client/pages/project-report/project-report-list-page.js.map +1 -0
- package/dist-client/pages/supervisor/supervisor-importer.d.ts +9 -0
- package/dist-client/pages/supervisor/supervisor-importer.js +100 -0
- package/dist-client/pages/supervisor/supervisor-importer.js.map +1 -0
- package/dist-client/pages/supervisor/supervisor-list-page.d.ts +62 -0
- package/dist-client/pages/supervisor/supervisor-list-page.js +331 -0
- package/dist-client/pages/supervisor/supervisor-list-page.js.map +1 -0
- package/dist-client/reducers/main.d.ts +6 -0
- package/dist-client/reducers/main.js +14 -0
- package/dist-client/reducers/main.js.map +1 -0
- package/dist-client/route.d.ts +1 -0
- package/dist-client/route.js +23 -0
- package/dist-client/route.js.map +1 -0
- package/dist-client/tsconfig.tsbuildinfo +1 -0
- package/dist-server/controllers/index.js +1 -0
- package/dist-server/controllers/index.js.map +1 -0
- package/dist-server/index.js +7 -0
- package/dist-server/index.js.map +1 -0
- package/dist-server/middlewares/index.js +8 -0
- package/dist-server/middlewares/index.js.map +1 -0
- package/dist-server/migrations/index.js +12 -0
- package/dist-server/migrations/index.js.map +1 -0
- package/dist-server/routes.js +25 -0
- package/dist-server/routes.js.map +1 -0
- package/dist-server/service/action-plan/action-plan-mutation.js +168 -0
- package/dist-server/service/action-plan/action-plan-mutation.js.map +1 -0
- package/dist-server/service/action-plan/action-plan-query.js +97 -0
- package/dist-server/service/action-plan/action-plan-query.js.map +1 -0
- package/dist-server/service/action-plan/action-plan-type.js +86 -0
- package/dist-server/service/action-plan/action-plan-type.js.map +1 -0
- package/dist-server/service/action-plan/action-plan.js +116 -0
- package/dist-server/service/action-plan/action-plan.js.map +1 -0
- package/dist-server/service/action-plan/index.js +10 -0
- package/dist-server/service/action-plan/index.js.map +1 -0
- package/dist-server/service/check-item/check-item-mutation.js +168 -0
- package/dist-server/service/check-item/check-item-mutation.js.map +1 -0
- package/dist-server/service/check-item/check-item-query.js +97 -0
- package/dist-server/service/check-item/check-item-query.js.map +1 -0
- package/dist-server/service/check-item/check-item-type.js +86 -0
- package/dist-server/service/check-item/check-item-type.js.map +1 -0
- package/dist-server/service/check-item/check-item.js +117 -0
- package/dist-server/service/check-item/check-item.js.map +1 -0
- package/dist-server/service/check-item/index.js +10 -0
- package/dist-server/service/check-item/index.js.map +1 -0
- package/dist-server/service/index.js +43 -0
- package/dist-server/service/index.js.map +1 -0
- package/dist-server/service/issue/index.js +10 -0
- package/dist-server/service/issue/index.js.map +1 -0
- package/dist-server/service/issue/issue-mutation.js +168 -0
- package/dist-server/service/issue/issue-mutation.js.map +1 -0
- package/dist-server/service/issue/issue-query.js +97 -0
- package/dist-server/service/issue/issue-query.js.map +1 -0
- package/dist-server/service/issue/issue-type.js +86 -0
- package/dist-server/service/issue/issue-type.js.map +1 -0
- package/dist-server/service/issue/issue.js +117 -0
- package/dist-server/service/issue/issue.js.map +1 -0
- package/dist-server/service/project-report/index.js +10 -0
- package/dist-server/service/project-report/index.js.map +1 -0
- package/dist-server/service/project-report/project-report-mutation.js +168 -0
- package/dist-server/service/project-report/project-report-mutation.js.map +1 -0
- package/dist-server/service/project-report/project-report-query.js +97 -0
- package/dist-server/service/project-report/project-report-query.js.map +1 -0
- package/dist-server/service/project-report/project-report-type.js +86 -0
- package/dist-server/service/project-report/project-report-type.js.map +1 -0
- package/dist-server/service/project-report/project-report.js +128 -0
- package/dist-server/service/project-report/project-report.js.map +1 -0
- package/dist-server/service/supervisor/index.js +10 -0
- package/dist-server/service/supervisor/index.js.map +1 -0
- package/dist-server/service/supervisor/supervisor-mutation.js +168 -0
- package/dist-server/service/supervisor/supervisor-mutation.js.map +1 -0
- package/dist-server/service/supervisor/supervisor-query.js +97 -0
- package/dist-server/service/supervisor/supervisor-query.js.map +1 -0
- package/dist-server/service/supervisor/supervisor-type.js +86 -0
- package/dist-server/service/supervisor/supervisor-type.js.map +1 -0
- package/dist-server/service/supervisor/supervisor.js +127 -0
- package/dist-server/service/supervisor/supervisor.js.map +1 -0
- package/dist-server/tsconfig.tsbuildinfo +1 -0
- package/helps/supervision/action-plan.md +160 -0
- package/helps/supervision/check-item.md +160 -0
- package/helps/supervision/issue.md +160 -0
- package/helps/supervision/project-report.md +160 -0
- package/helps/supervision/supervisor.md +160 -0
- package/package.json +37 -0
- package/server/controllers/index.ts +0 -0
- package/server/index.ts +4 -0
- package/server/middlewares/index.ts +3 -0
- package/server/migrations/index.ts +9 -0
- package/server/routes.ts +28 -0
- package/server/service/action-plan/action-plan-mutation.ts +198 -0
- package/server/service/action-plan/action-plan-query.ts +62 -0
- package/server/service/action-plan/action-plan-type.ts +61 -0
- package/server/service/action-plan/action-plan.ts +103 -0
- package/server/service/action-plan/index.ts +7 -0
- package/server/service/check-item/check-item-mutation.ts +198 -0
- package/server/service/check-item/check-item-query.ts +62 -0
- package/server/service/check-item/check-item-type.ts +61 -0
- package/server/service/check-item/check-item.ts +111 -0
- package/server/service/check-item/index.ts +7 -0
- package/server/service/index.ts +42 -0
- package/server/service/issue/index.ts +7 -0
- package/server/service/issue/issue-mutation.ts +198 -0
- package/server/service/issue/issue-query.ts +62 -0
- package/server/service/issue/issue-type.ts +61 -0
- package/server/service/issue/issue.ts +105 -0
- package/server/service/project-report/index.ts +7 -0
- package/server/service/project-report/project-report-mutation.ts +198 -0
- package/server/service/project-report/project-report-query.ts +62 -0
- package/server/service/project-report/project-report-type.ts +61 -0
- package/server/service/project-report/project-report.ts +113 -0
- package/server/service/supervisor/index.ts +7 -0
- package/server/service/supervisor/supervisor-mutation.ts +198 -0
- package/server/service/supervisor/supervisor-query.ts +62 -0
- package/server/service/supervisor/supervisor-type.ts +61 -0
- package/server/service/supervisor/supervisor.ts +113 -0
- package/server/tsconfig.json +10 -0
- package/things-factory.config.js +15 -0
- package/translations/en.json +1 -0
- package/translations/ko.json +1 -0
- package/translations/ms.json +1 -0
- package/translations/zh.json +1 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Resolver, Query, FieldResolver, Root, Args, Arg, Ctx, Directive } from 'type-graphql'
|
|
2
|
+
import { Attachment } from '@things-factory/attachment-base'
|
|
3
|
+
import { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'
|
|
4
|
+
import { User } from '@things-factory/auth-base'
|
|
5
|
+
import { Issue } from './issue'
|
|
6
|
+
import { IssueList } from './issue-type'
|
|
7
|
+
|
|
8
|
+
@Resolver(Issue)
|
|
9
|
+
export class IssueQuery {
|
|
10
|
+
@Query(returns => Issue!, { nullable: true, description: 'To fetch a Issue' })
|
|
11
|
+
async issue(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Issue> {
|
|
12
|
+
const { domain } = context.state
|
|
13
|
+
|
|
14
|
+
return await getRepository(Issue).findOne({
|
|
15
|
+
where: { domain: { id: domain.id }, id }
|
|
16
|
+
})
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@Query(returns => IssueList, { description: 'To fetch multiple Issues' })
|
|
20
|
+
async issues(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<IssueList> {
|
|
21
|
+
const { domain } = context.state
|
|
22
|
+
|
|
23
|
+
const queryBuilder = getQueryBuilderFromListParams({
|
|
24
|
+
domain,
|
|
25
|
+
params,
|
|
26
|
+
repository: await getRepository(Issue),
|
|
27
|
+
searchables: ['name', 'description']
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
const [items, total] = await queryBuilder.getManyAndCount()
|
|
31
|
+
|
|
32
|
+
return { items, total }
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@FieldResolver(type => String)
|
|
36
|
+
async thumbnail(@Root() issue: Issue): Promise<string | undefined> {
|
|
37
|
+
const attachment: Attachment = await getRepository(Attachment).findOne({
|
|
38
|
+
where: {
|
|
39
|
+
domain: { id: issue.domainId },
|
|
40
|
+
refType: Issue.name,
|
|
41
|
+
refBy: issue.id
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
return attachment?.fullpath
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@FieldResolver(type => Domain)
|
|
49
|
+
async domain(@Root() issue: Issue): Promise<Domain> {
|
|
50
|
+
return await getRepository(Domain).findOneBy({ id: issue.domainId })
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@FieldResolver(type => User)
|
|
54
|
+
async updater(@Root() issue: Issue): Promise<User> {
|
|
55
|
+
return await getRepository(User).findOneBy({ id: issue.updaterId })
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@FieldResolver(type => User)
|
|
59
|
+
async creator(@Root() issue: Issue): Promise<User> {
|
|
60
|
+
return await getRepository(User).findOneBy({ id: issue.creatorId })
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { FileUpload } from 'graphql-upload/GraphQLUpload.js'
|
|
2
|
+
import GraphQLUpload from 'graphql-upload/GraphQLUpload.js'
|
|
3
|
+
import { ObjectType, Field, InputType, Int, ID, registerEnumType } from 'type-graphql'
|
|
4
|
+
|
|
5
|
+
import { ObjectRef, ScalarObject } from '@things-factory/shell'
|
|
6
|
+
|
|
7
|
+
import { Issue, IssueStatus } from './issue'
|
|
8
|
+
|
|
9
|
+
@InputType()
|
|
10
|
+
export class NewIssue {
|
|
11
|
+
@Field()
|
|
12
|
+
name: string
|
|
13
|
+
|
|
14
|
+
@Field({ nullable: true })
|
|
15
|
+
description?: string
|
|
16
|
+
|
|
17
|
+
@Field(type => IssueStatus, { nullable: true })
|
|
18
|
+
state?: IssueStatus
|
|
19
|
+
|
|
20
|
+
@Field({ nullable: true })
|
|
21
|
+
active?: boolean
|
|
22
|
+
|
|
23
|
+
@Field({ nullable: true })
|
|
24
|
+
params?: string
|
|
25
|
+
|
|
26
|
+
@Field(type => GraphQLUpload, { nullable: true })
|
|
27
|
+
thumbnail?: FileUpload
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@InputType()
|
|
31
|
+
export class IssuePatch {
|
|
32
|
+
@Field(type => ID, { nullable: true })
|
|
33
|
+
id?: string
|
|
34
|
+
|
|
35
|
+
@Field({ nullable: true })
|
|
36
|
+
name?: string
|
|
37
|
+
|
|
38
|
+
@Field({ nullable: true })
|
|
39
|
+
description?: string
|
|
40
|
+
|
|
41
|
+
@Field(type => IssueStatus, { nullable: true })
|
|
42
|
+
state?: IssueStatus
|
|
43
|
+
|
|
44
|
+
@Field({ nullable: true })
|
|
45
|
+
active?: boolean
|
|
46
|
+
|
|
47
|
+
@Field(type => GraphQLUpload, { nullable: true })
|
|
48
|
+
thumbnail?: FileUpload
|
|
49
|
+
|
|
50
|
+
@Field({ nullable: true })
|
|
51
|
+
cuFlag?: string
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@ObjectType()
|
|
55
|
+
export class IssueList {
|
|
56
|
+
@Field(type => [Issue])
|
|
57
|
+
items: Issue[]
|
|
58
|
+
|
|
59
|
+
@Field(type => Int)
|
|
60
|
+
total: number
|
|
61
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CreateDateColumn,
|
|
3
|
+
UpdateDateColumn,
|
|
4
|
+
DeleteDateColumn,
|
|
5
|
+
Entity,
|
|
6
|
+
Index,
|
|
7
|
+
Column,
|
|
8
|
+
RelationId,
|
|
9
|
+
ManyToOne,
|
|
10
|
+
OneToMany,
|
|
11
|
+
PrimaryGeneratedColumn,
|
|
12
|
+
VersionColumn
|
|
13
|
+
} from 'typeorm'
|
|
14
|
+
import { ObjectType, Field, Int, ID, registerEnumType } from 'type-graphql'
|
|
15
|
+
|
|
16
|
+
import { Domain } from '@things-factory/shell'
|
|
17
|
+
import { User } from '@things-factory/auth-base'
|
|
18
|
+
import { CheckItem } from 'service/check-item/check-item'
|
|
19
|
+
import { ActionPlan } from 'service/action-plan/action-plan'
|
|
20
|
+
|
|
21
|
+
export enum IssueStatus {
|
|
22
|
+
STATUS_A = 'STATUS_A',
|
|
23
|
+
STATUS_B = 'STATUS_B'
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
registerEnumType(IssueStatus, {
|
|
27
|
+
name: 'IssueStatus',
|
|
28
|
+
description: 'state enumeration of a issue'
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
@Entity()
|
|
32
|
+
@Index('ix_issue_0', (issue: Issue) => [issue.domain, issue.name], {
|
|
33
|
+
unique: true,
|
|
34
|
+
where: '"deleted_at" IS NULL'
|
|
35
|
+
})
|
|
36
|
+
@ObjectType({ description: 'Entity for Issue' })
|
|
37
|
+
export class Issue {
|
|
38
|
+
@PrimaryGeneratedColumn('uuid')
|
|
39
|
+
@Field(type => ID)
|
|
40
|
+
readonly id: string
|
|
41
|
+
|
|
42
|
+
@ManyToOne(type => Domain)
|
|
43
|
+
@Field({ nullable: true })
|
|
44
|
+
domain?: Domain
|
|
45
|
+
|
|
46
|
+
@RelationId((issue: Issue) => issue.domain)
|
|
47
|
+
domainId?: string
|
|
48
|
+
|
|
49
|
+
@Column()
|
|
50
|
+
@Field({ nullable: true })
|
|
51
|
+
name?: string
|
|
52
|
+
|
|
53
|
+
@Column({ nullable: true })
|
|
54
|
+
@Field({ nullable: true })
|
|
55
|
+
description?: string
|
|
56
|
+
|
|
57
|
+
@Column({ nullable: true })
|
|
58
|
+
@Field({ nullable: true })
|
|
59
|
+
active?: boolean
|
|
60
|
+
|
|
61
|
+
@Column({ nullable: true })
|
|
62
|
+
@Field({ nullable: true })
|
|
63
|
+
state?: IssueStatus
|
|
64
|
+
|
|
65
|
+
@Column({ nullable: true })
|
|
66
|
+
@Field({ nullable: true })
|
|
67
|
+
params?: string
|
|
68
|
+
|
|
69
|
+
@Field(() => CheckItem)
|
|
70
|
+
@ManyToOne(() => CheckItem, checkItem => checkItem.issues)
|
|
71
|
+
checkItem: CheckItem
|
|
72
|
+
|
|
73
|
+
@Field(() => [ActionPlan])
|
|
74
|
+
@OneToMany(() => ActionPlan, actionPlan => actionPlan.issue)
|
|
75
|
+
actionPlans: ActionPlan[]
|
|
76
|
+
|
|
77
|
+
@CreateDateColumn()
|
|
78
|
+
@Field({ nullable: true })
|
|
79
|
+
createdAt?: Date
|
|
80
|
+
|
|
81
|
+
@UpdateDateColumn()
|
|
82
|
+
@Field({ nullable: true })
|
|
83
|
+
updatedAt?: Date
|
|
84
|
+
|
|
85
|
+
@DeleteDateColumn()
|
|
86
|
+
@Field({ nullable: true })
|
|
87
|
+
deletedAt?: Date
|
|
88
|
+
|
|
89
|
+
@ManyToOne(type => User, { nullable: true })
|
|
90
|
+
@Field(type => User, { nullable: true })
|
|
91
|
+
creator?: User
|
|
92
|
+
|
|
93
|
+
@RelationId((issue: Issue) => issue.creator)
|
|
94
|
+
creatorId?: string
|
|
95
|
+
|
|
96
|
+
@ManyToOne(type => User, { nullable: true })
|
|
97
|
+
@Field(type => User, { nullable: true })
|
|
98
|
+
updater?: User
|
|
99
|
+
|
|
100
|
+
@RelationId((issue: Issue) => issue.updater)
|
|
101
|
+
updaterId?: string
|
|
102
|
+
|
|
103
|
+
@Field(type => String, { nullable: true })
|
|
104
|
+
thumbnail?: string
|
|
105
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ProjectReport } from './project-report'
|
|
2
|
+
import { ProjectReportQuery } from './project-report-query'
|
|
3
|
+
import { ProjectReportMutation } from './project-report-mutation'
|
|
4
|
+
|
|
5
|
+
export const entities = [ProjectReport]
|
|
6
|
+
export const resolvers = [ProjectReportQuery, ProjectReportMutation]
|
|
7
|
+
export const subscribers = []
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'
|
|
2
|
+
import { In } from 'typeorm'
|
|
3
|
+
|
|
4
|
+
import { createAttachment, deleteAttachmentsByRef } from '@things-factory/attachment-base'
|
|
5
|
+
|
|
6
|
+
import { ProjectReport } from './project-report'
|
|
7
|
+
import { NewProjectReport, ProjectReportPatch } from './project-report-type'
|
|
8
|
+
|
|
9
|
+
@Resolver(ProjectReport)
|
|
10
|
+
export class ProjectReportMutation {
|
|
11
|
+
@Directive('@transaction')
|
|
12
|
+
@Mutation(returns => ProjectReport, { description: 'To create new ProjectReport' })
|
|
13
|
+
async createProjectReport(@Arg('projectReport') projectReport: NewProjectReport, @Ctx() context: ResolverContext): Promise<ProjectReport> {
|
|
14
|
+
const { domain, user, tx } = context.state
|
|
15
|
+
|
|
16
|
+
const result = await tx.getRepository(ProjectReport).save({
|
|
17
|
+
...projectReport,
|
|
18
|
+
domain,
|
|
19
|
+
creator: user,
|
|
20
|
+
updater: user
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
if (projectReport.thumbnail) {
|
|
24
|
+
await createAttachment(
|
|
25
|
+
null,
|
|
26
|
+
{
|
|
27
|
+
attachment: {
|
|
28
|
+
file: projectReport.thumbnail,
|
|
29
|
+
refType: ProjectReport.name,
|
|
30
|
+
refBy: result.id
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
context
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return result
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@Directive('@transaction')
|
|
41
|
+
@Mutation(returns => ProjectReport, { description: 'To modify ProjectReport information' })
|
|
42
|
+
async updateProjectReport(
|
|
43
|
+
@Arg('id') id: string,
|
|
44
|
+
@Arg('patch') patch: ProjectReportPatch,
|
|
45
|
+
@Ctx() context: ResolverContext
|
|
46
|
+
): Promise<ProjectReport> {
|
|
47
|
+
const { domain, user, tx } = context.state
|
|
48
|
+
|
|
49
|
+
const repository = tx.getRepository(ProjectReport)
|
|
50
|
+
const projectReport = await repository.findOne({
|
|
51
|
+
where: { domain: { id: domain.id }, id }
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
const result = await repository.save({
|
|
55
|
+
...projectReport,
|
|
56
|
+
...patch,
|
|
57
|
+
updater: user
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
if (patch.thumbnail) {
|
|
61
|
+
await deleteAttachmentsByRef(null, { refBys: [result.id] }, context)
|
|
62
|
+
await createAttachment(
|
|
63
|
+
null,
|
|
64
|
+
{
|
|
65
|
+
attachment: {
|
|
66
|
+
file: patch.thumbnail,
|
|
67
|
+
refType: ProjectReport.name,
|
|
68
|
+
refBy: result.id
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
context
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return result
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
@Directive('@transaction')
|
|
79
|
+
@Mutation(returns => [ProjectReport], { description: "To modify multiple ProjectReports' information" })
|
|
80
|
+
async updateMultipleProjectReport(
|
|
81
|
+
@Arg('patches', type => [ProjectReportPatch]) patches: ProjectReportPatch[],
|
|
82
|
+
@Ctx() context: ResolverContext
|
|
83
|
+
): Promise<ProjectReport[]> {
|
|
84
|
+
const { domain, user, tx } = context.state
|
|
85
|
+
|
|
86
|
+
let results = []
|
|
87
|
+
const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')
|
|
88
|
+
const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')
|
|
89
|
+
const projectReportRepo = tx.getRepository(ProjectReport)
|
|
90
|
+
|
|
91
|
+
if (_createRecords.length > 0) {
|
|
92
|
+
for (let i = 0; i < _createRecords.length; i++) {
|
|
93
|
+
const newRecord = _createRecords[i]
|
|
94
|
+
|
|
95
|
+
const result = await projectReportRepo.save({
|
|
96
|
+
...newRecord,
|
|
97
|
+
domain,
|
|
98
|
+
creator: user,
|
|
99
|
+
updater: user
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
if (newRecord.thumbnail) {
|
|
103
|
+
await createAttachment(
|
|
104
|
+
null,
|
|
105
|
+
{
|
|
106
|
+
attachment: {
|
|
107
|
+
file: newRecord.thumbnail,
|
|
108
|
+
refType: ProjectReport.name,
|
|
109
|
+
refBy: result.id
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
context
|
|
113
|
+
)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
results.push({ ...result, cuFlag: '+' })
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (_updateRecords.length > 0) {
|
|
121
|
+
for (let i = 0; i < _updateRecords.length; i++) {
|
|
122
|
+
const updateRecord = _updateRecords[i]
|
|
123
|
+
const projectReport = await projectReportRepo.findOneBy({ id: updateRecord.id })
|
|
124
|
+
|
|
125
|
+
const result = await projectReportRepo.save({
|
|
126
|
+
...projectReport,
|
|
127
|
+
...updateRecord,
|
|
128
|
+
updater: user
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
if (updateRecord.thumbnail) {
|
|
132
|
+
await deleteAttachmentsByRef(null, { refBys: [result.id] }, context)
|
|
133
|
+
await createAttachment(
|
|
134
|
+
null,
|
|
135
|
+
{
|
|
136
|
+
attachment: {
|
|
137
|
+
file: updateRecord.thumbnail,
|
|
138
|
+
refType: ProjectReport.name,
|
|
139
|
+
refBy: result.id
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
context
|
|
143
|
+
)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
results.push({ ...result, cuFlag: 'M' })
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return results
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
@Directive('@transaction')
|
|
154
|
+
@Mutation(returns => Boolean, { description: 'To delete ProjectReport' })
|
|
155
|
+
async deleteProjectReport(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {
|
|
156
|
+
const { domain, tx } = context.state
|
|
157
|
+
|
|
158
|
+
await tx.getRepository(ProjectReport).delete({ domain: { id: domain.id }, id })
|
|
159
|
+
await deleteAttachmentsByRef(null, { refBys: [id] }, context)
|
|
160
|
+
|
|
161
|
+
return true
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
@Directive('@transaction')
|
|
165
|
+
@Mutation(returns => Boolean, { description: 'To delete multiple ProjectReports' })
|
|
166
|
+
async deleteProjectReports(
|
|
167
|
+
@Arg('ids', type => [String]) ids: string[],
|
|
168
|
+
@Ctx() context: ResolverContext
|
|
169
|
+
): Promise<boolean> {
|
|
170
|
+
const { domain, tx } = context.state
|
|
171
|
+
|
|
172
|
+
await tx.getRepository(ProjectReport).delete({
|
|
173
|
+
domain: { id: domain.id },
|
|
174
|
+
id: In(ids)
|
|
175
|
+
})
|
|
176
|
+
|
|
177
|
+
await deleteAttachmentsByRef(null, { refBys: ids }, context)
|
|
178
|
+
|
|
179
|
+
return true
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
@Directive('@transaction')
|
|
183
|
+
@Mutation(returns => Boolean, { description: 'To import multiple ProjectReports' })
|
|
184
|
+
async importProjectReports(
|
|
185
|
+
@Arg('projectReports', type => [ProjectReportPatch]) projectReports: ProjectReportPatch[],
|
|
186
|
+
@Ctx() context: ResolverContext
|
|
187
|
+
): Promise<boolean> {
|
|
188
|
+
const { domain, tx } = context.state
|
|
189
|
+
|
|
190
|
+
await Promise.all(
|
|
191
|
+
projectReports.map(async (projectReport: ProjectReportPatch) => {
|
|
192
|
+
const createdProjectReport: ProjectReport = await tx.getRepository(ProjectReport).save({ domain, ...projectReport })
|
|
193
|
+
})
|
|
194
|
+
)
|
|
195
|
+
|
|
196
|
+
return true
|
|
197
|
+
}
|
|
198
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Resolver, Query, FieldResolver, Root, Args, Arg, Ctx, Directive } from 'type-graphql'
|
|
2
|
+
import { Attachment } from '@things-factory/attachment-base'
|
|
3
|
+
import { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'
|
|
4
|
+
import { User } from '@things-factory/auth-base'
|
|
5
|
+
import { ProjectReport } from './project-report'
|
|
6
|
+
import { ProjectReportList } from './project-report-type'
|
|
7
|
+
|
|
8
|
+
@Resolver(ProjectReport)
|
|
9
|
+
export class ProjectReportQuery {
|
|
10
|
+
@Query(returns => ProjectReport!, { nullable: true, description: 'To fetch a ProjectReport' })
|
|
11
|
+
async projectReport(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<ProjectReport> {
|
|
12
|
+
const { domain } = context.state
|
|
13
|
+
|
|
14
|
+
return await getRepository(ProjectReport).findOne({
|
|
15
|
+
where: { domain: { id: domain.id }, id }
|
|
16
|
+
})
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@Query(returns => ProjectReportList, { description: 'To fetch multiple ProjectReports' })
|
|
20
|
+
async projectReports(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<ProjectReportList> {
|
|
21
|
+
const { domain } = context.state
|
|
22
|
+
|
|
23
|
+
const queryBuilder = getQueryBuilderFromListParams({
|
|
24
|
+
domain,
|
|
25
|
+
params,
|
|
26
|
+
repository: await getRepository(ProjectReport),
|
|
27
|
+
searchables: ['name', 'description']
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
const [items, total] = await queryBuilder.getManyAndCount()
|
|
31
|
+
|
|
32
|
+
return { items, total }
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@FieldResolver(type => String)
|
|
36
|
+
async thumbnail(@Root() projectReport: ProjectReport): Promise<string | undefined> {
|
|
37
|
+
const attachment: Attachment = await getRepository(Attachment).findOne({
|
|
38
|
+
where: {
|
|
39
|
+
domain: { id: projectReport.domainId },
|
|
40
|
+
refType: ProjectReport.name,
|
|
41
|
+
refBy: projectReport.id
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
return attachment?.fullpath
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@FieldResolver(type => Domain)
|
|
49
|
+
async domain(@Root() projectReport: ProjectReport): Promise<Domain> {
|
|
50
|
+
return await getRepository(Domain).findOneBy({ id: projectReport.domainId })
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@FieldResolver(type => User)
|
|
54
|
+
async updater(@Root() projectReport: ProjectReport): Promise<User> {
|
|
55
|
+
return await getRepository(User).findOneBy({ id: projectReport.updaterId })
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@FieldResolver(type => User)
|
|
59
|
+
async creator(@Root() projectReport: ProjectReport): Promise<User> {
|
|
60
|
+
return await getRepository(User).findOneBy({ id: projectReport.creatorId })
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { FileUpload } from 'graphql-upload/GraphQLUpload.js'
|
|
2
|
+
import GraphQLUpload from 'graphql-upload/GraphQLUpload.js'
|
|
3
|
+
import { ObjectType, Field, InputType, Int, ID, registerEnumType } from 'type-graphql'
|
|
4
|
+
|
|
5
|
+
import { ObjectRef, ScalarObject } from '@things-factory/shell'
|
|
6
|
+
|
|
7
|
+
import { ProjectReport, ProjectReportStatus } from './project-report'
|
|
8
|
+
|
|
9
|
+
@InputType()
|
|
10
|
+
export class NewProjectReport {
|
|
11
|
+
@Field()
|
|
12
|
+
name: string
|
|
13
|
+
|
|
14
|
+
@Field({ nullable: true })
|
|
15
|
+
description?: string
|
|
16
|
+
|
|
17
|
+
@Field(type => ProjectReportStatus, { nullable: true })
|
|
18
|
+
state?: ProjectReportStatus
|
|
19
|
+
|
|
20
|
+
@Field({ nullable: true })
|
|
21
|
+
active?: boolean
|
|
22
|
+
|
|
23
|
+
@Field({ nullable: true })
|
|
24
|
+
params?: string
|
|
25
|
+
|
|
26
|
+
@Field(type => GraphQLUpload, { nullable: true })
|
|
27
|
+
thumbnail?: FileUpload
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@InputType()
|
|
31
|
+
export class ProjectReportPatch {
|
|
32
|
+
@Field(type => ID, { nullable: true })
|
|
33
|
+
id?: string
|
|
34
|
+
|
|
35
|
+
@Field({ nullable: true })
|
|
36
|
+
name?: string
|
|
37
|
+
|
|
38
|
+
@Field({ nullable: true })
|
|
39
|
+
description?: string
|
|
40
|
+
|
|
41
|
+
@Field(type => ProjectReportStatus, { nullable: true })
|
|
42
|
+
state?: ProjectReportStatus
|
|
43
|
+
|
|
44
|
+
@Field({ nullable: true })
|
|
45
|
+
active?: boolean
|
|
46
|
+
|
|
47
|
+
@Field(type => GraphQLUpload, { nullable: true })
|
|
48
|
+
thumbnail?: FileUpload
|
|
49
|
+
|
|
50
|
+
@Field({ nullable: true })
|
|
51
|
+
cuFlag?: string
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@ObjectType()
|
|
55
|
+
export class ProjectReportList {
|
|
56
|
+
@Field(type => [ProjectReport])
|
|
57
|
+
items: ProjectReport[]
|
|
58
|
+
|
|
59
|
+
@Field(type => Int)
|
|
60
|
+
total: number
|
|
61
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CreateDateColumn,
|
|
3
|
+
UpdateDateColumn,
|
|
4
|
+
DeleteDateColumn,
|
|
5
|
+
Entity,
|
|
6
|
+
Index,
|
|
7
|
+
Column,
|
|
8
|
+
RelationId,
|
|
9
|
+
ManyToOne,
|
|
10
|
+
PrimaryGeneratedColumn,
|
|
11
|
+
VersionColumn
|
|
12
|
+
} from 'typeorm'
|
|
13
|
+
import { ObjectType, Field, Int, ID, registerEnumType } from 'type-graphql'
|
|
14
|
+
|
|
15
|
+
import { Domain } from '@things-factory/shell'
|
|
16
|
+
import { User } from '@things-factory/auth-base'
|
|
17
|
+
import { Project } from '@dssp/project'
|
|
18
|
+
|
|
19
|
+
import { Supervisor } from '../supervisor/supervisor'
|
|
20
|
+
|
|
21
|
+
export enum ProjectReportStatus {
|
|
22
|
+
STATUS_A = 'STATUS_A',
|
|
23
|
+
STATUS_B = 'STATUS_B'
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
registerEnumType(ProjectReportStatus, {
|
|
27
|
+
name: 'ProjectReportStatus',
|
|
28
|
+
description: 'state enumeration of a projectReport'
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
@Entity()
|
|
32
|
+
@Index('ix_project_report_0', (projectReport: ProjectReport) => [projectReport.domain, projectReport.name], {
|
|
33
|
+
unique: true,
|
|
34
|
+
where: '"deleted_at" IS NULL'
|
|
35
|
+
})
|
|
36
|
+
@ObjectType({ description: 'Entity for ProjectReport' })
|
|
37
|
+
export class ProjectReport {
|
|
38
|
+
@PrimaryGeneratedColumn('uuid')
|
|
39
|
+
@Field(type => ID)
|
|
40
|
+
readonly id: string
|
|
41
|
+
|
|
42
|
+
@ManyToOne(type => Domain)
|
|
43
|
+
@Field({ nullable: true })
|
|
44
|
+
domain?: Domain
|
|
45
|
+
|
|
46
|
+
@RelationId((projectReport: ProjectReport) => projectReport.domain)
|
|
47
|
+
domainId?: string
|
|
48
|
+
|
|
49
|
+
@Column()
|
|
50
|
+
@Field({ nullable: true })
|
|
51
|
+
name?: string
|
|
52
|
+
|
|
53
|
+
@Column({ nullable: true })
|
|
54
|
+
@Field({ nullable: true })
|
|
55
|
+
description?: string
|
|
56
|
+
|
|
57
|
+
@Column({ nullable: true })
|
|
58
|
+
@Field({ nullable: true })
|
|
59
|
+
active?: boolean
|
|
60
|
+
|
|
61
|
+
@Column({ nullable: true })
|
|
62
|
+
@Field({ nullable: true })
|
|
63
|
+
state?: ProjectReportStatus
|
|
64
|
+
|
|
65
|
+
@Column({ nullable: true })
|
|
66
|
+
@Field({ nullable: true })
|
|
67
|
+
params?: string
|
|
68
|
+
|
|
69
|
+
@Column({ nullable: true })
|
|
70
|
+
@Field({ nullable: true })
|
|
71
|
+
content?: string
|
|
72
|
+
|
|
73
|
+
@Column({ nullable: true })
|
|
74
|
+
@Field({ nullable: true })
|
|
75
|
+
date?: Date
|
|
76
|
+
|
|
77
|
+
@Field(() => Project)
|
|
78
|
+
@ManyToOne(() => Project)
|
|
79
|
+
project?: Project
|
|
80
|
+
|
|
81
|
+
@Field(() => Supervisor)
|
|
82
|
+
@ManyToOne(() => Supervisor, supervisor => supervisor.reports)
|
|
83
|
+
supervisor: Supervisor
|
|
84
|
+
|
|
85
|
+
@CreateDateColumn()
|
|
86
|
+
@Field({ nullable: true })
|
|
87
|
+
createdAt?: Date
|
|
88
|
+
|
|
89
|
+
@UpdateDateColumn()
|
|
90
|
+
@Field({ nullable: true })
|
|
91
|
+
updatedAt?: Date
|
|
92
|
+
|
|
93
|
+
@DeleteDateColumn()
|
|
94
|
+
@Field({ nullable: true })
|
|
95
|
+
deletedAt?: Date
|
|
96
|
+
|
|
97
|
+
@ManyToOne(type => User, { nullable: true })
|
|
98
|
+
@Field(type => User, { nullable: true })
|
|
99
|
+
creator?: User
|
|
100
|
+
|
|
101
|
+
@RelationId((projectReport: ProjectReport) => projectReport.creator)
|
|
102
|
+
creatorId?: string
|
|
103
|
+
|
|
104
|
+
@ManyToOne(type => User, { nullable: true })
|
|
105
|
+
@Field(type => User, { nullable: true })
|
|
106
|
+
updater?: User
|
|
107
|
+
|
|
108
|
+
@RelationId((projectReport: ProjectReport) => projectReport.updater)
|
|
109
|
+
updaterId?: string
|
|
110
|
+
|
|
111
|
+
@Field(type => String, { nullable: true })
|
|
112
|
+
thumbnail?: string
|
|
113
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Supervisor } from './supervisor'
|
|
2
|
+
import { SupervisorQuery } from './supervisor-query'
|
|
3
|
+
import { SupervisorMutation } from './supervisor-mutation'
|
|
4
|
+
|
|
5
|
+
export const entities = [Supervisor]
|
|
6
|
+
export const resolvers = [SupervisorQuery, SupervisorMutation]
|
|
7
|
+
export const subscribers = []
|