diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index b7d313b..57223e9 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -18,7 +18,6 @@ on: pull_request: env: - # TODO: Change variable to your image's name. IMAGE_NAME: fsm-scheduling-samples jobs: @@ -42,7 +41,6 @@ jobs: # Push image to GitHub Packages. # See also https://docs.docker.com/docker-hub/builds/ push: - # Ensure test job passes before pushing image. needs: test runs-on: ubuntu-latest diff --git a/workbench/frontend/src/app/common/services/query.service.ts b/workbench/frontend/src/app/common/services/query.service.ts index 880d4d5..c950526 100644 --- a/workbench/frontend/src/app/common/services/query.service.ts +++ b/workbench/frontend/src/app/common/services/query.service.ts @@ -1,12 +1,15 @@ import { HttpHeaders, HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; -import { mergeMap, tap } from 'rxjs/operators'; +import { map, mergeMap, tap, withLatestFrom } from 'rxjs/operators'; import { ConfigService } from './config.service'; import { CLIENT_IDENTIFIER } from '../contants'; import { GlobalContext, AuthService } from './auth.service'; +import { combineLatest } from 'rxjs'; -type PersonObj = { id: string, firstName: string, lastName: string }; +type PersonObj = { id: string, firstName: string, lastName: string, skills: { name: string, start: string, end: string }[] }; type ActivityObj = { id: string, subject: string; startDateTime: string, earliestStartDateTime: string, dueDateTime: string, code: string }; +type TagObj = { id: string, name: string }; +type SkillObj = { id: string, tag: string, person: string, endDate: string, startDate: string }; type InternalCache = { resource: Map; @@ -64,26 +67,54 @@ export class QueryService { } } - private _query(key: keyof InternalCache, query: string) { + private _query(query: string) { // console.debug(query); return this.auth.globalContextWithAuth$.pipe( mergeMap(ctx => this.http.post(`${this.config.getApiUri()}/query`, { query }, { headers: this.getHeaders(ctx) })), - tap((list) => this.addToCache(key, list)) + ); } public queryActivities(query: string) { - return this._query('activity', query); + return this._query(query).pipe( + tap((list) => this.addToCache('activity', list)) + ) } - public queryResource(query: string) { - return this._query('resource', query); + + public queryResource(query: string) { + return combineLatest([ + this._query(query), + this._query(`SELECT tag.id as id, tag.name as name FROM Tag tag WHERE tag.inactive = false`), + this._query(`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.reduce((m, { id, name }) => m.set(id, name), new Map()) + const skillMap = skills.reduce((m, skill) => { + const item = { + 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(item) + } else { + m.set(skill.person, [item]) + } + return m; + }, new Map()) + + return resources.map(it => ({ ...it, skills: skillMap.has(it.id) ? skillMap.get(it.id) : [] })) + }), + tap((list) => this.addToCache('resource', list)) + ); } public getResourceFromCache(id: string): PersonObj { return this.getCache('resource').has(id) ? this.getCache('resource').get(id) - : { id, firstName: 'N/A', lastName: 'N/A' }; + : { id, firstName: 'N/A', lastName: 'N/A', skills: [] }; } public static toLastChangedDateStringFormat = (lastChanged: number): string => { diff --git a/workbench/frontend/src/app/slot-booking/services/slot-booking.service.ts b/workbench/frontend/src/app/slot-booking/services/slot-booking.service.ts index 38ee9c4..5112eab 100644 --- a/workbench/frontend/src/app/slot-booking/services/slot-booking.service.ts +++ b/workbench/frontend/src/app/slot-booking/services/slot-booking.service.ts @@ -25,7 +25,9 @@ export type SearchResponseWrapper = SearchResponse & { grouped: GroupedSearchResponse[] }; -type SearchResponseItemExteded = SearchResponseItem & { resourceVm: { id: string, firstName: string, lastName: string } | undefined | null } +type SearchResponseItemExteded = SearchResponseItem & { + resourceVm: { id: string, firstName: string, lastName: string } | undefined | null +} export type SearchResponseItem = { slot: { start: string; end: string; }, diff --git a/workbench/frontend/src/app/slot-booking/slot-booking.component.html b/workbench/frontend/src/app/slot-booking/slot-booking.component.html index 3425b14..ecd40c3 100644 --- a/workbench/frontend/src/app/slot-booking/slot-booking.component.html +++ b/workbench/frontend/src/app/slot-booking/slot-booking.component.html @@ -60,6 +60,10 @@ {{ item.resourceVm?.firstName }} {{ item.resourceVm?.lastName }} + + {{ skill.name }} +