diff --git a/src/app/_services/authentication.service.ts b/src/app/_services/authentication.service.ts index 727ad02..13d4eeb 100644 --- a/src/app/_services/authentication.service.ts +++ b/src/app/_services/authentication.service.ts @@ -134,4 +134,10 @@ export class AuthenticationService { conf => conf.bsData?.user?.roles?.filter(value => -1 !== roles.indexOf(value.name)).length > 0 )) } + + isNotAuthorized(roles: string[]): Observable { + return this.isAuthorized(roles).pipe(map( + isAuthorized => !isAuthorized + )) + } } diff --git a/src/app/admin/admin-basket/basket.component.html b/src/app/admin/admin-basket/basket.component.html index 9fff863..77e8918 100644 --- a/src/app/admin/admin-basket/basket.component.html +++ b/src/app/admin/admin-basket/basket.component.html @@ -59,7 +59,7 @@ Import time - {{ isDate(item.time) ? (item.time | date:'dd/MM/yyyy, HH:mm:ss') : 'never' }} + {{ item.time | date:'dd/MM/yyyy, HH:mm:ss' }} @@ -74,17 +74,17 @@ Project - {{ item.project }} + {{ adminDataService.projectMap.get(item.project_id).name }} Surveyor - {{ item.surveyor }} + {{ adminDataService.surveyorMap.get(item.surveyor_id).name }} Equipment - {{ item.equipment }} + {{ adminDataService.equipmentMap.get(item.equipment_id).name }} diff --git a/src/app/admin/admin-basket/data.service.ts b/src/app/admin/admin-basket/data.service.ts index b329eff..c69ad22 100644 --- a/src/app/admin/admin-basket/data.service.ts +++ b/src/app/admin/admin-basket/data.service.ts @@ -5,8 +5,7 @@ import { map } from 'rxjs/operators' // import { Apollo, gql } from 'apollo-angular' -import { Project } from '../admin-data.service' -import { AdminService, AdminBasket, BasketNameOnly } from '../../openapi' +import { AdminService, AdminBasket, BasketNameOnly, Project } from '../../openapi' export class AdminBasketFile { constructor( diff --git a/src/app/admin/admin-data.service.ts b/src/app/admin/admin-data.service.ts index 6030233..9cbb318 100644 --- a/src/app/admin/admin-data.service.ts +++ b/src/app/admin/admin-data.service.ts @@ -3,67 +3,7 @@ import { Observable, of as observableOf } from 'rxjs' import { map } from 'rxjs/operators' import { Store } from './admin-manage/data.service' -import { ApiService, SurveyMeta } from '../openapi' - -export class Project { - constructor( - public id: number, - public name: string, - ) {} -} - -export class Surveyor { - constructor( - public id: number, - public name: string, - ) {} -} - -export class Equipment { - constructor( - public id: number, - public name: string, - ) {} -} - -// export class SurveyMeta { -// constructor( -// public projects: Project[], -// public surveyors: Surveyor[], -// public equipments: Equipment[], -// public statuses: string[], -// public stores_misc: Store[], -// public stores_line_work: Store[], -// public defaults: Object -// ) {} -// } - -// const getSurveyMeta = gql` -// query survey_meta { -// survey_meta { -// projects { -// id -// name -// } -// surveyors { -// id -// name -// } -// equipments { -// id -// name -// } -// stores_misc { -// name -// } -// stores_line_work { -// name -// } -// statuses -// default -// } -// } -// ` +import { ApiService, SurveyMeta, Project, Surveyor, Equipment } from '../openapi' // const admin_models_menu_bar_query = gql` // query admin_models_menu_bar { @@ -79,6 +19,9 @@ export class Equipment { @Injectable() export class AdminDataService { surveyMeta: SurveyMeta + projectMap: Map + surveyorMap: Map + equipmentMap: Map constructor( // private apollo: Apollo, @@ -97,36 +40,13 @@ export class AdminDataService { getSurveyMeta(): Observable { return this.apiService.getSurveyMetaApiSurveyMetaGet().pipe(map( - surveyMeta => this.surveyMeta = surveyMeta + surveyMeta => { + this.surveyMeta = surveyMeta + this.projectMap = new Map(surveyMeta.projects.map(i => [i.id, i])) + this.surveyorMap = new Map(surveyMeta.surveyors.map(i => [i.id, i])) + this.equipmentMap = new Map(surveyMeta.equipments.map(i => [i.id, i])) + return surveyMeta + } )) - console.warn('Migrate Graphql') - return observableOf() - // return this.apollo.query({ - // query: getSurveyMeta, - // }).pipe(map( - // resp => { - // let data = resp['data']['survey_meta'] - // this.surveyMeta = new SurveyMeta( - // data['projects'].map( - // item => new Project(item['id'], item['name']) - // ).sort((i, j) => i.name > j.name ? 1 : -1), - // data['surveyors'].map( - // item => new Surveyor(item['id'], item['name']) - // ).sort((i, j) => i.name > j.name ? 1 : -1), - // data['equipments'].map( - // item => new Equipment(item['id'], item['name']) - // ).sort((i, j) => i.name > j.name ? 1 : -1), - // data['statuses'], - // data['stores_misc'].map( - // item => new Store(item['name']) - // ).sort((i, j) => i.name > j.name ? 1 : -1), - // data['stores_line_work'].map( - // item => new Store(item['name']) - // ).sort((i, j) => i.name > j.name ? 1 : -1), - // JSON.parse(data['default']), - // ) - // return this.surveyMeta - // } - // )) } } \ No newline at end of file diff --git a/src/app/admin/admin-manage/category/category-resolver.service.ts b/src/app/admin/admin-manage/category/category-resolver.service.ts index 858e4f9..5011488 100644 --- a/src/app/admin/admin-manage/category/category-resolver.service.ts +++ b/src/app/admin/admin-manage/category/category-resolver.service.ts @@ -1,19 +1,17 @@ import { Injectable } from '@angular/core' import { Router, RouterStateSnapshot, ActivatedRouteSnapshot } from '@angular/router' import { Observable } from 'rxjs' -import { map } from 'rxjs/operators' - -import { AdminManageDataService, Category } from '../data.service' +import { ApiService, CategoryRead } from '../../../openapi' @Injectable() export class CategoryResolver { constructor( - private adminManageDataService: AdminManageDataService, + public apiService: ApiService, private router: Router ) {} - resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable { - return this.adminManageDataService.getCategories() + resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable { + return this.apiService.getCategoriesApiCategoriesGet() } } diff --git a/src/app/admin/admin-manage/category/category.component.html b/src/app/admin/admin-manage/category/category.component.html index 3e7b4d0..44fc0d1 100644 --- a/src/app/admin/admin-manage/category/category.component.html +++ b/src/app/admin/admin-manage/category/category.component.html @@ -15,7 +15,7 @@