DataSet - createdBy & createdAt
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -10,6 +10,7 @@ export class DataSet extends Base {
|
||||
source?: string;
|
||||
name?: string;
|
||||
dataRows: DataRow[] = [];
|
||||
created?: string;
|
||||
|
||||
constructor(data: Partial<DataSet> = {}) {
|
||||
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<DataRow[]> {
|
||||
static parseGoogleSheet(sheetId: string, _http: HttpClient): Promise<any> {
|
||||
return new Promise((resolve, reject) => {
|
||||
_http.get<DataRow[]>(`${environment.api.url}/datasets/parseGoogleSheet/${sheetId}`,
|
||||
).pipe(map(data => data.map(x => new DataRow().deserialize(x))))
|
||||
_http.get<any>(`${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);
|
||||
|
||||
@@ -1,52 +1,53 @@
|
||||
<div>
|
||||
<form [formGroup]="form" novalidate>
|
||||
<mat-card appearance="outlined">
|
||||
<mat-toolbar color="secondary">
|
||||
Szczegóły warstwy danych
|
||||
<span class="fill-to-right"></span>
|
||||
<button mat-button (click)="export()">Eksportuj do Google</button>
|
||||
</mat-toolbar>
|
||||
<mat-card-content>
|
||||
<mat-grid-list cols="2" rowHeight="90px">
|
||||
<mat-grid-tile>
|
||||
<mat-form-field class="detail-input">
|
||||
<mat-label>Nazwa</mat-label>
|
||||
<input matInput formControlName="name">
|
||||
</mat-form-field>
|
||||
</mat-grid-tile>
|
||||
|
||||
<mat-grid-tile>
|
||||
<mat-form-field class="detail-input">
|
||||
<input matInput formControlName="source">
|
||||
</mat-form-field>
|
||||
</mat-grid-tile>
|
||||
</mat-grid-list>
|
||||
<form [formGroup]="form" novalidate>
|
||||
<mat-card appearance="outlined">
|
||||
<mat-toolbar color="secondary">
|
||||
Szczegóły warstwy danych
|
||||
<span class="fill-to-right"></span>
|
||||
<button mat-button (click)="export()">Eksportuj do Google</button>
|
||||
</mat-toolbar>
|
||||
<mat-card-content>
|
||||
<mat-grid-list cols="2" rowHeight="90px">
|
||||
<mat-grid-tile>
|
||||
<mat-form-field class="detail-input">
|
||||
<mat-label>Nazwa</mat-label>
|
||||
<input matInput formControlName="name">
|
||||
</mat-form-field>
|
||||
</mat-grid-tile>
|
||||
|
||||
<mat-table #table [dataSource]="dataSource" [trackBy]="trackByUid" matSort class="animate">
|
||||
|
||||
<ng-container matColumnDef="code">
|
||||
<mat-header-cell *matHeaderCellDef mat-sort-header>MPK</mat-header-cell>
|
||||
<mat-cell *matCellDef="let item">{{item.code}}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="desc1">
|
||||
<mat-header-cell *matHeaderCellDef mat-sort-header>Konto</mat-header-cell>
|
||||
<mat-cell *matCellDef="let item">{{item.desc1}}</mat-cell>
|
||||
</ng-container>
|
||||
<mat-grid-tile>
|
||||
<mat-form-field class="detail-input">
|
||||
<mat-label>Źródło</mat-label>
|
||||
<input matInput formControlName="source">
|
||||
</mat-form-field>
|
||||
</mat-grid-tile>
|
||||
|
||||
<ng-container matColumnDef="value">
|
||||
<mat-header-cell *matHeaderCellDef mat-sort-header>Wartość</mat-header-cell>
|
||||
<mat-cell *matCellDef="let item" align="right">{{item.value | number:'1.2-2'}}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
|
||||
<mat-row *matRowDef="let item; columns: displayedColumns;"></mat-row>
|
||||
</mat-table>
|
||||
<mat-paginator #paginator
|
||||
[pageSize]="50"
|
||||
[pageSizeOptions]="[5, 10, 20]">
|
||||
</mat-paginator>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
</form>
|
||||
</div>
|
||||
<mat-grid-tile *ngIf="document">
|
||||
<mat-form-field class="detail-input">
|
||||
<mat-label>Utworzono</mat-label>
|
||||
<input matInput disabled [value]="document.created">
|
||||
</mat-form-field>
|
||||
</mat-grid-tile>
|
||||
</mat-grid-list>
|
||||
|
||||
<mat-table #table [dataSource]="dataSource" [trackBy]="trackByUid" matSort class="animate">
|
||||
|
||||
<ng-container matColumnDef="code">
|
||||
<mat-header-cell *matHeaderCellDef mat-sort-header>MPK</mat-header-cell>
|
||||
<mat-cell *matCellDef="let item">{{item.code}}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="value">
|
||||
<mat-header-cell *matHeaderCellDef mat-sort-header>Wartość</mat-header-cell>
|
||||
<mat-cell *matCellDef="let item">{{item.value | number:'1.2-2'}}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
|
||||
<mat-row *matRowDef="let item; columns: displayedColumns;"></mat-row>
|
||||
</mat-table>
|
||||
<mat-paginator #paginator [pageSize]="50" [pageSizeOptions]="[5, 10, 20]">
|
||||
</mat-paginator>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
</form>
|
||||
</div>
|
||||
@@ -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<DataRow>;
|
||||
|
||||
@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<DataSet> {
|
||||
return await DataSet.getById(this.route$.snapshot.paramMap.get('id') || "", this.http$);
|
||||
|
||||
@@ -21,11 +21,8 @@
|
||||
|
||||
<mat-grid-tile>
|
||||
<mat-form-field class="detail-input">
|
||||
<mat-select placeholder="Źródło" formControlName="source" (selectionChange)="generateNumber()">
|
||||
<mat-option value="CSV">CSV</mat-option>
|
||||
<mat-select placeholder="Źródło" formControlName="source">
|
||||
<mat-option value="GoogleSheet">GoogleSheet</mat-option>
|
||||
<mat-option value="SAP">SAP</mat-option>
|
||||
<mat-option value="Symfonia">Symfonia</mat-option>
|
||||
</mat-select>
|
||||
<mat-error *ngIf="form.controls['source'].touched && form.controls['source'].invalid">
|
||||
Pole obowiązkowe
|
||||
|
||||
@@ -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$);
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
<div class="list-header">
|
||||
<mat-grid-list cols="10" rowHeight="60">
|
||||
<mat-grid-tile>
|
||||
<!--
|
||||
<button mat-button routerLink="Edit/new">
|
||||
Dodaj
|
||||
</button>
|
||||
-->
|
||||
</mat-grid-tile>
|
||||
<mat-grid-tile [colspan]="8">
|
||||
<mat-form-field class="searchListInput">
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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 { }
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user