Connected with DB and complted the Backup Service, Shift Update ongoin
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
<page-title title="Shift Update"></page-title>
|
||||
<app-input-form [fields]="tableHeaderList"></app-input-form>
|
||||
<app-input-form [fields]="tableHeaderList" (formValues)="addUpdate($event)"
|
||||
(clicked)="onClick()"></app-input-form>
|
||||
<app-table [tableHeaders]="tableHeaderList" [rowDataList]="updateDataList" (complete)="completeTask($event)" (delete)="deleteTask($event)"></app-table>
|
||||
@@ -1,10 +1,11 @@
|
||||
import { Component, EventEmitter, OnInit } from '@angular/core';
|
||||
import { Component, OnDestroy, OnInit } from '@angular/core';
|
||||
import { Subscription } from 'rxjs';
|
||||
|
||||
import { TableComponent } from '../../../shared/components/table/table.component';
|
||||
import { UpdateService } from './update.service';
|
||||
import { TitleComponent } from '../../../shared/components/title/title.component';
|
||||
import { ShortenPipe } from '../../../shared/pipe/shorten.pipe';
|
||||
import { InputFormComponent } from "../../../shared/components/input-form/input-form.component";
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
import { Update } from '../../../shared/model/update.model';
|
||||
|
||||
@Component({
|
||||
selector: 'app-shift-update',
|
||||
@@ -14,24 +15,40 @@ import { BehaviorSubject } from 'rxjs';
|
||||
styleUrl: './shift-update.component.scss',
|
||||
providers: [UpdateService]
|
||||
})
|
||||
export class ShiftUpdateComponent implements OnInit {
|
||||
export class ShiftUpdateComponent implements OnInit, OnDestroy {
|
||||
tableHeaderList = ['Date','Details','Remarks','Sales','Reference','Handler', 'Status']
|
||||
updateDataList: any[] = [];
|
||||
|
||||
updateDataList: Update[] = [];
|
||||
updateListSubscription!: Subscription;
|
||||
|
||||
|
||||
constructor(private updateService: UpdateService) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.updateDataList = this.updateService.allUpdate;
|
||||
this.updateListSubscription = this.updateService.allUpdate().subscribe((update)=>{
|
||||
this.updateDataList = update;
|
||||
console.log(this.updateDataList.keys)
|
||||
});
|
||||
console.log(this.completeTask)
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.updateListSubscription.unsubscribe();
|
||||
}
|
||||
|
||||
completeTask(event: string) {
|
||||
console.log(event)
|
||||
//
|
||||
}
|
||||
|
||||
deleteTask(event: boolean) {
|
||||
//
|
||||
}
|
||||
|
||||
addUpdate(newUpdate:any){
|
||||
this.updateService.addUpdate(newUpdate);
|
||||
}
|
||||
onClick(){
|
||||
this.updateService.allUpdate().subscribe((update)=>{
|
||||
this.updateDataList = update;
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,27 @@
|
||||
import { Injectable } from "@angular/core";
|
||||
import { sample_update } from "./sample_update";
|
||||
import { Observable } from "rxjs";
|
||||
import { Update } from "../../../shared/model/update.model";
|
||||
import { HttpClient } from "@angular/common/http";
|
||||
import { UPDATE_ADD_URL, UPDATE_GET_URL } from "../../../shared/constants/backend";
|
||||
|
||||
Injectable({
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
|
||||
export class UpdateService{
|
||||
get allUpdate(){
|
||||
return sample_update;
|
||||
|
||||
constructor(private httpClient: HttpClient){}
|
||||
|
||||
allUpdate() {
|
||||
return this.httpClient.get<Update[]>(UPDATE_GET_URL)
|
||||
}
|
||||
|
||||
addUpdate(newUpdate: Update) {
|
||||
newUpdate.deleted = false;
|
||||
this.httpClient.post(UPDATE_ADD_URL,newUpdate).subscribe((log)=>{
|
||||
console.log(log)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user