Commit 78537743 by Your Name

update contact api

parent 1d8c8def
......@@ -44,7 +44,9 @@ export class ContactAdminComponent implements OnInit {
constructor(private ContactService: ContactService, private modalService: NgbModal) { }
ngOnInit(): void {
this.listContact = this.ContactService.getListContact();
this.ContactService.getListContact().subscribe( result => {
this.listContact = result;
});
this.collectionSizeListRoom = this.listContact.length;
this.collectionSize = this.listContact.length
......
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { Contact } from "../models/contact.model";
@Injectable({ providedIn: 'root' })
export class ContactService {
constructor(private http: HttpClient) { }
url: string;
listContact: Contact[] = [
{
id: 1,
ctName: 'เกม',
ctDesc: 'กดจองแล้ว รายการจองไม่ขึ้น',
ctTab: 'รายการอุปกรณ์',
ctHead: 'กดจองไม่ได้',
ctStatus: 0,
sDate: '2021-12-17'
},
]
url: string = "http://915e-49-0-64-28.ngrok.io";
listContact: Contact[] = []
addContact(model: Contact) {
this.listContact.push(model);
......@@ -33,8 +24,8 @@ export class ContactService {
});
}
getListContact() {
return this.listContact;
getListContact(): Observable<Contact[]> {
return this.http.get<Contact[]>(this.url + "/contact/lists");
}
}
......@@ -23,29 +23,10 @@ export class EquirmentService {
// this.listEquirment.push(models);
// }
// getListEquirment() {
// this.http.get(this.url + "/eqment/lists").subscribe((response: Equirment[]) => {
// // this.listEquirment = response;
// console.log("...",response);
// return response;
// })
// }
getListEquirment(): Observable<Equirment[]> {
return this.http.get<Equirment[]>(this.url + "/eqment/lists");
}
getListRoom() {
this.http.get(this.url).subscribe((response: any) => {
console.log(response);
this.listEquirment = response.content;
}, error => {
console.log(error)
// alert("ไม่สามารถดึงข้อมูลห้องประชุมได้ เนื่องจาก :\n" + error.message)
})
}
searchListEquirment(searchModel: SearchEquirmentModel) {
this.http.get(this.url + '&startDate=' + searchModel.sDate.split("-")[2] + '-' + searchModel.sDate.split("-")[1] + '-' + searchModel.sDate.split("-")[0] + '&endDate=' + searchModel.eDate.split("-")[2] + '-' + searchModel.eDate.split("-")[1] + '-' + searchModel.eDate.split("-")[0] + '&startTime=' + searchModel.sTime + ':00' + '&endTime=' + searchModel.eTime + ':00').subscribe((response: any) => {
console.log(response);
......@@ -67,7 +48,7 @@ export class EquirmentService {
deleteEquirment(EquirmentModel: Equirment) {
this.http.delete(this.url + "/eqment/" + EquirmentModel.eqId).subscribe(response => {
console.log(response);
this.getListRoom()
this.getListEquirment()
alert("ลบข้อมูลอุปกรณ์สำเร็จ")
})
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment