From f0e7097163785123a4388872b92f13b2d908c021 Mon Sep 17 00:00:00 2001 From: Davo00 Date: Tue, 21 Nov 2023 10:23:30 +0100 Subject: [PATCH] UI changes --- .../resource-query.component.html | 32 +++++++------ .../resource-query.component.scss | 17 +++++++ .../resource-query.component.ts | 8 +++- .../src/app/common/services/query.service.ts | 46 ++++++++++++++++++- 4 files changed, 86 insertions(+), 17 deletions(-) diff --git a/workbench/frontend/src/app/common/components/resource-query/resource-query.component.html b/workbench/frontend/src/app/common/components/resource-query/resource-query.component.html index 801cf13..9773e13 100755 --- a/workbench/frontend/src/app/common/components/resource-query/resource-query.component.html +++ b/workbench/frontend/src/app/common/components/resource-query/resource-query.component.html @@ -1,8 +1,6 @@ -

resources: {{ (resources$ | async)?.length }}

- -
+

Resources: {{ (resources$ | async)?.length }}

delete @@ -11,12 +9,19 @@

resources: {{ (resources$ | async)?.length }}

+

Query Templates:

- - query-templates: - - - +
+ + + +
@@ -30,16 +35,14 @@

resources: {{ (resources$ | async)?.length }}


- - - Filter +
Crowd Internal
-
+
- + +
diff --git a/workbench/frontend/src/app/common/components/resource-query/resource-query.component.scss b/workbench/frontend/src/app/common/components/resource-query/resource-query.component.scss index e69de29..ad9037f 100644 --- a/workbench/frontend/src/app/common/components/resource-query/resource-query.component.scss +++ b/workbench/frontend/src/app/common/components/resource-query/resource-query.component.scss @@ -0,0 +1,17 @@ +.selected { + background-color: #e0e0e0; /* Greyish color for selected tab */ + color: #333; /* Adjust text color for better contrast */ + border-bottom: 3px solid #ccc; /* Border color for selected tab */ +} + +.mat-button { + transition: background-color 0.3s; /* Add a smooth transition for background color */ +} + +.mat-button:not(.selected):hover { + background-color: #e0e0e0; /* Change background color on hover for non-selected buttons */ +} + +.selected:hover { + background-color: #e0e0e0; /* Change background color on hover for non-selected buttons */ +} diff --git a/workbench/frontend/src/app/common/components/resource-query/resource-query.component.ts b/workbench/frontend/src/app/common/components/resource-query/resource-query.component.ts index 66f4f22..0c1e108 100644 --- a/workbench/frontend/src/app/common/components/resource-query/resource-query.component.ts +++ b/workbench/frontend/src/app/common/components/resource-query/resource-query.component.ts @@ -58,6 +58,9 @@ export class ResourceQueryComponent implements OnInit, OnDestroy { public allResources: any[] = []; public selectedSkills: string[] = []; + public selectedTemplate = 'default'; + + @Input() selectedMandatorySkills: string[]; @Output() change = new EventEmitter(); @@ -87,7 +90,7 @@ export class ResourceQueryComponent implements OnInit, OnDestroy { selectedSkills: [] }); - this.svc.queryResource(TEMPLATES.default).subscribe(resources => { + this.svc.queryResourceSkills(TEMPLATES.default).subscribe(resources => { this.allResources = resources; this.skillResourcesMap.clear(); @@ -120,7 +123,7 @@ export class ResourceQueryComponent implements OnInit, OnDestroy { withLatestFrom(merge(of(this.form.value), this.form.valueChanges)), mergeMap(([_, form]) => { this.isLoading$.next(true); - return this.svc.queryResource(form.query).pipe( + return this.svc.queryResourceSkills(form.query).pipe( catchError(error => { console.error(error); @@ -160,6 +163,7 @@ export class ResourceQueryComponent implements OnInit, OnDestroy { } public applyTmpl(t: keyof typeof TEMPLATES): void { + this.selectedTemplate = t; this.form.patchValue({ query: TEMPLATES[t] }); } diff --git a/workbench/frontend/src/app/common/services/query.service.ts b/workbench/frontend/src/app/common/services/query.service.ts index 6ac0fe5..401d7a0 100644 --- a/workbench/frontend/src/app/common/services/query.service.ts +++ b/workbench/frontend/src/app/common/services/query.service.ts @@ -110,8 +110,52 @@ export class QueryService { ); } + public queryResourceSkills, item extends { + id: string, + firstName: string, + lastName: string + }>(query: string): Observable { + return combineLatest([ + this._query(query), + this._query, TagObj>(`SELECT tag.id as id, tag.name as name + FROM Tag tag + WHERE tag.inactive = false`), + this._query, SkillObj>(`SELECT skill.id as id, + skill.tag as tag, + skill.person as person, + skill.startDate as startDate, + skill.endDate as endDate + FROM Skill skill + WHERE skill.inactive = false`) + ]) + .pipe( + map(([resources, tags, skills]) => { + const tagMap = tags.data.reduce((m, { id, name }) => m.set(id, name), new Map()); + const skillMap = skills.data.reduce((m, skill) => { + const currentItem = { + name: (tagMap.get(skill.tag) || skill.tag), + start: skill.startDate === 'null' ? null : skill.startDate, + end: skill.endDate === 'null' ? null : skill.endDate + }; + if (m.has(skill.person)) { + m.get(skill.person)?.push(currentItem); + } else { + m.set(skill.person, [currentItem]); + } + return m; + }, new Map()); + + return resources.data.map(it => ({ + ...it, + skills: skillMap.has(it.id) ? skillMap.get(it.id).sort((a, b) => (a.name > b.name) ? 1 : ((b.name > a.name) ? -1 : 0)) : [] + })); + }), + tap((currentList) => this.addToCache('resource', currentList)) + ); + } + - public queryResource, item extends { + public queryResourceSkills_new, item extends { id: string, firstName: string, lastName: string,