Admin basket: fix import error message and import date display update
This commit is contained in:
parent
3b59249531
commit
aa955a1b3b
2 changed files with 194 additions and 183 deletions
|
@ -1,5 +1,7 @@
|
|||
import { Component, OnInit, Input, ViewChild, ElementRef,
|
||||
ChangeDetectorRef, ChangeDetectionStrategy } from '@angular/core'
|
||||
import {
|
||||
Component, OnInit, Input, ViewChild, ElementRef,
|
||||
ChangeDetectorRef, ChangeDetectionStrategy
|
||||
} from '@angular/core'
|
||||
import { ActivatedRoute } from '@angular/router'
|
||||
import { UntypedFormGroup, UntypedFormControl } from '@angular/forms'
|
||||
|
||||
|
@ -26,12 +28,12 @@ export class AdminBasketComponent implements OnInit {
|
|||
private snackBar: MatSnackBar,
|
||||
private cdr: ChangeDetectorRef,
|
||||
public adminService: AdminService,
|
||||
) {}
|
||||
) { }
|
||||
|
||||
basket: AdminBasket
|
||||
dataSource: MatTableDataSource<object>
|
||||
@ViewChild(MatPaginator, {static: true}) paginator: MatPaginator
|
||||
@ViewChild(MatSort, {static: true}) sort: MatSort
|
||||
@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator
|
||||
@ViewChild(MatSort, { static: true }) sort: MatSort
|
||||
selection = new SelectionModel(true, [])
|
||||
unlockDeleteFormGroup: UntypedFormGroup = new UntypedFormGroup({})
|
||||
columns: string[] = [
|
||||
|
@ -81,17 +83,24 @@ export class AdminBasketComponent implements OnInit {
|
|||
basket: this.basket.name,
|
||||
fileId: item.id,
|
||||
dryRun: dryRun
|
||||
}).subscribe(
|
||||
resp => {
|
||||
this.basket.files.find(row => row.id == item.id).time = new Date(resp.time).toLocaleString()
|
||||
}).subscribe({
|
||||
next: resp => {
|
||||
this.basket.files.find(row => row.id == item.id).time = new Date(resp.time)
|
||||
this.snackBar.openFromComponent(HtmlSnackbarComponent, {
|
||||
data: resp,
|
||||
//duration: 3000
|
||||
})
|
||||
this.cdr.markForCheck()
|
||||
}
|
||||
},
|
||||
error: err => {
|
||||
this.snackBar.open(
|
||||
`Cannot import: ${err.body['detail'] || err.message || err.statusText}`,
|
||||
'Got it',
|
||||
{ 'politeness': 'assertive' }
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
deleteItem(item: FileImport) {
|
||||
return this.adminService.deleteBasketFileApiAdminBasketDeleteBasketFileIdGet({
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import { Component, Input, ViewChild, OnInit, HostBinding,
|
||||
ChangeDetectorRef, ChangeDetectionStrategy } from '@angular/core'
|
||||
import {
|
||||
Component, Input, ViewChild, OnInit, HostBinding,
|
||||
ChangeDetectorRef, ChangeDetectionStrategy
|
||||
} from '@angular/core'
|
||||
import { ActivatedRoute, ParamMap, Router } from '@angular/router'
|
||||
|
||||
import { SelectionModel } from '@angular/cdk/collections'
|
||||
|
@ -20,7 +22,7 @@ import { ModelDataService, ModelIntrospection, FieldIntrospection } from '../../
|
|||
templateUrl: './admin-list.component.html',
|
||||
styleUrls: ['./admin-list.component.css'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
animations: [ slideInDownAnimation ]
|
||||
animations: [slideInDownAnimation]
|
||||
})
|
||||
export class AdminListComponent implements OnInit {
|
||||
/*
|
||||
|
@ -30,8 +32,8 @@ export class AdminListComponent implements OnInit {
|
|||
*/
|
||||
|
||||
dataSource: MatTableDataSource<object>
|
||||
@ViewChild(MatPaginator, {static: true}) paginator: MatPaginator
|
||||
@ViewChild(MatSort, {static: true}) sort: MatSort
|
||||
@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator
|
||||
@ViewChild(MatSort, { static: true }) sort: MatSort
|
||||
model: ModelIntrospection
|
||||
allColumns: string[] = []
|
||||
pageIndex: number
|
||||
|
@ -44,7 +46,7 @@ export class AdminListComponent implements OnInit {
|
|||
protected dataService: ModelDataService,
|
||||
public snackBar: MatSnackBar,
|
||||
private cdr: ChangeDetectorRef,
|
||||
) {}
|
||||
) { }
|
||||
|
||||
ngOnInit() {
|
||||
this.route.params.subscribe(params => {
|
||||
|
@ -81,7 +83,7 @@ export class AdminListComponent implements OnInit {
|
|||
this.cdr.markForCheck()
|
||||
},
|
||||
error: err => {
|
||||
this.snackBar.open(err, 'close', {duration: 3000})
|
||||
this.snackBar.open(err, 'close', { duration: 3000 })
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue