upgrade UI
This commit is contained in:
parent
adf8283ae0
commit
bafef0f6b3
|
|
@ -27,6 +27,7 @@ const LotDb = class
|
|||
|
||||
async post(newDocument)
|
||||
{
|
||||
delete newDocument._id;
|
||||
let result = await this.collection.insertOne(newDocument);
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ const SaleDb = class
|
|||
|
||||
async post(newDocument)
|
||||
{
|
||||
delete newDocument._id;
|
||||
let result = await this.collection.insertOne(newDocument);
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,29 +37,37 @@ export class apiService {
|
|||
return this.http.get<SaleInfo>(this.ApiURL+'/sale/getSaleInfos/'+encodeUrl);
|
||||
}
|
||||
|
||||
prepareSale(saleInfo: SaleInfo): Observable<any> {
|
||||
prepareSale(Sale: Sale): Observable<any> {
|
||||
|
||||
let follow = this.http.get<any>(this.ApiURL+'/sale/prepareSale/'+saleInfo._id);
|
||||
let follow = this.http.get<any>(this.ApiURL+'/sale/prepareSale/'+Sale._id);
|
||||
return follow
|
||||
}
|
||||
|
||||
followSale(saleInfo: SaleInfo): Observable<any> {
|
||||
followSale(Sale: Sale): Observable<any> {
|
||||
|
||||
let follow = this.http.get<any>(this.ApiURL+'/sale/followSale/'+saleInfo._id);
|
||||
let follow = this.http.get<any>(this.ApiURL+'/sale/followSale/'+Sale._id);
|
||||
return follow
|
||||
}
|
||||
|
||||
// CRUD DB Sale
|
||||
resetSaleToReady(_id: String): void {
|
||||
this.getSale(_id).subscribe((sale: Sale) => {
|
||||
sale.status = "ready";
|
||||
this.updateSale(sale).subscribe();
|
||||
});
|
||||
}
|
||||
|
||||
// Sale CRUD
|
||||
|
||||
getSale(_id: String): Observable<Sale> {
|
||||
return this.http.get<Sale>(this.ApiURL+'/sale/sale/'+_id);
|
||||
}
|
||||
|
||||
saveSale(saleInfo: SaleInfo): Observable<SaleInfo> {
|
||||
return this.http.post<SaleInfo>(this.ApiURL+'/sale/sale', saleInfo);
|
||||
saveSale(Sale: Sale): Observable<Sale> {
|
||||
return this.http.post<Sale>(this.ApiURL+'/sale/sale', Sale);
|
||||
}
|
||||
|
||||
updateSale(saleInfo: SaleInfo): Observable<SaleInfo> {
|
||||
return this.http.put<SaleInfo>(this.ApiURL+'/sale/sale/'+saleInfo._id, saleInfo);
|
||||
updateSale(Sale: Sale): Observable<Sale> {
|
||||
return this.http.put<Sale>(this.ApiURL+'/sale/sale/'+Sale._id, Sale);
|
||||
}
|
||||
|
||||
deleteSale(_id: String): Observable<any> {
|
||||
|
|
@ -67,6 +75,7 @@ export class apiService {
|
|||
}
|
||||
|
||||
// Function DB Sale
|
||||
|
||||
|
||||
getAllSale(): Observable<SaleInfo[]> {
|
||||
return this.http.get<SaleInfo[]>(this.ApiURL+'/sale/getAll');
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ import { apiService } from 'src/app/core/services/api.service';
|
|||
|
||||
// Models
|
||||
import { SaleInfo } from 'src/app/core/services/model/saleInfo.interface';
|
||||
import { Sale } from 'src/app/core/services/model/sale.interface';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'loading-sale-dialog-dialog',
|
||||
|
|
@ -56,7 +58,19 @@ export class LoadingSaleDialogComponent implements OnInit {
|
|||
}
|
||||
|
||||
save(): void {
|
||||
this.apiService.saveSale(this.SaleInfo).subscribe( SaleInfo => {
|
||||
const Sale: Sale = {
|
||||
_id: { $oid: '' },
|
||||
idPlatform: this.SaleInfo.idPlatform,
|
||||
platform: this.SaleInfo.platform,
|
||||
url: this.SaleInfo.url,
|
||||
title: this.SaleInfo.title,
|
||||
date: this.SaleInfo.date,
|
||||
location: this.SaleInfo.location,
|
||||
saleHouseName: this.SaleInfo.saleHouseName,
|
||||
status: "ready"
|
||||
}
|
||||
|
||||
this.apiService.saveSale(Sale).subscribe( Sale => {
|
||||
this.dialogRef.close(true);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import { NotificationService } from 'src/app/core/services/notification.service'
|
|||
//Models
|
||||
import { Sale } from 'src/app/core/services/model/sale.interface';
|
||||
import { Lot } from 'src/app/core/services/model/lot.interface';
|
||||
import { SaleInfo } from 'src/app/core/services/model/saleInfo.interface';
|
||||
|
||||
@Component({
|
||||
selector: 'app-favorites-page',
|
||||
|
|
|
|||
|
|
@ -60,34 +60,48 @@
|
|||
<!-- PLateform House Column -->
|
||||
<ng-container matColumnDef="plateform">
|
||||
<th mat-header-cell *matHeaderCellDef> Plateforme </th>
|
||||
<td mat-cell *matCellDef="let element"> Interencheres </td>
|
||||
<td mat-cell *matCellDef="let element"> {{element.platform}} </td>
|
||||
</ng-container>
|
||||
|
||||
<!-- Prepare Column -->
|
||||
<ng-container matColumnDef="prepare">
|
||||
<!-- <ng-container matColumnDef="prepare">
|
||||
<th mat-header-cell *matHeaderCellDef> Prepare </th>
|
||||
<td mat-cell *matCellDef="let element">
|
||||
<button *ngIf="element.status == 'ready'" mat-button (click)="prepareSale(element)"><mat-icon>format_list_numbered</mat-icon></button>
|
||||
</td>
|
||||
</ng-container>
|
||||
</ng-container> -->
|
||||
|
||||
<!-- Follow Column -->
|
||||
<ng-container matColumnDef="follow">
|
||||
<!-- <ng-container matColumnDef="follow">
|
||||
<th mat-header-cell *matHeaderCellDef> Follow </th>
|
||||
<td mat-cell *matCellDef="let element">
|
||||
<button *ngIf="element.status == 'ready'" mat-button (click)="followSale(element)"><mat-icon>play_arrow</mat-icon></button>
|
||||
<button *ngIf="element.status == 'following'" mat-button (click)="stopFollowSale(element)"><mat-icon>stop</mat-icon></button>
|
||||
<div *ngIf="element.status == 'askStop'"><mat-progress-bar mode="indeterminate"></mat-progress-bar></div>
|
||||
</ng-container>
|
||||
</ng-container> -->
|
||||
|
||||
<!-- Delete Column -->
|
||||
<ng-container matColumnDef="delete">
|
||||
<!-- <ng-container matColumnDef="delete">
|
||||
<th mat-header-cell *matHeaderCellDef> Delete </th>
|
||||
<td mat-cell *matCellDef="let element">
|
||||
<button mat-button (click)="deleteSale(element._id)"><mat-icon>delete</mat-icon></button>
|
||||
</td>
|
||||
</ng-container> -->
|
||||
|
||||
<!-- Action Column -->
|
||||
<ng-container matColumnDef="action">
|
||||
<th mat-header-cell *matHeaderCellDef> Action </th>
|
||||
<td mat-cell *matCellDef="let element">
|
||||
<mat-select placeholder="Select action">
|
||||
<mat-option *ngIf="element.status == 'ready'" (click)="prepareSale(element)"><mat-icon>format_list_numbered</mat-icon> Prepare</mat-option>
|
||||
<mat-option *ngIf="element.status == 'ready'" (click)="followSale(element)"><mat-icon>play_arrow</mat-icon> Follow</mat-option>
|
||||
<mat-option *ngIf="element.status == 'following'" (click)="stopFollowSale(element)"><mat-icon>stop</mat-icon> Stop Following</mat-option>
|
||||
<mat-option *ngIf="element.status == 'following'" (click)="resetToReady(element._id)">Reset to Ready</mat-option>
|
||||
<mat-option (click)="deleteSale(element._id)"><mat-icon>delete</mat-icon> Delete</mat-option>
|
||||
</mat-select>
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
|
||||
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
||||
|
||||
|
|
@ -126,7 +140,7 @@
|
|||
<!-- PLateform House Column -->
|
||||
<ng-container matColumnDef="plateform">
|
||||
<th mat-header-cell *matHeaderCellDef> Plateforme </th>
|
||||
<td mat-cell *matCellDef="let element"> Interencheres </td>
|
||||
<td mat-cell *matCellDef="let element"> {{element.platform}} </td>
|
||||
</ng-container>
|
||||
|
||||
<!-- PostProcessing Column -->
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@ import * as moment from 'moment';
|
|||
// Services
|
||||
import { apiService } from 'src/app/core/services/api.service';
|
||||
import { NotificationService } from 'src/app/core/services/notification.service';
|
||||
import { SaleInfo } from 'src/app/core/services/model/saleInfo.interface';
|
||||
|
||||
import { Sale } from 'src/app/core/services/model/sale.interface';
|
||||
|
||||
@Component({
|
||||
selector: 'app-favorites-page',
|
||||
|
|
@ -18,7 +19,7 @@ export class SalesPageComponent implements OnInit {
|
|||
|
||||
url: string = '';
|
||||
refreshSalesId: any;
|
||||
displayedColumns: string[] = ['title', 'date', 'house', 'plateform', 'prepare', 'follow', 'delete'];
|
||||
displayedColumns: string[] = ['title', 'date', 'house', 'plateform', 'action'];
|
||||
displayedColumnsOld: string[] = ['title', 'date', 'house', 'plateform', 'postProcessing', 'delete'];
|
||||
|
||||
futureSales = []
|
||||
|
|
@ -48,14 +49,14 @@ export class SalesPageComponent implements OnInit {
|
|||
refreshSales(): void {
|
||||
this.apiService.getAllSale().subscribe((data: any) => {
|
||||
console.log(data);
|
||||
const today = moment();
|
||||
const today = moment().startOf('day');
|
||||
|
||||
this.futureSales = data
|
||||
.filter((element: SaleInfo) => moment(element.date).isAfter(today))
|
||||
.filter((element: Sale) => moment(element.date).isAfter(today))
|
||||
.sort((a: any, b: any) => moment(a.date).isAfter(b.date) ? 1 : -1);
|
||||
|
||||
this.pastSales = data
|
||||
.filter((element: SaleInfo) => moment(element.date).isBefore(today))
|
||||
.filter((element: Sale) => moment(element.date).isBefore(today))
|
||||
.sort((a: any, b: any) => moment(a.date).isAfter(b.date) ? 1 : -1);
|
||||
});
|
||||
}
|
||||
|
|
@ -67,9 +68,9 @@ export class SalesPageComponent implements OnInit {
|
|||
}, 5000);
|
||||
}
|
||||
|
||||
prepareSale(saleInfo: SaleInfo): void {
|
||||
prepareSale(Sale: Sale): void {
|
||||
|
||||
this.apiService.prepareSale(saleInfo).subscribe( data => {
|
||||
this.apiService.prepareSale(Sale).subscribe( data => {
|
||||
console.log(data);
|
||||
this.refreshSales();
|
||||
this.notificationService.openSnackBar("Prepare Sale");
|
||||
|
|
@ -77,9 +78,9 @@ export class SalesPageComponent implements OnInit {
|
|||
})
|
||||
}
|
||||
|
||||
followSale(saleInfo: SaleInfo): void {
|
||||
followSale(Sale: Sale): void {
|
||||
|
||||
this.apiService.followSale(saleInfo).subscribe( data => {
|
||||
this.apiService.followSale(Sale).subscribe( data => {
|
||||
console.log(data);
|
||||
this.refreshSales();
|
||||
this.notificationService.openSnackBar("Sale followed");
|
||||
|
|
@ -87,9 +88,9 @@ export class SalesPageComponent implements OnInit {
|
|||
})
|
||||
}
|
||||
|
||||
stopFollowSale(saleInfo: SaleInfo): void {
|
||||
saleInfo.status = "askStop";
|
||||
this.apiService.updateSale(saleInfo).subscribe( data => {
|
||||
stopFollowSale(Sale: Sale): void {
|
||||
Sale.status = "askStop";
|
||||
this.apiService.updateSale(Sale).subscribe( data => {
|
||||
this.refreshSales();
|
||||
this.notificationService.openSnackBar("Sale Stopping...");
|
||||
})
|
||||
|
|
@ -102,6 +103,10 @@ export class SalesPageComponent implements OnInit {
|
|||
})
|
||||
}
|
||||
|
||||
resetToReady(_id: string): void {
|
||||
this.apiService.resetSaleToReady(_id)
|
||||
}
|
||||
|
||||
navigateToSaleDetail(id: string) {
|
||||
console.log(id);
|
||||
clearInterval(this.refreshSalesId);
|
||||
|
|
|
|||
Loading…
Reference in New Issue