Commit 3b3c8056 by DESKTOP-HF0LVOG\myhr

Edit ปุ่มเพิ่มรายการ และเพิ่มหน้าอุปกรณ์ admin

parent 31cfe643
......@@ -21,6 +21,7 @@ import { EquipmentComponent } from "./pages/equipment/equipment.component";
import { CalenRoomComponent } from './pages/calen-room/calen-room.component';
import { AdminPendingComponent } from './pages/admin-pending/admin-pending.component';
import { PendingComponent } from './pages/pending/pending.component';
import { AdminEquirmentComponent } from './pages/admin-equirment/admin-equirment.component';
FullCalendarModule.registerPlugins([ // register FullCalendar plugins
dayGridPlugin,
......@@ -39,7 +40,7 @@ FullCalendarModule.registerPlugins([ // register FullCalendar plugins
ToastrModule.forRoot(),
FullCalendarModule,
],
declarations: [AppComponent, AdminLayoutComponent, AuthLayoutComponent, HomePageComponent, EquipmentComponent, CalenRoomComponent, AdminPendingComponent, PendingComponent],
declarations: [AppComponent, AdminLayoutComponent, AuthLayoutComponent, HomePageComponent, EquipmentComponent, CalenRoomComponent, AdminPendingComponent, PendingComponent, AdminEquirmentComponent],
providers: [],
bootstrap: [AppComponent]
})
......
......@@ -23,6 +23,13 @@ export const ROUTES: RouteInfo[] = [
class: ""
},
{
path: "/admin-equirment",
title: "รายการอุปกรณ์ Admin",
rtlTitle: "",
icon: "icon-bag-16",
class: ""
},
{
path: "/pending",
title: "รายการทั้งหมด",
rtlTitle: "",
......@@ -36,6 +43,7 @@ export const ROUTES: RouteInfo[] = [
icon: "icon-bag-16",
class: ""
},
{
path: "/lend-page",
title: "รายการดำเนินการ",
......
......@@ -12,11 +12,13 @@ import { EquipmentComponent } from "src/app/pages/equipment/equipment.component"
import { AdminPendingComponent } from "src/app/pages/admin-pending/admin-pending.component";
import { PendingComponent } from "src/app/pages/pending/pending.component";
import { LendPageComponent } from "src/app/pages/lend-page/lend-page.component";
import { AdminEquirmentComponent } from "src/app/pages/admin-equirment/admin-equirment.component";
// import { RtlComponent } from "../../pages/rtl/rtl.component";
export const AdminLayoutRoutes: Routes = [
{ path: "home-page", component: HomePageComponent },
{ path: "equipment", component: EquipmentComponent },
{ path: "admin-equirment", component: AdminEquirmentComponent },
{ path: "admin-pending", component: AdminPendingComponent },
{ path: "pending", component: PendingComponent },
{ path: "lend-page", component: LendPageComponent },
......
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AdminEquirmentComponent } from './admin-equirment.component';
describe('AdminEquirmentComponent', () => {
let component: AdminEquirmentComponent;
let fixture: ComponentFixture<AdminEquirmentComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ AdminEquirmentComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(AdminEquirmentComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core';
import { NgbModal, ModalDismissReasons } from '@ng-bootstrap/ng-bootstrap';
import { Equirment } from 'src/app/models/equirment.model';
import { Room } from 'src/app/models/rooms.model';
import { EquirmentService } from 'src/app/service/equirment.service';
import { RoomService } from 'src/app/service/room.service';
@Component({
selector: 'app-admin-equirment',
templateUrl: './admin-equirment.component.html',
styleUrls: ['./admin-equirment.component.scss']
})
export class AdminEquirmentComponent implements OnInit {
time = { hour: 13, minute: 30 };
page = 1;
pageSize = 10;
closeResult = '';
listEquirmentModel: Equirment[] = [];
listRoomModel: Room[] = [];
collectionSize = this.listEquirmentModel.length;
modelEquirment = new Equirment();
modelRoom = new Room();
constructor(private modalService: NgbModal, private equirmentService: EquirmentService, private roomService: RoomService) {
}
ngOnInit() {
this.listEquirmentModel = this.equirmentService.getListEquirment();
this.listRoomModel = this.roomService.getListRoom();
}
Eopen(contentequirment) {
this.modelEquirment = new Equirment();
this.modalService.open(contentequirment, { ariaLabelledBy: 'modal-basic-title' }).result.then((result) => {
this.closeResult = `Closed with: ${result}`;
}, (reason) => {
this.closeResult = `Dismissed ${this.getDismissReason(reason)}`;
});
}
Ropen(contentroom) {
this.modelRoom = new Room();
this.modalService.open(contentroom, { ariaLabelledBy: 'modal-basic-title' }).result.then((result) => {
this.closeResult = `Closed with: ${result}`;
}, (reason) => {
this.closeResult = `Dismissed ${this.getDismissReason(reason)}`;
});
}
private getDismissReason(reason: any): string {
if (reason === ModalDismissReasons.ESC) {
return 'by pressing ESC';
} else if (reason === ModalDismissReasons.BACKDROP_CLICK) {
return 'by clicking on a backdrop';
} else {
return `with: ${reason}`;
}
}
refreshCountries() {
this.listEquirmentModel = this.listEquirmentModel
this.listRoomModel = this.listRoomModel
.map((item, i) => ({ id: i + 1, ...item }))
.slice((this.page - 1) * this.pageSize, (this.page - 1) * this.pageSize + this.pageSize);
}
NgbdTimepickerBasic() {
}
saveEquirment() {
this.equirmentService.addEquirment(this.modelEquirment);
this.modalService.dismissAll();
this.ngOnInit();
}
saveRoom() {
this.roomService.addRoom(this.modelRoom);
this.modalService.dismissAll();
this.ngOnInit();
}
}
......@@ -20,7 +20,7 @@
<div class="card-body">
<button class="btn btn-lg btn-outline-primary"
(click)="Ropen(content)">เพิ่มรายการ</button>
(click)="open(contentroom)">เพิ่มรายการ</button>
<div class="row">
<div class="col-sm-3" *ngFor="let item of listRoomModel">
......@@ -64,6 +64,8 @@
</div>
</ng-template>
</li>
<li ngbNavItem>
<a ngbNavLink>การเบิก</a>
<ng-template ngbNavContent>
......@@ -71,7 +73,7 @@
<div class="col-sm-12">
<div class="">
<div class="card-body">
<ng-template #content let-modal style="padding: 0; ">
<ng-template #contentequirment let-modal style="padding: 0; ">
<div class=" col-md-12">
<div class="card">
<div class=" card-header">
......@@ -126,7 +128,7 @@
</ng-template>
<button class="btn btn-lg btn-outline-primary"
(click)="Eqopen(content)">เพิ่มรายการ</button>
(click)="open(contentequirment)">เพิ่มรายการ</button>
<div class="row">
<div class="col-sm-3" *ngFor="let item of listEquirmentModel">
......@@ -176,7 +178,7 @@
<div [ngbNavOutlet]="nav"></div>
</div>
<ng-template #content let-modal style="padding: 0; ">
<ng-template #contentroom let-modal style="padding: 0; ">
<div class=" col-md-12">
<div class="card">
<div class=" card-header">
......
......@@ -32,18 +32,18 @@ export class EquipmentComponent implements OnInit {
this.listRoomModel = this.roomService.getListRoom();
}
Eqopen(content) {
Eopen(contentequirment) {
this.modelEquirment = new Equirment();
this.modalService.open(content, { ariaLabelledBy: 'modal-basic-title' }).result.then((result) => {
this.modalService.open(contentequirment, { ariaLabelledBy: 'modal-basic-title' }).result.then((result) => {
this.closeResult = `Closed with: ${result}`;
}, (reason) => {
this.closeResult = `Dismissed ${this.getDismissReason(reason)}`;
});
}
Ropen(content) {
Ropen(contentroom) {
this.modelRoom = new Room();
this.modalService.open(content, { ariaLabelledBy: 'modal-basic-title' }).result.then((result) => {
this.modalService.open(contentroom, { ariaLabelledBy: 'modal-basic-title' }).result.then((result) => {
this.closeResult = `Closed with: ${result}`;
}, (reason) => {
this.closeResult = `Dismissed ${this.getDismissReason(reason)}`;
......
......@@ -44,7 +44,7 @@ export class RoomService {
]
listRoomSearch: Room[] = [];
addRoom(model : Room){
addRoom(model: Room) {
this.listRoomModel.push(model);
}
......@@ -61,7 +61,7 @@ export class RoomService {
}
searchListRoom(searchModel: SearchRoomModel) {
this.http.get(this.url + '/limits?roomlimit='+searchModel.roomlimit+'&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) => {
this.http.get(this.url + '/limits?roomlimit=' + searchModel.roomlimit + '&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);
this.listRoomSearch = response;
}, error => {
......@@ -77,7 +77,7 @@ export class RoomService {
// // })
// }
deleteRoom(roomModel: Room) {
this.http.delete(this.url + "/" + roomModel.rId).subscribe(response => {
console.log(response);
......
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