From 149734cb1956f72d43887c4fa87d4cf0b2d1130c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Zieli=C5=84ski?= Date: Tue, 27 Dec 2022 22:22:21 +0100 Subject: [PATCH] DataSet - createdBy & createdAt --- Frontend/src/app/models/base.model.ts | 4 +- Frontend/src/app/models/dataSet.model.ts | 11 ++- .../data-set-detail.component.html | 99 ++++++++++--------- .../data-set-detail.component.ts | 12 ++- .../data-set-edit.component.html | 5 +- .../data-set-edit/data-set-edit.component.ts | 5 - .../data-sets-list.component.html | 2 + .../data-sets-list.component.ts | 7 +- .../app/modules/data-sets/data-sets.module.ts | 5 +- Frontend/src/environments/environment.ts | 4 +- 10 files changed, 82 insertions(+), 72 deletions(-) diff --git a/Frontend/src/app/models/base.model.ts b/Frontend/src/app/models/base.model.ts index 1318aa1..23331e2 100644 --- a/Frontend/src/app/models/base.model.ts +++ b/Frontend/src/app/models/base.model.ts @@ -19,8 +19,8 @@ export class Base implements Deserializable, Serializable { } deserialize(input: any): this { - if (input.createdAt) { input.createdAt = moment(input.createdAt); } - if (input.modifiedAt) { input.modifiedAt = moment(input.modifiedAt); } + if (input.createdAt) { input.createdAt = moment(input.createdAt).utc(true); } + if (input.modifiedAt) { input.modifiedAt = moment(input.modifiedAt).utc(true); } if (input.createdBy) { input.createdBy = new User(input.createdBy); } if (input.modifiedBy) { input.modifiedBy = new User(input.modifiedBy); } Object.assign(this, input); diff --git a/Frontend/src/app/models/dataSet.model.ts b/Frontend/src/app/models/dataSet.model.ts index eef4740..1216485 100644 --- a/Frontend/src/app/models/dataSet.model.ts +++ b/Frontend/src/app/models/dataSet.model.ts @@ -10,6 +10,7 @@ export class DataSet extends Base { source?: string; name?: string; dataRows: DataRow[] = []; + created?: string; constructor(data: Partial = {}) { super(); @@ -34,6 +35,8 @@ export class DataSet extends Base { modifiedAt: '', createdBy: '', modifiedBy: '', + modified: '', + created: '' }); } fillForm(form: UntypedFormGroup) { @@ -92,10 +95,12 @@ export class DataSet extends Base { }) }) } - static parseGoogleSheet(sheetId: string, _http: HttpClient): Promise { + static parseGoogleSheet(sheetId: string, _http: HttpClient): Promise { return new Promise((resolve, reject) => { - _http.get(`${environment.api.url}/datasets/parseGoogleSheet/${sheetId}`, - ).pipe(map(data => data.map(x => new DataRow().deserialize(x)))) + _http.get(`${environment.api.url}/datasets/parseGoogleSheet/${sheetId}`, + ).pipe(map(data => { + data.dataRows = data.dataRows.map((x: any) => new DataRow().deserialize(x)) + })) .subscribe({ next: (data) => { resolve(data); diff --git a/Frontend/src/app/modules/data-sets/data-set-detail/data-set-detail.component.html b/Frontend/src/app/modules/data-sets/data-set-detail/data-set-detail.component.html index 5fc74ef..766a3cb 100644 --- a/Frontend/src/app/modules/data-sets/data-set-detail/data-set-detail.component.html +++ b/Frontend/src/app/modules/data-sets/data-set-detail/data-set-detail.component.html @@ -1,52 +1,53 @@
-
- - - Szczegóły warstwy danych - - - - - - - - Nazwa - - - - - - - - - - + + + + Szczegóły warstwy danych + + + + + + + + Nazwa + + + - - - - MPK - {{item.code}} - - - - Konto - {{item.desc1}} - + + + Źródło + + + - - Wartość - {{item.value | number:'1.2-2'}} - - - - - - - - - - -
\ No newline at end of file + + + Utworzono + + + + + + + + + MPK + {{item.code}} + + + + Wartość + {{item.value | number:'1.2-2'}} + + + + + + + + + + + \ No newline at end of file diff --git a/Frontend/src/app/modules/data-sets/data-set-detail/data-set-detail.component.ts b/Frontend/src/app/modules/data-sets/data-set-detail/data-set-detail.component.ts index 799e659..e271b68 100644 --- a/Frontend/src/app/modules/data-sets/data-set-detail/data-set-detail.component.ts +++ b/Frontend/src/app/modules/data-sets/data-set-detail/data-set-detail.component.ts @@ -1,10 +1,11 @@ import { DataSource } from '@angular/cdk/collections'; +import { DatePipe, DecimalPipe } from '@angular/common'; import { HttpClient } from '@angular/common/http'; import { Component, ViewChild } from '@angular/core'; import { UntypedFormGroup, UntypedFormBuilder } from '@angular/forms'; import { MatPaginator } from '@angular/material/paginator'; import { MatSnackBar } from '@angular/material/snack-bar'; -import { MatSort } from '@angular/material/sort'; +import { MatSort, MatSortable } from '@angular/material/sort'; import { MatTableDataSource } from '@angular/material/table'; import { Router, ActivatedRoute } from '@angular/router'; import moment from 'moment'; @@ -20,9 +21,9 @@ import { DataSet } from 'src/app/models/dataSet.model'; export class DataSetDetailComponent { public form!: UntypedFormGroup; - private document!: DataSet; + public document!: DataSet; - displayedColumns = ['code', 'value', 'desc1']; + displayedColumns = ['code', 'value']; dataSource!: MatTableDataSource; @ViewChild(MatPaginator) paginator!: MatPaginator; @@ -34,7 +35,8 @@ export class DataSetDetailComponent { private http$: HttpClient, private route$: ActivatedRoute, private auth$: AuthService, - private snackBar: MatSnackBar + private snackBar: MatSnackBar, + private datePipe: DatePipe ) { } async ngOnInit() { @@ -45,6 +47,8 @@ export class DataSetDetailComponent { this.dataSource.sort = this.sort; this.document.fillForm(this.form); this.form.disable(); + this.document.created = `${this.datePipe.transform(this.document.createdAt?.toDate(), 'short')}, ${this.document.createdBy?.userName}`; + this.dataSource.sort.sort({ id: 'code', start: 'desc' } as MatSortable); } private async load(): Promise { return await DataSet.getById(this.route$.snapshot.paramMap.get('id') || "", this.http$); diff --git a/Frontend/src/app/modules/data-sets/data-set-edit/data-set-edit.component.html b/Frontend/src/app/modules/data-sets/data-set-edit/data-set-edit.component.html index 24c61fa..c4be0c6 100644 --- a/Frontend/src/app/modules/data-sets/data-set-edit/data-set-edit.component.html +++ b/Frontend/src/app/modules/data-sets/data-set-edit/data-set-edit.component.html @@ -21,11 +21,8 @@ - - CSV + GoogleSheet - SAP - Symfonia Pole obowiązkowe diff --git a/Frontend/src/app/modules/data-sets/data-set-edit/data-set-edit.component.ts b/Frontend/src/app/modules/data-sets/data-set-edit/data-set-edit.component.ts index d643c60..f81e213 100644 --- a/Frontend/src/app/modules/data-sets/data-set-edit/data-set-edit.component.ts +++ b/Frontend/src/app/modules/data-sets/data-set-edit/data-set-edit.component.ts @@ -53,11 +53,6 @@ export class DataSetEditComponent implements OnInit { const id = await DataSet.add(this.document, this.http$); this.router$.navigate(['../../Detail', id], { relativeTo: this.route$ }); } - generateNumber() { - this.form.patchValue({ - name: `${this.form.controls['source'].value}-${moment().format("YYYY")}${moment().format("MM")}${moment().format("DD")}${moment().format("HH")}${moment().format("mm")}` - }) - } async onFileSelected(event: any) { const file = event.target.files[0]; this.document.dataRows = await DataSet.parseFile(file, this.http$); diff --git a/Frontend/src/app/modules/data-sets/data-sets-list/data-sets-list.component.html b/Frontend/src/app/modules/data-sets/data-sets-list/data-sets-list.component.html index 5a51bc7..a14a79c 100644 --- a/Frontend/src/app/modules/data-sets/data-sets-list/data-sets-list.component.html +++ b/Frontend/src/app/modules/data-sets/data-sets-list/data-sets-list.component.html @@ -2,9 +2,11 @@
+ diff --git a/Frontend/src/app/modules/data-sets/data-sets-list/data-sets-list.component.ts b/Frontend/src/app/modules/data-sets/data-sets-list/data-sets-list.component.ts index 8178d50..d97fa8a 100644 --- a/Frontend/src/app/modules/data-sets/data-sets-list/data-sets-list.component.ts +++ b/Frontend/src/app/modules/data-sets/data-sets-list/data-sets-list.component.ts @@ -1,7 +1,7 @@ import { HttpClient } from '@angular/common/http'; import { Component, OnInit, ViewChild } from '@angular/core'; import { MatPaginator } from '@angular/material/paginator'; -import { MatSort } from '@angular/material/sort'; +import { MatSort, MatSortable } from '@angular/material/sort'; import { MatTableDataSource } from '@angular/material/table'; import { DataSet } from 'src/app/models/dataSet.model'; @@ -19,12 +19,15 @@ export class DataSetsListComponent implements OnInit { constructor( private _http: HttpClient - ) { } + ) { + console.log(Intl.DateTimeFormat().resolvedOptions().timeZone); + } async ngOnInit() { this.dataSource = new MatTableDataSource(await DataSet.getList(this._http)); this.dataSource.paginator = this.paginator; this.dataSource.sort = this.sort; + this.dataSource.sort.sort({ id: 'number', start: 'desc' } as MatSortable); } applyFilter(event: Event) { diff --git a/Frontend/src/app/modules/data-sets/data-sets.module.ts b/Frontend/src/app/modules/data-sets/data-sets.module.ts index 6b13112..96922c8 100644 --- a/Frontend/src/app/modules/data-sets/data-sets.module.ts +++ b/Frontend/src/app/modules/data-sets/data-sets.module.ts @@ -1,5 +1,5 @@ import { NgModule } from '@angular/core'; -import { CommonModule } from '@angular/common'; +import { CommonModule, DatePipe } from '@angular/common'; import { DataSetsRoutingModule } from './data-sets-routing.module'; import { DataSetsListComponent } from './data-sets-list/data-sets-list.component'; import { MaterialModule } from 'src/app/material.module'; @@ -19,6 +19,9 @@ import { FormsModule, ReactiveFormsModule } from '@angular/forms'; MaterialModule, FormsModule, ReactiveFormsModule + ], + providers: [ + DatePipe ] }) export class DataSetsModule { } diff --git a/Frontend/src/environments/environment.ts b/Frontend/src/environments/environment.ts index 06438ce..0b30576 100644 --- a/Frontend/src/environments/environment.ts +++ b/Frontend/src/environments/environment.ts @@ -5,8 +5,8 @@ export const environment = { production: false, api: { - url: "http://localhost:5400/api" - //url: "https://diuna.bim-it.pl/api" + //url: "http://localhost:5400/api" + url: "https://diuna.bim-it.pl/api" }, google: { clientId: "107631825312-bkfe438ehr9k9ecb2h76g802tj6advma.apps.googleusercontent.com"