Update tag actions (WIP)

This commit is contained in:
phil 2024-03-30 20:45:09 +05:30
parent 61f0175957
commit a0dee656d4
17 changed files with 195 additions and 30 deletions

View file

@ -7,6 +7,7 @@ import { map } from 'rxjs/operators'
import { Tag } from '../info/info-tags/tags.service'
import { TaggedLayer, TaggedFeature, FormFieldInput } from '../info/info-data.service'
import { ApiService, ActionsStore, ActionResults } from '../openapi'
export class ActionParam {
constructor(
@ -24,12 +25,12 @@ export class Action {
) {}
}
export class ActionsStore {
constructor(
public store: string,
public actions: Action[],
) {}
}
// export class ActionsStore {
// constructor(
// public store: string,
// public actions: Action[],
// ) {}
// }
export class ActionResult {
constructor(
@ -39,13 +40,13 @@ export class ActionResult {
) {}
}
export class ActionResults {
constructor(
public name: string,
public message: string,
public actionResults: ActionResult[],
) {}
}
// export class ActionResults {
// constructor(
// public name: string,
// public message: string,
// public actionResults: ActionResult[],
// ) {}
// }
export class ActionsResults {
constructor(
@ -137,7 +138,7 @@ export class ActionsService {
public actionsProviderService$ = this.actionsProviderService.asObservable()
constructor(
// private apollo: Apollo,
private apiService: ApiService,
) {
this.getTagsActionsStores().subscribe(
actionsStores => {
@ -147,8 +148,7 @@ export class ActionsService {
}
public getTagsActionsStores(): Observable<ActionsStore[]> {
console.warn('Migrate Graphql')
return observableOf()
return this.apiService.getActionsApiActionsGet()
// return this.apollo.query({
// query: getTagsActionsQuery,
// }).pipe(map(
@ -183,18 +183,14 @@ export class ActionsService {
actionNames: string[],
params: ActionParam[],
formFields?: FormFieldInput[]
): Observable<ActionsResults> {
console.warn('Migrate Graphql')
return observableOf()
// return this.apollo.mutate({
// mutation: executeTagsActionsQuery,
// variables: {
// stores: stores,
// ids: ids,
// names: actionNames,
// params: params,
// formFields: formFields
// }
): Observable<ActionResults> {
return this.apiService.executeTagActionApiExecTagActionActionPost({
"stores": stores,
"ids": ids,
"actionNames": actionNames,
"params": params,
"formFields": formFields
})
// }).pipe(map(
// result => result['data']['executeAction']['result'].map(
// res => new ActionsResults(

View file

@ -1,5 +1,6 @@
<mat-tab-group fxFlexFill>
<mat-tab *ngFor='let action of source.modelInfo.actions'>
<mat-tab *ngFor='let action of source.modelInfo.actions'
[disabled]="authenticationService.isNotAuthorized(action.roles) | async">
<ng-template mat-tab-label>
<mat-icon [matTooltip]="action.name">{{ action.icon }}</mat-icon>
</ng-template>

View file

@ -162,7 +162,7 @@
Download Shapefiles of selected layers (EPSG {{ (configService.conf | async).bsData?.geo.srid }}) [<i><b>Deprecated</b>: use Geopackage</i>]
</button>
</mat-menu>
<button mat-raised-button [disabled]="authenticationService.isNotAuthorized(['base_map_creator']) | async"
<button mat-raised-button [hidden]="authenticationService.isNotAuthorized(['base_map_creator']) | async"
matTooltip="Create a base map with the selected layers"
(click)="createBaseMap()">
Create a base map...

View file

@ -7,12 +7,19 @@ export { CancelablePromise, CancelError } from './core/CancelablePromise';
export { OpenAPI } from './core/OpenAPI';
export type { OpenAPIConfig } from './core/OpenAPI';
export type { Action } from './models/Action';
export type { ActionParam } from './models/ActionParam';
export type { ActionResult } from './models/ActionResult';
export type { ActionResults } from './models/ActionResults';
export type { ActionsResults } from './models/ActionsResults';
export type { ActionsStore } from './models/ActionsStore';
export type { AdminBasket } from './models/AdminBasket';
export type { Attachment } from './models/Attachment';
export type { BaseMapWithStores } from './models/BaseMapWithStores';
export type { BaseStyle } from './models/BaseStyle';
export type { BasketDefault } from './models/BasketDefault';
export type { BasketNameOnly } from './models/BasketNameOnly';
export type { Body_execute_tag_action_api_execTagAction__action__post } from './models/Body_execute_tag_action_api_execTagAction__action__post';
export type { Body_login_for_access_token_api_token_post } from './models/Body_login_for_access_token_api_token_post';
export type { BootstrapData } from './models/BootstrapData';
export type { CategoryGroup } from './models/CategoryGroup';
@ -28,6 +35,7 @@ export type { Equipment } from './models/Equipment';
export type { FeatureInfo } from './models/FeatureInfo';
export type { FileImport } from './models/FileImport';
export type { FormField } from './models/FormField';
export type { FormFieldInput } from './models/FormFieldInput';
export type { Geo } from './models/Geo';
export type { HTTPValidationError } from './models/HTTPValidationError';
export type { InfoCategory } from './models/InfoCategory';
@ -56,6 +64,9 @@ export type { Surveyor } from './models/Surveyor';
export type { Tag } from './models/Tag';
export type { TagAction } from './models/TagAction';
export type { TagActions } from './models/TagActions';
export type { TaggedFeature } from './models/TaggedFeature';
export type { TaggedLayer } from './models/TaggedLayer';
export type { Tags } from './models/Tags';
export type { TileServer } from './models/TileServer';
export type { Token } from './models/Token';
export type { UserRead } from './models/UserRead';

View file

@ -0,0 +1,11 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { ActionParam } from './ActionParam';
export type Action = {
name: string;
roles: Array<string>;
params: Array<ActionParam>;
};

View file

@ -0,0 +1,10 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export type ActionParam = {
name: string;
type: string;
dflt: string;
};

View file

@ -0,0 +1,10 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { TaggedLayer } from './TaggedLayer';
export type ActionResult = {
message?: (string | null);
taggedLayers?: Array<TaggedLayer>;
};

View file

@ -0,0 +1,11 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { ActionResult } from './ActionResult';
export type ActionResults = {
name?: (string | null);
message?: (string | null);
actionResults?: Array<ActionResult>;
};

View file

@ -0,0 +1,10 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { ActionResults } from './ActionResults';
export type ActionsResults = {
message?: (string | null);
actionResults?: Array<ActionResults>;
};

View file

@ -0,0 +1,10 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { Action } from './Action';
export type ActionsStore = {
store: string;
actions: Array<Action>;
};

View file

@ -0,0 +1,14 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { ActionParam } from './ActionParam';
import type { FormFieldInput } from './FormFieldInput';
export type Body_execute_tag_action_api_execTagAction__action__post = {
stores: Array<string>;
ids: Array<Array<string>>;
actionNames: Array<string>;
params: Array<(ActionParam | null)>;
formFields: Array<FormFieldInput>;
};

View file

@ -0,0 +1,9 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export type FormFieldInput = {
name: string;
value: string;
};

View file

@ -6,6 +6,7 @@ import type { FormField } from './FormField';
export type ModelAction = {
name: string;
icon: string;
roles?: (Array<string> | null);
formFields: Array<FormField>;
};

View file

@ -0,0 +1,12 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { Tags } from './Tags';
export type TaggedFeature = {
id: string;
tags: Tags;
lat: number;
lon: number;
};

View file

@ -0,0 +1,10 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { TaggedFeature } from './TaggedFeature';
export type TaggedLayer = {
store: string;
taggedFeatures: Array<TaggedFeature>;
};

View file

@ -0,0 +1,12 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export type Tags = {
id?: (number | null);
geom: string;
store: string;
ref_id: number;
tags: Record<string, any>;
};

View file

@ -5,6 +5,9 @@
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import type { Observable } from 'rxjs';
import type { ActionsResults } from '../models/ActionsResults';
import type { ActionsStore } from '../models/ActionsStore';
import type { Body_execute_tag_action_api_execTagAction__action__post } from '../models/Body_execute_tag_action_api_execTagAction__action__post';
import type { Body_login_for_access_token_api_token_post } from '../models/Body_login_for_access_token_api_token_post';
import type { BootstrapData } from '../models/BootstrapData';
import type { CategoryRead } from '../models/CategoryRead';
@ -335,4 +338,38 @@ export class ApiService {
},
});
}
/**
* Get Actions
* @returns ActionsStore Successful Response
* @throws ApiError
*/
public getActionsApiActionsGet(): Observable<Array<ActionsStore>> {
return __request(OpenAPI, this.http, {
method: 'GET',
url: '/api/actions',
errors: {
404: `Not found`,
},
});
}
/**
* Execute Tag Action
* @param requestBody
* @returns ActionsResults Successful Response
* @throws ApiError
*/
public executeTagActionApiExecTagActionActionPost(
requestBody: Body_execute_tag_action_api_execTagAction__action__post,
): Observable<ActionsResults> {
return __request(OpenAPI, this.http, {
method: 'POST',
url: '/api/execTagAction/{action}',
body: requestBody,
mediaType: 'application/json',
errors: {
404: `Not found`,
422: `Validation Error`,
},
});
}
}