Admin basket: update/fix file import
remove useless AdminBasketFile model definition cleanups, typings
This commit is contained in:
parent
f442272898
commit
b6496f9dba
7 changed files with 109 additions and 178 deletions
src/app
|
@ -1,9 +1,7 @@
|
||||||
import { Component, OnInit, Input,
|
import { Component, Input,
|
||||||
ChangeDetectorRef, ChangeDetectionStrategy } from '@angular/core'
|
ChangeDetectorRef, ChangeDetectionStrategy } from '@angular/core'
|
||||||
import { ActivatedRoute } from '@angular/router'
|
|
||||||
|
|
||||||
import { AdminDataService } from '../../admin-data.service'
|
import { FileImport } from '../../../openapi'
|
||||||
import { AdminBasketFile } from '../data.service'
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'gisaf-admin-basket-item',
|
selector: 'gisaf-admin-basket-item',
|
||||||
|
@ -11,15 +9,10 @@ import { AdminBasketFile } from '../data.service'
|
||||||
styleUrls: ['./basket-item.component.css'],
|
styleUrls: ['./basket-item.component.css'],
|
||||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
})
|
})
|
||||||
export class AdminBasketItemComponent implements OnInit {
|
export class AdminBasketItemComponent {
|
||||||
constructor(
|
constructor(
|
||||||
public adminDataService: AdminDataService,
|
|
||||||
private route: ActivatedRoute,
|
|
||||||
private cdr: ChangeDetectorRef,
|
private cdr: ChangeDetectorRef,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@Input() file: AdminBasketFile
|
@Input() file: FileImport
|
||||||
|
|
||||||
ngOnInit() {
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -1,13 +1,11 @@
|
||||||
import { Component, OnInit, Input, ViewChild, ElementRef,
|
import { Component, OnInit, Input, ViewChild, ElementRef,
|
||||||
ChangeDetectorRef, ChangeDetectionStrategy, SimpleChanges, OnChanges } from '@angular/core'
|
ChangeDetectorRef, ChangeDetectionStrategy, SimpleChanges, OnChanges } from '@angular/core'
|
||||||
import { HttpClient } from '@angular/common/http'
|
|
||||||
import { FormGroup, Validators, FormControl } from '@angular/forms'
|
import { FormGroup, Validators, FormControl } from '@angular/forms'
|
||||||
|
|
||||||
import { MatTableDataSource } from '@angular/material/table'
|
import { MatTableDataSource } from '@angular/material/table'
|
||||||
|
|
||||||
import { AdminDataService } from '../../admin-data.service'
|
import { AdminDataService } from '../../admin-data.service'
|
||||||
import { AdminBasketFile } from '../data.service'
|
import { AdminBasket, AdminService, FileImport } from '../../../openapi'
|
||||||
import { AdminBasket, AdminService } from '../../../openapi'
|
|
||||||
import { MatSnackBar } from '@angular/material/snack-bar'
|
import { MatSnackBar } from '@angular/material/snack-bar'
|
||||||
import { HtmlSnackbarComponent } from '../../../custom-snackbar/custom-snackbar.component'
|
import { HtmlSnackbarComponent } from '../../../custom-snackbar/custom-snackbar.component'
|
||||||
|
|
||||||
|
@ -21,7 +19,6 @@ export class AdminBasketUploadComponent implements OnInit, OnChanges {
|
||||||
constructor(
|
constructor(
|
||||||
public adminDataService: AdminDataService,
|
public adminDataService: AdminDataService,
|
||||||
private cdr: ChangeDetectorRef,
|
private cdr: ChangeDetectorRef,
|
||||||
private http: HttpClient,
|
|
||||||
private snackBar: MatSnackBar,
|
private snackBar: MatSnackBar,
|
||||||
public adminService: AdminService,
|
public adminService: AdminService,
|
||||||
) {}
|
) {}
|
||||||
|
@ -81,33 +78,17 @@ export class AdminBasketUploadComponent implements OnInit, OnChanges {
|
||||||
}
|
}
|
||||||
}).subscribe(
|
}).subscribe(
|
||||||
resp => {
|
resp => {
|
||||||
let importResult = resp['import_result']
|
this.dataSource.data.push(resp.fileImport)
|
||||||
const importTime = resp['time'] || (importResult && importResult['time'])
|
|
||||||
const fileImport = new AdminBasketFile(
|
|
||||||
resp['id'],
|
|
||||||
resp['dir'],
|
|
||||||
resp['name'],
|
|
||||||
resp['url'],
|
|
||||||
resp['md5'],
|
|
||||||
importTime && new Date(importTime),
|
|
||||||
resp['comment'],
|
|
||||||
resp['status'],
|
|
||||||
resp['store'],
|
|
||||||
resp['project'],
|
|
||||||
resp['surveyor'],
|
|
||||||
resp['equipment'],
|
|
||||||
)
|
|
||||||
this.dataSource.data.push(fileImport)
|
|
||||||
this.dataSource.data = this.dataSource.data
|
this.dataSource.data = this.dataSource.data
|
||||||
let msg = 'File ' + fileImport.name + ' added to basket'
|
if (resp.details) {
|
||||||
if (importResult) {
|
|
||||||
this.snackBar.openFromComponent(HtmlSnackbarComponent, {
|
this.snackBar.openFromComponent(HtmlSnackbarComponent, {
|
||||||
data: importResult
|
data: resp.details
|
||||||
//duration: 3000
|
//duration: 3000
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
let msg = 'File ' + resp.fileImport.name + ' added to basket'
|
||||||
this.snackBar.open(msg, 'Close')
|
this.snackBar.open(msg, 'Close')
|
||||||
}
|
}
|
||||||
this.cdr.markForCheck()
|
this.cdr.markForCheck()
|
||||||
|
|
|
@ -10,8 +10,7 @@ import { MatSort } from '@angular/material/sort'
|
||||||
import { MatTableDataSource } from '@angular/material/table'
|
import { MatTableDataSource } from '@angular/material/table'
|
||||||
|
|
||||||
import { AdminDataService } from '../admin-data.service'
|
import { AdminDataService } from '../admin-data.service'
|
||||||
import { AdminBasketFile } from './data.service'
|
import { AdminBasket, AdminService, FileImport } from '../../openapi'
|
||||||
import { AdminBasket, AdminService } from '../../openapi'
|
|
||||||
import { HtmlSnackbarComponent } from '../../custom-snackbar/custom-snackbar.component'
|
import { HtmlSnackbarComponent } from '../../custom-snackbar/custom-snackbar.component'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -73,11 +72,11 @@ export class AdminBasketComponent implements OnInit {
|
||||||
this.dataSource.filter = this.filterText.trim().toLowerCase()
|
this.dataSource.filter = this.filterText.trim().toLowerCase()
|
||||||
}
|
}
|
||||||
|
|
||||||
download(item: AdminBasketFile) {
|
download(item: FileImport) {
|
||||||
window.open('/api/admin/basket/download/' + 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: FileImport, dryRun: boolean) {
|
||||||
return this.adminService.importBasketFileApiAdminBasketImportBasketFileIdGet({
|
return this.adminService.importBasketFileApiAdminBasketImportBasketFileIdGet({
|
||||||
basket: this.basket.name,
|
basket: this.basket.name,
|
||||||
fileId: item.id,
|
fileId: item.id,
|
||||||
|
@ -94,7 +93,7 @@ export class AdminBasketComponent implements OnInit {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteItem(item: AdminBasketFile) {
|
deleteItem(item: FileImport) {
|
||||||
return this.adminService.deleteBasketFileApiAdminBasketDeleteBasketFileIdGet({
|
return this.adminService.deleteBasketFileApiAdminBasketDeleteBasketFileIdGet({
|
||||||
basket: this.basket.name,
|
basket: this.basket.name,
|
||||||
fileId: item.id
|
fileId: item.id
|
||||||
|
|
|
@ -1,38 +0,0 @@
|
||||||
import { Injectable } from '@angular/core'
|
|
||||||
|
|
||||||
import { Observable, of as observableOf } from 'rxjs'
|
|
||||||
import { map } from 'rxjs/operators'
|
|
||||||
|
|
||||||
// import { Apollo, gql } from 'apollo-angular'
|
|
||||||
|
|
||||||
import { AdminService, AdminBasket, BasketNameOnly, Project,
|
|
||||||
BasketImportResult
|
|
||||||
} from '../../openapi'
|
|
||||||
|
|
||||||
export class AdminBasketFile {
|
|
||||||
constructor(
|
|
||||||
public id: number,
|
|
||||||
public dir: string,
|
|
||||||
public name: string,
|
|
||||||
public url: string,
|
|
||||||
public md5: string,
|
|
||||||
public time: Date,
|
|
||||||
public comment: string,
|
|
||||||
public status: string,
|
|
||||||
public store: string,
|
|
||||||
public project: string,
|
|
||||||
public surveyor: string,
|
|
||||||
public equipment: string,
|
|
||||||
public import_result?: string,
|
|
||||||
) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class AdminBasketUploadFieldData {
|
|
||||||
constructor(
|
|
||||||
public stores: string[],
|
|
||||||
public statuses: string[],
|
|
||||||
public projects: string[],
|
|
||||||
public surveyors: string[],
|
|
||||||
public equipments: string[],
|
|
||||||
) {}
|
|
||||||
}
|
|
|
@ -196,67 +196,6 @@ export const $AdminBasket = {
|
||||||
title: 'AdminBasket'
|
title: 'AdminBasket'
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
export const $AdminBasketFile = {
|
|
||||||
properties: {
|
|
||||||
id: {
|
|
||||||
type: 'integer',
|
|
||||||
title: 'Id'
|
|
||||||
},
|
|
||||||
dir: {
|
|
||||||
type: 'string',
|
|
||||||
title: 'Dir'
|
|
||||||
},
|
|
||||||
name: {
|
|
||||||
type: 'string',
|
|
||||||
title: 'Name'
|
|
||||||
},
|
|
||||||
url: {
|
|
||||||
type: 'string',
|
|
||||||
title: 'Url'
|
|
||||||
},
|
|
||||||
md5: {
|
|
||||||
type: 'string',
|
|
||||||
title: 'Md5'
|
|
||||||
},
|
|
||||||
time: {
|
|
||||||
type: 'string',
|
|
||||||
format: 'date-time',
|
|
||||||
title: 'Time'
|
|
||||||
},
|
|
||||||
comment: {
|
|
||||||
type: 'string',
|
|
||||||
title: 'Comment'
|
|
||||||
},
|
|
||||||
status: {
|
|
||||||
type: 'string',
|
|
||||||
title: 'Status'
|
|
||||||
},
|
|
||||||
store: {
|
|
||||||
type: 'string',
|
|
||||||
title: 'Store'
|
|
||||||
},
|
|
||||||
project: {
|
|
||||||
type: 'string',
|
|
||||||
title: 'Project'
|
|
||||||
},
|
|
||||||
surveyor: {
|
|
||||||
type: 'string',
|
|
||||||
title: 'Surveyor'
|
|
||||||
},
|
|
||||||
equipment: {
|
|
||||||
type: 'string',
|
|
||||||
title: 'Equipment'
|
|
||||||
},
|
|
||||||
import_result: {
|
|
||||||
type: 'string',
|
|
||||||
title: 'Import Result'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
type: 'object',
|
|
||||||
required: ['id', 'dir', 'name', 'url', 'md5', 'time', 'comment', 'status', 'store', 'project', 'surveyor', 'equipment', 'import_result'],
|
|
||||||
title: 'AdminBasketFile'
|
|
||||||
} as const;
|
|
||||||
|
|
||||||
export const $Attachment = {
|
export const $Attachment = {
|
||||||
properties: {
|
properties: {
|
||||||
name: {
|
name: {
|
||||||
|
@ -386,7 +325,14 @@ export const $BasketImportResult = {
|
||||||
title: 'Time'
|
title: 'Time'
|
||||||
},
|
},
|
||||||
message: {
|
message: {
|
||||||
type: 'string',
|
anyOf: [
|
||||||
|
{
|
||||||
|
type: 'string'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'null'
|
||||||
|
}
|
||||||
|
],
|
||||||
title: 'Message'
|
title: 'Message'
|
||||||
},
|
},
|
||||||
details: {
|
details: {
|
||||||
|
@ -415,10 +361,19 @@ export const $BasketImportResult = {
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
title: 'Details'
|
title: 'Details'
|
||||||
|
},
|
||||||
|
fileImport: {
|
||||||
|
anyOf: [
|
||||||
|
{
|
||||||
|
'$ref': '#/components/schemas/FileImport'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'null'
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
type: 'object',
|
type: 'object',
|
||||||
required: ['message'],
|
|
||||||
title: 'BasketImportResult'
|
title: 'BasketImportResult'
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
@ -1313,7 +1268,14 @@ export const $FileImport = {
|
||||||
title: 'Id'
|
title: 'Id'
|
||||||
},
|
},
|
||||||
url: {
|
url: {
|
||||||
type: 'string',
|
anyOf: [
|
||||||
|
{
|
||||||
|
type: 'string'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'null'
|
||||||
|
}
|
||||||
|
],
|
||||||
title: 'Url'
|
title: 'Url'
|
||||||
},
|
},
|
||||||
dir: {
|
dir: {
|
||||||
|
@ -1329,20 +1291,48 @@ export const $FileImport = {
|
||||||
title: 'Md5'
|
title: 'Md5'
|
||||||
},
|
},
|
||||||
time: {
|
time: {
|
||||||
type: 'string',
|
anyOf: [
|
||||||
format: 'date-time',
|
{
|
||||||
|
type: 'string',
|
||||||
|
format: 'date-time'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'null'
|
||||||
|
}
|
||||||
|
],
|
||||||
title: 'Time'
|
title: 'Time'
|
||||||
},
|
},
|
||||||
comment: {
|
comment: {
|
||||||
type: 'string',
|
anyOf: [
|
||||||
|
{
|
||||||
|
type: 'string'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'null'
|
||||||
|
}
|
||||||
|
],
|
||||||
title: 'Comment'
|
title: 'Comment'
|
||||||
},
|
},
|
||||||
status: {
|
status: {
|
||||||
type: 'string',
|
anyOf: [
|
||||||
|
{
|
||||||
|
type: 'string'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'null'
|
||||||
|
}
|
||||||
|
],
|
||||||
title: 'Status'
|
title: 'Status'
|
||||||
},
|
},
|
||||||
store: {
|
store: {
|
||||||
type: 'string',
|
anyOf: [
|
||||||
|
{
|
||||||
|
type: 'string'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'null'
|
||||||
|
}
|
||||||
|
],
|
||||||
title: 'Store'
|
title: 'Store'
|
||||||
},
|
},
|
||||||
basket: {
|
basket: {
|
||||||
|
@ -1350,15 +1340,36 @@ export const $FileImport = {
|
||||||
title: 'Basket'
|
title: 'Basket'
|
||||||
},
|
},
|
||||||
project_id: {
|
project_id: {
|
||||||
type: 'integer',
|
anyOf: [
|
||||||
|
{
|
||||||
|
type: 'integer'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'null'
|
||||||
|
}
|
||||||
|
],
|
||||||
title: 'Project Id'
|
title: 'Project Id'
|
||||||
},
|
},
|
||||||
surveyor_id: {
|
surveyor_id: {
|
||||||
type: 'integer',
|
anyOf: [
|
||||||
|
{
|
||||||
|
type: 'integer'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'null'
|
||||||
|
}
|
||||||
|
],
|
||||||
title: 'Surveyor Id'
|
title: 'Surveyor Id'
|
||||||
},
|
},
|
||||||
equipment_id: {
|
equipment_id: {
|
||||||
type: 'integer',
|
anyOf: [
|
||||||
|
{
|
||||||
|
type: 'integer'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'null'
|
||||||
|
}
|
||||||
|
],
|
||||||
title: 'Equipment Id'
|
title: 'Equipment Id'
|
||||||
},
|
},
|
||||||
path: {
|
path: {
|
||||||
|
@ -1369,7 +1380,7 @@ export const $FileImport = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
type: 'object',
|
type: 'object',
|
||||||
required: ['url', 'dir', 'name', 'md5', 'time', 'comment', 'status', 'store', 'basket', 'project_id', 'surveyor_id', 'equipment_id', 'path'],
|
required: ['dir', 'name', 'md5', 'basket', 'project_id', 'surveyor_id', 'equipment_id', 'path'],
|
||||||
title: 'FileImport',
|
title: 'FileImport',
|
||||||
description: `Files to import or imported in the DB.
|
description: `Files to import or imported in the DB.
|
||||||
Give either url or path.`
|
Give either url or path.`
|
||||||
|
|
|
@ -433,7 +433,7 @@ export class AdminService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Upload Basket File
|
* Upload Basket File
|
||||||
* @returns AdminBasketFile Successful Response
|
* @returns BasketImportResult Successful Response
|
||||||
* @throws ApiError
|
* @throws ApiError
|
||||||
*/
|
*/
|
||||||
public uploadBasketFileApiAdminBasketUploadNamePost(data: $OpenApiTs['/api/admin/basket/upload/{name}']['post']['req']): Observable<$OpenApiTs['/api/admin/basket/upload/{name}']['post']['res'][200]> {
|
public uploadBasketFileApiAdminBasketUploadNamePost(data: $OpenApiTs['/api/admin/basket/upload/{name}']['post']['req']): Observable<$OpenApiTs['/api/admin/basket/upload/{name}']['post']['res'][200]> {
|
||||||
|
|
|
@ -42,22 +42,6 @@ export type AdminBasket = {
|
||||||
projects?: Array<Project>;
|
projects?: Array<Project>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type AdminBasketFile = {
|
|
||||||
id: number;
|
|
||||||
dir: string;
|
|
||||||
name: string;
|
|
||||||
url: string;
|
|
||||||
md5: string;
|
|
||||||
time: string;
|
|
||||||
comment: string;
|
|
||||||
status: string;
|
|
||||||
store: string;
|
|
||||||
project: string;
|
|
||||||
surveyor: string;
|
|
||||||
equipment: string;
|
|
||||||
import_result: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type Attachment = {
|
export type Attachment = {
|
||||||
name: string;
|
name: string;
|
||||||
path: string;
|
path: string;
|
||||||
|
@ -89,10 +73,11 @@ export type BasketDefault = {
|
||||||
|
|
||||||
export type BasketImportResult = {
|
export type BasketImportResult = {
|
||||||
time?: string;
|
time?: string;
|
||||||
message: string;
|
message?: string | null;
|
||||||
details?: {
|
details?: {
|
||||||
[key: string]: (string | number | boolean);
|
[key: string]: (string | number | boolean);
|
||||||
} | null;
|
} | null;
|
||||||
|
fileImport?: FileImport | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type BasketNameOnly = {
|
export type BasketNameOnly = {
|
||||||
|
@ -263,18 +248,18 @@ export type FeatureInfo = {
|
||||||
*/
|
*/
|
||||||
export type FileImport = {
|
export type FileImport = {
|
||||||
id?: number | null;
|
id?: number | null;
|
||||||
url: string;
|
url?: string | null;
|
||||||
dir: string;
|
dir: string;
|
||||||
name: string;
|
name: string;
|
||||||
md5: string;
|
md5: string;
|
||||||
time: string;
|
time?: string | null;
|
||||||
comment: string;
|
comment?: string | null;
|
||||||
status: string;
|
status?: string | null;
|
||||||
store: string;
|
store?: string | null;
|
||||||
basket: string;
|
basket: string;
|
||||||
project_id: number;
|
project_id: number | null;
|
||||||
surveyor_id: number;
|
surveyor_id: number | null;
|
||||||
equipment_id: number;
|
equipment_id: number | null;
|
||||||
readonly path: string;
|
readonly path: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -848,7 +833,7 @@ export type $OpenApiTs = {
|
||||||
/**
|
/**
|
||||||
* Successful Response
|
* Successful Response
|
||||||
*/
|
*/
|
||||||
200: AdminBasketFile;
|
200: BasketImportResult;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue