Login fix and rename columns in DB

This commit is contained in:
2022-12-19 18:36:57 +01:00
parent 120abcaf1d
commit db13b1ab1b
18 changed files with 480 additions and 56 deletions

View File

@@ -2,7 +2,7 @@
<form [formGroup]="form" (ngSubmit)="save()" novalidate>
<mat-card appearance="outlined">
<mat-toolbar color="secondary">
Edycja zbioru danych
Edycja warstwy danych
<span class="fill-to-right"></span>
<button mat-button type="submit" [disabled]="form.invalid">Zapisz</button>
<button mat-button type="button" routerLink="../..">Anuluj</button>
@@ -11,9 +11,9 @@
<mat-grid-list cols="2" rowHeight="90px">
<mat-grid-tile>
<mat-form-field class="detail-input">
<mat-label>Numer</mat-label>
<input matInput formControlName="number">
<mat-error *ngIf="form.controls['number'].touched && form.controls['number'].invalid">
<mat-label>Nazwa</mat-label>
<input matInput formControlName="name">
<mat-error *ngIf="form.controls['name'].touched && form.controls['name'].invalid">
Pole obowiązkowe
</mat-error>
</mat-form-field>
@@ -21,19 +21,48 @@
<mat-grid-tile>
<mat-form-field class="detail-input">
<mat-select placeholder="Źródło" formControlName="name" (selectionChange)="generateNumber()">
<mat-option value="Import ręczny">Import ręczny</mat-option>
<mat-option value="Arkusz Google">Arkusz Google</mat-option>
<mat-select placeholder="Źródło" formControlName="source" (selectionChange)="generateNumber()">
<mat-option value="CSV">CSV</mat-option>
<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['name'].touched && form.controls['name'].invalid">
<mat-error *ngIf="form.controls['source'].touched && form.controls['source'].invalid">
Pole obowiązkowe
</mat-error>
</mat-form-field>
</mat-grid-tile>
</mat-grid-list>
<input type="file" class="file-input" (change)="onFileSelected($event)" #fileUpload>
<button mat-mini-fab color="primary" type="button" class="upload-btn" (click)="fileUpload.click()">
<mat-icon>attach_file</mat-icon>
</button>
<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>
<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>

View File

@@ -1 +1,5 @@
@import "../../../main-view/main-view.component.scss";
@import "../../../main-view/main-view.component.scss";
.file-input {
display: none;
}

View File

@@ -1,10 +1,14 @@
import { HttpClient } from '@angular/common/http';
import { Component, OnInit } from '@angular/core';
import { Component, OnInit, ViewChild } from '@angular/core';
import { UntypedFormBuilder, UntypedFormGroup } from '@angular/forms';
import { MatDialog } from '@angular/material/dialog';
import { MatPaginator } from '@angular/material/paginator';
import { MatSort } from '@angular/material/sort';
import { MatTableDataSource } from '@angular/material/table';
import { Router, ActivatedRoute } from '@angular/router';
import moment from 'moment';
import { AuthService } from 'src/app/auth/auth.service';
import { DataRow } from 'src/app/models/dataRow.model copy';
import { DataSet } from 'src/app/models/dataSet.model';
import { DataService } from 'src/app/services/data.service';
import { v4 as uuidv4 } from 'uuid';
@@ -19,6 +23,12 @@ export class DataSetEditComponent implements OnInit {
public form!: UntypedFormGroup;
private document!: DataSet;
displayedColumns = ['code', 'value', 'desc1'];
dataSource!: MatTableDataSource<DataRow>;
@ViewChild(MatPaginator) paginator!: MatPaginator;
@ViewChild(MatSort) sort!: MatSort;
constructor(
private fb$: UntypedFormBuilder,
private router$: Router,
@@ -62,7 +72,17 @@ export class DataSetEditComponent implements OnInit {
}
generateNumber() {
this.form.patchValue({
number: `${this.form.controls['name'].value}-${moment().format("YYYY")}-${moment().format("MM")}`
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$);
this.dataSource = new MatTableDataSource(this.document.dataRows);
this.dataSource.paginator = this.paginator;
this.dataSource.sort = this.sort;
}
trackByUid(index : number, item : DataRow) {
return item.id;
}
}