Merge branch 'main' of codeberg.org:Philo/gisaf-app

This commit is contained in:
phil 2024-04-18 15:40:32 +05:30
commit 21c7fb059f
10 changed files with 188 additions and 154 deletions

View file

@ -7,7 +7,7 @@
(input)="applyFilter()"
matTooltip="Filter the items of the basket from the table"
[(ngModel)]="filterText"/>
<button mat-button matSuffix mat-icon-button
<button matSuffix mat-icon-button
*ngIf="filterText"
aria-label="Clear"
(click)="filterText='';applyFilter()"

View file

@ -74,7 +74,7 @@ export class AdminBasketComponent implements OnInit {
}
download(item: AdminBasketFile) {
window.open('/download/basket/' + this.basket.name + '/' + item.id + '/' + item.name)
window.open('/api/admin/basket/download/' + this.basket.name + '/' + item.id + '/' + item.name)
}
importItem(item: AdminBasketFile, dryRun: boolean) {

View file

@ -5,7 +5,9 @@ import { map } from 'rxjs/operators'
// import { Apollo, gql } from 'apollo-angular'
import { AdminService, AdminBasket, BasketNameOnly, Project } from '../../openapi'
import { AdminService, AdminBasket, BasketNameOnly, Project,
BasketImportResult
} from '../../openapi'
export class AdminBasketFile {
constructor(
@ -25,24 +27,6 @@ export class AdminBasketFile {
) {}
}
// export class AdminBasket {
// constructor(
// public name: string,
// public files?: AdminBasketFile[],
// public columns?: string[],
// public uploadFields?: string[],
// public projects?: Project[],
// ) {}
// }
export class BasketImportResult {
constructor(
public time: Date,
public message: string,
public details?: string,
) {}
}
export class AdminBasketUploadFieldData {
constructor(
public stores: string[],
@ -53,71 +37,6 @@ export class AdminBasketUploadFieldData {
) {}
}
// const getAdminBasketsQuery = gql`
// query admin_baskets {
// admin_baskets {
// name
// }
// }
// `
// const getAdminBasketUploadFieldDataQuery = gql`
// query admin_basket_upload_field_data {
// admin_basket_upload_field_data {
// store
// status
// project
// surveyor
// equipment
// }
// }
// `
// const getAdminBasketQuery = gql`
// query admin_basket ($name: String!) {
// admin_basket (name: $name) {
// name
// files {
// id
// name
// dir
// url
// md5
// time
// comment
// status
// store
// project
// surveyor
// equipment
// }
// columns
// uploadFields
// projects
// }
// }
// `
// const deleteAdminBasketItemMutation = gql`
// mutation deleteBasketItem ($basket: String!, $id: Int!) {
// deleteBasketItem (basket: $basket, id: $id) {
// result
// }
// }
// `
// const importAdminBasketItemMutation = gql`
// mutation importBasketItem ($basket: String!, $id: Int!, $dryRun: Boolean) {
// importBasketItem (basket: $basket, id: $id, dryRun: $dryRun) {
// result {
// message
// time
// details
// }
// }
// }
// `
@Injectable()
export class AdminBasketDataService {
constructor(
@ -152,45 +71,14 @@ export class AdminBasketDataService {
getBasket(name: string): Observable<AdminBasket> {
// Get all info and content of a basket
return this.adminService.getBasketApiAdminBasketNameGet({name: name})
console.warn('Migrate Graphql')
return observableOf()
// return this.apollo.query({
// query: getAdminBasketQuery,
// variables: {
// name: name
// }
// }).pipe(map(
// res => {
// let data = res['data']['admin_basket']
// return new AdminBasket(
// data['name'],
// data['files'].map(file => new AdminBasketFile(
// file['id'],
// file['dir'],
// file['name'],
// file['url'],
// file['md5'],
// new Date(file['time']),
// file['comment'],
// file['status'],
// file['store'],
// file['project'],
// file['surveyor'],
// file['equipment'],
// )),
// data['columns'],
// data['uploadFields'],
// // XXX: the proejct id isn't actually used in the UI,
// // but required in class definition
// data['projects'] && data['projects'].map(
// (projectName: string) => new Project(undefined, projectName)
// ),
// )
// }
// ))
}
importItem(basket: string, id: number, dryRun: boolean=false): Observable<BasketImportResult> {
importItem(basket: string, fileId: number, dryRun: boolean=false): Observable<BasketImportResult> {
return this.adminService.importBasketFileApiAdminBasketImportBasketFileIdGet({
basket: basket,
fileId: fileId,
dryRun: dryRun
})
console.warn('Migrate Graphql')
return observableOf()
// return this.apollo.mutate({

View file

@ -1,21 +1,9 @@
import { Injectable, Input } from '@angular/core'
import { Observable, of as observableOf } from 'rxjs'
import { Injectable } from '@angular/core'
import { Observable } from 'rxjs'
import { map } from 'rxjs/operators'
import { Store } from './admin-manage/data.service'
import { ApiService, SurveyMeta, Project, Surveyor, Equipment } from '../openapi'
// const admin_models_menu_bar_query = gql`
// query admin_models_menu_bar {
// admin_models_menu_bar{
// name
// items{
// name
// module
// }
// }
// }`
@Injectable()
export class AdminDataService {
surveyMeta: SurveyMeta
@ -24,20 +12,9 @@ export class AdminDataService {
equipmentMap: Map<number, Equipment>
constructor(
// private apollo: Apollo,
public apiService: ApiService,
) {}
getModelsMenuBar(): Observable<object[]> {
console.warn('Migrate Graphql')
return observableOf()
// return this.apollo.query({
// query: admin_models_menu_bar_query
// }).pipe(map(
// res => res['admin_models_menu_bar_query']
// ))
}
getSurveyMeta(): Observable<SurveyMeta> {
return this.apiService.getSurveyMetaApiSurveyMetaGet().pipe(map(
surveyMeta => {

View file

@ -22,7 +22,6 @@ export class AdminResolver {
return forkJoin([
this.basketDataService.getBaskets(),
this.dataService.getSurveyMeta(),
//this.dataService.getModelsMenuBar(),
])
}
}

View file

@ -22,6 +22,9 @@ export class DownloaderComponent implements OnInit {
}
execute() {
window.open('/downloader/' + this.downloader.name + '/' + this.source.modelInfo.store + '/' + this.source.featureInfo.id)
window.open('/api/download/plugin/'
+ '/' + this.downloader.name
+ '/' + this.source.modelInfo.store
+ '/' + this.source.featureInfo.id)
}
}

View file

@ -50,7 +50,7 @@ export const OpenAPI: OpenAPIConfig = {
RESULT: 'body',
TOKEN: undefined,
USERNAME: undefined,
VERSION: '2023.4.dev56+g775030d.d20240325',
VERSION: '2023.4.dev63+g52e1d21.d20240408',
WITH_CREDENTIALS: false,
interceptors: {response: new Interceptors(),
},

View file

@ -88,6 +88,14 @@ export type BasketDefault = {
export type BasketImportResult = {
time: string;
message: string;
details: string;
};
export type BasketNameOnly = {
name: string;
};
@ -115,6 +123,12 @@ export type Body_login_for_access_token_api_token_post = {
export type Body_upload_basket_file_api_admin_basket_upload__name__post = {
file: Blob | File;
};
export type BootstrapData = {
version?: string;
title?: string;
@ -233,7 +247,7 @@ export type DataProvider = {
export type Downloader = {
roles?: Array<string>;
name: string;
icon?: string | null;
icon: string | null;
};

View file

@ -259,6 +259,24 @@ export const $BasketDefault = {
},
} as const;
export const $BasketImportResult = {
properties: {
time: {
type: 'string',
isRequired: true,
format: 'date-time',
},
message: {
type: 'string',
isRequired: true,
},
details: {
type: 'string',
isRequired: true,
},
},
} as const;
export const $BasketNameOnly = {
properties: {
name: {
@ -358,11 +376,21 @@ export const $Body_login_for_access_token_api_token_post = {
},
} as const;
export const $Body_upload_basket_file_api_admin_basket_upload__name__post = {
properties: {
file: {
type: 'binary',
isRequired: true,
format: 'binary',
},
},
} as const;
export const $BootstrapData = {
properties: {
version: {
type: 'string',
default: '2023.4.dev56+g775030d.d20240325',
default: '2023.4.dev63+g52e1d21.d20240408',
},
title: {
type: 'string',
@ -841,6 +869,7 @@ export const $Downloader = {
}, {
type: 'null',
}],
isRequired: true,
},
},
} as const;

View file

@ -4,7 +4,7 @@ import type { Observable } from 'rxjs';
import { OpenAPI } from './core/OpenAPI';
import { request as __request } from './core/request';
import type { ActionsResults,ActionsStore,Body_execute_tag_action_api_execTagActions_post,Body_login_for_access_token_api_token_post,BootstrapData,CategoryRead,DataProvider,FeatureInfo,MeasuresItem,ModelInfo,PlotParams,Project,RoleRead,Store,SurveyMeta,Token,UserRead,UserRoleLink,AdminBasket,BasketNameOnly,Dashboard,DashboardGroup,DashboardHome,BaseStyle,MapInitData,MaplibreStyle } from './models';
import type { ActionsResults,ActionsStore,Body_execute_tag_action_api_execTagActions_post,Body_login_for_access_token_api_token_post,BootstrapData,CategoryRead,DataProvider,FeatureInfo,MeasuresItem,ModelInfo,PlotParams,Project,RoleRead,Store,SurveyMeta,Token,UserRead,UserRoleLink,AdminBasket,BasketImportResult,BasketNameOnly,Body_upload_basket_file_api_admin_basket_upload__name__post,Dashboard,DashboardGroup,DashboardHome,BaseStyle,MapInitData,MaplibreStyle } from './models';
export type TDataLoginForAccessTokenApiTokenPost = {
formData: Body_login_for_access_token_api_token_post
@ -453,6 +453,23 @@ export type TDataGetBasketApiAdminBasketNameGet = {
name: string
}
export type TDataUploadBasketFileApiAdminBasketUploadNamePost = {
formData: Body_upload_basket_file_api_admin_basket_upload__name__post
name: string
}
export type TDataDownloadBasketFileApiAdminBasketDownloadNameFileIdFileNameGet = {
fileId: number
fileName: string
name: string
}
export type TDataImportBasketFileApiAdminBasketImportBasketFileIdGet = {
basket: string
dryRun?: boolean
fileId: number
}
@Injectable({
providedIn: 'root',
@ -498,6 +515,82 @@ name,
});
}
/**
* Upload Basket File
* @returns unknown Successful Response
* @throws ApiError
*/
public uploadBasketFileApiAdminBasketUploadNamePost(data: TDataUploadBasketFileApiAdminBasketUploadNamePost): Observable<unknown> {
const {
formData,
name,
} = data;
return __request(OpenAPI, this.http, {
method: 'POST',
url: '/api/admin/basket/upload/{name}',
path: {
name
},
formData: formData,
mediaType: 'multipart/form-data',
errors: {
404: `Not found`,
422: `Validation Error`,
},
});
}
/**
* Download Basket File
* @returns unknown Successful Response
* @throws ApiError
*/
public downloadBasketFileApiAdminBasketDownloadNameFileIdFileNameGet(data: TDataDownloadBasketFileApiAdminBasketDownloadNameFileIdFileNameGet): Observable<unknown> {
const {
fileId,
fileName,
name,
} = data;
return __request(OpenAPI, this.http, {
method: 'GET',
url: '/api/admin/basket/download/{name}/{file_id}/{file_name}',
path: {
name, file_id: fileId, file_name: fileName
},
errors: {
404: `Not found`,
422: `Validation Error`,
},
});
}
/**
* Import Basket File
* @returns BasketImportResult Successful Response
* @throws ApiError
*/
public importBasketFileApiAdminBasketImportBasketFileIdGet(data: TDataImportBasketFileApiAdminBasketImportBasketFileIdGet): Observable<BasketImportResult> {
const {
basket,
dryRun = false,
fileId,
} = data;
return __request(OpenAPI, this.http, {
method: 'GET',
url: '/api/admin/basket/import/{basket}/{file_id}',
path: {
basket, file_id: fileId
},
query: {
dryRun
},
errors: {
404: `Not found`,
422: `Validation Error`,
},
});
}
}
export type TDataGetDashboardPageApiDashboardPageGroupNameGet = {
@ -647,6 +740,12 @@ store: string
value: string
}
export type TDataExecuteActionApiDownloadPluginNameStoreIdGet = {
id: number
name: string
store: string
}
@Injectable({
providedIn: 'root',
@ -680,4 +779,29 @@ value,
});
}
/**
* Execute Action
* Download the result of an action
* @returns unknown Successful Response
* @throws ApiError
*/
public executeActionApiDownloadPluginNameStoreIdGet(data: TDataExecuteActionApiDownloadPluginNameStoreIdGet): Observable<unknown> {
const {
id,
name,
store,
} = data;
return __request(OpenAPI, this.http, {
method: 'GET',
url: '/api/download/plugin/{name}/{store}/{id}',
path: {
name, store, id
},
errors: {
404: `Not found`,
422: `Validation Error`,
},
});
}
}