Fix authorization in many places (use async)
Admin basket: Fix display
This commit is contained in:
parent
339d8f2210
commit
909e250fe9
26 changed files with 121 additions and 229 deletions
|
@ -134,4 +134,10 @@ export class AuthenticationService {
|
||||||
conf => conf.bsData?.user?.roles?.filter(value => -1 !== roles.indexOf(value.name)).length > 0
|
conf => conf.bsData?.user?.roles?.filter(value => -1 !== roles.indexOf(value.name)).length > 0
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isNotAuthorized(roles: string[]): Observable<boolean> {
|
||||||
|
return this.isAuthorized(roles).pipe(map(
|
||||||
|
isAuthorized => !isAuthorized
|
||||||
|
))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@
|
||||||
|
|
||||||
<ng-container matColumnDef="time">
|
<ng-container matColumnDef="time">
|
||||||
<th mat-header-cell *matHeaderCellDef mat-sort-header>Import time</th>
|
<th mat-header-cell *matHeaderCellDef mat-sort-header>Import time</th>
|
||||||
<td mat-cell *matCellDef="let item">{{ isDate(item.time) ? (item.time | date:'dd/MM/yyyy, HH:mm:ss') : 'never' }}</td>
|
<td mat-cell *matCellDef="let item">{{ item.time | date:'dd/MM/yyyy, HH:mm:ss' }}</td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-container matColumnDef="url">
|
<ng-container matColumnDef="url">
|
||||||
|
@ -74,17 +74,17 @@
|
||||||
|
|
||||||
<ng-container matColumnDef="project">
|
<ng-container matColumnDef="project">
|
||||||
<th mat-header-cell *matHeaderCellDef mat-sort-header>Project</th>
|
<th mat-header-cell *matHeaderCellDef mat-sort-header>Project</th>
|
||||||
<td mat-cell *matCellDef="let item">{{ item.project }}</td>
|
<td mat-cell *matCellDef="let item">{{ adminDataService.projectMap.get(item.project_id).name }}</td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-container matColumnDef="surveyor">
|
<ng-container matColumnDef="surveyor">
|
||||||
<th mat-header-cell *matHeaderCellDef mat-sort-header>Surveyor</th>
|
<th mat-header-cell *matHeaderCellDef mat-sort-header>Surveyor</th>
|
||||||
<td mat-cell *matCellDef="let item">{{ item.surveyor }}</td>
|
<td mat-cell *matCellDef="let item">{{ adminDataService.surveyorMap.get(item.surveyor_id).name }}</td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-container matColumnDef="equipment">
|
<ng-container matColumnDef="equipment">
|
||||||
<th mat-header-cell *matHeaderCellDef mat-sort-header>Equipment</th>
|
<th mat-header-cell *matHeaderCellDef mat-sort-header>Equipment</th>
|
||||||
<td mat-cell *matCellDef="let item">{{ item.equipment }}</td>
|
<td mat-cell *matCellDef="let item">{{ adminDataService.equipmentMap.get(item.equipment_id).name }}</td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<tr mat-header-row *matHeaderRowDef="getColumns();sticky:true"></tr>
|
<tr mat-header-row *matHeaderRowDef="getColumns();sticky:true"></tr>
|
||||||
|
|
|
@ -5,8 +5,7 @@ import { map } from 'rxjs/operators'
|
||||||
|
|
||||||
// import { Apollo, gql } from 'apollo-angular'
|
// import { Apollo, gql } from 'apollo-angular'
|
||||||
|
|
||||||
import { Project } from '../admin-data.service'
|
import { AdminService, AdminBasket, BasketNameOnly, Project } from '../../openapi'
|
||||||
import { AdminService, AdminBasket, BasketNameOnly } from '../../openapi'
|
|
||||||
|
|
||||||
export class AdminBasketFile {
|
export class AdminBasketFile {
|
||||||
constructor(
|
constructor(
|
||||||
|
|
|
@ -3,67 +3,7 @@ import { Observable, of as observableOf } from 'rxjs'
|
||||||
import { map } from 'rxjs/operators'
|
import { map } from 'rxjs/operators'
|
||||||
|
|
||||||
import { Store } from './admin-manage/data.service'
|
import { Store } from './admin-manage/data.service'
|
||||||
import { ApiService, SurveyMeta } from '../openapi'
|
import { ApiService, SurveyMeta, Project, Surveyor, Equipment } 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
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// `
|
|
||||||
|
|
||||||
// const admin_models_menu_bar_query = gql`
|
// const admin_models_menu_bar_query = gql`
|
||||||
// query admin_models_menu_bar {
|
// query admin_models_menu_bar {
|
||||||
|
@ -79,6 +19,9 @@ export class Equipment {
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AdminDataService {
|
export class AdminDataService {
|
||||||
surveyMeta: SurveyMeta
|
surveyMeta: SurveyMeta
|
||||||
|
projectMap: Map<number, Project>
|
||||||
|
surveyorMap: Map<number, Surveyor>
|
||||||
|
equipmentMap: Map<number, Equipment>
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
// private apollo: Apollo,
|
// private apollo: Apollo,
|
||||||
|
@ -97,36 +40,13 @@ export class AdminDataService {
|
||||||
|
|
||||||
getSurveyMeta(): Observable<SurveyMeta> {
|
getSurveyMeta(): Observable<SurveyMeta> {
|
||||||
return this.apiService.getSurveyMetaApiSurveyMetaGet().pipe(map(
|
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
|
|
||||||
// }
|
|
||||||
// ))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,19 +1,17 @@
|
||||||
import { Injectable } from '@angular/core'
|
import { Injectable } from '@angular/core'
|
||||||
import { Router, RouterStateSnapshot, ActivatedRouteSnapshot } from '@angular/router'
|
import { Router, RouterStateSnapshot, ActivatedRouteSnapshot } from '@angular/router'
|
||||||
import { Observable } from 'rxjs'
|
import { Observable } from 'rxjs'
|
||||||
import { map } from 'rxjs/operators'
|
|
||||||
|
|
||||||
import { AdminManageDataService, Category } from '../data.service'
|
|
||||||
|
|
||||||
|
import { ApiService, CategoryRead } from '../../../openapi'
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class CategoryResolver {
|
export class CategoryResolver {
|
||||||
constructor(
|
constructor(
|
||||||
private adminManageDataService: AdminManageDataService,
|
public apiService: ApiService,
|
||||||
private router: Router
|
private router: Router
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Category[]> {
|
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<CategoryRead[]> {
|
||||||
return this.adminManageDataService.getCategories()
|
return this.apiService.getCategoriesApiCategoriesGet()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
</button>
|
</button>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<button mat-raised-button aria-label="New"
|
<button mat-raised-button aria-label="New"
|
||||||
*ngIf="authenticationService.isAuthorized(edit_roles)"
|
*ngIf="authenticationService.isAuthorized(edit_roles) | async"
|
||||||
(click)="editItem()">
|
(click)="editItem()">
|
||||||
<mat-icon>create</mat-icon>
|
<mat-icon>create</mat-icon>
|
||||||
Add new category
|
Add new category
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-container matColumnDef="delete"
|
<ng-container matColumnDef="delete"
|
||||||
*ngIf="authenticationService.isAuthorized(edit_roles)"
|
*ngIf="authenticationService.isAuthorized(edit_roles) | async"
|
||||||
>
|
>
|
||||||
<th mat-header-cell *matHeaderCellDef>
|
<th mat-header-cell *matHeaderCellDef>
|
||||||
<form [formGroup]="unlockDeleteFormGroup" class='unlockCheckbox'>
|
<form [formGroup]="unlockDeleteFormGroup" class='unlockCheckbox'>
|
||||||
|
|
|
@ -10,9 +10,10 @@ import { MatPaginator } from '@angular/material/paginator'
|
||||||
import { MatDialog } from '@angular/material/dialog'
|
import { MatDialog } from '@angular/material/dialog'
|
||||||
|
|
||||||
import { GisafAdminCategoryDialogComponent } from './dialog.component'
|
import { GisafAdminCategoryDialogComponent } from './dialog.component'
|
||||||
import { Category, AdminManageDataService } from '../data.service'
|
import { AdminManageDataService } from '../data.service'
|
||||||
import { AuthenticationService } from '../../../_services/authentication.service'
|
import { AuthenticationService } from '../../../_services/authentication.service'
|
||||||
import { CategoryField, categoryFields } from './fields'
|
import { CategoryField, categoryFields } from './fields'
|
||||||
|
import { CategoryRead } from '../../../openapi'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'gisaf-admin-category',
|
selector: 'gisaf-admin-category',
|
||||||
|
@ -22,7 +23,7 @@ import { CategoryField, categoryFields } from './fields'
|
||||||
})
|
})
|
||||||
export class CategoryComponent implements OnInit {
|
export class CategoryComponent implements OnInit {
|
||||||
edit_roles = ['category manager']
|
edit_roles = ['category manager']
|
||||||
categories: Category[] = []
|
categories: CategoryRead[] = []
|
||||||
fields: string[] = categoryFields.map(f=>f.name)
|
fields: string[] = categoryFields.map(f=>f.name)
|
||||||
actions: string[] = [
|
actions: string[] = [
|
||||||
'edit',
|
'edit',
|
||||||
|
@ -58,24 +59,28 @@ export class CategoryComponent implements OnInit {
|
||||||
'canDelete': new UntypedFormControl(),
|
'canDelete': new UntypedFormControl(),
|
||||||
})
|
})
|
||||||
this.columns = categoryFields.filter(f=>f.inTable).map(f=>f.name)
|
this.columns = categoryFields.filter(f=>f.inTable).map(f=>f.name)
|
||||||
if (this.authenticationService.isAuthorized(this.edit_roles)) {
|
this.authenticationService.isAuthorized(this.edit_roles).subscribe(
|
||||||
this.columns = this.columns.concat(this.actions)
|
isAuthorized => {
|
||||||
}
|
if (isAuthorized) {
|
||||||
|
this.columns = this.columns.concat(this.actions)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
applyFilter() {
|
applyFilter() {
|
||||||
this.dataSource.filter = this.filterText.trim().toLowerCase();
|
this.dataSource.filter = this.filterText.trim().toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
editItem(data?: Category) {
|
editItem(data?: CategoryRead) {
|
||||||
const dialogRef = this.dialog.open(GisafAdminCategoryDialogComponent, {
|
const dialogRef = this.dialog.open(GisafAdminCategoryDialogComponent, {
|
||||||
width: '75%',
|
width: '75%',
|
||||||
data: {
|
data: {
|
||||||
'category': data || new Category(''),
|
'category': data
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
dialogRef.afterClosed().subscribe(
|
dialogRef.afterClosed().subscribe(
|
||||||
(category: Category) => category &&
|
(category: CategoryRead) => category &&
|
||||||
this.adminManageDataService.saveCategory(
|
this.adminManageDataService.saveCategory(
|
||||||
category
|
category
|
||||||
).subscribe({
|
).subscribe({
|
||||||
|
@ -86,7 +91,7 @@ export class CategoryComponent implements OnInit {
|
||||||
this.dataSource.data[row] = category
|
this.dataSource.data[row] = category
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.dataSource.data.push(category as Category)
|
this.dataSource.data.push(category as CategoryRead)
|
||||||
}
|
}
|
||||||
let msg = 'Category ' + category.name + ' ' + result['_mode']
|
let msg = 'Category ' + category.name + ' ' + result['_mode']
|
||||||
if (result['message']) {
|
if (result['message']) {
|
||||||
|
@ -105,7 +110,7 @@ export class CategoryComponent implements OnInit {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteItem(category: Category) {
|
deleteItem(category: CategoryRead) {
|
||||||
this.adminManageDataService.deleteCategory(category).subscribe({
|
this.adminManageDataService.deleteCategory(category).subscribe({
|
||||||
next: (message: string) => {
|
next: (message: string) => {
|
||||||
this.snackBar.open(message, 'Close')
|
this.snackBar.open(message, 'Close')
|
||||||
|
|
|
@ -4,11 +4,11 @@ import { UntypedFormGroup, UntypedFormControl, Validators } from '@angular/forms
|
||||||
|
|
||||||
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'
|
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'
|
||||||
|
|
||||||
import { Category } from '../data.service'
|
|
||||||
import { categoryFields } from './fields'
|
import { categoryFields } from './fields'
|
||||||
|
import { CategoryRead } from '../../../openapi'
|
||||||
|
|
||||||
export interface DialogData {
|
export interface DialogData {
|
||||||
category: Category
|
category: CategoryRead
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ export class GisafAdminCategoryDialogComponent implements OnInit {
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
let category: Category = this.data['category']
|
let category: CategoryRead = this.data['category']
|
||||||
this.formGroup = new UntypedFormGroup({})
|
this.formGroup = new UntypedFormGroup({})
|
||||||
//this.formGroup.addControl('name', new FormControl(category.name, [Validators.required]))
|
//this.formGroup.addControl('name', new FormControl(category.name, [Validators.required]))
|
||||||
for (let categoryField of categoryFields) {
|
for (let categoryField of categoryFields) {
|
||||||
|
|
|
@ -18,7 +18,7 @@ export const categoryFields: CategoryField[] = [
|
||||||
new CategoryField('minor_group_2', [Validators.required, Validators.maxLength(4), Validators.minLength(4)], 'string', '----'),
|
new CategoryField('minor_group_2', [Validators.required, Validators.maxLength(4), Validators.minLength(4)], 'string', '----'),
|
||||||
new CategoryField('status', [Validators.required, Validators.maxLength(1), Validators.minLength(1)], 'string', 'E'),
|
new CategoryField('status', [Validators.required, Validators.maxLength(1), Validators.minLength(1)], 'string', 'E'),
|
||||||
//new CategoryField('auto_import', [], 'boolean'),
|
//new CategoryField('auto_import', [], 'boolean'),
|
||||||
new CategoryField('model_type', [Validators.required, Validators.pattern('^(Point|Line|Polygon)$')], 'string', 'Point'),
|
new CategoryField('gis_type', [Validators.required, Validators.pattern('^(Point|Line|Polygon)$')], 'string', 'Point'),
|
||||||
new CategoryField('long_name'),
|
new CategoryField('long_name'),
|
||||||
new CategoryField('symbol', [Validators.maxLength(1), Validators.minLength(1)], 'string'),
|
new CategoryField('symbol', [Validators.maxLength(1), Validators.minLength(1)], 'string'),
|
||||||
new CategoryField('mapbox_type_custom', [], 'string', '', false),
|
new CategoryField('mapbox_type_custom', [], 'string', '', false),
|
||||||
|
|
|
@ -5,6 +5,8 @@ import { map } from 'rxjs/operators'
|
||||||
|
|
||||||
// import { Apollo, gql } from 'apollo-angular'
|
// import { Apollo, gql } from 'apollo-angular'
|
||||||
|
|
||||||
|
import { ApiService, Project, CategoryRead } from '../../openapi'
|
||||||
|
|
||||||
// const getSurveyStores = gql`
|
// const getSurveyStores = gql`
|
||||||
// query geo_survey_stores {
|
// query geo_survey_stores {
|
||||||
// geo_survey_stores {
|
// geo_survey_stores {
|
||||||
|
@ -217,39 +219,39 @@ export class Store {
|
||||||
) {}
|
) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Category {
|
// export class Category {
|
||||||
constructor(
|
// constructor(
|
||||||
public name: string,
|
// public name: string,
|
||||||
public description?: string,
|
// public description?: string,
|
||||||
public group?: string,
|
// public group?: string,
|
||||||
public minor_group_1?: string,
|
// public minor_group_1?: string,
|
||||||
public minor_group_2?: string,
|
// public minor_group_2?: string,
|
||||||
public status?: string,
|
// public status?: string,
|
||||||
public auto_import?: string,
|
// public auto_import?: string,
|
||||||
public model_type?: string,
|
// public model_type?: string,
|
||||||
public long_name?: string,
|
// public long_name?: string,
|
||||||
public symbol?: string,
|
// public symbol?: string,
|
||||||
public mapbox_type_custom?: string,
|
// public mapbox_type_custom?: string,
|
||||||
public mapbox_paint?: string,
|
// public mapbox_paint?: string,
|
||||||
public mapbox_layout?: string,
|
// public mapbox_layout?: string,
|
||||||
public viewable_role?: string,
|
// public viewable_role?: string,
|
||||||
public extra?: string,
|
// public extra?: string,
|
||||||
) {}
|
// ) {}
|
||||||
}
|
// }
|
||||||
|
|
||||||
export class Project {
|
// export class Project {
|
||||||
constructor(
|
// constructor(
|
||||||
public id: number,
|
// public id: number,
|
||||||
public name: string,
|
// public name: string,
|
||||||
public contact_person?: string,
|
// public contact_person?: string,
|
||||||
public site?: string,
|
// public site?: string,
|
||||||
public date_approved?: Date,
|
// public date_approved?: Date,
|
||||||
public start_date_planned?: Date,
|
// public start_date_planned?: Date,
|
||||||
public start_date_effective?: Date,
|
// public start_date_effective?: Date,
|
||||||
public end_date_planned?: Date,
|
// public end_date_planned?: Date,
|
||||||
public end_date_effective?: Date,
|
// public end_date_effective?: Date,
|
||||||
) {}
|
// ) {}
|
||||||
}
|
// }
|
||||||
|
|
||||||
export class RawSurveyPoint {
|
export class RawSurveyPoint {
|
||||||
constructor(
|
constructor(
|
||||||
|
@ -302,6 +304,7 @@ export class IntegrityCheck {
|
||||||
export class AdminManageDataService {
|
export class AdminManageDataService {
|
||||||
constructor(
|
constructor(
|
||||||
// private apollo: Apollo,
|
// private apollo: Apollo,
|
||||||
|
public apiService: ApiService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
getRawSurveyStores(): Observable<Store[]> {
|
getRawSurveyStores(): Observable<Store[]> {
|
||||||
|
@ -397,47 +400,15 @@ export class AdminManageDataService {
|
||||||
// ))
|
// ))
|
||||||
}
|
}
|
||||||
|
|
||||||
getCategories(): Observable<Category[]> {
|
getCategories(): Observable<CategoryRead[]> {
|
||||||
console.warn('Migrate Graphql')
|
return this.apiService.getCategoriesApiCategoriesGet()
|
||||||
return observableOf()
|
|
||||||
// return this.apollo.query({
|
|
||||||
// query: categoriesQuery,
|
|
||||||
// }).pipe(map(
|
|
||||||
// res => res['data']['categories'].map(
|
|
||||||
// (category: object) => new Category(
|
|
||||||
// category['name'],
|
|
||||||
// category['description'],
|
|
||||||
// category['group'],
|
|
||||||
// category['minor_group_1'],
|
|
||||||
// category['minor_group_2'],
|
|
||||||
// category['status'],
|
|
||||||
// category['auto_import'],
|
|
||||||
// category['model_type'],
|
|
||||||
// category['long_name'],
|
|
||||||
// category['symbol'],
|
|
||||||
// category['mapbox_type_custom'],
|
|
||||||
// category['mapbox_paint'],
|
|
||||||
// category['mapbox_layout'],
|
|
||||||
// category['viewable_role'],
|
|
||||||
// category['extra'],
|
|
||||||
// )
|
|
||||||
// )
|
|
||||||
// ))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getProjects(): Observable<Project[]> {
|
getProjects(): Observable<Project[]> {
|
||||||
console.warn('Migrate Graphql')
|
return this.apiService.getProjectsApiProjectsGet()
|
||||||
return observableOf()
|
|
||||||
// return this.apollo.query({
|
|
||||||
// query: projectsQuery,
|
|
||||||
// }).pipe(map(
|
|
||||||
// res => res['data']['projects'].map(
|
|
||||||
// (project: object) => project as Project
|
|
||||||
// )
|
|
||||||
// ))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
saveCategory(category: Category): Observable<object> {
|
saveCategory(category: CategoryRead): Observable<object> {
|
||||||
console.warn('Migrate Graphql')
|
console.warn('Migrate Graphql')
|
||||||
return observableOf()
|
return observableOf()
|
||||||
// return this.apollo.mutate({
|
// return this.apollo.mutate({
|
||||||
|
@ -450,7 +421,7 @@ export class AdminManageDataService {
|
||||||
// ))
|
// ))
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteCategory(category: Category): Observable<string> {
|
deleteCategory(category: CategoryRead): Observable<string> {
|
||||||
console.warn('Migrate Graphql')
|
console.warn('Migrate Graphql')
|
||||||
return observableOf()
|
return observableOf()
|
||||||
// return this.apollo.mutate({
|
// return this.apollo.mutate({
|
||||||
|
|
|
@ -6,7 +6,8 @@ import { UntypedFormGroup, UntypedFormControl } from '@angular/forms'
|
||||||
import { map, startWith } from 'rxjs/operators'
|
import { map, startWith } from 'rxjs/operators'
|
||||||
import { Observable } from 'rxjs'
|
import { Observable } from 'rxjs'
|
||||||
|
|
||||||
import { AdminManageDataService, Category, RawSurveyPoint } from '../data.service'
|
import { AdminManageDataService, RawSurveyPoint } from '../data.service'
|
||||||
|
import { CategoryRead } from '../../../openapi'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'gisaf-admin-points-by-orig-id',
|
selector: 'gisaf-admin-points-by-orig-id',
|
||||||
|
@ -16,9 +17,9 @@ import { AdminManageDataService, Category, RawSurveyPoint } from '../data.servic
|
||||||
})
|
})
|
||||||
export class AdminPointsByOrigIdComponent implements OnInit {
|
export class AdminPointsByOrigIdComponent implements OnInit {
|
||||||
formGroup: UntypedFormGroup
|
formGroup: UntypedFormGroup
|
||||||
categories: Category[]
|
categories: CategoryRead[]
|
||||||
rawSurveyPoints: RawSurveyPoint[]
|
rawSurveyPoints: RawSurveyPoint[]
|
||||||
filteredCategories: Observable<Category[]>
|
filteredCategories: Observable<CategoryRead[]>
|
||||||
destinationControl: UntypedFormControl = new UntypedFormControl()
|
destinationControl: UntypedFormControl = new UntypedFormControl()
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
@ -43,7 +44,7 @@ export class AdminPointsByOrigIdComponent implements OnInit {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private _filter(value: string): Category[] {
|
private _filter(value: string): CategoryRead[] {
|
||||||
const filterValue = value.toUpperCase()
|
const filterValue = value.toUpperCase()
|
||||||
return this.categories.filter(
|
return this.categories.filter(
|
||||||
category => category.name.indexOf(filterValue) != -1
|
category => category.name.indexOf(filterValue) != -1
|
||||||
|
|
|
@ -4,8 +4,8 @@ import { UntypedFormGroup, UntypedFormControl, Validators } from '@angular/forms
|
||||||
|
|
||||||
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'
|
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'
|
||||||
|
|
||||||
import { Project } from '../data.service'
|
|
||||||
import { projectFields, ProjectField } from './fields'
|
import { projectFields, ProjectField } from './fields'
|
||||||
|
import { Project } from '../../../openapi'
|
||||||
|
|
||||||
export interface DialogData {
|
export interface DialogData {
|
||||||
project: Project
|
project: Project
|
||||||
|
|
|
@ -3,7 +3,8 @@ import { Router, RouterStateSnapshot, ActivatedRouteSnapshot } from '@angular/ro
|
||||||
import { Observable } from 'rxjs'
|
import { Observable } from 'rxjs'
|
||||||
import { map } from 'rxjs/operators'
|
import { map } from 'rxjs/operators'
|
||||||
|
|
||||||
import { AdminManageDataService, Project } from '../data.service'
|
import { AdminManageDataService } from '../data.service'
|
||||||
|
import { Project } from '../../../openapi'
|
||||||
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
</button>
|
</button>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<button mat-raised-button aria-label="New"
|
<button mat-raised-button aria-label="New"
|
||||||
*ngIf="authenticationService.isAuthorized(edit_roles)"
|
*ngIf="authenticationService.isAuthorized(edit_roles) | async"
|
||||||
(click)="editItem()">
|
(click)="editItem()">
|
||||||
<mat-icon>create</mat-icon>
|
<mat-icon>create</mat-icon>
|
||||||
Add new project
|
Add new project
|
||||||
|
@ -29,7 +29,7 @@
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-container matColumnDef="delete"
|
<ng-container matColumnDef="delete"
|
||||||
*ngIf="authenticationService.isAuthorized(edit_roles)"
|
*ngIf="authenticationService.isAuthorized(edit_roles) | async"
|
||||||
>
|
>
|
||||||
<th mat-header-cell *matHeaderCellDef>
|
<th mat-header-cell *matHeaderCellDef>
|
||||||
<form [formGroup]="unlockDeleteFormGroup" class='unlockCheckbox'>
|
<form [formGroup]="unlockDeleteFormGroup" class='unlockCheckbox'>
|
||||||
|
|
|
@ -10,10 +10,11 @@ import { MatPaginator } from '@angular/material/paginator'
|
||||||
import { MatDialog } from '@angular/material/dialog'
|
import { MatDialog } from '@angular/material/dialog'
|
||||||
|
|
||||||
import { AdminDataService } from '../../admin-data.service'
|
import { AdminDataService } from '../../admin-data.service'
|
||||||
import { Project, AdminManageDataService } from '../data.service'
|
import { AdminManageDataService } from '../data.service'
|
||||||
import { GisafAdminProjectDialogComponent } from './dialog.component'
|
import { GisafAdminProjectDialogComponent } from './dialog.component'
|
||||||
import { AuthenticationService } from '../../../_services/authentication.service'
|
import { AuthenticationService } from '../../../_services/authentication.service'
|
||||||
import { ProjectField, projectFields } from './fields'
|
import { ProjectField, projectFields } from './fields'
|
||||||
|
import { Project } from '../../../openapi'
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -61,9 +62,13 @@ export class ProjectComponent implements OnInit {
|
||||||
'canDelete': new UntypedFormControl(),
|
'canDelete': new UntypedFormControl(),
|
||||||
})
|
})
|
||||||
this.columns = projectFields.filter(f=>f.inTable).map(f=>f.name)
|
this.columns = projectFields.filter(f=>f.inTable).map(f=>f.name)
|
||||||
if (this.authenticationService.isAuthorized(this.edit_roles)) {
|
this.authenticationService.isAuthorized(this.edit_roles).subscribe(
|
||||||
this.columns = this.columns.concat(this.actions)
|
isAuthorized => {
|
||||||
}
|
if (isAuthorized) {
|
||||||
|
this.columns = this.columns.concat(this.actions)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
applyFilter() {
|
applyFilter() {
|
||||||
|
@ -74,7 +79,7 @@ export class ProjectComponent implements OnInit {
|
||||||
const dialogRef = this.dialog.open(GisafAdminProjectDialogComponent, {
|
const dialogRef = this.dialog.open(GisafAdminProjectDialogComponent, {
|
||||||
width: '75%',
|
width: '75%',
|
||||||
data: {
|
data: {
|
||||||
'project': data || new Project(undefined, ''),
|
'project': data || {},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
dialogRef.afterClosed().subscribe(
|
dialogRef.afterClosed().subscribe(
|
||||||
|
|
|
@ -3,7 +3,8 @@ import { Component, OnInit, Input,
|
||||||
|
|
||||||
import { MatSnackBar } from '@angular/material/snack-bar'
|
import { MatSnackBar } from '@angular/material/snack-bar'
|
||||||
|
|
||||||
import { AdminManageDataService, RawSurveyPoint, Category } from '../data.service'
|
import { AdminManageDataService, RawSurveyPoint } from '../data.service'
|
||||||
|
import { CategoryRead } from '../../../openapi'
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
|
|
@ -66,7 +66,7 @@
|
||||||
</mat-expansion-panel>
|
</mat-expansion-panel>
|
||||||
|
|
||||||
<mat-expansion-panel
|
<mat-expansion-panel
|
||||||
*ngIf="authenticationService.isAuthorized(['manager'])"
|
*ngIf="authenticationService.isAuthorized(['manager']) | async"
|
||||||
>
|
>
|
||||||
<mat-expansion-panel-header>
|
<mat-expansion-panel-header>
|
||||||
<mat-panel-title>
|
<mat-panel-title>
|
||||||
|
@ -87,7 +87,7 @@
|
||||||
</mat-list-item>
|
</mat-list-item>
|
||||||
|
|
||||||
<mat-list-item class='root'
|
<mat-list-item class='root'
|
||||||
*ngIf="authenticationService.isAuthorized(['manager'])"
|
*ngIf="authenticationService.isAuthorized(['manager']) | async"
|
||||||
>
|
>
|
||||||
<button mat-button
|
<button mat-button
|
||||||
routerLink="/admin/manage/access"
|
routerLink="/admin/manage/access"
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
*ngFor="let item of menuItem.pages"
|
*ngFor="let item of menuItem.pages"
|
||||||
>
|
>
|
||||||
<button mat-button
|
<button mat-button
|
||||||
[hidden]="isHidden(item) | async"
|
[hidden]="authenticationService.isNotAuthorized([item.viewable_role]) | async"
|
||||||
matTooltip="{{ item.description }}"
|
matTooltip="{{ item.description }}"
|
||||||
matTooltipPosition="right"
|
matTooltipPosition="right"
|
||||||
routerLink="/dashboard/{{ item.group }}/{{ item.name }}"
|
routerLink="/dashboard/{{ item.group }}/{{ item.name }}"
|
||||||
|
|
|
@ -29,10 +29,4 @@ export class DashboardMenuComponent implements OnInit {
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
isHidden(dashboard: DashboardPageMetaData): Observable<boolean> {
|
|
||||||
return this.authenticationService.isAuthorized([dashboard.viewable_role]).pipe(map(
|
|
||||||
r => !r
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<button mat-raised-button color='primary' [hidden]='!isAuthorized'
|
<button mat-raised-button color='primary'
|
||||||
|
[hidden]='authenticationService.isNotAuthorized(action.roles) | async'
|
||||||
(click)="execute()">
|
(click)="execute()">
|
||||||
<mat-icon aria-label="submit">done</mat-icon>
|
<mat-icon aria-label="submit">done</mat-icon>
|
||||||
{{ action.name }}
|
{{ action.name }}
|
||||||
|
|
|
@ -22,16 +22,11 @@ export class TagActionComponent {
|
||||||
private actionsService: ActionsService,
|
private actionsService: ActionsService,
|
||||||
private infoDataService: InfoDataService,
|
private infoDataService: InfoDataService,
|
||||||
private snackBar: MatSnackBar,
|
private snackBar: MatSnackBar,
|
||||||
private authenticationService: AuthenticationService,
|
public authenticationService: AuthenticationService,
|
||||||
protected mapControlService: MapControlService,
|
protected mapControlService: MapControlService,
|
||||||
private cdr: ChangeDetectorRef,
|
private cdr: ChangeDetectorRef,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
get isAuthorized() {
|
|
||||||
// At least one role of the user must match the roles of the action
|
|
||||||
return this.authenticationService.roles.filter(r => this.action.roles.indexOf(r.name) != -1).length > 0
|
|
||||||
}
|
|
||||||
|
|
||||||
execute() {
|
execute() {
|
||||||
this.actionsService.execute(
|
this.actionsService.execute(
|
||||||
[this.source.modelInfo.store],
|
[this.source.modelInfo.store],
|
||||||
|
|
|
@ -102,6 +102,7 @@ export class TagFormComponent implements OnInit {
|
||||||
)) {
|
)) {
|
||||||
for (let tagKey of store.tagActions) {
|
for (let tagKey of store.tagActions) {
|
||||||
if (tagKey.actions.map(
|
if (tagKey.actions.map(
|
||||||
|
// FIXME: isAuthorized is async!!
|
||||||
action => this.authenticationService.isAuthorized(action.roles)
|
action => this.authenticationService.isAuthorized(action.roles)
|
||||||
).filter(i => i).length > 0) {
|
).filter(i => i).length > 0) {
|
||||||
this.pluginsFormGroup.addControl(
|
this.pluginsFormGroup.addControl(
|
||||||
|
|
|
@ -30,7 +30,7 @@ export class ToolsComponent {
|
||||||
private infoDataService: InfoDataService,
|
private infoDataService: InfoDataService,
|
||||||
private actionsService: ActionsService,
|
private actionsService: ActionsService,
|
||||||
private snackBar: MatSnackBar,
|
private snackBar: MatSnackBar,
|
||||||
private authenticationService: AuthenticationService
|
public authenticationService: AuthenticationService
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,10 +65,6 @@ export class ToolsComponent {
|
||||||
return formFields
|
return formFields
|
||||||
}
|
}
|
||||||
|
|
||||||
get isAuthorized() {
|
|
||||||
return this.authenticationService.user.value
|
|
||||||
}
|
|
||||||
|
|
||||||
executeAction(action: ModelAction, fullInfo: FullInfo) {
|
executeAction(action: ModelAction, fullInfo: FullInfo) {
|
||||||
this.actionsService.execute(
|
this.actionsService.execute(
|
||||||
[fullInfo.modelInfo.store],
|
[fullInfo.modelInfo.store],
|
||||||
|
|
|
@ -162,7 +162,7 @@
|
||||||
Download Shapefiles of selected layers (EPSG {{ (configService.conf | async).bsData?.geo.srid }}) [<i><b>Deprecated</b>: use Geopackage</i>]
|
Download Shapefiles of selected layers (EPSG {{ (configService.conf | async).bsData?.geo.srid }}) [<i><b>Deprecated</b>: use Geopackage</i>]
|
||||||
</button>
|
</button>
|
||||||
</mat-menu>
|
</mat-menu>
|
||||||
<button mat-raised-button [disabled]="!(authenticationService.isAuthorized(['base_map_creator']) | async)"
|
<button mat-raised-button [disabled]="authenticationService.isNotAuthorized(['base_map_creator']) | async"
|
||||||
matTooltip="Create a base map with the selected layers"
|
matTooltip="Create a base map with the selected layers"
|
||||||
(click)="createBaseMap()">
|
(click)="createBaseMap()">
|
||||||
Create a base map...
|
Create a base map...
|
||||||
|
|
|
@ -24,7 +24,7 @@ export class TreeLayerItemComponent implements OnInit {
|
||||||
constructor(
|
constructor(
|
||||||
protected mapControlService: MapControlService,
|
protected mapControlService: MapControlService,
|
||||||
private cdr: ChangeDetectorRef,
|
private cdr: ChangeDetectorRef,
|
||||||
private authenticationService: AuthenticationService,
|
public authenticationService: AuthenticationService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
@ -42,9 +42,7 @@ export class TreeLayerItemComponent implements OnInit {
|
||||||
return of(false)
|
return of(false)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return this.authenticationService.isAuthorized([role]).pipe(map(
|
return this.authenticationService.isNotAuthorized([role])
|
||||||
a => !a
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ export type OpenAPIConfig = {
|
||||||
|
|
||||||
export const OpenAPI: OpenAPIConfig = {
|
export const OpenAPI: OpenAPIConfig = {
|
||||||
BASE: '',
|
BASE: '',
|
||||||
VERSION: '2023.4.dev53+gd539a72.d20240320',
|
VERSION: '2023.4.dev56+g775030d.d20240325',
|
||||||
WITH_CREDENTIALS: false,
|
WITH_CREDENTIALS: false,
|
||||||
CREDENTIALS: 'include',
|
CREDENTIALS: 'include',
|
||||||
TOKEN: undefined,
|
TOKEN: undefined,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue