Commit b4e64e7e by DESKTOP-E0VCCBD\zedan

update

parent 85b53eab
......@@ -19,7 +19,7 @@
<div class="flex items-center gap-2">
<label for="startDate" class="whitespace-nowrap">Start Date:</label>
<input
type="date"[(ngModel)]="startDate"
type="date" [(ngModel)]="startDate"
id="startDate"
name="startDate"
class="border rounded px-2 py-1"
......@@ -104,7 +104,7 @@
</div>
</div>
<div class="flex flex-wrap gap-2">
<a href="javascript:void(0);" class="hs-dropdown-toggle ti-btn ti-btn-primary-full me-2" (click)="applyFilters()"
<a href="javascript:void(0);" class="hs-dropdown-toggle ti-btn ti-btn-primary-full me-2" (click)="getDashbord()"
data-hs-overlay="#modal-detail"><i class="font-semibold align-middle"></i>Apply
</a>
</div>
......
......@@ -44,9 +44,10 @@ export class HomeCommonComponent {
rawData: any[];
allSelected = false;
someSelected = false;
startDate: string = '';
endDate: string = '';
itmes:string='';
today = new Date();
startDate : string = ''
endDate : string = ''
itmes: string = '';
selectedProjects: string[] = [];
selectedEquipmentType: string = 'ALL';
isDropdownOpen = false;
......@@ -54,7 +55,7 @@ export class HomeCommonComponent {
projectSelection: { [key: string]: boolean } = {};
itemSelection: { [key: string]: boolean } = {};
confirmPassword = ""
dashbordList:string[] = [];
dashbordList: string[] = [];
equipmentList: EquipmentModel[] = []
projectList: ProjectModel[] = []
itemsList: UserProfileModel[] = []
......@@ -67,7 +68,7 @@ export class HomeCommonComponent {
pageIndex = 0;
uploaderProfile: FileUploader | undefined;
uploadErrorMsg: string = "";
dashboardModel: DashboardModel
dashboardModel: DashboardModel
get searchTerm(): string {
return this._searchTerm;
}
......@@ -157,7 +158,7 @@ export class HomeCommonComponent {
type: 'datetime',
},
};
constructor(private el: ElementRef, private renderer: Renderer2, private cdr: ChangeDetectorRef, private userService: UserService, public translate: TranslateService, private tokenService: TokenService, private ProjectService: ProjectService, private EquipmentService: EquipmentService,private DashboardService:DashboardService) {
constructor(private el: ElementRef, private renderer: Renderer2, private cdr: ChangeDetectorRef, private userService: UserService, public translate: TranslateService, private tokenService: TokenService, private ProjectService: ProjectService, private EquipmentService: EquipmentService, private DashboardService: DashboardService) {
......@@ -833,6 +834,14 @@ export class HomeCommonComponent {
};
}
formatDateToYYYYMMDD(date: Date): string {
const year = date.getFullYear();
const month = (date.getMonth() + 1).toString().padStart(2, '0'); // เพิ่ม 1 เพราะเดือนเริ่มที่ 0
const day = date.getDate().toString().padStart(2, '0');
return `${year}-${month}-${day}`;
}
onProjectCheckboxChange(event: any) {
const value = event.target.value;
......@@ -846,8 +855,8 @@ export class HomeCommonComponent {
this.isDropdownOpen = !this.isDropdownOpen;
}
toggleDropdown1() {
this.isDropdownOpen1= !this.isDropdownOpen1;
toggleDropdown1() {
this.isDropdownOpen1 = !this.isDropdownOpen1;
}
......@@ -896,11 +905,15 @@ export class HomeCommonComponent {
this.EquipmentService.getLists().subscribe(result => {
this.equipmentList = result
})
this.getDashbord
const today = new Date();
const firstDay = new Date(today.getFullYear(), today.getMonth(), 1);
this.startDate = this.formatDateToYYYYMMDD(firstDay);
this.endDate = this.formatDateToYYYYMMDD(today);
this.getDashbord()
}
getDashbord(){
this.DashboardService.getDashboard().subscribe(result => {
getDashbord() {
this.DashboardService.getDashboard(this.startDate, this.endDate).subscribe(result => {
this.dashboardModel = result
console.log(this.dashboardModel)
})
......@@ -990,20 +1003,6 @@ export class HomeCommonComponent {
}
applyFilters() {
const selectedProjects = Object.keys(this.projectSelection).filter(p => this.projectSelection[p]);
const filteredData = this.rawData.filter(item => {
return (!this.startDate || item.date >= this.startDate) &&
(!this.endDate || item.date <= this.endDate) &&
(selectedProjects.length === 0 || selectedProjects.includes(item.project_name)) &&
(this.selectedEquipmentType === 'ALL' || item.equipment_type === this.selectedEquipmentType);
});
}
updatePagedItems() {
const startIndex = this.pageIndex * 10;
const endIndex = startIndex + 10;
......
......@@ -918,12 +918,26 @@ public series: ApexAxisChartSeries = [];
this.EquipmentService.getLists().subscribe(result => {
this.equipmentList = result
})
this.DashboardService.getDashboard().subscribe(result => {
const today = new Date();
const firstDay = new Date(today.getFullYear(), today.getMonth(), 1);
this.startDate = this.formatDateToYYYYMMDD(firstDay);
this.endDate = this.formatDateToYYYYMMDD(today);
this.getDashbord()
}
getDashbord() {
this.DashboardService.getDashboard(this.startDate, this.endDate).subscribe(result => {
this.dashboardModel = result
console.log(this.dashboardModel)
})
}
formatDateToYYYYMMDD(date: Date): string {
const year = date.getFullYear();
const month = (date.getMonth() + 1).toString().padStart(2, '0'); // เพิ่ม 1 เพราะเดือนเริ่มที่ 0
const day = date.getDate().toString().padStart(2, '0');
return `${year}-${month}-${day}`;
}
filter(v: string) {
return this.itemsList?.filter(
......
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