Admin baskets: fix/update download, get file, import
Cleanups
This commit is contained in:
parent
998efbaf72
commit
846fe6425d
9 changed files with 184 additions and 153 deletions
|
@ -7,7 +7,7 @@
|
||||||
(input)="applyFilter()"
|
(input)="applyFilter()"
|
||||||
matTooltip="Filter the items of the basket from the table"
|
matTooltip="Filter the items of the basket from the table"
|
||||||
[(ngModel)]="filterText"/>
|
[(ngModel)]="filterText"/>
|
||||||
<button mat-button matSuffix mat-icon-button
|
<button matSuffix mat-icon-button
|
||||||
*ngIf="filterText"
|
*ngIf="filterText"
|
||||||
aria-label="Clear"
|
aria-label="Clear"
|
||||||
(click)="filterText='';applyFilter()"
|
(click)="filterText='';applyFilter()"
|
||||||
|
|
|
@ -74,7 +74,7 @@ export class AdminBasketComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
download(item: AdminBasketFile) {
|
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) {
|
importItem(item: AdminBasketFile, dryRun: boolean) {
|
||||||
|
|
|
@ -5,7 +5,9 @@ import { map } from 'rxjs/operators'
|
||||||
|
|
||||||
// import { Apollo, gql } from 'apollo-angular'
|
// import { Apollo, gql } from 'apollo-angular'
|
||||||
|
|
||||||
import { AdminService, AdminBasket, BasketNameOnly, Project } from '../../openapi'
|
import { AdminService, AdminBasket, BasketNameOnly, Project,
|
||||||
|
BasketImportResult
|
||||||
|
} from '../../openapi'
|
||||||
|
|
||||||
export class AdminBasketFile {
|
export class AdminBasketFile {
|
||||||
constructor(
|
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 {
|
export class AdminBasketUploadFieldData {
|
||||||
constructor(
|
constructor(
|
||||||
public stores: string[],
|
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()
|
@Injectable()
|
||||||
export class AdminBasketDataService {
|
export class AdminBasketDataService {
|
||||||
constructor(
|
constructor(
|
||||||
|
@ -152,45 +71,14 @@ export class AdminBasketDataService {
|
||||||
getBasket(name: string): Observable<AdminBasket> {
|
getBasket(name: string): Observable<AdminBasket> {
|
||||||
// Get all info and content of a basket
|
// Get all info and content of a basket
|
||||||
return this.adminService.getBasketApiAdminBasketNameGet({name: name})
|
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')
|
console.warn('Migrate Graphql')
|
||||||
return observableOf()
|
return observableOf()
|
||||||
// return this.apollo.mutate({
|
// return this.apollo.mutate({
|
||||||
|
|
|
@ -1,21 +1,9 @@
|
||||||
import { Injectable, Input } from '@angular/core'
|
import { Injectable } from '@angular/core'
|
||||||
import { Observable, of as observableOf } from 'rxjs'
|
import { Observable } from 'rxjs'
|
||||||
import { map } from 'rxjs/operators'
|
import { map } from 'rxjs/operators'
|
||||||
|
|
||||||
import { Store } from './admin-manage/data.service'
|
|
||||||
import { ApiService, SurveyMeta, Project, Surveyor, Equipment } from '../openapi'
|
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()
|
@Injectable()
|
||||||
export class AdminDataService {
|
export class AdminDataService {
|
||||||
surveyMeta: SurveyMeta
|
surveyMeta: SurveyMeta
|
||||||
|
@ -24,20 +12,9 @@ export class AdminDataService {
|
||||||
equipmentMap: Map<number, Equipment>
|
equipmentMap: Map<number, Equipment>
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
// private apollo: Apollo,
|
|
||||||
public apiService: ApiService,
|
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> {
|
getSurveyMeta(): Observable<SurveyMeta> {
|
||||||
return this.apiService.getSurveyMetaApiSurveyMetaGet().pipe(map(
|
return this.apiService.getSurveyMetaApiSurveyMetaGet().pipe(map(
|
||||||
surveyMeta => {
|
surveyMeta => {
|
||||||
|
|
|
@ -22,7 +22,6 @@ export class AdminResolver {
|
||||||
return forkJoin([
|
return forkJoin([
|
||||||
this.basketDataService.getBaskets(),
|
this.basketDataService.getBaskets(),
|
||||||
this.dataService.getSurveyMeta(),
|
this.dataService.getSurveyMeta(),
|
||||||
//this.dataService.getModelsMenuBar(),
|
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ export const OpenAPI: OpenAPIConfig = {
|
||||||
RESULT: 'body',
|
RESULT: 'body',
|
||||||
TOKEN: undefined,
|
TOKEN: undefined,
|
||||||
USERNAME: undefined,
|
USERNAME: undefined,
|
||||||
VERSION: '2023.4.dev56+g775030d.d20240325',
|
VERSION: '2023.4.dev63+g52e1d21.d20240408',
|
||||||
WITH_CREDENTIALS: false,
|
WITH_CREDENTIALS: false,
|
||||||
interceptors: {response: new Interceptors(),
|
interceptors: {response: new Interceptors(),
|
||||||
},
|
},
|
||||||
|
|
|
@ -88,6 +88,14 @@ export type BasketDefault = {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export type BasketImportResult = {
|
||||||
|
time: string;
|
||||||
|
message: string;
|
||||||
|
details: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export type BasketNameOnly = {
|
export type BasketNameOnly = {
|
||||||
name: string;
|
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 = {
|
export type BootstrapData = {
|
||||||
version?: string;
|
version?: string;
|
||||||
title?: string;
|
title?: string;
|
||||||
|
@ -233,7 +247,7 @@ export type DataProvider = {
|
||||||
export type Downloader = {
|
export type Downloader = {
|
||||||
roles?: Array<string>;
|
roles?: Array<string>;
|
||||||
name: string;
|
name: string;
|
||||||
icon?: string | null;
|
icon: string | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -259,6 +259,24 @@ export const $BasketDefault = {
|
||||||
},
|
},
|
||||||
} as const;
|
} 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 = {
|
export const $BasketNameOnly = {
|
||||||
properties: {
|
properties: {
|
||||||
name: {
|
name: {
|
||||||
|
@ -358,11 +376,21 @@ export const $Body_login_for_access_token_api_token_post = {
|
||||||
},
|
},
|
||||||
} as const;
|
} 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 = {
|
export const $BootstrapData = {
|
||||||
properties: {
|
properties: {
|
||||||
version: {
|
version: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
default: '2023.4.dev56+g775030d.d20240325',
|
default: '2023.4.dev63+g52e1d21.d20240408',
|
||||||
},
|
},
|
||||||
title: {
|
title: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
|
@ -841,6 +869,7 @@ export const $Downloader = {
|
||||||
}, {
|
}, {
|
||||||
type: 'null',
|
type: 'null',
|
||||||
}],
|
}],
|
||||||
|
isRequired: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
|
@ -4,7 +4,7 @@ import type { Observable } from 'rxjs';
|
||||||
import { OpenAPI } from './core/OpenAPI';
|
import { OpenAPI } from './core/OpenAPI';
|
||||||
import { request as __request } from './core/request';
|
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 = {
|
export type TDataLoginForAccessTokenApiTokenPost = {
|
||||||
formData: Body_login_for_access_token_api_token_post
|
formData: Body_login_for_access_token_api_token_post
|
||||||
|
@ -453,6 +453,23 @@ export type TDataGetBasketApiAdminBasketNameGet = {
|
||||||
name: string
|
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({
|
@Injectable({
|
||||||
providedIn: 'root',
|
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 = {
|
export type TDataGetDashboardPageApiDashboardPageGroupNameGet = {
|
||||||
|
@ -647,6 +740,12 @@ store: string
|
||||||
value: string
|
value: string
|
||||||
|
|
||||||
}
|
}
|
||||||
|
export type TDataExecuteActionApiDownloadPluginNameStoreIdGet = {
|
||||||
|
id: number
|
||||||
|
name: string
|
||||||
|
store: string
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
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`,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue