Commit 6242f8d4 by Nakarin Luankla

UPDATE หน้ารายการเอกสาร ,อนุมัติรายการเอกสาร ยิงAPI

parent b83119d7
...@@ -5,7 +5,7 @@ import { ...@@ -5,7 +5,7 @@ import {
} from '@angular/common'; } from '@angular/common';
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { HttpClientModule } from '@angular/common/http'; import { HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
...@@ -36,6 +36,7 @@ import { PerfectScrollbarConfigInterface } from 'ngx-perfect-scrollbar'; ...@@ -36,6 +36,7 @@ import { PerfectScrollbarConfigInterface } from 'ngx-perfect-scrollbar';
import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader'; import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { HttpRequestInterceptor } from './service/http-request.interceptor';
export function HttpLoaderFactory(http: HttpClient) { export function HttpLoaderFactory(http: HttpClient) {
...@@ -93,6 +94,11 @@ const DEFAULT_PERFECT_SCROLLBAR_CONFIG: PerfectScrollbarConfigInterface = { ...@@ -93,6 +94,11 @@ const DEFAULT_PERFECT_SCROLLBAR_CONFIG: PerfectScrollbarConfigInterface = {
], ],
providers: [ providers: [
{ {
provide: HTTP_INTERCEPTORS,
useClass: HttpRequestInterceptor,
multi: true,
},
{
provide: PERFECT_SCROLLBAR_CONFIG, provide: PERFECT_SCROLLBAR_CONFIG,
useValue: DEFAULT_PERFECT_SCROLLBAR_CONFIG useValue: DEFAULT_PERFECT_SCROLLBAR_CONFIG
} }
......
<div class="modal-header">
<h5 class="modal-title" id="editLabel">ข้อความแจ้งเตือน</h5>
<button type="button" class="close" (click)="activeModal.dismiss('dismiss')" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<ng-container *ngIf="innerHTML!=undefined then InnerHTML else Message"></ng-container>
<ng-template #Message>
<div class="modal-body">
{{message}}
</div>
</ng-template>
<ng-template #InnerHTML>
<div class="modal-body" [innerHTML]="innerHTML">
</div>
</ng-template>
\ No newline at end of file
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AlertModalComponent } from './alert-modal.component';
describe('AlertModalComponent', () => {
let component: AlertModalComponent;
let fixture: ComponentFixture<AlertModalComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ AlertModalComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(AlertModalComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, Input, OnInit } from '@angular/core';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
@Component({
selector: 'app-alert-modal',
templateUrl: './alert-modal.component.html',
styleUrls: ['./alert-modal.component.scss']
})
export class AlertModalComponent implements OnInit {
@Input() message: string = ""
@Input() innerHTML?: string
constructor(public activeModal: NgbActiveModal) { }
ngOnInit(): void {
}
}
<div class="row">
<div class="col-12">
<div class="card card-body">
<h4 class="card-title">รายการหลักสูตร</h4>
<div class="d-flex mb-3 mt-3">
<input type="text" class="form-control w-25" placeholder="ค้นหา" [(ngModel)]="search" >
</div>
<div class="table-responsive">
<table class="table table-striped mb-0 no-wrap v-middle ">
<thead class="bg-info text-white">
<tr>
<th class="text-center" scope="col">#</th>
<th scope="col">รูปภาพ</th>
<th scope="col">ชื่อ</th>
<th scope="col">รายละเอียด</th>
<th scope="col">ประเภทหลักสูตร</th>
<th scope="col">ลิงค์</th>
<th scope="col">สถานะ</th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
<tr *ngIf="listCourse.length == 0">
<td colspan="8" class="text-center">ไม่พบข้อมูล</td>
</tr>
<tr *ngFor="let data of filterListCourse() | slice: (page-1) * pageSize : (page-1) * pageSize + pageSize ; let i = index">
<td class="text-center">{{i+1}}</td>
<td><img width="100" class="border p-1" src="{{data.thumbnail}}"></td>
<td>{{ data.thName }}</td>
<td class="text-wrap">{{ data.thDesc }}</td>
<td>{{data.ctype}}</td>
<td><a href="{{data.link1}}" target="_blank">คลิก</a></td>
<td>{{ getStatus(data.status) }}</td>
<td>
<button type="button" class="btn btn-circle btn-success rounded-circle btn-sm mr-2" (click)="onApprove(data)"><i class="fa fa-check"></i></button>
<button type="button" class="btn btn-circle btn-danger rounded-circle btn-sm mr-2" (click)="onCancelApprove(data)"><i class="fas fa-times"></i></button>
</td>
</tr>
</tbody>
</table>
</div>
<div class="d-flex justify-content-end py-2">
<select class="custom-select m-r-5" style="width: auto" [(ngModel)]="pageSize" (ngModelChange)="page">
<option [ngValue]="10">รายการต่อหน้า: 10</option>
<option [ngValue]="50">รายการต่อหน้า: 50</option>
<option [ngValue]="100">รายการต่อหน้า: 100</option>
</select>
<ngb-pagination [(page)]="page" [pageSize]="pageSize" [collectionSize]="listCourse.length" [maxSize]="3" [rotate]="true">
<ng-template ngbPaginationPrevious>ก่อนหน้า</ng-template>
<ng-template ngbPaginationNext>ถัดไป</ng-template>
</ngb-pagination>
</div>
</div>
</div>
</div>
\ No newline at end of file
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ApproveCourseComponent } from './approve-course.component';
describe('ApproveCourseComponent', () => {
let component: ApproveCourseComponent;
let fixture: ComponentFixture<ApproveCourseComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ApproveCourseComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(ApproveCourseComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { CourseModel } from 'src/app/model/course.model';
import { CourseService } from 'src/app/service/course.service';
import { ConfirmModalComponent } from '../confirm-modal/confirm-modal.component';
import { AlertModalComponent } from '../alert-modal/alert-modal.component';
@Component({
selector: 'app-approve-course',
templateUrl: './approve-course.component.html',
styleUrls: ['./approve-course.component.scss']
})
export class ApproveCourseComponent implements OnInit {
page = 1;
pageSize = 10;
listCourse:CourseModel[]=[]
search:string = ''
constructor(private modalService: NgbModal,private courseService:CourseService) {
}
getStatus(status:string){
if(status == '0'){
return 'รออนุมัติ'
} else if(status == '1'){
return 'เปิดใช้งาน'
} else if(status == '2'){
return 'ไม่อนุมัติ'
}
}
filterListCourse(){
return this.listCourse.filter(x => x.thName.toLowerCase().includes(this.search.toLowerCase())||x.engName.toLowerCase().includes(this.search.toLowerCase()))
}
async getListCourse(){
try {
const data = await this.courseService.getListCourse('0').toPromise();
this.listCourse = data
} catch (error) {
console.error('Error loading data:', error);
}
}
onApprove(item:CourseModel){
const modalRef = this.modalService.open(ConfirmModalComponent, {
centered: true,
backdrop: 'static',
})
modalRef.componentInstance.message = 'คุณต้องการอนุมัติข้อมูลหรือไม่'
modalRef.result.then(result => {
item.status = 1
this.courseService.approve(item).subscribe(result => {
if (result) {
this.openAlertModal('บันทึกข้อมูลสำเร็จ')
this.getListCourse();
} else {
this.openAlertModal('ไม่สามารถบันทึกข้อมูลได้')
}
}, error => {
this.openAlertModal(error.message)
})
}, reject => { })
}
onCancelApprove(item:CourseModel){
const modalRef = this.modalService.open(ConfirmModalComponent, {
centered: true,
backdrop: 'static',
})
modalRef.componentInstance.message = 'คุณต้องการไม่อนุมัติข้อมูลหรือไม่'
modalRef.result.then(result => {
item.status = 2
this.courseService.approve(item).subscribe(result => {
if (result) {
this.openAlertModal('บันทึกข้อมูลสำเร็จ')
this.getListCourse();
} else {
this.openAlertModal('ไม่สามารถบันทึกข้อมูลได้')
}
}, error => {
this.openAlertModal(error.message)
})
}, reject => { })
}
ngOnInit() {
this.getListCourse();
}
openAlertModal(message?: string) {
const modalRef = this.modalService.open(AlertModalComponent, {
centered: true,
backdrop: 'static'
})
modalRef.componentInstance.message = message ? message : ""
modalRef.result.then(result => {
this.modalService.dismissAll()
}, reason => {
this.modalService.dismissAll()
})
}
}
<div class="row">
<div class="col-12">
<div class="card card-body">
<h4 class="card-title">รายการเอกสาร</h4>
<div class="d-flex mb-3 mt-3">
<input type="text" class="form-control w-25" placeholder="ค้นหา" [(ngModel)]="search" >
</div>
<div class="table-responsive">
<table class="table table-striped mb-0 no-wrap v-middle ">
<thead class="bg-info text-white">
<tr>
<th class="text-center" scope="col">#</th>
<th scope="col">รูปภาพ</th>
<!-- <th scope="col">รหัสเอกสาร</th> -->
<th scope="col">ชื่อ</th>
<th scope="col">รายละเอียด</th>
<th scope="col">ลิงค์</th>
<th scope="col">สถานะ</th>
<!-- <th scope="col">ไฟล์</th> -->
<th scope="col"></th>
</tr>
</thead>
<tbody>
<tr *ngIf="listDoc.length == 0">
<td colspan="7" class="text-center">ไม่พบข้อมูล</td>
</tr>
<tr *ngFor="let data of filterListDoc() | slice: (page-1) * pageSize : (page-1) * pageSize + pageSize ; let i = index">
<td class="text-center">{{i+1}}</td>
<td><img width="100" class="border p-1" src="{{data.thumbnail}}"></td>
<!-- <td >{{data.id}}</td> -->
<td>{{ data.thName }}</td>
<td>{{ data.thDesc }}</td>
<td><a href="{{data.link1}}" target="_blank">คลิก</a></td>
<td>{{ getStatus(data.status) }}</td>
<!-- <td><a (click)="downloadFile(data.logId)">ดาวน์โหลด</a></td> -->
<td>
<button type="button" class="btn btn-circle btn-success rounded-circle btn-sm mr-2" (click)="onApprove(data)"><i class="fa fa-check"></i></button>
<button type="button" class="btn btn-circle btn-danger rounded-circle btn-sm mr-2" (click)="onCancelApprove(data)"><i class="fas fa-times"></i></button>
</td>
</tr>
</tbody>
</table>
</div>
<div class="d-flex justify-content-end py-2">
<select class="custom-select m-r-5" style="width: auto" [(ngModel)]="pageSize" (ngModelChange)="page">
<option [ngValue]="10">รายการต่อหน้า: 10</option>
<option [ngValue]="50">รายการต่อหน้า: 50</option>
<option [ngValue]="100">รายการต่อหน้า: 100</option>
</select>
<ngb-pagination [(page)]="page" [pageSize]="pageSize" [collectionSize]="listDoc.length" [maxSize]="3" [rotate]="true">
<ng-template ngbPaginationPrevious>ก่อนหน้า</ng-template>
<ng-template ngbPaginationNext>ถัดไป</ng-template>
</ngb-pagination>
</div>
</div>
</div>
</div>
\ No newline at end of file
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ApproveDocComponent } from './approve-doc.component';
describe('ApproveDocComponent', () => {
let component: ApproveDocComponent;
let fixture: ComponentFixture<ApproveDocComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ApproveDocComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(ApproveDocComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core';
import { ConfirmModalComponent } from '../confirm-modal/confirm-modal.component';
import { DocumentModel } from 'src/app/model/document.model';
import { AlertModalComponent } from '../alert-modal/alert-modal.component';
import { DocumentService } from 'src/app/service/document.service';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
@Component({
selector: 'app-approve-doc',
templateUrl: './approve-doc.component.html',
styleUrls: ['./approve-doc.component.scss']
})
export class ApproveDocComponent implements OnInit {
page = 1;
pageSize = 10;
listDoc:DocumentModel[]=[]
search:string = ''
constructor(private modalService: NgbModal,private documentService:DocumentService) {
}
getStatus(status:string){
if(status == '0'){
return 'รออนุมัติ'
} else if(status == '1'){
return 'เปิดใช้งาน'
} else if(status == '2'){
return 'ไม่อนุมัติ'
}
}
filterListDoc(){
return this.listDoc.filter(x => x.thName.toLowerCase().includes(this.search.toLowerCase())||x.engName.toLowerCase().includes(this.search.toLowerCase()))
}
async getListDoc(){
try {
const data = await this.documentService.getListDoc('0').toPromise();
this.listDoc = data
} catch (error) {
console.error('Error loading data:', error);
}
}
onApprove(item:DocumentModel){
const modalRef = this.modalService.open(ConfirmModalComponent, {
centered: true,
backdrop: 'static',
})
modalRef.componentInstance.message = 'คุณต้องการอนุมัติข้อมูลหรือไม่'
modalRef.result.then(result => {
item.status = 1
this.documentService.approve(item).subscribe(result => {
if (result) {
this.openAlertModal('บันทึกข้อมูลสำเร็จ')
this.getListDoc();
} else {
this.openAlertModal('ไม่สามารถบันทึกข้อมูลได้')
}
}, error => {
this.openAlertModal(error.message)
})
}, reject => { })
}
onCancelApprove(item:DocumentModel){
const modalRef = this.modalService.open(ConfirmModalComponent, {
centered: true,
backdrop: 'static',
})
modalRef.componentInstance.message = 'คุณต้องการไม่อนุมัติข้อมูลหรือไม่'
modalRef.result.then(result => {
item.status = 2
this.documentService.approve(item).subscribe(result => {
if (result) {
this.openAlertModal('บันทึกข้อมูลสำเร็จ')
this.getListDoc();
} else {
this.openAlertModal('ไม่สามารถบันทึกข้อมูลได้')
}
}, error => {
this.openAlertModal(error.message)
})
}, reject => { })
}
ngOnInit() {
this.getListDoc();
}
openAlertModal(message?: string) {
const modalRef = this.modalService.open(AlertModalComponent, {
centered: true,
backdrop: 'static'
})
modalRef.componentInstance.message = message ? message : ""
modalRef.result.then(result => {
this.modalService.dismissAll()
}, reason => {
this.modalService.dismissAll()
})
}
}
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<div class="card card-body"> <div class="card card-body">
<h4 class="card-title">รายการ Excel</h4> <h4 class="card-title">รายการ Excel</h4>
<div class="d-flex mb-3 mt-3"> <div class="d-flex mb-3 mt-3">
<input type="text" class="form-control w-25" placeholder="ค้นหา" [(ngModel)]='searchTerm'> <input type="text" class="form-control w-25" placeholder="ค้นหา" [(ngModel)]="search" >
<!-- <button class="btn btn-primary ml-auto" (click)="openModal(editTemplateModal)">เพิ่มไฟล์ Excel</button> -->
</div>
<div class="table-responsive table-bordered">
<table class="table table-striped mb-0 no-wrap v-middle ">
<thead>
<tr>
<th class="text-center" scope="col">#</th>
<th scope="col">รูปภาพ</th>
<th scope="col">รหัสเอกสาร</th>
<th scope="col">ชื่อ</th>
<th scope="col">รายละเอียด</th>
<th scope="col">วันที่อัพโหลด</th>
<th scope="col">สถานะ</th>
<th scope="col">ลิงค์</th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
<tr *ngFor="let data of testdata | slice: (page-1) * pageSize : (page-1) * pageSize + pageSize ; let i = index">
<td class="text-center">{{i+1}}</td>
<td><img width="100" class="border p-1" src="{{data.img}}"></td>
<td >{{data.id}}</td>
<td>{{ data.name }}</td>
<td>{{ data.detail }}</td>
<td>{{ data.dateupload }}</td>
<td>{{ data.status }}</td>
<td><a href="{{data.link}}" target="_blank">คลิก</a></td>
<td>
<button type="button" class="btn btn-circle btn-success rounded-circle btn-sm mr-2"><i class="fa fa-check"></i></button>
<button type="button" class="btn btn-circle btn-danger rounded-circle btn-sm mr-2"><i class="fas fa-times"></i></button>
</td>
</tr>
</tbody>
</table>
</div>
<div class="d-flex justify-content-center mt-5">
<ngb-pagination [(page)]="page" [pageSize]="pageSize" [collectionSize]="testdata.length"></ngb-pagination>
</div>
</div> </div>
</div> <div class="table-responsive">
</div> <table class="table table-striped mb-0 no-wrap v-middle ">
<thead class="bg-info text-white">
<tr>
<ng-template #editTemplateModal let-modal> <th class="text-center" scope="col">#</th>
<div class="modal-header"> <th scope="col">รูปภาพ</th>
<h5 class="modal-title" id="edittemplateLabel">เพิ่มไฟล์ Excel</h5> <!-- <th scope="col">รหัสเอกสาร</th> -->
<button type="button" class="close" (click)="closeBtnClick()" aria-label="Close"> <th scope="col">ชื่อ</th>
<span aria-hidden="true">&times;</span> <th scope="col">รายละเอียด</th>
</button> <th scope="col">ลิงค์</th>
</div> <th scope="col">สถานะ</th>
<!-- <th scope="col">ไฟล์</th> -->
<div class="modal-body"> <th scope="col"></th>
<div class="form-group row"> </tr>
<label for="name" class="col-sm-4 col-form-label">ชื่อรายงาน (ไทย)</label> </thead>
<div class="col-sm-8"> <tbody>
<input type="text" class="form-control" id="nameth"> <tr *ngIf="listExcel.length == 0">
</div> <td colspan="7" class="text-center">ไม่พบข้อมูล</td>
</div> </tr>
<div class="form-group row"> <tr *ngFor="let data of filterListExcel() | slice: (page-1) * pageSize : (page-1) * pageSize + pageSize ; let i = index">
<label for="name" class="col-sm-4 col-form-label">ชื่อรายงาน (อังกฤษ)</label> <td class="text-center">{{i+1}}</td>
<div class="col-sm-8"> <td><img width="100" class="border p-1" src="{{data.thumbnail}}"></td>
<input type="text" class="form-control" id="nameeng"> <!-- <td >{{data.id}}</td> -->
</div> <td>{{ data.thName }}</td>
</div> <td>{{ data.thDesc }}</td>
<td><a href="{{data.link1}}" target="_blank">คลิก</a></td>
<div class="form-group row"> <td>{{ getStatus(data.status) }}</td>
<label for="position" class="col-sm-4 col-form-label">รายละเอียดรายงาน (ไทย)</label> <!-- <td><a (click)="downloadFile(data.logId)">ดาวน์โหลด</a></td> -->
<div class="col-sm-8"> <td>
<textarea class="form-control"></textarea> <button type="button" class="btn btn-circle btn-success rounded-circle btn-sm mr-2" (click)="onApprove(data)"><i class="fa fa-check"></i></button>
</div> <button type="button" class="btn btn-circle btn-danger rounded-circle btn-sm mr-2" (click)="onCancelApprove(data)"><i class="fas fa-times"></i></button>
</div> </td>
</tr>
<div class="form-group row"> </tbody>
<label for="position" class="col-sm-4 col-form-label">รายละเอียดรายงาน (อังกฤษ)</label> </table>
<div class="col-sm-8"> </div>
<textarea class="form-control"></textarea> <div class="d-flex justify-content-end py-2">
</div>
</div>
<div class="form-group row"> <select class="custom-select m-r-5" style="width: auto" [(ngModel)]="pageSize" (ngModelChange)="page">
<label for="name" class="col-sm-4 col-form-label">รูปภาพตัวอย่างรายงาน</label> <option [ngValue]="10">รายการต่อหน้า: 10</option>
<div class="col-sm-8"> <option [ngValue]="50">รายการต่อหน้า: 50</option>
<input type="file" class="form-control"> <option [ngValue]="100">รายการต่อหน้า: 100</option>
</div> </select>
</div> <ngb-pagination [(page)]="page" [pageSize]="pageSize" [collectionSize]="listExcel.length" [maxSize]="3" [rotate]="true">
<ng-template ngbPaginationPrevious>ก่อนหน้า</ng-template>
<ng-template ngbPaginationNext>ถัดไป</ng-template>
</ngb-pagination>
<div class="form-group row"> </div>
<label for="name" class="col-sm-4 col-form-label">ลิงค์ตัวอย่าง</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="nameeng">
</div>
</div>
<div class="form-group row">
<label for="position" class="col-sm-4 col-form-label">หมายเหตุ</label>
<div class="col-sm-8">
<textarea class="form-control"></textarea>
</div>
</div>
<div class="modal-footer ">
<button type="submit" class="btn btn-info" [disabled]="edittemplate.invalid">บันทึก</button>
<button type="button" class="btn btn-danger" (click)="closeBtnClick()">ปิด</button>
</div>
</div> </div>
</ng-template> </div>
</div>
\ No newline at end of file \ No newline at end of file
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { ExcelModel } from 'src/app/model/excel.model';
import { ExcelService } from 'src/app/service/excel.service';
import { AlertModalComponent } from '../alert-modal/alert-modal.component';
import { ConfirmModalComponent } from '../confirm-modal/confirm-modal.component';
@Component({ @Component({
selector: 'app-approve-excel', selector: 'app-approve-excel',
...@@ -7,81 +11,86 @@ import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; ...@@ -7,81 +11,86 @@ import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
styleUrls: ['./approve-excel.component.scss'] styleUrls: ['./approve-excel.component.scss']
}) })
export class ApproveExcelComponent implements OnInit { export class ApproveExcelComponent implements OnInit {
page = 1;
get searchTerm(): string { pageSize = 10;
return this._searchTerm; listExcel:ExcelModel[]=[]
search:string = ''
constructor(private modalService: NgbModal,private excelService:ExcelService) {
} }
set searchTerm(val: string) { getStatus(status:string){
this._searchTerm = val; if(status == '0'){
this.filterArray = this.filter(val); return 'รออนุมัติ'
} else if(status == '1'){
return 'เปิดใช้งาน'
} else if(status == '2'){
return 'ไม่อนุมัติ'
}
} }
page = 1; filterListExcel(){
pageSize = 7; return this.listExcel.filter(x => x.thName.toLowerCase().includes(this.search.toLowerCase())||x.engName.toLowerCase().includes(this.search.toLowerCase()))
filterArray: {
id:string;
name: String;
detail: String;
dateupload: String;
status: String;
link: String;
}[] = [];
_searchTerm = '';
testdata: {
id:string;
name: String;
detail: String;
dateupload: String;
status: String;
link: String;
img:string
}[] = [];
constructor(private modalService: NgbModal) {
} }
async getListExcel(){
ngOnInit() { try {
this.testdata = [ const data = await this.excelService.getListExcel('0').toPromise();
{ this.listExcel = data
id:'2024-1101', } catch (error) {
name: "Template Excel ข้อมูลพนักงาน", console.error('Error loading data:', error);
detail: "แสดงรายชื่อพนักงานทั้งหมด", }
dateupload: "11/06/2024",
status: "รออนุมัติ",
link: "https://www.youtube.com/watch?v=wOK9j3q20tw",
img:'assets/images/phototest/9a60ef19-7813-4094-bc45-17b7d9decc70.jpg'
},
{
id:'2024-1102',
name: "หนังสือรับรองเงินเดือน Word",
detail: "เอกสารใบรับรองเงินเดือน",
dateupload: "10/06/2024",
status: "รออนุมัติ",
link: "https://www.youtube.com/watch?v=wOK9j3q20tw",
img:'assets/images/phototest/3daddc9f-f69a-470b-8275-7db59db1a89b.jpg'
},
];
this.filterArray = this.testdata
} }
onApprove(item:ExcelModel){
filter(v: string) { const modalRef = this.modalService.open(ConfirmModalComponent, {
return this.testdata.filter(x => x.name.toLowerCase().indexOf(v.toLowerCase()) !== -1); centered: true,
backdrop: 'static',
})
modalRef.componentInstance.message = 'คุณต้องการอนุมัติข้อมูลหรือไม่'
modalRef.result.then(result => {
item.status = 1
this.excelService.approve(item).subscribe(result => {
if (result) {
this.openAlertModal('บันทึกข้อมูลสำเร็จ')
this.getListExcel();
} else {
this.openAlertModal('ไม่สามารถบันทึกข้อมูลได้')
}
}, error => {
this.openAlertModal(error.message)
})
}, reject => { })
} }
onCancelApprove(item:ExcelModel){
openModal(targetModal: NgbModal,) { const modalRef = this.modalService.open(ConfirmModalComponent, {
this.modalService.open(targetModal, {
centered: true, centered: true,
backdrop: 'static', backdrop: 'static',
size: 'lg' })
}); modalRef.componentInstance.message = 'คุณต้องการไม่อนุมัติข้อมูลหรือไม่'
modalRef.result.then(result => {
item.status = 2
this.excelService.approve(item).subscribe(result => {
if (result) {
this.openAlertModal('บันทึกข้อมูลสำเร็จ')
this.getListExcel();
} else {
this.openAlertModal('ไม่สามารถบันทึกข้อมูลได้')
}
}, error => {
this.openAlertModal(error.message)
})
}, reject => { })
}
ngOnInit() {
this.getListExcel();
} }
openAlertModal(message?: string) {
closeBtnClick() { const modalRef = this.modalService.open(AlertModalComponent, {
this.modalService.dismissAll(); centered: true,
this.ngOnInit(); backdrop: 'static'
})
modalRef.componentInstance.message = message ? message : ""
modalRef.result.then(result => {
this.modalService.dismissAll()
}, reason => {
this.modalService.dismissAll()
})
} }
} }
...@@ -85,6 +85,11 @@ import { PortalCreateCategoryComponent } from './portal-create-category/portal-c ...@@ -85,6 +85,11 @@ import { PortalCreateCategoryComponent } from './portal-create-category/portal-c
import { ListDocComponent } from './list-doc/list-doc.component'; import { ListDocComponent } from './list-doc/list-doc.component';
import { ApproveExcelComponent } from './approve-excel/approve-excel.component'; import { ApproveExcelComponent } from './approve-excel/approve-excel.component';
import { ListExcelComponent } from './list-excell/list-excell.component'; import { ListExcelComponent } from './list-excell/list-excell.component';
import { ConfirmModalComponent } from './confirm-modal/confirm-modal.component';
import { AlertModalComponent } from './alert-modal/alert-modal.component';
import { ListCourseComponent } from './list-course/list-course.component';
import { ApproveDocComponent } from './approve-doc/approve-doc.component';
import { ApproveCourseComponent } from './approve-course/approve-course.component';
@NgModule({ @NgModule({
...@@ -147,7 +152,12 @@ import { ListExcelComponent } from './list-excell/list-excell.component'; ...@@ -147,7 +152,12 @@ import { ListExcelComponent } from './list-excell/list-excell.component';
PortalCreateCategoryComponent, PortalCreateCategoryComponent,
ListDocComponent, ListDocComponent,
ApproveExcelComponent, ApproveExcelComponent,
ListExcelComponent ListExcelComponent,
ConfirmModalComponent,
AlertModalComponent,
ListCourseComponent,
ApproveDocComponent,
ApproveCourseComponent
], ],
providers: [ providers: [
ContactService, ContactService,
......
...@@ -40,6 +40,9 @@ import { PortalCreateCategoryComponent } from "./portal-create-category/portal-c ...@@ -40,6 +40,9 @@ import { PortalCreateCategoryComponent } from "./portal-create-category/portal-c
import { ListDocComponent } from "./list-doc/list-doc.component"; import { ListDocComponent } from "./list-doc/list-doc.component";
import { ApproveExcelComponent } from "./approve-excel/approve-excel.component"; import { ApproveExcelComponent } from "./approve-excel/approve-excel.component";
import { ListExcelComponent } from "./list-excell/list-excell.component"; import { ListExcelComponent } from "./list-excell/list-excell.component";
import { ListCourseComponent } from "./list-course/list-course.component";
import { ApproveDocComponent } from "./approve-doc/approve-doc.component";
import { ApproveCourseComponent } from "./approve-course/approve-course.component";
export const AppsRoutes: Routes = [ export const AppsRoutes: Routes = [
{ {
path: "", path: "",
...@@ -185,9 +188,9 @@ export const AppsRoutes: Routes = [ ...@@ -185,9 +188,9 @@ export const AppsRoutes: Routes = [
path: "portal-category-list-approve", path: "portal-category-list-approve",
component: PortalCategoryListApproveComponent, component: PortalCategoryListApproveComponent,
data: { data: {
title: "Category List Approve", title: "รายการเอกสารรอการอนุมัติ",
urls: [ urls: [
{ title: "Category List Approve" }, { title: "รายการเอกสารรอการอนุมัติ" },
], ],
}, },
}, },
...@@ -195,10 +198,32 @@ export const AppsRoutes: Routes = [ ...@@ -195,10 +198,32 @@ export const AppsRoutes: Routes = [
path: "approve-excel", path: "approve-excel",
component: ApproveExcelComponent, component: ApproveExcelComponent,
data: { data: {
title: "Approve Excel", title: "อนุมัติ Excel",
urls: [ urls: [
{ title: "Category List Approve" ,url: "apps/portal-category-list-approve"}, { title: "รายการเอกสารรอการอนุมัติ" ,url: "apps/portal-category-list-approve"},
{ title: "Approve Excel" }, { title: "อนุมัติ Excel" },
],
},
},
{
path: "approve-doc",
component: ApproveDocComponent,
data: {
title: "อนุมัติเอกสาร",
urls: [
{ title: "รายการเอกสารรอการอนุมัติ" ,url: "apps/portal-category-list-approve"},
{ title: "อนุมัติเอกสาร" },
],
},
},
{
path: "approve-course",
component: ApproveCourseComponent,
data: {
title: "อนุมัติหลักสูตร",
urls: [
{ title: "รายการเอกสารรอการอนุมัติ" ,url: "apps/portal-category-list-approve"},
{ title: "อนุมัติหลักสูตร" },
], ],
}, },
}, },
...@@ -216,9 +241,9 @@ export const AppsRoutes: Routes = [ ...@@ -216,9 +241,9 @@ export const AppsRoutes: Routes = [
path: "portal-category-list", path: "portal-category-list",
component: PortalCategoryListComponent, component: PortalCategoryListComponent,
data: { data: {
title: "Category List", title: "รายการเอกสาร",
urls: [ urls: [
{ title: "Category List" }, { title: "รายการเอกสาร" },
], ],
}, },
}, },
...@@ -236,9 +261,9 @@ export const AppsRoutes: Routes = [ ...@@ -236,9 +261,9 @@ export const AppsRoutes: Routes = [
path: "portal-create-category", path: "portal-create-category",
component: PortalCreateCategoryComponent, component: PortalCreateCategoryComponent,
data: { data: {
title: "Create Category", title: "รายการเอกสาร",
urls: [ urls: [
{ title: "Create Category" }, { title: "รายการเอกสาร" },
], ],
}, },
}, },
...@@ -266,10 +291,10 @@ export const AppsRoutes: Routes = [ ...@@ -266,10 +291,10 @@ export const AppsRoutes: Routes = [
path: "list-doc", path: "list-doc",
component: ListDocComponent, component: ListDocComponent,
data: { data: {
title: "List", title: "รายการเอกสาร",
urls: [ urls: [
{ title: "Create Category", url: "apps/portal-create-category" }, { title: "รายการเอกสาร", url: "apps/portal-create-category" },
{ title: "List" }, { title: "รายการเอกสาร" },
], ],
}, },
}, },
...@@ -277,10 +302,21 @@ export const AppsRoutes: Routes = [ ...@@ -277,10 +302,21 @@ export const AppsRoutes: Routes = [
path: "list-excel", path: "list-excel",
component: ListExcelComponent, component: ListExcelComponent,
data: { data: {
title: "List Excell", title: "รายการ Excel",
urls: [
{ title: "รายการเอกสาร", url: "apps/portal-create-category" },
{ title: "รายการ Excel" },
],
},
},
{
path: "list-course",
component: ListCourseComponent,
data: {
title: "รายการหลักสูตร",
urls: [ urls: [
{ title: "Create Category", url: "apps/portal-create-category" }, { title: "รายการเอกสาร", url: "apps/portal-create-category" },
{ title: "List" }, { title: "รายการหลักสูตร" },
], ],
}, },
}, },
......
<div class="modal-header">
<h5 class="modal-title" id="editLabel">ข้อความแจ้งเตือน</h5>
<button type="button" class="close" (click)="activeModal.dismiss('dismiss')" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
{{message}}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-info" (click)="activeModal.close('close')">
ยืนยัน
</button>
<button type="button" class="btn btn-danger" (click)="activeModal.dismiss('dismiss')">
ยกเลิก
</button>
</div>
\ No newline at end of file
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ConfirmModalComponent } from './confirm-modal.component';
describe('ConfirmModalComponent', () => {
let component: ConfirmModalComponent;
let fixture: ComponentFixture<ConfirmModalComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ConfirmModalComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(ConfirmModalComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, Input, OnInit } from '@angular/core';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
@Component({
selector: 'app-confirm-modal',
templateUrl: './confirm-modal.component.html',
styleUrls: ['./confirm-modal.component.scss']
})
export class ConfirmModalComponent implements OnInit {
@Input() message: string = "";
constructor(public activeModal: NgbActiveModal) { }
ngOnInit(): void {
}
}
<div class="row">
<div class="col-12">
<div class="card card-body">
<h4 class="card-title">รายการหลักสูตร</h4>
<div class="d-flex mb-3 mt-3">
<input type="text" class="form-control w-25" placeholder="ค้นหา" [(ngModel)]="search" >
<button class="btn btn-primary ml-auto" (click)="openModal(editTemplateModal)">เพิ่มไฟล์หลักสูตร</button>
</div>
<div class="table-responsive ">
<table class="table table-striped mb-0 no-wrap v-middle ">
<thead class="bg-info text-white">
<tr>
<th class="text-center" scope="col">#</th>
<th scope="col">รูปภาพ</th>
<th scope="col">ชื่อ</th>
<th scope="col">รายละเอียด</th>
<th scope="col">ประเภทหลักสูตร</th>
<th scope="col">ลิงค์</th>
<th scope="col">สถานะ</th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
<tr *ngFor="let data of filterListCourse() | slice: (page-1) * pageSize : (page-1) * pageSize + pageSize ; let i = index">
<td class="text-center">{{i+1}}</td>
<td><img width="100" class="border p-1" src="{{data.thumbnail}}"></td>
<!-- <td >{{data.id}}</td> -->
<td>{{ data.thName }}</td>
<td class="text-wrap">{{ data.thDesc }}</td>
<td>{{data.ctype}}</td>
<td><a href="{{data.link1}}" target="_blank">คลิก</a></td>
<td>{{ getStatus(data.status) }}</td>
<!-- <td><a (click)="downloadFile(data.logId)">ดาวน์โหลด</a></td> -->
<td>
<button type="button" [disabled]="data.status != 0" class="btn btn-circle btn-primary rounded-circle btn-sm mr-2" (click)="openModal(editTemplateModal,data)" placement="top" ngbTooltip="แก้ไข">
<i class="fas fa-edit"></i>
</button>
<button type="button" [disabled]="data.status != 0" class="btn btn-circle btn-danger rounded-circle btn-sm mr-2" (click)="deleteFile(data)" placement="top" ngbTooltip="ลบ">
<i class="fas fa-trash-alt"></i>
</button>
<!-- <a href="javascript: void(0);" (click)="openModal(editTemplateModal,data)" class="link mr-2"
placement="top" ngbTooltip="แก้ไข">
<i-feather name="edit-2" class="feather-sm text-primary"></i-feather>
</a>
<a href="javascript: void(0);" class="link" (click)="deleteFile(data)" placement="top"
ngbTooltip="ลบ">
<i-feather name="trash-2" class="feather-sm text-danger"></i-feather>
</a> -->
</td>
</tr>
</tbody>
</table>
</div>
<div class="d-flex justify-content-end py-2">
<select class="custom-select m-r-5" style="width: auto" [(ngModel)]="pageSize" (ngModelChange)="page">
<option [ngValue]="10">รายการต่อหน้า: 10</option>
<option [ngValue]="50">รายการต่อหน้า: 50</option>
<option [ngValue]="100">รายการต่อหน้า: 100</option>
</select>
<ngb-pagination [(page)]="page" [pageSize]="pageSize" [collectionSize]="listCourse.length" [maxSize]="3" [rotate]="true">
<ng-template ngbPaginationPrevious>ก่อนหน้า</ng-template>
<ng-template ngbPaginationNext>ถัดไป</ng-template>
</ngb-pagination>
</div>
</div>
</div>
</div>
<ng-template #editTemplateModal let-modal>
<div class="modal-header">
<h5 class="modal-title" id="edittemplateLabel">{{checkEdit?"แก้ไขไฟล์หลักสูตร":"เพิ่มไฟล์หลักสูตร"}}</h5>
<button type="button" class="close" (click)="closeBtnClick()" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="form-group row">
<label for="nameth" class="col-sm-4 col-form-label">ชื่อหลักสูตร (ไทย)</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="nameth" [(ngModel)]="modelCourse.thName">
</div>
</div>
<div class="form-group row">
<label for="nameeng" class="col-sm-4 col-form-label">ชื่อหลักสูตร (อังกฤษ)</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="nameeng" [(ngModel)]="modelCourse.engName">
</div>
</div>
<div class="form-group row">
<label for="position" class="col-sm-4 col-form-label">รายละเอียดหลักสูตร (ไทย)</label>
<div class="col-sm-8">
<textarea class="form-control" [(ngModel)]="modelCourse.thDesc"></textarea>
</div>
</div>
<div class="form-group row">
<label for="position" class="col-sm-4 col-form-label">รายละเอียดหลักสูตร (อังกฤษ)</label>
<div class="col-sm-8">
<textarea class="form-control" [(ngModel)]="modelCourse.engDesc"></textarea>
</div>
</div>
<div class="form-group row">
<label for="position" class="col-sm-4 col-form-label">วัตถุประสงค์</label>
<div class="col-sm-8">
<textarea class="form-control" [(ngModel)]="modelCourse.objective"></textarea>
</div>
</div>
<div class="form-group row">
<label for="position" class="col-sm-4 col-form-label">ตัวอย่างบนเรียน</label>
<div class="col-sm-8">
<textarea class="form-control" [(ngModel)]="modelCourse.courseOutline"></textarea>
</div>
</div>
<div class="form-group row">
<label for="position" class="col-sm-4 col-form-label">ประเภทหลักสูตร</label>
<div class="col-sm-8">
<input type="text" class="form-control" [(ngModel)]="modelCourse.courseType" >
</div>
</div>
<div class="form-group row">
<label for="position" class="col-sm-4 col-form-label">ระดับผู้เรียน</label>
<div class="col-sm-8">
<input type="text" class="form-control" [(ngModel)]="modelCourse.courseLevel" >
</div>
</div>
<div class="form-group row">
<label for="position" class="col-sm-4 col-form-label">ระยะเวลาในการเรียนรู้ (ชั่วโมง)</label>
<div class="col-sm-8">
<input type="text" class="form-control" [(ngModel)]="modelCourse.courseTime">
</div>
</div>
<div class="form-group row">
<label for="position" class="col-sm-4 col-form-label">ชื่อผู้สอน</label>
<div class="col-sm-8">
<input type="text" class="form-control" [(ngModel)]="modelCourse.courseTrainer" >
</div>
</div>
<div class="form-group row">
<label for="position" class="col-sm-4 col-form-label">ประวัติผู้สอน</label>
<div class="col-sm-8">
<textarea class="form-control" [(ngModel)]="modelCourse.courseTrainerDetail"></textarea>
</div>
</div>
<div class="form-group row">
<label for="name" class="col-sm-4 col-form-label">ไฟล์อัพโหลด</label>
<div class="col-sm-8">
<input type="file" class="form-control" (change)="onSelectFile($event)">
</div>
</div>
<div class="form-group row">
<label for="name" class="col-sm-4 col-form-label">Link รูปภาพตัวอย่างรายงาน</label>
<div class="col-sm-8">
<input type="text" class="form-control"[(ngModel)]="modelCourse.thumbnail">
</div>
</div>
<div class="form-group row">
<label for="name" class="col-sm-4 col-form-label">Link ตัวอย่าง</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="nameeng" [(ngModel)]="modelCourse.link1">
</div>
</div>
<div class="form-group row">
<label for="position" class="col-sm-4 col-form-label">หมายเหตุ</label>
<div class="col-sm-8">
<textarea class="form-control"[(ngModel)]="modelCourse.remark"></textarea>
</div>
</div>
<div class="modal-footer ">
<button type="submit" class="btn btn-info" (click)="onSumit()" [disabled]="!modelCourse.tname||!modelCourse.ename">บันทึก</button>
<button type="button" class="btn btn-danger" (click)="closeBtnClick()">ปิด</button>
</div>
</div>
</ng-template>
\ No newline at end of file
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ListCourseComponent } from './list-course.component';
describe('ListCourseComponent', () => {
let component: ListCourseComponent;
let fixture: ComponentFixture<ListCourseComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ListCourseComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(ListCourseComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { ExcelService } from 'src/app/service/excel.service';
import { ConfirmModalComponent } from '../confirm-modal/confirm-modal.component';
import { AlertModalComponent } from '../alert-modal/alert-modal.component';
import { CourseModel } from 'src/app/model/course.model';
import { CourseService } from 'src/app/service/course.service';
@Component({
selector: 'app-list-course',
templateUrl: './list-course.component.html',
styleUrls: ['./list-course.component.scss']
})
export class ListCourseComponent implements OnInit {
page = 1;
pageSize = 10;
listCourse:CourseModel[]=[]
modelCourse:CourseModel = new CourseModel({});
checkEdit:boolean = false
search:string = ''
constructor(private modalService: NgbModal,private courseService:CourseService) {
}
onSelectFile(event:any) {
if (event.target.files && event.target.files[0]) {
let reader = new FileReader();
reader.readAsDataURL(event.target.files[0]); // read file as data url
reader.onload = (event) => { // called once readAsDataURL is completed
if(event){
let base64 = event.target!.result as string
this.modelCourse.courseObj = base64.split(',')[1];
}
}
}
}
async downloadFile(logId:string){
try {
const data = await this.courseService.downloadFile(logId).toPromise();
} catch (error) {
console.error('Error loading data:', error);
}
}
deleteFile(item:CourseModel){
const modalRef = this.modalService.open(ConfirmModalComponent, {
centered: true,
backdrop: 'static',
})
modalRef.componentInstance.message = 'คุณต้องการลบข้อมูลหรือไม่'
modalRef.result.then(result => {
this.courseService.deleteCourse(item).subscribe(result => {
if (result) {
this.openAlertModal('ลบข้อมูลสำเร็จ')
this.getListCourse();
} else {
this.openAlertModal('ไม่สามารถลบข้อมูลได้')
}
}, error => {
this.openAlertModal(error.message)
})
}, reject => { })
}
openAlertModal(message?: string) {
const modalRef = this.modalService.open(AlertModalComponent, {
centered: true,
backdrop: 'static'
})
modalRef.componentInstance.message = message ? message : ""
modalRef.result.then(result => {
this.modalService.dismissAll()
}, reason => {
this.modalService.dismissAll()
})
}
onUpdate(){
const modalRef = this.modalService.open(ConfirmModalComponent, {
centered: true,
backdrop: 'static',
})
modalRef.componentInstance.message = 'คุณต้องการอัพเดทข้อมูลหรือไม่'
modalRef.result.then(result => {
console.log(this.modelCourse);
this.courseService.createCourse(this.modelCourse).subscribe(result => {
if (result) {
this.openAlertModal('อัพเดทข้อมูลสำเร็จ')
this.getListCourse();
} else {
this.openAlertModal('ไม่สามารถอัพเดทข้อมูลได้')
}
}, error => {
this.openAlertModal(error.message)
})
}, reject => { })
}
onCreate(){
const modalRef = this.modalService.open(ConfirmModalComponent, {
centered: true,
backdrop: 'static',
})
modalRef.componentInstance.message = 'คุณต้องการบันทึกข้อมูลหรือไม่'
modalRef.result.then(result => {
this.courseService.createCourse(this.modelCourse).subscribe(result => {
if (result) {
this.openAlertModal('บันทึกข้อมูลสำเร็จ')
this.getListCourse();
} else {
this.openAlertModal('ไม่สามารถสร้างเอกสารได้')
}
}, error => {
this.openAlertModal(error.message)
})
}, reject => { })
}
onSumit() {
if(this.checkEdit){
this.onUpdate();
}else{
this.onCreate();
}
}
async getExcelById(targetModal: NgbModal,id:string){
try {
const data = await this.courseService.getCourseById(id).toPromise();
this.modelCourse = new CourseModel(data)
if(data){
this.modalService.open(targetModal, {
centered: true,
backdrop: 'static',
size: 'lg'
});
}
} catch (error) {
console.error('Error loading data:', error);
}
}
openModal(targetModal: NgbModal,item?:CourseModel) {
if(item){
this.getExcelById(targetModal,item.logId)
this.checkEdit = true
}else{
this.modelCourse = new CourseModel({});
this.checkEdit = false
this.modalService.open(targetModal, {
centered: true,
backdrop: 'static',
size: 'lg'
});
}
}
getStatus(status:string){
if(status == '0'){
return 'รออนุมัติ'
} else if(status == '1'){
return 'เปิดใช้งาน'
} else if(status == '2'){
return 'ไม่อนุมัติ'
}
}
async getListCourse(){
try {
const data = await this.courseService.getListCourse().toPromise();
this.listCourse = data
} catch (error) {
console.error('Error loading data:', error);
}
}
filterListCourse(){
return this.listCourse.filter(x => x.thName.toLowerCase().includes(this.search.toLowerCase())||x.engName.toLowerCase().includes(this.search.toLowerCase()))
}
ngOnInit() {
this.getListCourse();
}
closeBtnClick() {
this.modalService.dismissAll();
this.ngOnInit();
}
}
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { ConfirmModalComponent } from '../confirm-modal/confirm-modal.component';
import { DatePipe } from '@angular/common'; import { AlertModalComponent } from '../alert-modal/alert-modal.component';
import { UserService } from '../users/userService.service'; import { DocumentService } from 'src/app/service/document.service';
import { User } from '../users/user'; import { DocumentModel } from 'src/app/model/document.model';
@Component({ @Component({
selector: 'app-list-doc', selector: 'app-list-doc',
...@@ -11,89 +11,166 @@ import { User } from '../users/user'; ...@@ -11,89 +11,166 @@ import { User } from '../users/user';
styleUrls: ['./list-doc.component.scss'] styleUrls: ['./list-doc.component.scss']
}) })
export class ListDocComponent implements OnInit { export class ListDocComponent implements OnInit {
page = 1;
get searchTerm(): string { pageSize = 10;
return this._searchTerm; listDoc:DocumentModel[]=[]
modelDoc:DocumentModel = new DocumentModel({});
checkEdit:boolean = false
search:string = ''
constructor(private modalService: NgbModal,private documentService:DocumentService) {
} }
set searchTerm(val: string) {
this._searchTerm = val; onSelectFile(event:any) {
this.filterArray = this.filter(val); if (event.target.files && event.target.files[0]) {
let reader = new FileReader();
reader.readAsDataURL(event.target.files[0]); // read file as data url
reader.onload = (event) => { // called once readAsDataURL is completed
if(event){
let base64 = event.target!.result as string
this.modelDoc.doclObj = base64.split(',')[1];
}
}
}
} }
page = 1; async downloadFile(logId:string){
pageSize = 7; try {
const data = await this.documentService.downloadFile(logId).toPromise();
filterArray: { } catch (error) {
id:string; console.error('Error loading data:', error);
name: String; }
detail: String;
dateupload: String;
status: String;
link: String;
}[] = [];
_searchTerm = '';
testdata: {
id:string;
name: String;
detail: String;
dateupload: String;
status: String;
link: String;
}[] = [];
constructor(private modalService: NgbModal) {
} }
deleteFile(item:DocumentModel){
const modalRef = this.modalService.open(ConfirmModalComponent, {
centered: true,
backdrop: 'static',
})
modalRef.componentInstance.message = 'คุณต้องการลบข้อมูลหรือไม่'
modalRef.result.then(result => {
this.documentService.deleteExcel(item).subscribe(result => {
if (result) {
this.openAlertModal('ลบข้อมูลสำเร็จ')
this.getListDoc();
} else {
this.openAlertModal('ไม่สามารถลบข้อมูลได้')
}
}, error => {
this.openAlertModal(error.message)
})
}, reject => { })
ngOnInit() {
this.testdata = [
{
id:'2024-1101',
name: "Template Excel ข้อมูลพนักงาน",
detail: "แสดงรายชื่อพนักงานทั้งหมด",
dateupload: "11/06/2024",
status: "รออนุมัติ",
link: "https://www.youtube.com/watch?v=wOK9j3q20tw",
},
{
id:'2024-1102',
name: "หนังสือรับรองเงินเดือน Word",
detail: "เอกสารใบรับรองเงินเดือน",
dateupload: "10/06/2024",
status: "รออนุมัติ",
link: "https://www.youtube.com/watch?v=wOK9j3q20tw",
},
{
id:'2024-1103',
name: "Resume",
detail: "ตัวอย่าง Resume",
dateupload: "09/06/2024",
status: "เปิดใช้งาน",
link: "https://www.youtube.com/watch?v=wOK9j3q20tw",
},
{
id:'2024-1104',
name: "Template Excel เวลาการทำงาน",
detail: "ข้อมูลเวลาการทำงาน ",
dateupload: "09/06/2024",
status: "ไม่อนุมัติ",
link: "https://www.youtube.com/watch?v=wOK9j3q20tw",
},
];
this.filterArray = this.testdata
} }
openAlertModal(message?: string) {
filter(v: string) { const modalRef = this.modalService.open(AlertModalComponent, {
return this.testdata.filter(x => x.name.toLowerCase().indexOf(v.toLowerCase()) !== -1); centered: true,
backdrop: 'static'
})
modalRef.componentInstance.message = message ? message : ""
modalRef.result.then(result => {
this.modalService.dismissAll()
}, reason => {
this.modalService.dismissAll()
})
} }
openModal(targetModal: NgbModal, user: User | null) { onUpdate(){
this.modalService.open(targetModal, { const modalRef = this.modalService.open(ConfirmModalComponent, {
centered: true, centered: true,
backdrop: 'static', backdrop: 'static',
size: 'lg' })
}); modalRef.componentInstance.message = 'คุณต้องการอัพเดทข้อมูลหรือไม่'
modalRef.result.then(result => {
console.log(this.modelDoc);
this.documentService.createDoc(this.modelDoc).subscribe(result => {
if (result) {
this.openAlertModal('อัพเดทข้อมูลสำเร็จ')
this.getListDoc();
} else {
this.openAlertModal('ไม่สามารถอัพเดทข้อมูลได้')
}
}, error => {
this.openAlertModal(error.message)
})
}, reject => { })
}
onCreate(){
const modalRef = this.modalService.open(ConfirmModalComponent, {
centered: true,
backdrop: 'static',
})
modalRef.componentInstance.message = 'คุณต้องการบันทึกข้อมูลหรือไม่'
modalRef.result.then(result => {
this.documentService.createDoc(this.modelDoc).subscribe(result => {
if (result) {
this.openAlertModal('บันทึกข้อมูลสำเร็จ')
this.getListDoc();
} else {
this.openAlertModal('ไม่สามารถสร้างเอกสารได้')
}
}, error => {
this.openAlertModal(error.message)
})
}, reject => { })
}
onSumit() {
if(this.checkEdit){
this.onUpdate();
}else{
this.onCreate();
}
}
async getExcelById(targetModal: NgbModal,id:string){
try {
const data = await this.documentService.getDocById(id).toPromise();
this.modelDoc = new DocumentModel(data)
if(data){
this.modalService.open(targetModal, {
centered: true,
backdrop: 'static',
size: 'lg'
});
}
} catch (error) {
console.error('Error loading data:', error);
}
}
openModal(targetModal: NgbModal,item?:DocumentModel) {
if(item){
this.getExcelById(targetModal,item.logId)
this.checkEdit = true
}else{
this.modelDoc = new DocumentModel({});
this.checkEdit = false
this.modalService.open(targetModal, {
centered: true,
backdrop: 'static',
size: 'lg'
});
}
}
getStatus(status:string){
if(status == '0'){
return 'รออนุมัติ'
} else if(status == '1'){
return 'เปิดใช้งาน'
} else if(status == '2'){
return 'ไม่อนุมัติ'
}
}
async getListDoc(){
try {
const data = await this.documentService.getListDoc().toPromise();
this.listDoc = data
} catch (error) {
console.error('Error loading data:', error);
}
}
filterListDoc(){
return this.listDoc.filter(x => x.thName.toLowerCase().includes(this.search.toLowerCase())||x.engName.toLowerCase().includes(this.search.toLowerCase()))
}
ngOnInit() {
this.getListDoc();
} }
...@@ -101,4 +178,5 @@ export class ListDocComponent implements OnInit { ...@@ -101,4 +178,5 @@ export class ListDocComponent implements OnInit {
this.modalService.dismissAll(); this.modalService.dismissAll();
this.ngOnInit(); this.ngOnInit();
} }
} }
...@@ -3,52 +3,60 @@ ...@@ -3,52 +3,60 @@
<div class="card card-body"> <div class="card card-body">
<h4 class="card-title">รายการ Excel</h4> <h4 class="card-title">รายการ Excel</h4>
<div class="d-flex mb-3 mt-3"> <div class="d-flex mb-3 mt-3">
<input type="text" class="form-control w-25" placeholder="ค้นหา" [(ngModel)]='searchTerm'> <input type="text" class="form-control w-25" placeholder="ค้นหา" [(ngModel)]="search" >
<button class="btn btn-primary ml-auto" (click)="openModal(editTemplateModal)">เพิ่มไฟล์ Excel</button> <button class="btn btn-primary ml-auto" (click)="openModal(editTemplateModal)">เพิ่มไฟล์ Excel</button>
</div> </div>
<div class="table-responsive table-bordered"> <div class="table-responsive">
<table class="table table-striped mb-0 no-wrap v-middle "> <table class="table table-striped mb-0 no-wrap v-middle ">
<thead> <thead class="bg-info text-white">
<tr> <tr>
<th class="text-center" scope="col">#</th> <th class="text-center" scope="col">#</th>
<th scope="col">รูปภาพ</th> <th scope="col">รูปภาพ</th>
<th scope="col">รหัสเอกสาร</th> <!-- <th scope="col">รหัสเอกสาร</th> -->
<th scope="col">ชื่อ</th> <th scope="col">ชื่อ</th>
<th scope="col">รายละเอียด</th> <th scope="col">รายละเอียด</th>
<th scope="col">วันที่อัพโหลด</th>
<th scope="col">สถานะ</th>
<th scope="col">ลิงค์</th> <th scope="col">ลิงค์</th>
<th scope="col">สถานะ</th>
<!-- <th scope="col">ไฟล์</th> -->
<th scope="col"></th> <th scope="col"></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr *ngFor="let data of testdata | slice: (page-1) * pageSize : (page-1) * pageSize + pageSize ; let i = index"> <tr *ngFor="let data of filterListExcel() | slice: (page-1) * pageSize : (page-1) * pageSize + pageSize ; let i = index">
<td class="text-center">{{i+1}}</td> <td class="text-center">{{i+1}}</td>
<td><img width="100" class="border p-1" src="{{data.img}}"></td> <td><img width="100" class="border p-1" src="{{data.thumbnail}}"></td>
<td >{{data.id}}</td> <!-- <td >{{data.id}}</td> -->
<td>{{ data.name }}</td> <td>{{ data.thName }}</td>
<td>{{ data.detail }}</td> <td>{{ data.thDesc }}</td>
<td>{{ data.dateupload }}</td> <td><a href="{{data.link1}}" target="_blank">คลิก</a></td>
<td>{{ data.status }}</td> <td>{{ getStatus(data.status) }}</td>
<td><a href="{{data.link}}" target="_blank">คลิก</a></td> <!-- <td><a (click)="downloadFile(data.logId)">ดาวน์โหลด</a></td> -->
<td> <td>
<a href="javascript: void(0);" (click)="openModal(editTemplateModal, template)" class="link mr-2" <button type="button" [disabled]="data.status != 0" class="btn btn-circle btn-primary rounded-circle btn-sm mr-2" (click)="openModal(editTemplateModal,data)" placement="top" ngbTooltip="แก้ไข">
placement="top" ngbTooltip="แก้ไข"> <i class="fas fa-edit"></i>
<i-feather name="edit-2" class="feather-sm text-primary"></i-feather> </button>
</a> <button type="button" [disabled]="data.status != 0" class="btn btn-circle btn-danger rounded-circle btn-sm mr-2" (click)="deleteFile(data)" placement="top" ngbTooltip="ลบ">
<a href="javascript: void(0);" class="link" (click)="deletetemplate(template.id)" placement="top" <i class="fas fa-trash-alt"></i>
ngbTooltip="ลบ"> </button>
<i-feather name="trash-2" class="feather-sm text-danger"></i-feather>
</a>
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div> </div>
<div class="d-flex justify-content-center mt-5"> <div class="d-flex justify-content-end py-2">
<ngb-pagination [(page)]="page" [pageSize]="pageSize" [collectionSize]="testdata.length"></ngb-pagination>
<select class="custom-select m-r-5" style="width: auto" [(ngModel)]="pageSize" (ngModelChange)="page">
<option [ngValue]="10">รายการต่อหน้า: 10</option>
<option [ngValue]="50">รายการต่อหน้า: 50</option>
<option [ngValue]="100">รายการต่อหน้า: 100</option>
</select>
<ngb-pagination [(page)]="page" [pageSize]="pageSize" [collectionSize]="listExcel.length" [maxSize]="3" [rotate]="true">
<ng-template ngbPaginationPrevious>ก่อนหน้า</ng-template>
<ng-template ngbPaginationNext>ถัดไป</ng-template>
</ngb-pagination>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
...@@ -56,7 +64,7 @@ ...@@ -56,7 +64,7 @@
<ng-template #editTemplateModal let-modal> <ng-template #editTemplateModal let-modal>
<div class="modal-header"> <div class="modal-header">
<h5 class="modal-title" id="edittemplateLabel">เพิ่มไฟล์ Excel</h5> <h5 class="modal-title" id="edittemplateLabel">{{checkEdit?"แก้ไขไฟล์ Excel":"เพิ่มไฟล์ Excel"}}</h5>
<button type="button" class="close" (click)="closeBtnClick()" aria-label="Close"> <button type="button" class="close" (click)="closeBtnClick()" aria-label="Close">
<span aria-hidden="true">&times;</span> <span aria-hidden="true">&times;</span>
</button> </button>
...@@ -64,57 +72,71 @@ ...@@ -64,57 +72,71 @@
<div class="modal-body"> <div class="modal-body">
<div class="form-group row"> <div class="form-group row">
<label for="name" class="col-sm-4 col-form-label">ชื่อรายงาน (ไทย)</label> <label for="nameth" class="col-sm-4 col-form-label">ชื่อรายงาน (ไทย)</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input type="text" class="form-control" id="nameth"> <input type="text" class="form-control" id="nameth" [(ngModel)]="modelExcel.thName">
</div> </div>
</div> </div>
<div class="form-group row"> <div class="form-group row">
<label for="name" class="col-sm-4 col-form-label">ชื่อรายงาน (อังกฤษ)</label> <label for="nameeng" class="col-sm-4 col-form-label">ชื่อรายงาน (อังกฤษ)</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input type="text" class="form-control" id="nameeng"> <input type="text" class="form-control" id="nameeng" [(ngModel)]="modelExcel.engName">
</div> </div>
</div> </div>
<div class="form-group row"> <div class="form-group row">
<label for="position" class="col-sm-4 col-form-label">รายละเอียดรายงาน (ไทย)</label> <label for="position" class="col-sm-4 col-form-label">รายละเอียดรายงาน (ไทย)</label>
<div class="col-sm-8"> <div class="col-sm-8">
<textarea class="form-control"></textarea> <textarea class="form-control" [(ngModel)]="modelExcel.thDesc"></textarea>
</div> </div>
</div> </div>
<div class="form-group row">
<label for="position" class="col-sm-4 col-form-label">รายละเอียดรายงาน (อังกฤษ)</label>
<div class="col-sm-8">
<textarea class="form-control" [(ngModel)]="modelExcel.engDesc"></textarea>
</div>
</div>
<div class="form-group row"> <div class="form-group row">
<label for="position" class="col-sm-4 col-form-label">รายละเอียดรายงาน (อังกฤษ)</label> <label for="position" class="col-sm-4 col-form-label">ดาต้าเบสที่รองรับ</label>
<div class="col-sm-8"> <div class="col-sm-8">
<textarea class="form-control"></textarea> <input type="text" class="form-control" id="nameeng" [(ngModel)]="modelExcel.dbSupport">
</div> </div>
</div> </div>
<div class="form-group row"> <div class="form-group row">
<label for="name" class="col-sm-4 col-form-label">รูปภาพตัวอย่างรายงาน</label> <label for="name" class="col-sm-4 col-form-label">ไฟล์อัพโหลด</label>
<div class="col-sm-8">
<input type="file" class="form-control" (change)="onSelectFile($event)">
</div>
</div>
<div class="form-group row">
<label for="name" class="col-sm-4 col-form-label">Link รูปภาพตัวอย่างรายงาน</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input type="file" class="form-control"> <input type="text" class="form-control"[(ngModel)]="modelExcel.thumbnail">
</div> </div>
</div> </div>
<div class="form-group row"> <div class="form-group row">
<label for="name" class="col-sm-4 col-form-label">ลิงค์ตัวอย่าง</label> <label for="name" class="col-sm-4 col-form-label">Link ตัวอย่าง</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input type="text" class="form-control" id="nameeng"> <input type="text" class="form-control" id="nameeng" [(ngModel)]="modelExcel.link1">
</div> </div>
</div> </div>
<div class="form-group row"> <div class="form-group row">
<label for="position" class="col-sm-4 col-form-label">หมายเหตุ</label> <label for="position" class="col-sm-4 col-form-label">หมายเหตุ</label>
<div class="col-sm-8"> <div class="col-sm-8">
<textarea class="form-control"></textarea> <textarea class="form-control"[(ngModel)]="modelExcel.remark"></textarea>
</div> </div>
</div> </div>
<div class="modal-footer "> <div class="modal-footer ">
<button type="submit" class="btn btn-info" [disabled]="edittemplate.invalid">บันทึก</button> <button type="submit" class="btn btn-info" (click)="onSumit()" [disabled]="!modelExcel.tname||!modelExcel.ename">บันทึก</button>
<button type="button" class="btn btn-danger" (click)="closeBtnClick()">ปิด</button> <button type="button" class="btn btn-danger" (click)="closeBtnClick()">ปิด</button>
</div> </div>
</div> </div>
......
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { ExcelModel } from 'src/app/model/excel.model';
import { ExcelService } from 'src/app/service/excel.service';
import { ConfirmModalComponent } from '../confirm-modal/confirm-modal.component';
import { AlertModalComponent } from '../alert-modal/alert-modal.component';
@Component({ @Component({
selector: 'app-list-excel', selector: 'app-list-excel',
...@@ -7,95 +11,166 @@ import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; ...@@ -7,95 +11,166 @@ import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
styleUrls: ['./list-excell.component.scss'] styleUrls: ['./list-excell.component.scss']
}) })
export class ListExcelComponent implements OnInit { export class ListExcelComponent implements OnInit {
page = 1;
pageSize = 10;
get searchTerm(): string { listExcel:ExcelModel[]=[]
return this._searchTerm; modelExcel:ExcelModel = new ExcelModel({});
checkEdit:boolean = false
search:string = ''
constructor(private modalService: NgbModal,private excelService:ExcelService) {
} }
set searchTerm(val: string) {
this._searchTerm = val; onSelectFile(event:any) {
this.filterArray = this.filter(val); if (event.target.files && event.target.files[0]) {
let reader = new FileReader();
reader.readAsDataURL(event.target.files[0]); // read file as data url
reader.onload = (event) => { // called once readAsDataURL is completed
if(event){
let base64 = event.target!.result as string
this.modelExcel.excelObj = base64.split(',')[1];
}
}
}
} }
page = 1; async downloadFile(logId:string){
pageSize = 7; try {
const data = await this.excelService.downloadFile(logId).toPromise();
filterArray: { } catch (error) {
id:string; console.error('Error loading data:', error);
name: String; }
detail: String;
dateupload: String;
status: String;
link: String;
}[] = [];
_searchTerm = '';
testdata: {
id:string;
name: String;
detail: String;
dateupload: String;
status: String;
link: String;
img:string
}[] = [];
constructor(private modalService: NgbModal) {
} }
deleteFile(item:ExcelModel){
const modalRef = this.modalService.open(ConfirmModalComponent, {
centered: true,
backdrop: 'static',
})
modalRef.componentInstance.message = 'คุณต้องการลบข้อมูลหรือไม่'
modalRef.result.then(result => {
this.excelService.deleteExcel(item).subscribe(result => {
if (result) {
this.openAlertModal('ลบข้อมูลสำเร็จ')
this.getListExcel();
} else {
this.openAlertModal('ไม่สามารถลบข้อมูลได้')
}
}, error => {
this.openAlertModal(error.message)
})
}, reject => { })
ngOnInit() {
this.testdata = [
{
id:'2024-1101',
name: "Template Excel ข้อมูลพนักงาน",
detail: "แสดงรายชื่อพนักงานทั้งหมด",
dateupload: "11/06/2024",
status: "รออนุมัติ",
link: "https://www.youtube.com/watch?v=wOK9j3q20tw",
img:'assets/images/phototest/9a60ef19-7813-4094-bc45-17b7d9decc70.jpg'
},
{
id:'2024-1102',
name: "หนังสือรับรองเงินเดือน Word",
detail: "เอกสารใบรับรองเงินเดือน",
dateupload: "10/06/2024",
status: "รออนุมัติ",
link: "https://www.youtube.com/watch?v=wOK9j3q20tw",
img:'assets/images/phototest/3daddc9f-f69a-470b-8275-7db59db1a89b.jpg'
},
{
id:'2024-1103',
name: "Resume",
detail: "ตัวอย่าง Resume",
dateupload: "09/06/2024",
status: "เปิดใช้งาน",
link: "https://www.youtube.com/watch?v=wOK9j3q20tw",
img:'assets/images/phototest/acb4b666-437e-47d1-94ca-4dbce9ce0761.jpg'
},
{
id:'2024-1104',
name: "Template Excel เวลาการทำงาน",
detail: "ข้อมูลเวลาการทำงาน ",
dateupload: "09/06/2024",
status: "ไม่อนุมัติ",
link: "https://www.youtube.com/watch?v=wOK9j3q20tw",
img:'assets/images/phototest/3daddc9f-f69a-470b-8275-7db59db1a89b.jpg'
},
];
this.filterArray = this.testdata
} }
openAlertModal(message?: string) {
filter(v: string) { const modalRef = this.modalService.open(AlertModalComponent, {
return this.testdata.filter(x => x.name.toLowerCase().indexOf(v.toLowerCase()) !== -1); centered: true,
backdrop: 'static'
})
modalRef.componentInstance.message = message ? message : ""
modalRef.result.then(result => {
this.modalService.dismissAll()
}, reason => {
this.modalService.dismissAll()
})
} }
openModal(targetModal: NgbModal) { onUpdate(){
this.modalService.open(targetModal, { const modalRef = this.modalService.open(ConfirmModalComponent, {
centered: true,
backdrop: 'static',
})
modalRef.componentInstance.message = 'คุณต้องการอัพเดทข้อมูลหรือไม่'
modalRef.result.then(result => {
console.log(this.modelExcel);
this.excelService.createExcel(this.modelExcel).subscribe(result => {
if (result) {
this.openAlertModal('อัพเดทข้อมูลสำเร็จ')
this.getListExcel();
} else {
this.openAlertModal('ไม่สามารถอัพเดทข้อมูลได้')
}
}, error => {
this.openAlertModal(error.message)
})
}, reject => { })
}
onCreate(){
const modalRef = this.modalService.open(ConfirmModalComponent, {
centered: true, centered: true,
backdrop: 'static', backdrop: 'static',
size: 'lg' })
}); modalRef.componentInstance.message = 'คุณต้องการบันทึกข้อมูลหรือไม่'
modalRef.result.then(result => {
this.excelService.createExcel(this.modelExcel).subscribe(result => {
if (result) {
this.openAlertModal('บันทึกข้อมูลสำเร็จ')
this.getListExcel();
} else {
this.openAlertModal('ไม่สามารถสร้างเอกสารได้')
}
}, error => {
this.openAlertModal(error.message)
})
}, reject => { })
}
onSumit() {
if(this.checkEdit){
this.onUpdate();
}else{
this.onCreate();
}
}
async getExcelById(targetModal: NgbModal,id:string){
try {
const data = await this.excelService.getExcelById(id).toPromise();
this.modelExcel = new ExcelModel(data)
if(data){
this.modalService.open(targetModal, {
centered: true,
backdrop: 'static',
size: 'lg'
});
}
} catch (error) {
console.error('Error loading data:', error);
}
}
openModal(targetModal: NgbModal,item?:ExcelModel) {
if(item){
this.getExcelById(targetModal,item.logId)
this.checkEdit = true
}else{
this.modelExcel = new ExcelModel({});
this.checkEdit = false
this.modalService.open(targetModal, {
centered: true,
backdrop: 'static',
size: 'lg'
});
}
}
getStatus(status:string){
if(status == '0'){
return 'รออนุมัติ'
} else if(status == '1'){
return 'เปิดใช้งาน'
} else if(status == '2'){
return 'ไม่อนุมัติ'
}
}
async getListExcel(){
try {
const data = await this.excelService.getListExcel().toPromise();
this.listExcel = data
} catch (error) {
console.error('Error loading data:', error);
}
}
filterListExcel(){
return this.listExcel.filter(x => x.thName.toLowerCase().includes(this.search.toLowerCase())||x.engName.toLowerCase().includes(this.search.toLowerCase()))
}
ngOnInit() {
this.getListExcel();
} }
......
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<div class="card card-body"> <div class="card card-body">
<h4 class="card-title">Category List Approve</h4> <h4 class="card-title">รายการเอกสารรอการอนุมัติ</h4>
<div class="d-flex mb-1 mt-1"> <div class="row justify-content-center">
<input type="text" class="form-control w-25" placeholder="Search" [(ngModel)]='searchTerm'> <div class="col-md-4 " *ngFor="let c of testdata|slice: (page-1) * pageSize : (page-1) * pageSize + pageSize">
<!-- <button class="btn btn-primary ml-auto" (click)="openModal(editTemplateModal)">Add File Type Category</button> --> <div class="card border border-2">
</div> <div class="card-body text-center">
</div> <img src="{{ c.img }}" class="rounded-circle border p-1" width="100">
</div> <h3 class="card-title mt-3 mb-0">{{c.name}}</h3>
</div> </div>
<div class="d-flex justify-content-between bg-light border-top p-3">
<div class="row justify-content-center"> <div>
<div class="col-md-4" *ngFor="let c of testdata|slice: (page-1) * pageSize : (page-1) * pageSize + pageSize"> <span class="align-middle">{{ c.document }}</span>
<div class="card"> </div>
<div class="card-body text-center"> <div >
<img src="{{ c.img }}" class="rounded-circle border p-1" width="100"> <button class="btn btn-info btn-sm text-nowrap" (click)="openView(c.id)">รายละเอียด</button>
<h3 class="card-title mt-3 mb-0">{{c.name}}</h3> </div>
<div class="mt-1 pt-1"> </div>
<h4 class="card-title mt-3 mb-0">{{c.details}}</h4> </div>
<br />
</div>
<div class="mt-3">
<a (click)="openView(c.id)">
<button class="btn btn-info">View</button>
</a>
<!-- <button class="btn btn-warning">Edit</button>
<button class="btn btn-danger">Delete</button> -->
<!-- <button class="btn btn-light">Follow</button> -->
</div>
</div>
<div class="d-flex text-center justify-content-md-center bg-light border-top">
<div class="col-12 border-bottom py-3">
{{ c.document }}
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="d-flex justify-content-center mt-5"> \ No newline at end of file
<ngb-pagination [(page)]="page" [pageSize]="pageSize" [collectionSize]="testdata.length"></ngb-pagination>
</div>
<!-- Add File -->
<ng-template #editTemplateModal let-modal>
<div class="modal-header">
<h5 class="modal-title" id="edittemplateLabel">Add File Type Category</h5>
<button type="button" class="close" (click)="closeBtnClick()" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<form [formGroup]="edittemplate" (ngSubmit)="onSubmit()">
<div class="form-group row">
<label for="name" class="col-sm-4 col-form-label">ชื่อประเภทไฟล์</label>
<div class="col-sm-8">
<input type="text" class="form-control" formControlName="Name" id="name" (blur)=logValidationErrors(edittemplate)>
</div>
</div>
<div class="form-group row">
<label for="position" class="col-sm-4 col-form-label">รายละเอียด</label>
<div class="col-sm-8">
<textarea class="form-control"></textarea>
</div>
</div>
<div class="form-group row">
<label for="name" class="col-sm-4 col-form-label">รูปประเภทไฟล์</label>
<div class="col-sm-8">
<input type="file" class="form-control">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" (click)="closeBtnClick()">Close</button>
<button type="submit" class="btn btn-primary" >Save</button>
</div>
</form>
</div>
</ng-template>
...@@ -41,21 +41,21 @@ export class PortalCategoryListApproveComponent implements OnInit { ...@@ -41,21 +41,21 @@ export class PortalCategoryListApproveComponent implements OnInit {
{ {
id:'1', id:'1',
img: "assets/images/icon/excel.png", img: "assets/images/icon/excel.png",
name: "ประเภทไฟล์: Excel", name: "Excel",
details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx", details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
document: "จำนวนเอกสาร 8 ฉบับ" document: "จำนวนเอกสาร 8 ฉบับ"
}, },
{ {
id:'2', id:'2',
img: "assets/images/icon/document.png", img: "assets/images/icon/document.png",
name: "ประเภทไฟล์: Document", name: "Document",
details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx", details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
document: "จำนวนเอกสาร 3 ฉบับ" document: "จำนวนเอกสาร 3 ฉบับ"
}, },
{ {
id:'3', id:'3',
img: "assets/images/icon/course.png", img: "assets/images/icon/course.png",
name: "ประเภทไฟล์: Course", name: "Course",
details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx", details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
document: "จำนวนเอกสาร 5 ฉบับ" document: "จำนวนเอกสาร 5 ฉบับ"
}, },
...@@ -64,6 +64,10 @@ export class PortalCategoryListApproveComponent implements OnInit { ...@@ -64,6 +64,10 @@ export class PortalCategoryListApproveComponent implements OnInit {
openView(id:string){ openView(id:string){
if(id =='1'){ if(id =='1'){
this.router.navigate(['apps/approve-excel']); this.router.navigate(['apps/approve-excel']);
} else if(id =='2'){
this.router.navigate(['apps/approve-doc']);
}else if(id =='3'){
this.router.navigate(['apps/approve-course']);
} }
} }
openModal(targetModal: NgbModal) { openModal(targetModal: NgbModal) {
......
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<div class="card card-body"> <div class="card card-body">
<h4 class="card-title">Category List</h4> <h4 class="card-title">รายการเอกสาร</h4>
<div class="d-flex mb-1 mt-1"> <div class="row justify-content-center">
<input type="text" class="form-control w-25" placeholder="Search" [(ngModel)]='searchTerm'> <div class="col-md-4 " *ngFor="let c of testdata|slice: (page-1) * pageSize : (page-1) * pageSize + pageSize">
<!-- <button class="btn btn-primary ml-auto" (click)="openModal(editTemplateModal)">Add File Type Category</button> --> <div class="card border border-2">
</div> <div class="card-body text-center">
</div> <img src="{{ c.img }}" class="rounded-circle border p-1" width="100">
</div> <h3 class="card-title mt-3 mb-0">{{c.name}}</h3>
</div> </div>
<div class="d-flex justify-content-between bg-light border-top p-3">
<div class="row justify-content-center"> <div>
<div class="col-md-4" *ngFor="let c of testdata|slice: (page-1) * pageSize : (page-1) * pageSize + pageSize"> <span class="align-middle">{{ c.document }}</span>
<div class="card"> </div>
<div class="card-body text-center"> <div >
<img src="{{ c.img }}" class="rounded-circle border p-1" width="100"> <button class="btn btn-info btn-sm text-nowrap" (click)="openView(c.id)">รายละเอียด</button>
<h3 class="card-title mt-3 mb-0">{{c.name}}</h3> </div>
<div class="mt-1 pt-1"> </div>
<h4 class="card-title mt-3 mb-0">{{c.details}}</h4> </div>
<br />
</div>
<div class="mt-3">
<a (click)="routerLink('/apps/portal-template-list',c.type)">
<button class="btn btn-info">View</button>
</a>
<!-- <button class="btn btn-warning">Edit</button>
<button class="btn btn-danger">Delete</button> -->
<!-- <button class="btn btn-light">Follow</button> -->
</div>
</div>
<div class="d-flex text-center justify-content-md-center bg-light border-top">
<div class="col-12 border-bottom py-3">
{{ c.document }}
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="d-flex justify-content-center mt-5"> \ No newline at end of file
<ngb-pagination [(page)]="page" [pageSize]="pageSize" [collectionSize]="testdata.length"></ngb-pagination>
</div>
<!-- Add File -->
<ng-template #editTemplateModal let-modal>
<div class="modal-header">
<h5 class="modal-title" id="edittemplateLabel">Add File Type Category</h5>
<button type="button" class="close" (click)="closeBtnClick()" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<form [formGroup]="edittemplate" (ngSubmit)="onSubmit()">
<div class="form-group row">
<label for="name" class="col-sm-4 col-form-label">ชื่อประเภทไฟล์</label>
<div class="col-sm-8">
<input type="text" class="form-control" formControlName="Name" id="name" (blur)=logValidationErrors(edittemplate)>
</div>
</div>
<div class="form-group row">
<label for="position" class="col-sm-4 col-form-label">รายละเอียด</label>
<div class="col-sm-8">
<textarea class="form-control"></textarea>
</div>
</div>
<div class="form-group row">
<label for="name" class="col-sm-4 col-form-label">รูปประเภทไฟล์</label>
<div class="col-sm-8">
<input type="file" class="form-control">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" (click)="closeBtnClick()">Close</button>
<button type="submit" class="btn btn-primary" >Save</button>
</div>
</form>
</div>
</ng-template>
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { NgbModal } from "@ng-bootstrap/ng-bootstrap";
import { FormBuilder, FormGroup, Validators } from "@angular/forms";
import { Router } from '@angular/router'; import { Router } from '@angular/router';
@Component({ @Component({
...@@ -11,18 +9,8 @@ import { Router } from '@angular/router'; ...@@ -11,18 +9,8 @@ import { Router } from '@angular/router';
export class PortalCategoryListComponent implements OnInit { export class PortalCategoryListComponent implements OnInit {
constructor( constructor(
private fb: FormBuilder, private routes: Router
private modalService: NgbModal,
private router:Router
) {} ) {}
get searchTerm(): string {
return this._searchTerm;
}
set searchTerm(val: string) {
this._searchTerm = val;
}
_searchTerm = "";
page = 1; page = 1;
pageSize = 7; pageSize = 7;
...@@ -41,41 +29,35 @@ export class PortalCategoryListComponent implements OnInit { ...@@ -41,41 +29,35 @@ export class PortalCategoryListComponent implements OnInit {
{ {
id:'1', id:'1',
img: "assets/images/icon/excel.png", img: "assets/images/icon/excel.png",
name: "ประเภทไฟล์: Excel", name: "Excel",
details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx", details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
document: "จำนวนเอกสาร 8 ฉบับ" document: "จำนวนเอกสาร 8 ฉบับ"
}, },
{ {
id:'2', id:'2',
img: "assets/images/icon/document.png", img: "assets/images/icon/document.png",
name: "ประเภทไฟล์: Document", name: "Document",
details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx", details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
document: "จำนวนเอกสาร 3 ฉบับ" document: "จำนวนเอกสาร 3 ฉบับ"
}, },
{ {
id:'3', id:'3',
img: "assets/images/icon/course.png", img: "assets/images/icon/course.png",
name: "ประเภทไฟล์: Course", name: "Course",
details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx", details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
document: "จำนวนเอกสาร 5 ฉบับ" document: "จำนวนเอกสาร 5 ฉบับ"
}, },
]; ];
} }
openModal(targetModal: NgbModal) { openView(id:string){
this.modalService.open(targetModal, { if(id =='1'){
centered: true, this.routes.navigate(['apps/list-excel']);
backdrop: "static", }else if(id =='2'){
}); this.routes.navigate(['apps/list-doc']);
} }else if(id =='3'){
this.routes.navigate(['apps/list-course']);
closeBtnClick() { }
this.modalService.dismissAll();
this.ngOnInit();
}
routerLink(path: String, type: String){
this.router.navigate([path,{type:type}])
} }
} }
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<div class="card card-body"> <div class="card card-body">
<h4 class="card-title">Create Category</h4> <h4 class="card-title">รายการเอกสาร</h4>
<div class="d-flex mb-3 mt-3"> <!-- <div class="d-flex mb-3 mt-3">
<input type="text" class="form-control w-25" placeholder="Search" [(ngModel)]='searchTerm'> <input type="text" class="form-control w-25" placeholder="ค้นหาเอกสาร" >
<!-- <button class="btn btn-primary ml-auto" (click)="openModal(editTemplateModal)">Add File Type Category</button> --> <button class="btn btn-primary ml-auto" (click)="openModal(editTemplateModal)">Add File Type Category</button>
</div> </div> -->
</div> <div class="row justify-content-center">
</div> <div class="col-md-4 " *ngFor="let c of testdata|slice: (page-1) * pageSize : (page-1) * pageSize + pageSize">
</div> <div class="card border border-2">
<div class="row justify-content-center"> <div class="card-body text-center">
<div class="col-md-4" *ngFor="let c of testdata|slice: (page-1) * pageSize : (page-1) * pageSize + pageSize"> <img src="{{ c.img }}" class="rounded-circle border p-1" width="100">
<div class="card"> <h3 class="card-title mt-3 mb-0">{{c.name}}</h3>
<div class="card-body text-center"> </div>
<img src="{{ c.img }}" class="rounded-circle border p-1" width="100"> <div class="d-flex justify-content-between bg-light border-top p-3">
<h3 class="card-title mt-3 mb-0">{{c.name}}</h3> <div>
<div class="mt-1 pt-1"> <span class="align-middle">{{ c.document }}</span>
<h4 class="card-title mt-3 mb-0">{{c.details}}</h4> </div>
<br /> <div >
</div> <button class="btn btn-info btn-sm text-nowrap" (click)="openView(c.id)">รายละเอียด</button>
<div class="mt-3"> </div>
<button class="btn btn-info" (click)="openView(c.id)">View</button> </div>
</div> </div>
</div>
<div class="d-flex text-center justify-content-md-center bg-light border-top">
<div class="col-12 border-bottom py-3">
{{ c.document }}
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="d-flex justify-content-center mt-5">
<ngb-pagination [(page)]="page" [pageSize]="pageSize" [collectionSize]="testdata.length"></ngb-pagination>
</div>
......
...@@ -12,15 +12,8 @@ import { Router } from '@angular/router'; ...@@ -12,15 +12,8 @@ import { Router } from '@angular/router';
export class PortalCreateCategoryComponent implements OnInit { export class PortalCreateCategoryComponent implements OnInit {
constructor(private fb: FormBuilder, private modalService: NgbModal, private datePipe: DatePipe,private routes: Router,) {} constructor(private fb: FormBuilder, private modalService: NgbModal, private datePipe: DatePipe,private routes: Router,) {}
get searchTerm(): string {
return this._searchTerm;
}
set searchTerm(val: string) {
this._searchTerm = val;
}
page = 1; page = 1;
pageSize = 9; pageSize = 10;
testdata: { testdata: {
id:string; id:string;
...@@ -30,43 +23,26 @@ export class PortalCreateCategoryComponent implements OnInit { ...@@ -30,43 +23,26 @@ export class PortalCreateCategoryComponent implements OnInit {
document: String; document: String;
}[] = []; }[] = [];
_searchTerm = "";
formsErrors = [];
ngOnInit() { ngOnInit() {
// this.editUser = this.fb.group({
// id: [""],
// Name: ["", Validators.required],
// Position: ["", Validators.required],
// Email: ["", Validators.required],
// Mobile: ["", Validators.required],
// DateOfJoining: ["", Validators.required],
// Salary: ["", Validators.required],
// Projects: ["", Validators.required],
// });
this.testdata = [ this.testdata = [
{ {
id:'1', id:'1',
img: "assets/images/icon/excel.png", img: "assets/images/icon/excel.png",
name: "ประเภทไฟล์: Excel", name: "Excel",
details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx", details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
document: "จำนวนเอกสาร 8 ฉบับ" document: "จำนวนเอกสาร 8 ฉบับ"
}, },
{ {
id:'2', id:'2',
img: "assets/images/icon/document.png", img: "assets/images/icon/document.png",
name: "ประเภทไฟล์: Document", name: "Document",
details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx", details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
document: "จำนวนเอกสาร 3 ฉบับ" document: "จำนวนเอกสาร 3 ฉบับ"
}, },
{ {
id:'3', id:'3',
img: "assets/images/icon/course.png", img: "assets/images/icon/course.png",
name: "ประเภทไฟล์: Course", name: "Course",
details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx", details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
document: "จำนวนเอกสาร 5 ฉบับ" document: "จำนวนเอกสาร 5 ฉบับ"
}, },
...@@ -75,7 +51,11 @@ export class PortalCreateCategoryComponent implements OnInit { ...@@ -75,7 +51,11 @@ export class PortalCreateCategoryComponent implements OnInit {
openView(id:string){ openView(id:string){
if(id =='1'){ if(id =='1'){
this.routes.navigate(['apps/list-excel/']); this.routes.navigate(['apps/list-excel']);
}else if(id =='2'){
this.routes.navigate(['apps/list-doc']);
}else if(id =='3'){
this.routes.navigate(['apps/list-course']);
} }
} }
openModal(targetModal: NgbModal) { openModal(targetModal: NgbModal) {
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
</div> </div>
<div class="form-group text-center"> <div class="form-group text-center">
<div class="col-xs-12 p-b-20"> <div class="col-xs-12 p-b-20">
<a class="btn btn-block btn-lg btn-info" href="/apps/portal-create-category">Log In</a> <a class="btn btn-block btn-lg btn-info" (click)="login()">Log In</a>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
......
import { Component } from '@angular/core'; import { Component } from '@angular/core';
import { Router } from '@angular/router';
@Component({ @Component({
selector: 'app-login', selector: 'app-login',
templateUrl: './login.component.html' templateUrl: './login.component.html'
}) })
export class LoginComponent { export class LoginComponent {
constructor() {} constructor(private routes: Router) {}
loginform = true; loginform = true;
recoverform = false; recoverform = false;
...@@ -14,4 +15,7 @@ export class LoginComponent { ...@@ -14,4 +15,7 @@ export class LoginComponent {
this.loginform = !this.loginform; this.loginform = !this.loginform;
this.recoverform = !this.recoverform; this.recoverform = !this.recoverform;
} }
login(){
this.routes.navigate(['apps/portal-create-category']);
}
} }
...@@ -116,8 +116,7 @@ ...@@ -116,8 +116,7 @@
<!-- footer --> <!-- footer -->
<!-- ============================================================== --> <!-- ============================================================== -->
<footer class="footer text-center"> <footer class="footer text-center">
All Rights Reserved by Xtreme Admin. Designed and Developed by myHR Portal
<a href="https://wrappixel.com">WrapPixel</a>.
</footer> </footer>
<!-- ============================================================== --> <!-- ============================================================== -->
<!-- End footer --> <!-- End footer -->
...@@ -127,9 +126,9 @@ ...@@ -127,9 +126,9 @@
<!-- End Page wrapper --> <!-- End Page wrapper -->
<!-- ============================================================== --> <!-- ============================================================== -->
<aside class="customizer" [ngClass]="{'show-service-panel': showSettings}"> <aside class="customizer" [ngClass]="{'show-service-panel': showSettings}">
<a href="javascript:void(0)" class="service-panel-toggle" (click)="showSettings = !showSettings"> <!-- <a href="javascript:void(0)" class="service-panel-toggle" (click)="showSettings = !showSettings">
<i class="fa fa-spin fa-cog"></i> <i class="fa fa-spin fa-cog"></i>
</a> </a> -->
<div class="customizer-body custom-pills" [perfectScrollbar]="config"> <div class="customizer-body custom-pills" [perfectScrollbar]="config">
......
...@@ -33,7 +33,7 @@ export class FullComponent implements OnInit { ...@@ -33,7 +33,7 @@ export class FullComponent implements OnInit {
boxed: 'full', // two possible values: full, boxed boxed: 'full', // two possible values: full, boxed
navbarbg: 'skin1', // six possible values: skin(1/2/3/4/5/6) navbarbg: 'skin1', // six possible values: skin(1/2/3/4/5/6)
sidebarbg: 'skin6', // six possible values: skin(1/2/3/4/5/6) sidebarbg: 'skin6', // six possible values: skin(1/2/3/4/5/6)
logobg: 'skin6' // six possible values: skin(1/2/3/4/5/6) logobg: 'skin1' // six possible values: skin(1/2/3/4/5/6)
}; };
Logo() { Logo() {
......
export interface CourseModel {
logId: string
objective: string
thumbnail: string
link1: string
courseObj: string
uploadBy: string
remark: string
status: number
approveBy: string
thName: string
engName: string
thDesc: string
engDesc: string
courseOutline: string
courseType: string
courseLevel: string
courseTime: string
courseTrainer: string
courseTrainerDetail: string
}
export class CourseModel implements CourseModel {
logId: string
objective: string
thumbnail: string
link1: string
courseObj: string
uploadBy: string
remark: string
status: number
approveBy: string
thName: string
engName: string
thDesc: string
engDesc: string
courseOutline: string
courseType: string
courseLevel: string
courseTime: string
courseTrainer: string
courseTrainerDetail: string
constructor(data: Partial<any>) {
this.logId = data.logId?data.logId:''
this.objective = data.objective?data.objective:''
this.thumbnail = data.thumbnail?data.thumbnail:''
this.link1 = data.link1?data.link1:''
this.courseObj = data.courseObj?data.courseObj:''
this.uploadBy = data.uploadBy?data.uploadBy:''
this.remark = data.remark?data.remark:''
this.status = data.status?data.status:0
this.approveBy = data.approveBy?data.approveBy:''
this.thName = data.thName?data.thName:''
this.engName = data.engName?data.engName:''
this.thDesc = data.thDesc?data.thDesc:''
this.engDesc = data.engDesc?data.engDesc:''
this.courseOutline = data.courseOutline?data.courseOutline:''
this.courseType = data.courseType?data.courseType:''
this.courseLevel = data.courseLevel?data.courseLevel:''
this.courseTime = data.courseTime?data.courseTime:''
this.courseTrainer = data.courseTrainer?data.courseTrainer:''
this.courseTrainerDetail = data.courseTrainerDetail?data.courseTrainerDetail:''
}
}
\ No newline at end of file
export interface DocumentModel {
logId: string
thumbnail: string
link1: string
langSupport: string
doclObj: string
uploadBy: string
remark: string
status: number
approveBy: string
thName: string
engName: string
thDesc: string
engDesc: string
}
export class DocumentModel implements DocumentModel {
logId: string
thumbnail: string
link1: string
langSupport: string
doclObj: string
uploadBy: string
remark: string
status: number
approveBy: string
thName: string
engName: string
thDesc: string
engDesc: string
constructor(data: Partial<any>) {
this.logId = data.logId?data.logId:''
this.thumbnail = data.thumbnail?data.thumbnail:''
this.link1 = data.link1?data.link1:''
this.langSupport = data.langSupport?data.langSupport:''
this.doclObj = data.doclObj?data.doclObj:''
this.uploadBy = data.uploadBy?data.uploadBy:''
this.remark = data.remark?data.remark:''
this.status = data.status?data.status:0
this.approveBy = data.approveBy?data.approveBy:''
this.thName = data.thName?data.thName:''
this.engName = data.engName?data.engName:''
this.thDesc = data.thDesc?data.thDesc:''
this.engDesc = data.engDesc?data.engDesc:''
}
}
\ No newline at end of file
export interface ExcelModel {
logId: string
thumbnail: string
link1: string
dbSupport: string
excelObj: string
uploadBy: string
remark: string
status: number
approveBy: string
thName: string
engName: string
thDesc: string
engDesc: string
}
export class ExcelModel implements ExcelModel {
logId: string
thumbnail: string
link1: string
dbSupport: string
excelObj: string
uploadBy: string
remark: string
status: number
approveBy: string
thName: string
engName: string
thDesc: string
engDesc: string
constructor(data: Partial<any>) {
this.logId = data.logId?data.logId:''
this.thumbnail = data.thumbnail?data.thumbnail:''
this.link1 = data.link1?data.link1:''
this.dbSupport = data.dbSupport?data.dbSupport:''
this.excelObj = data.excelObj?data.excelObj:''
this.uploadBy = data.uploadBy?data.uploadBy:''
this.remark = data.remark?data.remark:''
this.status = data.status?data.status:0
this.approveBy = data.approveBy?data.approveBy:''
this.thName = data.thName?data.thName:''
this.engName = data.engName?data.engName:''
this.thDesc = data.thDesc?data.thDesc:''
this.engDesc = data.engDesc?data.engDesc:''
}
}
\ No newline at end of file
import { Injectable } from '@angular/core';
import { environment } from 'src/environments/environment';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Observable, of } from 'rxjs';
import { map, tap } from 'rxjs/operators';
import { CourseModel } from '../model/course.model';
@Injectable({
providedIn: 'root'
})
export class CourseService {
url = environment.url
createStatus: boolean = true
constructor(private http: HttpClient) { }
getListCourse(status?:string): Observable<CourseModel[]> {
if(status){
return this.http.get<CourseModel[]>(this.url + "course-center/upload/lists?status="+status)
}else{
return this.http.get<CourseModel[]>(this.url + "course-center/upload/lists")
}
}
getCourseById(logId:string): Observable<CourseModel> {
return this.http.get<CourseModel>(this.url + "course-center/upload/"+logId)
}
downloadFile(logId:string){
return this.http.get<CourseModel>(this.url + "course-center/files/download/"+logId)
}
createCourse(model: CourseModel): Observable<boolean> {
if (this.createStatus) {
this.createStatus = false
return this.http.post(this.url + 'course-center', model, { observe: 'response' })
.pipe(
tap(x => this.createStatus = true),
map(r => r.status == 200)
);
} else {
return of(false)
}
}
deleteCourse(model: CourseModel): Observable<any> {
let body = {
logId: model.logId
}
let option = {
headers: new HttpHeaders({
"Content-Type": "application/json",
}),
body: body
}
return this.http.delete<any>(this.url + 'course-center/upload', option)
}
approve(model: CourseModel): Observable<any> {
let body = {
logId: model.logId,
status: model.status
}
return this.http.put<any>(this.url + "course-center/approve",body)
}
}
import { Injectable } from '@angular/core';
import { environment } from 'src/environments/environment';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Observable, of } from 'rxjs';
import { map, tap } from 'rxjs/operators';
import { DocumentModel } from '../model/document.model';
@Injectable({
providedIn: 'root'
})
export class DocumentService {
url = environment.url
createStatus: boolean = true
constructor(private http: HttpClient) { }
getListDoc(status?:string): Observable<DocumentModel[]> {
if(status){
return this.http.get<DocumentModel[]>(this.url + "document-center/upload/lists?status="+status)
}else{
return this.http.get<DocumentModel[]>(this.url + "document-center/upload/lists")
}
}
getDocById(logId:string): Observable<DocumentModel> {
return this.http.get<DocumentModel>(this.url + "document-center/upload/"+logId)
}
downloadFile(logId:string){
return this.http.get<DocumentModel>(this.url + "document-center/files/download/"+logId)
}
createDoc(model: DocumentModel): Observable<boolean> {
if (this.createStatus) {
this.createStatus = false
return this.http.post(this.url + 'document-center', model, { observe: 'response' })
.pipe(
tap(x => this.createStatus = true),
map(r => r.status == 200)
);
} else {
return of(false)
}
}
deleteExcel(model: DocumentModel): Observable<any> {
let body = {
logId: model.logId
}
let option = {
headers: new HttpHeaders({
"Content-Type": "application/json",
}),
body: body
}
return this.http.delete<any>(this.url + 'document-center/upload', option)
}
approve(model: DocumentModel): Observable<any> {
let body = {
logId: model.logId,
status: model.status
}
return this.http.put<any>(this.url + "document-center/approve",body)
}
}
import { Injectable } from '@angular/core';
import { environment } from 'src/environments/environment';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Observable, of } from 'rxjs';
import { ExcelModel } from '../model/excel.model';
import { map, tap } from 'rxjs/operators';
@Injectable({
providedIn: 'root'
})
export class ExcelService {
url = environment.url
createStatus: boolean = true
constructor(private http: HttpClient) { }
getListExcel(status?: string): Observable<ExcelModel[]> {
if(status){
return this.http.get<ExcelModel[]>(this.url + "excel-center/upload/lists?status="+status)
}else{
return this.http.get<ExcelModel[]>(this.url + "excel-center/upload/lists")
}
}
getExcelById(logId:string): Observable<ExcelModel> {
return this.http.get<ExcelModel>(this.url + "excel-center/upload/"+logId)
}
downloadFile(logId:string){
return this.http.get<ExcelModel>(this.url + "excel-center/files/download/"+logId)
}
createExcel(model: ExcelModel): Observable<boolean> {
if (this.createStatus) {
this.createStatus = false
return this.http.post(this.url + 'excel-center', model, { observe: 'response' })
.pipe(
tap(x => this.createStatus = true),
map(r => r.status == 200)
);
} else {
return of(false)
}
}
deleteExcel(model: ExcelModel): Observable<any> {
let body = {
logId: model.logId
}
let option = {
headers: new HttpHeaders({
"Content-Type": "application/json",
}),
body: body
}
return this.http.delete<any>(this.url + 'excel-center/upload', option)
}
approve(model: ExcelModel): Observable<any> {
let body = {
logId: model.logId,
status: model.status
}
return this.http.put<any>(this.url + "excel-center/approve",body)
}
}
import { Injectable } from '@angular/core';
import { HttpEvent, HttpHandler, HttpRequest } from '@angular/common/http';
import { Observable } from 'rxjs';
import { environment } from 'src/environments/environment';
@Injectable()
export class HttpRequestInterceptor {
token= 'eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJBdXRoIiwidWlkIjoiOGFhNDUzMzAtMzE0Yy0xMWU3LWJhZjMtMmQ3ZDA5ODc3NzQ0Iiwicm9sZSI6InVzZXIiLCJpc3MiOiJDb21wdXRlciBTY2llbmNlIENvcnBvcmF0aW9uIExpbWl0ZWQiLCJmdWxsTmFtZSI6InRlZXJhZGFjaCBrdWhhdGFuYXNhdGllbiIsIm1lbWJlcklkIjoiOGFhNDUzMzAtMzE0Yy0xMWU3LWJhZjMtMmQ3ZDA5ODc3NzQ0In0.FO7u8g7KfzkmZFTuuniBCEQxduPjcvzMbH7iug3DT90'
constructor() { }
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
let authHeader = localStorage.getItem('accessToken') ? localStorage.getItem('accessToken')! : "Bearer "+this.token
const overideReq = {
headers: req.headers.set('Authorization', authHeader),
url: req.url
}
const authReq = req.clone(overideReq)
return next.handle(authReq)
}
}
\ No newline at end of file
...@@ -10,148 +10,17 @@ ...@@ -10,148 +10,17 @@
<!-- ============================================================== --> <!-- ============================================================== -->
<!-- mega menu --> <!-- mega menu -->
<!-- ============================================================== --> <!-- ============================================================== -->
<li class="nav-item mega-dropdown" ngbDropdown [autoClose]="false">
<a ngbDropdownToggle class="nav-link waves-effect waves-dark" href="javascript:void(0)" data-toggle="dropdown" aria-haspopup="true"
aria-expanded="false">
<span class="d-none d-md-block">Mega
<i class="fa fa-angle-down"></i>
</span>
<span class="d-block d-md-none">
<i class="mdi mdi-dialpad font-24"></i>
</span>
</a>
<div class="dropdown-menu" ngbDropdownMenu>
<div class="mega-dropdown-menu row">
<div class="col-lg-3 col-xlg-2 m-b-30">
<h4 class="m-b-20">CAROUSEL</h4>
<!-- CAROUSEL -->
<ngb-carousel>
<ng-template ngbSlide>
<img src="assets/images/big/img1.jpg" class="img-fluid" alt="Random first slide">
<div class="carousel-caption">
<h3 class="text-white font-bold">First slide label</h3>
</div>
</ng-template>
<ng-template ngbSlide>
<img src="assets/images/big/img2.jpg" class="img-fluid" alt="Random second slide">
<div class="carousel-caption">
<h3 class="text-white font-bold">Second slide label</h3>
</div>
</ng-template>
<ng-template ngbSlide>
<img src="assets/images/big/img3.jpg" class="img-fluid" alt="Random third slide">
<div class="carousel-caption">
<h3 class="text-white font-bold">Third slide label</h3>
</div>
</ng-template>
</ngb-carousel>
<!-- End CAROUSEL -->
</div>
<div class="col-lg-3 m-b-30">
<h4 class="m-b-20">ACCORDION</h4>
<!-- Accordian -->
<ngb-accordion [closeOthers]="true" activeIds="static-1" class="accordion nav-accordion">
<ngb-panel id="static-1" title="Simple">
<ng-template ngbPanelContent>
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid.
</ng-template>
</ngb-panel>
<ngb-panel id="static-2">
<ng-template ngbPanelTitle>
<span>&#9733;
<b>Fancy</b> title &#9733;</span>
</ng-template>
<ng-template ngbPanelContent>
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid.
</ng-template>
</ngb-panel>
<ngb-panel id="static-3" title="Disabled" [disabled]="true">
<ng-template ngbPanelContent>
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid.
</ng-template>
</ngb-panel>
</ngb-accordion>
</div>
<div class="col-lg-3 m-b-30">
<h4 class="m-b-20">CONTACT US</h4>
<!-- Contact -->
<form>
<div class="form-group">
<input type="text" class="form-control" id="exampleInputname1" placeholder="Enter Name"> </div>
<div class="form-group">
<input type="email" class="form-control" placeholder="Enter email"> </div>
<div class="form-group">
<textarea class="form-control" id="exampleTextarea" rows="3" placeholder="Message"></textarea>
</div>
<button type="submit" class="btn btn-info">Submit</button>
</form>
</div>
<div class="col-lg-3 col-xlg-4 m-b-30">
<h4 class="m-b-20">List style</h4>
<!-- List style -->
<ul class="list-style-none">
<li>
<a href="javascript:void(0)">
<i class="fa fa-check text-success"></i> You can give link</a>
</li>
<li>
<a href="javascript:void(0)">
<i class="fa fa-check text-success"></i> Give link</a>
</li>
<li>
<a href="javascript:void(0)">
<i class="fa fa-check text-success"></i> Another Give link</a>
</li>
<li>
<a href="javascript:void(0)">
<i class="fa fa-check text-success"></i> Forth link</a>
</li>
<li>
<a href="javascript:void(0)">
<i class="fa fa-check text-success"></i> Another fifth link</a>
</li>
</ul>
</div>
</div>
</div>
</li>
<!-- ============================================================== --> <!-- ============================================================== -->
<!-- End mega menu --> <!-- End mega menu -->
<!-- ============================================================== --> <!-- ============================================================== -->
<!-- ============================================================== --> <!-- ============================================================== -->
<!-- create new --> <!-- create new -->
<!-- ============================================================== --> <!-- ============================================================== -->
<li class="nav-item dropdown" ngbDropdown>
<a ngbDropdownToggle class="nav-link dropdown-toggle" href="javascript:void(0)" id="navbarDropdown" role="button" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false">
<span class="d-none d-md-block">Create New
<i class="fa fa-angle-down"></i>
</span>
<span class="d-block d-md-none">
<i class="fa fa-plus"></i>
</span>
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown" ngbDropdownMenu>
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</li>
<!-- ============================================================== --> <!-- ============================================================== -->
<!-- Search --> <!-- Search -->
<!-- ============================================================== --> <!-- ============================================================== -->
<li class="nav-item search-box">
<a (click)="showSearch = !showSearch" class="nav-link waves-effect waves-dark" href="javascript:void(0)">
<i class="ti-search"></i>
</a>
<form class="app-search position-absolute" [ngClass]="{'show-search': showSearch}">
<input type="text" class="form-control" placeholder="Search &amp; enter">
<a class="srh-btn" (click)="showSearch = !showSearch">
<i class="ti-close"></i>
</a>
</form>
</li>
</ul> </ul>
<!-- ============================================================== --> <!-- ============================================================== -->
<!-- Right side toggle and nav items --> <!-- Right side toggle and nav items -->
......
import { RouteInfo } from "./vertical-sidebar.metadata"; import { RouteInfo } from "./vertical-sidebar.metadata";
export const ROUTES: RouteInfo[] = [ export const ROUTES: RouteInfo[] = [
{ {
path: "manage", path: '/apps/portal-create-category',
title: "Manage", title: 'รายการเอกสาร',
icon: "Home",
class: "has-arrow",
extralink: false,
label: "",
labelClass: "badge badge-info sidebar-badge",
submenu: [
{
path: '/apps/portal-category-manage',
title: 'Category Manage',
icon: 'mdi mdi-adjust', icon: 'mdi mdi-adjust',
class: '', class: '',
label: "", label: "",
...@@ -21,18 +13,8 @@ export const ROUTES: RouteInfo[] = [ ...@@ -21,18 +13,8 @@ export const ROUTES: RouteInfo[] = [
submenu: [] submenu: []
}, },
{ {
path: '/apps/portal-template-manage', path: '/apps/import-template',
title: 'Template Manage', title: 'นำเข้า Template',
icon: 'mdi mdi-adjust',
class: '',
label: "",
labelClass: "",
extralink: true,
submenu: []
},
{
path: '/apps/portal-category-list-approve',
title: 'Category List Approve',
icon: 'mdi mdi-adjust', icon: 'mdi mdi-adjust',
class: '', class: '',
label: "", label: "",
...@@ -41,18 +23,8 @@ export const ROUTES: RouteInfo[] = [ ...@@ -41,18 +23,8 @@ export const ROUTES: RouteInfo[] = [
submenu: [] submenu: []
}, },
{ {
path: '/apps/portal-template-approve', path: '/apps/export-template',
title: 'Template List Approve', title: 'ส่งออก Template',
icon: 'mdi mdi-adjust',
class: '',
label: "",
labelClass: "",
extralink: true,
submenu: []
},
{
path: '/apps/portal-category-list',
title: 'Category List',
icon: 'mdi mdi-adjust', icon: 'mdi mdi-adjust',
class: '', class: '',
label: "", label: "",
...@@ -61,22 +33,18 @@ export const ROUTES: RouteInfo[] = [ ...@@ -61,22 +33,18 @@ export const ROUTES: RouteInfo[] = [
submenu: [] submenu: []
}, },
{ {
path: '/apps/portal-template-list', path: "",
title: 'Template List', title: "การจัดการ",
icon: 'mdi mdi-adjust', icon: "edit",
class: '', class: "has-arrow",
extralink: false,
label: "", label: "",
labelClass: "", labelClass: "badge badge-info sidebar-badge",
extralink: true, submenu: [
submenu: []
},
]
},
{ {
path: '/apps/portal-create-category', path: '/apps/portal-category-list-approve',
title: 'Create Category', title: 'รายการอนุมัติ',
icon: 'mdi mdi-adjust', icon: '',
class: '', class: '',
label: "", label: "",
labelClass: "", labelClass: "",
...@@ -84,25 +52,18 @@ export const ROUTES: RouteInfo[] = [ ...@@ -84,25 +52,18 @@ export const ROUTES: RouteInfo[] = [
submenu: [] submenu: []
}, },
{ {
path: '/apps/import-template', path: '/apps/portal-category-list',
title: 'Import Template', title: 'รายการเอกสาร',
icon: 'mdi mdi-adjust', icon: '',
class: '', class: '',
label: "", label: "",
labelClass: "", labelClass: "",
extralink: false, extralink: false,
submenu: [] submenu: []
}, },
{ ]
path: '/apps/export-template',
title: 'Export Template',
icon: 'mdi mdi-adjust',
class: '',
label: "",
labelClass: "",
extralink: false,
submenu: []
}, },
// //
// { // {
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
// The list of file replacements can be found in `angular.json`. // The list of file replacements can be found in `angular.json`.
export const environment = { export const environment = {
url:'http://192.168.40.35:30537/',
production: false production: false
}; };
......
...@@ -8,10 +8,10 @@ ...@@ -8,10 +8,10 @@
<meta name="keywords" content="wrappixel, admin dashboard, html css dashboard, web dashboard, angular admin, angular, css3 dashboard, angular dashboard, xtreme admin angular dashboard, frontend, responsive angular admin template, material design, material dashboard angular dashboard template"> <meta name="keywords" content="wrappixel, admin dashboard, html css dashboard, web dashboard, angular admin, angular, css3 dashboard, angular dashboard, xtreme admin angular dashboard, frontend, responsive angular admin template, material design, material dashboard angular dashboard template">
<meta name="description" content="Xtreme is powerful and clean admin dashboard template, inpired from Bootstrap Framework"> <meta name="description" content="Xtreme is powerful and clean admin dashboard template, inpired from Bootstrap Framework">
<meta name="robots" content="noindex,nofollow"> <meta name="robots" content="noindex,nofollow">
<title>Xtreme Admin Template by WrapPixel</title> <title>myHR Portal</title>
<link rel="canonical" href="https://www.wrappixel.com/templates/xtreme-angular-admin/" /> <link rel="canonical" href="https://www.wrappixel.com/templates/xtreme-angular-admin/" />
<!-- Favicon icon --> <!-- Favicon icon -->
<link rel="icon" type="image/png" sizes="16x16" href="assets/images/favicon.png"> <link rel="icon" type="image/png" sizes="16x16" href="assets/images/logo-myhr-dark.png">
<link <link
href="https://fonts.googleapis.com/css2?family=Nunito:wght@300;400;600;700;800&display=swap" href="https://fonts.googleapis.com/css2?family=Nunito:wght@300;400;600;700;800&display=swap"
rel="stylesheet" rel="stylesheet"
......
/* You can add global styles to this file, and also import other style files */ /* You can add global styles to this file, and also import other style files */
@import url('https://fonts.googleapis.com/css?family=Nunito+Sans:300,400,600,700,800'); @import url('https://fonts.googleapis.com/css?family=Nunito+Sans:300,400,600,700,800');
\ No newline at end of file @import url("https://fonts.googleapis.com/css?family=Kanit:300,400,600,700,800");
@import url("https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css");
body {
font-family: "Kanit", sans-serif !important;
}
\ No newline at end of file
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