Commit 2a1273b8 by Nakarin Luankla

UPDATE mdel ใหม่ ,download file

parent 6242f8d4
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
"version": "0.0.0", "version": "0.0.0",
"scripts": { "scripts": {
"ng": "ng", "ng": "ng",
"start": "ng serve", "start": "ng serve --host 192.168.68.85",
"build": "ng build", "build": "ng build",
"test": "ng test", "test": "ng test",
"lint": "ng lint", "lint": "ng lint",
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
"dom-autoscroller": "^2.3.4", "dom-autoscroller": "^2.3.4",
"dom-plane": "^1.0.2", "dom-plane": "^1.0.2",
"dom-set": "^1.1.1", "dom-set": "^1.1.1",
"file-saver": "^2.0.5",
"flatpickr": "^4.6.6", "flatpickr": "^4.6.6",
"handlebars": "^4.7.7", "handlebars": "^4.7.7",
"lodash": "^4.17.19", "lodash": "^4.17.19",
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
</tr> </tr>
<tr *ngFor="let data of filterListCourse() | slice: (page-1) * pageSize : (page-1) * pageSize + pageSize ; let i = index"> <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 class="text-center">{{i+1}}</td>
<td><img width="100" class="border p-1" src="{{data.thumbnail}}"></td> <td><img width="100" class="border p-1" src="{{data.getImage()}}"></td>
<td>{{ data.thName }}</td> <td>{{ data.thName }}</td>
<td class="text-wrap">{{ data.thDesc }}</td> <td class="text-wrap">{{ data.thDesc }}</td>
<td>{{data.ctype}}</td> <td>{{data.ctype}}</td>
......
...@@ -32,7 +32,7 @@ export class ApproveCourseComponent implements OnInit { ...@@ -32,7 +32,7 @@ export class ApproveCourseComponent implements OnInit {
async getListCourse(){ async getListCourse(){
try { try {
const data = await this.courseService.getListCourse('0').toPromise(); const data = await this.courseService.getListCourse('0').toPromise();
this.listCourse = data this.listCourse = data.map(x => new CourseModel(x))
} catch (error) { } catch (error) {
console.error('Error loading data:', error); console.error('Error loading data:', error);
} }
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
</tr> </tr>
<tr *ngFor="let data of filterListDoc() | slice: (page-1) * pageSize : (page-1) * pageSize + pageSize ; let i = index"> <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 class="text-center">{{i+1}}</td>
<td><img width="100" class="border p-1" src="{{data.thumbnail}}"></td> <td><img width="100" class="border p-1" src="{{data.getImage()}}"></td>
<!-- <td >{{data.id}}</td> --> <!-- <td >{{data.id}}</td> -->
<td>{{ data.thName }}</td> <td>{{ data.thName }}</td>
<td>{{ data.thDesc }}</td> <td>{{ data.thDesc }}</td>
......
...@@ -32,7 +32,7 @@ export class ApproveDocComponent implements OnInit { ...@@ -32,7 +32,7 @@ export class ApproveDocComponent implements OnInit {
async getListDoc(){ async getListDoc(){
try { try {
const data = await this.documentService.getListDoc('0').toPromise(); const data = await this.documentService.getListDoc('0').toPromise();
this.listDoc = data this.listDoc = data.map(x => new DocumentModel(x))
} catch (error) { } catch (error) {
console.error('Error loading data:', error); console.error('Error loading data:', error);
} }
......
...@@ -14,9 +14,9 @@ ...@@ -14,9 +14,9 @@
<!-- <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" class="text-center">ลิงค์</th>
<th scope="col">สถานะ</th> <th scope="col" class="text-center">สถานะ</th>
<!-- <th scope="col">ไฟล์</th> --> <th scope="col" class="text-center">ไฟล์</th>
<th scope="col"></th> <th scope="col"></th>
</tr> </tr>
</thead> </thead>
...@@ -26,13 +26,30 @@ ...@@ -26,13 +26,30 @@
</tr> </tr>
<tr *ngFor="let data of filterListExcel() | 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.thumbnail}}"></td> <td><img width="100" class="border p-1" src="{{data.getImage()}}"></td>
<!-- <td >{{data.id}}</td> --> <!-- <td >{{data.id}}</td> -->
<td>{{ data.thName }}</td> <td>{{ data.thName }}</td>
<td>{{ data.thDesc }}</td> <td>{{ data.thDesc }}</td>
<td><a href="{{data.link1}}" target="_blank">คลิก</a></td> <td class="text-center"><i class="fas fa-link pointer" (click)="openLink(data.link1)"></i></td>
<td>{{ getStatus(data.status) }}</td> <td class="text-center"> <i class="fas fa-download pointer" (click)="downloadFile(data.logId)"></i></td>
<!-- <td><a (click)="downloadFile(data.logId)">ดาวน์โหลด</a></td> --> <td class="text-center">
<span class="fa-stack rt_anim" *ngIf="data.status == '0'" ngbTooltip="รออนุมัติ" container="body" tooltipClass="myhrcolor-1">
<i class="fa fa-circle fa-stack-2x text-info"></i>
<i class=" fas fa-hourglass-half fa-stack-1x fa-inverse"></i>
</span>
<span class="fa-stack rt_anim" *ngIf="data.status == '1'" ngbTooltip="เปิดใช้งาน" container="body" tooltipClass="myhrcolor-2">
<i class="fa fa-circle fa-stack-2x text-success"></i>
<i class=" fas fa-check fa-stack-1x fa-inverse"></i>
</span>
<span class="fa-stack rt_anim" *ngIf="data.status == '2'" ngbTooltip="ไม่อนุมัติ" container="body" tooltipClass="myhrcolor-3">
<i class="fa fa-circle fa-stack-2x text-danger"></i>
<i class="fas fa-times fa-stack-1x fa-inverse" style="font-size: 1.25em;"></i>
</span>
</td>
<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-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> <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>
......
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ApproveExcelComponent } from './approve-excel.component';
describe('ApproveExcelComponent', () => {
let component: ApproveExcelComponent;
let fixture: ComponentFixture<ApproveExcelComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ApproveExcelComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(ApproveExcelComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
...@@ -4,7 +4,8 @@ import { ExcelModel } from 'src/app/model/excel.model'; ...@@ -4,7 +4,8 @@ import { ExcelModel } from 'src/app/model/excel.model';
import { ExcelService } from 'src/app/service/excel.service'; import { ExcelService } from 'src/app/service/excel.service';
import { AlertModalComponent } from '../alert-modal/alert-modal.component'; import { AlertModalComponent } from '../alert-modal/alert-modal.component';
import { ConfirmModalComponent } from '../confirm-modal/confirm-modal.component'; import { ConfirmModalComponent } from '../confirm-modal/confirm-modal.component';
declare var require: any
const FileSaver = require('file-saver');
@Component({ @Component({
selector: 'app-approve-excel', selector: 'app-approve-excel',
templateUrl: './approve-excel.component.html', templateUrl: './approve-excel.component.html',
...@@ -17,13 +18,14 @@ export class ApproveExcelComponent implements OnInit { ...@@ -17,13 +18,14 @@ export class ApproveExcelComponent implements OnInit {
search:string = '' search:string = ''
constructor(private modalService: NgbModal,private excelService:ExcelService) { constructor(private modalService: NgbModal,private excelService:ExcelService) {
} }
getStatus(status:string){ async downloadFile(logId:string){
if(status == '0'){ try {
return 'รออนุมัติ' const data = await this.excelService.downloadFile(logId).toPromise();
} else if(status == '1'){ if(data){
return 'เปิดใช้งาน' FileSaver.saveAs(new Blob([data]), "file_download.xlsx");
} else if(status == '2'){ }
return 'ไม่อนุมัติ' } catch (error) {
console.error('Error loading data:', error);
} }
} }
filterListExcel(){ filterListExcel(){
...@@ -32,7 +34,7 @@ export class ApproveExcelComponent implements OnInit { ...@@ -32,7 +34,7 @@ export class ApproveExcelComponent implements OnInit {
async getListExcel(){ async getListExcel(){
try { try {
const data = await this.excelService.getListExcel('0').toPromise(); const data = await this.excelService.getListExcel('0').toPromise();
this.listExcel = data this.listExcel = data.map(x => new ExcelModel(x))
} catch (error) { } catch (error) {
console.error('Error loading data:', error); console.error('Error loading data:', error);
} }
...@@ -93,4 +95,7 @@ export class ApproveExcelComponent implements OnInit { ...@@ -93,4 +95,7 @@ export class ApproveExcelComponent implements OnInit {
this.modalService.dismissAll() this.modalService.dismissAll()
}) })
} }
openLink(url:string){
window.open(url, "_blank");
}
} }
...@@ -90,6 +90,9 @@ import { AlertModalComponent } from './alert-modal/alert-modal.component'; ...@@ -90,6 +90,9 @@ import { AlertModalComponent } from './alert-modal/alert-modal.component';
import { ListCourseComponent } from './list-course/list-course.component'; import { ListCourseComponent } from './list-course/list-course.component';
import { ApproveDocComponent } from './approve-doc/approve-doc.component'; import { ApproveDocComponent } from './approve-doc/approve-doc.component';
import { ApproveCourseComponent } from './approve-course/approve-course.component'; import { ApproveCourseComponent } from './approve-course/approve-course.component';
import { ViewListExcelComponent } from './view-list-excel/view-list-excel.component';
import { ViewListDocComponent } from './view-list-doc/view-list-doc.component';
import { ViewListCourseComponent } from './view-list-course/view-list-course.component';
@NgModule({ @NgModule({
...@@ -157,7 +160,10 @@ import { ApproveCourseComponent } from './approve-course/approve-course.componen ...@@ -157,7 +160,10 @@ import { ApproveCourseComponent } from './approve-course/approve-course.componen
AlertModalComponent, AlertModalComponent,
ListCourseComponent, ListCourseComponent,
ApproveDocComponent, ApproveDocComponent,
ApproveCourseComponent ApproveCourseComponent,
ViewListExcelComponent,
ViewListDocComponent,
ViewListCourseComponent
], ],
providers: [ providers: [
ContactService, ContactService,
......
...@@ -43,6 +43,9 @@ import { ListExcelComponent } from "./list-excell/list-excell.component"; ...@@ -43,6 +43,9 @@ import { ListExcelComponent } from "./list-excell/list-excell.component";
import { ListCourseComponent } from "./list-course/list-course.component"; import { ListCourseComponent } from "./list-course/list-course.component";
import { ApproveDocComponent } from "./approve-doc/approve-doc.component"; import { ApproveDocComponent } from "./approve-doc/approve-doc.component";
import { ApproveCourseComponent } from "./approve-course/approve-course.component"; import { ApproveCourseComponent } from "./approve-course/approve-course.component";
import { ViewListCourseComponent } from "./view-list-course/view-list-course.component";
import { ViewListExcelComponent } from "./view-list-excel/view-list-excel.component";
import { ViewListDocComponent } from "./view-list-doc/view-list-doc.component";
export const AppsRoutes: Routes = [ export const AppsRoutes: Routes = [
{ {
path: "", path: "",
...@@ -248,6 +251,39 @@ export const AppsRoutes: Routes = [ ...@@ -248,6 +251,39 @@ export const AppsRoutes: Routes = [
}, },
}, },
{ {
path: "view-list-excel",
component: ViewListExcelComponent,
data: {
title: "รายการ Excel",
urls: [
{ title: "รายการเอกสาร" ,url: "apps/portal-category-list"},
{title:"รายการ Excel"}
],
},
},
{
path: "view-list-doc",
component: ViewListDocComponent,
data: {
title: "รายการเอกสาร",
urls: [
{ title: "รายการเอกสาร" ,url: "apps/portal-category-list"},
{title:"รายการเอกสาร"}
],
},
},
{
path: "view-list-course",
component: ViewListCourseComponent,
data: {
title: "รายการหลักสูตร",
urls: [
{ title: "รายการเอกสาร" ,url: "apps/portal-category-list"},
{title:"รายการหลักสูตร"}
],
},
},
{
path: "portal-template-list", path: "portal-template-list",
component: PortalTemplateListComponent, component: PortalTemplateListComponent,
data: { data: {
...@@ -261,9 +297,9 @@ export const AppsRoutes: Routes = [ ...@@ -261,9 +297,9 @@ export const AppsRoutes: Routes = [
path: "portal-create-category", path: "portal-create-category",
component: PortalCreateCategoryComponent, component: PortalCreateCategoryComponent,
data: { data: {
title: "รายการเอกสาร", title: "รายการอัพโหลดเอกสาร",
urls: [ urls: [
{ title: "รายการเอกสาร" }, { title: "รายการอัพโหลดเอกสาร" },
], ],
}, },
}, },
...@@ -293,7 +329,7 @@ export const AppsRoutes: Routes = [ ...@@ -293,7 +329,7 @@ export const AppsRoutes: Routes = [
data: { data: {
title: "รายการเอกสาร", title: "รายการเอกสาร",
urls: [ urls: [
{ title: "รายการเอกสาร", url: "apps/portal-create-category" }, { title: "รายการอัพโหลดเอกสาร", url: "apps/portal-create-category" },
{ title: "รายการเอกสาร" }, { title: "รายการเอกสาร" },
], ],
}, },
...@@ -304,7 +340,7 @@ export const AppsRoutes: Routes = [ ...@@ -304,7 +340,7 @@ export const AppsRoutes: Routes = [
data: { data: {
title: "รายการ Excel", title: "รายการ Excel",
urls: [ urls: [
{ title: "รายการเอกสาร", url: "apps/portal-create-category" }, { title: "รายการอัพโหลดเอกสาร", url: "apps/portal-create-category" },
{ title: "รายการ Excel" }, { title: "รายการ Excel" },
], ],
}, },
...@@ -315,7 +351,7 @@ export const AppsRoutes: Routes = [ ...@@ -315,7 +351,7 @@ export const AppsRoutes: Routes = [
data: { data: {
title: "รายการหลักสูตร", title: "รายการหลักสูตร",
urls: [ urls: [
{ title: "รายการเอกสาร", url: "apps/portal-create-category" }, { title: "รายการอัพโหลดเอกสาร", url: "apps/portal-create-category" },
{ title: "รายการหลักสูตร" }, { title: "รายการหลักสูตร" },
], ],
}, },
......
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();
});
});
...@@ -23,11 +23,11 @@ ...@@ -23,11 +23,11 @@
<tbody> <tbody>
<tr *ngFor="let data of filterListCourse() | slice: (page-1) * pageSize : (page-1) * pageSize + pageSize ; let i = index"> <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 class="text-center">{{i+1}}</td>
<td><img width="100" class="border p-1" src="{{data.thumbnail}}"></td> <td><img width="100" class="border p-1" src="{{data.getImage()}}"></td>
<!-- <td >{{data.id}}</td> --> <!-- <td >{{data.id}}</td> -->
<td>{{ data.thName }}</td> <td>{{ data.thName }}</td>
<td class="text-wrap">{{ data.thDesc }}</td> <td class="text-wrap">{{ data.thDesc }}</td>
<td>{{data.ctype}}</td> <td>{{data.courseType}}</td>
<td><a href="{{data.link1}}" target="_blank">คลิก</a></td> <td><a href="{{data.link1}}" target="_blank">คลิก</a></td>
<td>{{ getStatus(data.status) }}</td> <td>{{ getStatus(data.status) }}</td>
<!-- <td><a (click)="downloadFile(data.logId)">ดาวน์โหลด</a></td> --> <!-- <td><a (click)="downloadFile(data.logId)">ดาวน์โหลด</a></td> -->
...@@ -162,13 +162,12 @@ ...@@ -162,13 +162,12 @@
</div> </div>
</div> </div>
<div class="form-group row"> <div class="form-group row">
<label for="name" class="col-sm-4 col-form-label">Link รูปภาพตัวอย่างรายงาน</label> <label for="name" class="col-sm-4 col-form-label">รูปภาพตัวอย่าง</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input type="text" class="form-control"[(ngModel)]="modelCourse.thumbnail"> <input type="file" class="form-control" (change)="onUploadImage($event)">
</div> </div>
</div> </div>
<div class="form-group row"> <div class="form-group row">
<label for="name" class="col-sm-4 col-form-label">Link ตัวอย่าง</label> <label for="name" class="col-sm-4 col-form-label">Link ตัวอย่าง</label>
<div class="col-sm-8"> <div class="col-sm-8">
...@@ -186,7 +185,7 @@ ...@@ -186,7 +185,7 @@
<div class="modal-footer "> <div class="modal-footer ">
<button type="submit" class="btn btn-info" (click)="onSumit()" [disabled]="!modelCourse.tname||!modelCourse.ename">บันทึก</button> <button type="submit" class="btn btn-info" (click)="onSumit()" [disabled]="!modelCourse.thName||!modelCourse.engName">บันทึก</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 { 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();
});
});
...@@ -5,6 +5,7 @@ import { ConfirmModalComponent } from '../confirm-modal/confirm-modal.component' ...@@ -5,6 +5,7 @@ import { ConfirmModalComponent } from '../confirm-modal/confirm-modal.component'
import { AlertModalComponent } from '../alert-modal/alert-modal.component'; import { AlertModalComponent } from '../alert-modal/alert-modal.component';
import { CourseModel } from 'src/app/model/course.model'; import { CourseModel } from 'src/app/model/course.model';
import { CourseService } from 'src/app/service/course.service'; import { CourseService } from 'src/app/service/course.service';
import { UploadService } from 'src/app/service/upload.service';
@Component({ @Component({
selector: 'app-list-course', selector: 'app-list-course',
...@@ -18,9 +19,23 @@ export class ListCourseComponent implements OnInit { ...@@ -18,9 +19,23 @@ export class ListCourseComponent implements OnInit {
modelCourse:CourseModel = new CourseModel({}); modelCourse:CourseModel = new CourseModel({});
checkEdit:boolean = false checkEdit:boolean = false
search:string = '' search:string = ''
constructor(private modalService: NgbModal,private courseService:CourseService) { constructor(private modalService: NgbModal,private courseService:CourseService,private uploadService:UploadService) {
}
async onUploadImage(event:any){
try{
if (event.target.files.length > 0) {
let fileData = event.target.files[0];
const formData = new FormData();
formData.append('file', fileData);
const data = await this.uploadService.uploadImage(formData).toPromise();
if(data){
this.modelCourse.thumbnail = data.body.fileId
}
}
} catch (error) {
console.error('Error loading data:', error);
}
} }
onSelectFile(event:any) { onSelectFile(event:any) {
if (event.target.files && event.target.files[0]) { if (event.target.files && event.target.files[0]) {
let reader = new FileReader(); let reader = new FileReader();
...@@ -161,7 +176,7 @@ export class ListCourseComponent implements OnInit { ...@@ -161,7 +176,7 @@ export class ListCourseComponent implements OnInit {
async getListCourse(){ async getListCourse(){
try { try {
const data = await this.courseService.getListCourse().toPromise(); const data = await this.courseService.getListCourse().toPromise();
this.listCourse = data this.listCourse = data.map(x => new CourseModel(x))
} catch (error) { } catch (error) {
console.error('Error loading data:', error); console.error('Error loading data:', error);
} }
...@@ -177,7 +192,6 @@ export class ListCourseComponent implements OnInit { ...@@ -177,7 +192,6 @@ export class ListCourseComponent implements OnInit {
closeBtnClick() { closeBtnClick() {
this.modalService.dismissAll(); this.modalService.dismissAll();
this.ngOnInit();
} }
} }
...@@ -15,22 +15,41 @@ ...@@ -15,22 +15,41 @@
<!-- <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" class="text-center">ลิงค์</th>
<th scope="col">สถานะ</th> <th scope="col" class="text-center">ไฟล์ (ไทย)</th>
<!-- <th scope="col">ไฟล์</th> --> <th scope="col" class="text-center">ไฟล์ (อังกฤษ)</th>
<th scope="col" class="text-center">สถานะ</th>
<th scope="col"></th> <th scope="col"></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr *ngFor="let data of filterListDoc() | slice: (page-1) * pageSize : (page-1) * pageSize + pageSize ; let i = index"> <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 class="text-center">{{i+1}}</td>
<td><img width="100" class="border p-1" src="{{data.thumbnail}}"></td> <td><img width="100" class="border p-1" src="{{data.getImage()}}"></td>
<!-- <td >{{data.id}}</td> --> <!-- <td >{{data.id}}</td> -->
<td>{{ data.thName }}</td> <td>{{ data.thName }}</td>
<td>{{ data.thDesc }}</td> <td>{{ data.thDesc }}</td>
<td><a href="{{data.link1}}" target="_blank">คลิก</a></td> <td class="text-center"><i class="fas fa-link pointer" (click)="openLink(data.link1)"></i></td>
<td>{{ getStatus(data.status) }}</td> <td class="text-center"> <i class="fas fa-download pointer" (click)="downloadFile(data.logId,'tha')"></i></td>
<!-- <td><a (click)="downloadFile(data.logId)">ดาวน์โหลด</a></td> --> <td class="text-center"> <i class="fas fa-download pointer" (click)="downloadFile(data.logId,'eng')"></i></td>
<td class="text-center">
<span class="fa-stack rt_anim" *ngIf="data.status == '0'" ngbTooltip="รออนุมัติ" container="body" tooltipClass="myhrcolor-1">
<i class="fa fa-circle fa-stack-2x text-info"></i>
<i class=" fas fa-hourglass-half fa-stack-1x fa-inverse"></i>
</span>
<span class="fa-stack rt_anim" *ngIf="data.status == '1'" ngbTooltip="เปิดใช้งาน" container="body" tooltipClass="myhrcolor-2">
<i class="fa fa-circle fa-stack-2x text-success"></i>
<i class=" fas fa-check fa-stack-1x fa-inverse"></i>
</span>
<span class="fa-stack rt_anim" *ngIf="data.status == '2'" ngbTooltip="ไม่อนุมัติ" container="body" tooltipClass="myhrcolor-3">
<i class="fa fa-circle fa-stack-2x text-danger"></i>
<i class="fas fa-times fa-stack-1x fa-inverse" style="font-size: 1.25em;"></i>
</span>
</td>
<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="แก้ไข"> <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> <i class="fas fa-edit"></i>
...@@ -72,27 +91,27 @@ ...@@ -72,27 +91,27 @@
<div class="modal-body"> <div class="modal-body">
<div class="form-group row"> <div class="form-group row">
<label for="nameth" 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" [(ngModel)]="modelDoc.thName"> <input type="text" class="form-control" id="nameth" [(ngModel)]="modelDoc.thName">
</div> </div>
</div> </div>
<div class="form-group row"> <div class="form-group row">
<label for="nameeng" 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" [(ngModel)]="modelDoc.engName"> <input type="text" class="form-control" id="nameeng" [(ngModel)]="modelDoc.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" [(ngModel)]="modelDoc.thDesc"></textarea> <textarea class="form-control" [(ngModel)]="modelDoc.thDesc"></textarea>
</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" [(ngModel)]="modelDoc.engDesc"></textarea> <textarea class="form-control" [(ngModel)]="modelDoc.engDesc"></textarea>
</div> </div>
...@@ -107,15 +126,24 @@ ...@@ -107,15 +126,24 @@
<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,'th')">
<div class="msg-detail">ไฟล์ที่อนุญาต:*.doc</div>
</div>
</div>
<div class="form-group row">
<label for="name" class="col-sm-4 col-form-label">ไฟล์อัพโหลด (อังกฤษ)</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input type="file" class="form-control" (change)="onSelectFile($event)"> <input type="file" class="form-control" (change)="onSelectFile($event,'eng')">
<div class="msg-detail">ไฟล์ที่อนุญาต:*.doc</div>
</div> </div>
</div> </div>
<div class="form-group row"> <div class="form-group row">
<label for="name" class="col-sm-4 col-form-label">Link รูปภาพตัวอย่างรายงาน</label> <label for="name" class="col-sm-4 col-form-label">รูปภาพตัวอย่าง</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input type="text" class="form-control"[(ngModel)]="modelDoc.thumbnail"> <input type="file" class="form-control" (change)="onUploadImage($event)">
<div class="msg-detail">ไฟล์ที่อนุญาต:*.jpeg, *.jpg, *.png</div>
</div> </div>
</div> </div>
...@@ -136,7 +164,7 @@ ...@@ -136,7 +164,7 @@
<div class="modal-footer "> <div class="modal-footer ">
<button type="submit" class="btn btn-info" (click)="onSumit()" [disabled]="!modelDoc.tname||!modelDoc.ename">บันทึก</button> <button type="submit" class="btn btn-info" (click)="onSumit()" [disabled]="!modelDoc.thName||!modelDoc.engName">บันทึก</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>
......
...@@ -4,7 +4,9 @@ import { ConfirmModalComponent } from '../confirm-modal/confirm-modal.component' ...@@ -4,7 +4,9 @@ import { ConfirmModalComponent } from '../confirm-modal/confirm-modal.component'
import { AlertModalComponent } from '../alert-modal/alert-modal.component'; import { AlertModalComponent } from '../alert-modal/alert-modal.component';
import { DocumentService } from 'src/app/service/document.service'; import { DocumentService } from 'src/app/service/document.service';
import { DocumentModel } from 'src/app/model/document.model'; import { DocumentModel } from 'src/app/model/document.model';
import { UploadService } from 'src/app/service/upload.service';
declare var require: any
const FileSaver = require('file-saver');
@Component({ @Component({
selector: 'app-list-doc', selector: 'app-list-doc',
templateUrl: './list-doc.component.html', templateUrl: './list-doc.component.html',
...@@ -17,24 +19,56 @@ export class ListDocComponent implements OnInit { ...@@ -17,24 +19,56 @@ export class ListDocComponent implements OnInit {
modelDoc:DocumentModel = new DocumentModel({}); modelDoc:DocumentModel = new DocumentModel({});
checkEdit:boolean = false checkEdit:boolean = false
search:string = '' search:string = ''
constructor(private modalService: NgbModal,private documentService:DocumentService) { constructor(private modalService: NgbModal,private documentService:DocumentService, private uploadService:UploadService) {
} }
async onUploadImage(event:any){
onSelectFile(event:any) { try{
if (event.target.files.length > 0) {
let fileData = event.target.files[0];
const formData = new FormData();
formData.append('file', fileData);
const allowedTypes = ['image/png', 'image/jpeg', 'image/jpg'];
if (!allowedTypes.includes(fileData.type)) {
this.openAlertModal('อัพโหลดได้เฉพาะไฟล์ *.jpeg, *.jpg, *.png เท่านั้น')
} else {
const data = await this.uploadService.uploadImage(formData).toPromise();
if(data){
this.modelDoc.thumbnail = data.body.fileId
}
}
}
} catch (error) {
console.error('Error loading data:', error);
}
}
onSelectFile(event:any,lang:string) {
if (event.target.files && event.target.files[0]) { if (event.target.files && event.target.files[0]) {
let reader = new FileReader(); const reader = new FileReader();
const file: File = event.target.files[0];
reader.readAsDataURL(event.target.files[0]); // read file as data url reader.readAsDataURL(event.target.files[0]); // read file as data url
reader.onload = (event) => { // called once readAsDataURL is completed reader.onload = (event) => { // called once readAsDataURL is completed
if(event){ if(event){
let base64 = event.target!.result as string const allowedTypes = ['application/vnd.openxmlformats-officedocument.wordprocessingml.document'];
this.modelDoc.doclObj = base64.split(',')[1]; if (!allowedTypes.includes(file.type)) {
this.openAlertModal('อัพโหลดได้เฉพาะไฟล์ *.doc เท่านั้น')
} else {
let base64 = event.target!.result as string
if(lang == 'th'){
this.modelDoc.thDocObj = base64.split(',')[1];
}else {
this.modelDoc.engDocObj = base64.split(',')[1];
}
}
} }
} }
} }
} }
async downloadFile(logId:string){ async downloadFile(logId:string,lang:string){
try { try {
const data = await this.documentService.downloadFile(logId).toPromise(); const data = await this.documentService.downloadFile(logId,lang).toPromise();
if(data){
FileSaver.saveAs(new Blob([data]), "file_download.doc");
}
} catch (error) { } catch (error) {
console.error('Error loading data:', error); console.error('Error loading data:', error);
} }
...@@ -66,9 +100,9 @@ export class ListDocComponent implements OnInit { ...@@ -66,9 +100,9 @@ export class ListDocComponent implements OnInit {
}) })
modalRef.componentInstance.message = message ? message : "" modalRef.componentInstance.message = message ? message : ""
modalRef.result.then(result => { modalRef.result.then(result => {
this.modalService.dismissAll() // this.modalService.dismissAll()
}, reason => { }, reason => {
this.modalService.dismissAll() // this.modalService.dismissAll()
}) })
} }
...@@ -82,6 +116,7 @@ export class ListDocComponent implements OnInit { ...@@ -82,6 +116,7 @@ export class ListDocComponent implements OnInit {
console.log(this.modelDoc); console.log(this.modelDoc);
this.documentService.createDoc(this.modelDoc).subscribe(result => { this.documentService.createDoc(this.modelDoc).subscribe(result => {
if (result) { if (result) {
this.modalService.dismissAll()
this.openAlertModal('อัพเดทข้อมูลสำเร็จ') this.openAlertModal('อัพเดทข้อมูลสำเร็จ')
this.getListDoc(); this.getListDoc();
} else { } else {
...@@ -101,6 +136,7 @@ export class ListDocComponent implements OnInit { ...@@ -101,6 +136,7 @@ export class ListDocComponent implements OnInit {
modalRef.result.then(result => { modalRef.result.then(result => {
this.documentService.createDoc(this.modelDoc).subscribe(result => { this.documentService.createDoc(this.modelDoc).subscribe(result => {
if (result) { if (result) {
this.modalService.dismissAll()
this.openAlertModal('บันทึกข้อมูลสำเร็จ') this.openAlertModal('บันทึกข้อมูลสำเร็จ')
this.getListDoc(); this.getListDoc();
} else { } else {
...@@ -160,7 +196,7 @@ export class ListDocComponent implements OnInit { ...@@ -160,7 +196,7 @@ export class ListDocComponent implements OnInit {
async getListDoc(){ async getListDoc(){
try { try {
const data = await this.documentService.getListDoc().toPromise(); const data = await this.documentService.getListDoc().toPromise();
this.listDoc = data this.listDoc = data.map(x => new DocumentModel(x))
} catch (error) { } catch (error) {
console.error('Error loading data:', error); console.error('Error loading data:', error);
} }
...@@ -176,7 +212,8 @@ export class ListDocComponent implements OnInit { ...@@ -176,7 +212,8 @@ export class ListDocComponent implements OnInit {
closeBtnClick() { closeBtnClick() {
this.modalService.dismissAll(); this.modalService.dismissAll();
this.ngOnInit();
} }
openLink(url:string){
window.open(url, "_blank");
}
} }
...@@ -15,22 +15,40 @@ ...@@ -15,22 +15,40 @@
<!-- <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" class="text-center">ลิงค์</th>
<th scope="col">สถานะ</th> <th scope="col" class="text-center">ไฟล์</th>
<!-- <th scope="col">ไฟล์</th> --> <th scope="col" class="text-center">สถานะ</th>
<th scope="col"></th> <th scope="col"></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr *ngFor="let data of filterListExcel() | 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.thumbnail}}"></td> <td><img width="100" class="border p-1" src="{{data.getImage()}}"></td>
<!-- <td >{{data.id}}</td> --> <!-- <td >{{data.id}}</td> -->
<td>{{ data.thName }}</td> <td>{{ data.thName }}</td>
<td>{{ data.thDesc }}</td> <td>{{ data.thDesc }}</td>
<td><a href="{{data.link1}}" target="_blank">คลิก</a></td> <td class="text-center"><i class="fas fa-link pointer" (click)="openLink(data.link1)"></i></td>
<td>{{ getStatus(data.status) }}</td> <td class="text-center"> <i class="fas fa-download pointer" (click)="downloadFile(data.logId)"></i></td>
<!-- <td><a (click)="downloadFile(data.logId)">ดาวน์โหลด</a></td> --> <td class="text-center">
<span class="fa-stack rt_anim" *ngIf="data.status == '0'" ngbTooltip="รออนุมัติ" container="body" tooltipClass="myhrcolor-1">
<i class="fa fa-circle fa-stack-2x text-info"></i>
<i class=" fas fa-hourglass-half fa-stack-1x fa-inverse"></i>
</span>
<span class="fa-stack rt_anim" *ngIf="data.status == '1'" ngbTooltip="เปิดใช้งาน" container="body" tooltipClass="myhrcolor-2">
<i class="fa fa-circle fa-stack-2x text-success"></i>
<i class=" fas fa-check fa-stack-1x fa-inverse"></i>
</span>
<span class="fa-stack rt_anim" *ngIf="data.status == '2'" ngbTooltip="ไม่อนุมัติ" container="body" tooltipClass="myhrcolor-3">
<i class="fa fa-circle fa-stack-2x text-danger"></i>
<i class="fas fa-times fa-stack-1x fa-inverse" style="font-size: 1.25em;"></i>
</span>
</td>
<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="แก้ไข"> <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> <i class="fas fa-edit"></i>
...@@ -72,27 +90,27 @@ ...@@ -72,27 +90,27 @@
<div class="modal-body"> <div class="modal-body">
<div class="form-group row"> <div class="form-group row">
<label for="nameth" 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" [(ngModel)]="modelExcel.thName"> <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="nameeng" 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" [(ngModel)]="modelExcel.engName"> <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" [(ngModel)]="modelExcel.thDesc"></textarea> <textarea class="form-control" [(ngModel)]="modelExcel.thDesc"></textarea>
</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" [(ngModel)]="modelExcel.engDesc"></textarea> <textarea class="form-control" [(ngModel)]="modelExcel.engDesc"></textarea>
</div> </div>
...@@ -105,17 +123,20 @@ ...@@ -105,17 +123,20 @@
</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"> <div class="col-sm-8">
<input type="file" class="form-control" (change)="onSelectFile($event)"> <input type="file" class="form-control" (change)="onSelectFile($event)">
<div class="msg-detail">ไฟล์ที่อนุญาต:*.xlsx</div>
</div> </div>
</div> </div>
<div class="form-group row"> <div class="form-group row">
<label for="name" class="col-sm-4 col-form-label">Link รูปภาพตัวอย่างรายงาน</label> <label for="name" class="col-sm-4 col-form-label">รูปภาพตัวอย่าง</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input type="text" class="form-control"[(ngModel)]="modelExcel.thumbnail"> <input type="file" class="form-control" (change)="onUploadImage($event)">
<div class="msg-detail">ไฟล์ที่อนุญาต:*.jpeg, *.jpg, *.png</div>
</div> </div>
</div> </div>
...@@ -136,7 +157,7 @@ ...@@ -136,7 +157,7 @@
<div class="modal-footer "> <div class="modal-footer ">
<button type="submit" class="btn btn-info" (click)="onSumit()" [disabled]="!modelExcel.tname||!modelExcel.ename">บันทึก</button> <button type="submit" class="btn btn-info" (click)="onSumit()" [disabled]="!modelExcel.thName||!modelExcel.engName">บันทึก</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 { ComponentFixture, TestBed } from '@angular/core/testing';
import { ListExcelComponent } from './list-excell.component';
describe('ListExcelComponent', () => {
let component: ListExcelComponent;
let fixture: ComponentFixture<ListExcelComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ListExcelComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(ListExcelComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
...@@ -4,7 +4,9 @@ import { ExcelModel } from 'src/app/model/excel.model'; ...@@ -4,7 +4,9 @@ import { ExcelModel } from 'src/app/model/excel.model';
import { ExcelService } from 'src/app/service/excel.service'; import { ExcelService } from 'src/app/service/excel.service';
import { ConfirmModalComponent } from '../confirm-modal/confirm-modal.component'; import { ConfirmModalComponent } from '../confirm-modal/confirm-modal.component';
import { AlertModalComponent } from '../alert-modal/alert-modal.component'; import { AlertModalComponent } from '../alert-modal/alert-modal.component';
import { UploadService } from 'src/app/service/upload.service';
declare var require: any
const FileSaver = require('file-saver');
@Component({ @Component({
selector: 'app-list-excel', selector: 'app-list-excel',
templateUrl: './list-excell.component.html', templateUrl: './list-excell.component.html',
...@@ -17,28 +19,60 @@ export class ListExcelComponent implements OnInit { ...@@ -17,28 +19,60 @@ export class ListExcelComponent implements OnInit {
modelExcel:ExcelModel = new ExcelModel({}); modelExcel:ExcelModel = new ExcelModel({});
checkEdit:boolean = false checkEdit:boolean = false
search:string = '' search:string = ''
constructor(private modalService: NgbModal,private excelService:ExcelService) { constructor(private modalService: NgbModal,private excelService:ExcelService,private uploadService:UploadService) {
}
async onUploadImage(event:any){
try{
if (event.target.files.length > 0) {
let fileData = event.target.files[0];
const formData = new FormData();
formData.append('file', fileData);
const allowedTypes = ['image/png', 'image/jpeg', 'image/jpg'];
if (!allowedTypes.includes(fileData.type)) {
this.openAlertModal('อัพโหลดได้เฉพาะไฟล์ *.jpeg, *.jpg, *.png เท่านั้น')
} else {
const data = await this.uploadService.uploadImage(formData).toPromise();
if(data){
this.modelExcel.thumbnail = data.body.fileId
}
}
}
} catch (error) {
console.error('Error loading data:', error);
} }
}
onSelectFile(event:any) { onSelectFile(event:any) {
if (event.target.files && event.target.files[0]) { if (event.target.files && event.target.files[0]) {
let reader = new FileReader(); const reader = new FileReader();
const file: File = event.target.files[0];
reader.readAsDataURL(event.target.files[0]); // read file as data url reader.readAsDataURL(event.target.files[0]); // read file as data url
reader.onload = (event) => { // called once readAsDataURL is completed reader.onload = (event) => { // called once readAsDataURL is completed
if(event){ if(event){
let base64 = event.target!.result as string const allowedTypes = ['application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'];
this.modelExcel.excelObj = base64.split(',')[1]; if (!allowedTypes.includes(file.type)) {
this.openAlertModal('อัพโหลดได้เฉพาะไฟล์ *.xlsx เท่านั้น')
} else {
let base64 = event.target!.result as string
this.modelExcel.excelObj = base64.split(',')[1];
}
} }
} }
} }
} }
async downloadFile(logId:string){ async downloadFile(logId:string){
try { try {
const data = await this.excelService.downloadFile(logId).toPromise(); const data = await this.excelService.downloadFile(logId).toPromise();
if(data){
FileSaver.saveAs(new Blob([data]), "file_download.xlsx");
}
} catch (error) { } catch (error) {
console.error('Error loading data:', error); console.error('Error loading data:', error);
} }
} }
deleteFile(item:ExcelModel){ deleteFile(item:ExcelModel){
const modalRef = this.modalService.open(ConfirmModalComponent, { const modalRef = this.modalService.open(ConfirmModalComponent, {
centered: true, centered: true,
...@@ -66,9 +100,9 @@ export class ListExcelComponent implements OnInit { ...@@ -66,9 +100,9 @@ export class ListExcelComponent implements OnInit {
}) })
modalRef.componentInstance.message = message ? message : "" modalRef.componentInstance.message = message ? message : ""
modalRef.result.then(result => { modalRef.result.then(result => {
this.modalService.dismissAll() // this.modalService.dismissAll()
}, reason => { }, reason => {
this.modalService.dismissAll() // this.modalService.dismissAll()
}) })
} }
...@@ -82,6 +116,7 @@ export class ListExcelComponent implements OnInit { ...@@ -82,6 +116,7 @@ export class ListExcelComponent implements OnInit {
console.log(this.modelExcel); console.log(this.modelExcel);
this.excelService.createExcel(this.modelExcel).subscribe(result => { this.excelService.createExcel(this.modelExcel).subscribe(result => {
if (result) { if (result) {
this.modalService.dismissAll()
this.openAlertModal('อัพเดทข้อมูลสำเร็จ') this.openAlertModal('อัพเดทข้อมูลสำเร็จ')
this.getListExcel(); this.getListExcel();
} else { } else {
...@@ -101,6 +136,7 @@ export class ListExcelComponent implements OnInit { ...@@ -101,6 +136,7 @@ export class ListExcelComponent implements OnInit {
modalRef.result.then(result => { modalRef.result.then(result => {
this.excelService.createExcel(this.modelExcel).subscribe(result => { this.excelService.createExcel(this.modelExcel).subscribe(result => {
if (result) { if (result) {
this.modalService.dismissAll()
this.openAlertModal('บันทึกข้อมูลสำเร็จ') this.openAlertModal('บันทึกข้อมูลสำเร็จ')
this.getListExcel(); this.getListExcel();
} else { } else {
...@@ -148,6 +184,9 @@ export class ListExcelComponent implements OnInit { ...@@ -148,6 +184,9 @@ export class ListExcelComponent implements OnInit {
} }
} }
openLink(url:string){
window.open(url, "_blank");
}
getStatus(status:string){ getStatus(status:string){
if(status == '0'){ if(status == '0'){
return 'รออนุมัติ' return 'รออนุมัติ'
...@@ -160,7 +199,7 @@ export class ListExcelComponent implements OnInit { ...@@ -160,7 +199,7 @@ export class ListExcelComponent implements OnInit {
async getListExcel(){ async getListExcel(){
try { try {
const data = await this.excelService.getListExcel().toPromise(); const data = await this.excelService.getListExcel().toPromise();
this.listExcel = data this.listExcel = data.map(x => new ExcelModel(x))
} catch (error) { } catch (error) {
console.error('Error loading data:', error); console.error('Error loading data:', error);
} }
...@@ -176,7 +215,6 @@ export class ListExcelComponent implements OnInit { ...@@ -176,7 +215,6 @@ export class ListExcelComponent implements OnInit {
closeBtnClick() { closeBtnClick() {
this.modalService.dismissAll(); this.modalService.dismissAll();
this.ngOnInit();
} }
} }
...@@ -52,11 +52,11 @@ export class PortalCategoryListComponent implements OnInit { ...@@ -52,11 +52,11 @@ export class PortalCategoryListComponent implements OnInit {
openView(id:string){ openView(id:string){
if(id =='1'){ if(id =='1'){
this.routes.navigate(['apps/list-excel']); this.routes.navigate(['apps/view-list-excel']);
}else if(id =='2'){ }else if(id =='2'){
this.routes.navigate(['apps/list-doc']); this.routes.navigate(['apps/view-list-doc']);
}else if(id =='3'){ }else if(id =='3'){
this.routes.navigate(['apps/list-course']); this.routes.navigate(['apps/view-list-course']);
} }
} }
......
<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">รายการเอกสาร</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="ค้นหาเอกสาร" > <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 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>
</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>
</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 { ComponentFixture, TestBed } from '@angular/core/testing';
import { ApproveCourseComponent } from './approve-course.component'; import { ViewListCourseComponent } from './view-list-course.component';
describe('ApproveCourseComponent', () => { describe('ViewListCourseComponent', () => {
let component: ApproveCourseComponent; let component: ViewListCourseComponent;
let fixture: ComponentFixture<ApproveCourseComponent>; let fixture: ComponentFixture<ViewListCourseComponent>;
beforeEach(async () => { beforeEach(async () => {
await TestBed.configureTestingModule({ await TestBed.configureTestingModule({
declarations: [ ApproveCourseComponent ] declarations: [ ViewListCourseComponent ]
}) })
.compileComponents(); .compileComponents();
}); });
beforeEach(() => { beforeEach(() => {
fixture = TestBed.createComponent(ApproveCourseComponent); fixture = TestBed.createComponent(ViewListCourseComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
fixture.detectChanges(); fixture.detectChanges();
}); });
......
import { Component, OnInit } from '@angular/core';
import { AlertModalComponent } from '../alert-modal/alert-modal.component';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { CourseService } from 'src/app/service/course.service';
import { CourseModel } from 'src/app/model/course.model';
@Component({
selector: 'app-view-list-course',
templateUrl: './view-list-course.component.html',
styleUrls: ['./view-list-course.component.scss']
})
export class ViewListCourseComponent 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);
}
}
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> -->
</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> -->
</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 { ComponentFixture, TestBed } from '@angular/core/testing';
import { ApproveDocComponent } from './approve-doc.component'; import { ViewListDocComponent } from './view-list-doc.component';
describe('ApproveDocComponent', () => { describe('ViewListDocComponent', () => {
let component: ApproveDocComponent; let component: ViewListDocComponent;
let fixture: ComponentFixture<ApproveDocComponent>; let fixture: ComponentFixture<ViewListDocComponent>;
beforeEach(async () => { beforeEach(async () => {
await TestBed.configureTestingModule({ await TestBed.configureTestingModule({
declarations: [ ApproveDocComponent ] declarations: [ ViewListDocComponent ]
}) })
.compileComponents(); .compileComponents();
}); });
beforeEach(() => { beforeEach(() => {
fixture = TestBed.createComponent(ApproveDocComponent); fixture = TestBed.createComponent(ViewListDocComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
fixture.detectChanges(); fixture.detectChanges();
}); });
......
import { Component, OnInit } from '@angular/core';
import { AlertModalComponent } from '../alert-modal/alert-modal.component';
import { ConfirmModalComponent } from '../confirm-modal/confirm-modal.component';
import { DocumentModel } from 'src/app/model/document.model';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { DocumentService } from 'src/app/service/document.service';
@Component({
selector: 'app-view-list-doc',
templateUrl: './view-list-doc.component.html',
styleUrls: ['./view-list-doc.component.scss']
})
export class ViewListDocComponent 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);
}
}
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="col-12">
<div class="card card-body">
<h4 class="card-title">รายการ Excel</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" class="text-center">ลิงค์</th>
<th scope="col" class="text-center">ไฟล์</th>
<th scope="col" class="text-center">จำนวนดาวน์โหลด</th>
</tr>
</thead>
<tbody>
<tr *ngIf="listExcel.length == 0">
<td colspan="7" class="text-center">ไม่พบข้อมูล</td>
</tr>
<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><img width="100" class="border p-1" src="{{data.getImage()}}"></td>
<!-- <td >{{data.id}}</td> -->
<td>{{ data.thName }}</td>
<td>{{ data.thDesc }}</td>
<td class="text-center"><i class="fas fa-link pointer" (click)="openLink(data.link1)"></i></td>
<td class="text-center"> <i class="fas fa-download pointer" (click)="downloadFile(data.excelId)"></i></td>
<td class="text-center">{{data.dwTime}} ครั้ง</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]="listExcel.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 { Component, OnInit } from '@angular/core';
import { ConfirmModalComponent } from '../confirm-modal/confirm-modal.component';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { ExcelService } from 'src/app/service/excel.service';
import { AlertModalComponent } from '../alert-modal/alert-modal.component';
import { ExcelContentModel } from 'src/app/model/excel-content.model';
declare var require: any
const FileSaver = require('file-saver');
@Component({
selector: 'app-view-list-excel',
templateUrl: './view-list-excel.component.html',
styleUrls: ['./view-list-excel.component.scss']
})
export class ViewListExcelComponent implements OnInit {
page = 1;
pageSize = 10;
listExcel:ExcelContentModel[]=[]
search:string = ''
constructor(private modalService: NgbModal,private excelService:ExcelService) {
}
async downloadFile(logId:string){
try {
const data = await this.excelService.downloadFileContent(logId).toPromise();
if(data){
FileSaver.saveAs(new Blob([data]), "file_download.xlsx");
}
} catch (error) {
console.error('Error loading data:', error);
}
}
getStatus(status:string){
if(status == '0'){
return 'รออนุมัติ'
} else if(status == '1'){
return 'เปิดใช้งาน'
} else if(status == '2'){
return 'ไม่อนุมัติ'
}
}
filterListExcel(){
return this.listExcel.filter(x => x.thName.toLowerCase().includes(this.search.toLowerCase())||x.engName.toLowerCase().includes(this.search.toLowerCase()))
}
async getListExcel(){
try {
const data = await this.excelService.getListExcelContent().toPromise();
this.listExcel = data.map(x => new ExcelContentModel(x))
} catch (error) {
console.error('Error loading data:', error);
}
}
ngOnInit() {
this.getListExcel();
}
openLink(url:string){
window.open(url, "_blank");
}
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()
})
}
}
import { environment } from "src/environments/environment"
export interface CourseModel { export interface CourseModel {
logId: string logId: string
objective: string objective: string
...@@ -61,4 +63,11 @@ export class CourseModel implements CourseModel { ...@@ -61,4 +63,11 @@ export class CourseModel implements CourseModel {
this.courseTrainer = data.courseTrainer?data.courseTrainer:'' this.courseTrainer = data.courseTrainer?data.courseTrainer:''
this.courseTrainerDetail = data.courseTrainerDetail?data.courseTrainerDetail:'' this.courseTrainerDetail = data.courseTrainerDetail?data.courseTrainerDetail:''
} }
getImage(){
if(this.thumbnail){
return environment.url+"files/image/"+this.thumbnail
}else{
return 'assets/images/big/auth-bg.jpg'
}
}
} }
\ No newline at end of file
import { environment } from "src/environments/environment"
export interface DocumentModel { export interface DocumentModel {
logId: string logId: string
thumbnail: string thumbnail: string
link1: string link1: string
langSupport: string langSupport: string
doclObj: string thDocObj: string
engDocObj: string
uploadBy: string uploadBy: string
remark: string remark: string
status: number status: number
...@@ -19,7 +22,8 @@ export class DocumentModel implements DocumentModel { ...@@ -19,7 +22,8 @@ export class DocumentModel implements DocumentModel {
thumbnail: string thumbnail: string
link1: string link1: string
langSupport: string langSupport: string
doclObj: string thDocObj: string
engDocObj: string
uploadBy: string uploadBy: string
remark: string remark: string
status: number status: number
...@@ -33,7 +37,8 @@ export class DocumentModel implements DocumentModel { ...@@ -33,7 +37,8 @@ export class DocumentModel implements DocumentModel {
this.thumbnail = data.thumbnail?data.thumbnail:'' this.thumbnail = data.thumbnail?data.thumbnail:''
this.link1 = data.link1?data.link1:'' this.link1 = data.link1?data.link1:''
this.langSupport = data.langSupport?data.langSupport:'' this.langSupport = data.langSupport?data.langSupport:''
this.doclObj = data.doclObj?data.doclObj:'' this.thDocObj = data.thDocObj?data.thDocObj:''
this.engDocObj = data.engDocObj?data.engDocObj:''
this.uploadBy = data.uploadBy?data.uploadBy:'' this.uploadBy = data.uploadBy?data.uploadBy:''
this.remark = data.remark?data.remark:'' this.remark = data.remark?data.remark:''
this.status = data.status?data.status:0 this.status = data.status?data.status:0
...@@ -45,4 +50,11 @@ export class DocumentModel implements DocumentModel { ...@@ -45,4 +50,11 @@ export class DocumentModel implements DocumentModel {
} }
getImage(){
if(this.thumbnail){
return environment.url+"files/image/"+this.thumbnail
}else{
return 'assets/images/big/auth-bg.jpg'
}
}
} }
\ No newline at end of file
import { environment } from "src/environments/environment"
export interface ExcelContentModel { excelId: string
thName: string
engName: string
thDesc: string
engDesc: string
thumbnail: string
link1: string
dbSupport: string
excelObj: any
uploadBy: string
dwTime: number
remark: string
referId: string
approveBy: string
}
export class ExcelContentModel implements ExcelContentModel {
excelId: string
thName: string
engName: string
thDesc: string
engDesc: string
thumbnail: string
link1: string
dbSupport: string
excelObj: any
uploadBy: string
dwTime: number
remark: string
referId: string
approveBy: string
constructor(data: Partial<any>) {
this.excelId = data.excelId?data.excelId:''
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.dwTime = data.dwTime?data.dwTime: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.referId = data.referId?data.referId:''
}
getImage(){
if(this.thumbnail){
return environment.url+"files/image/"+this.thumbnail
}else{
return 'assets/images/big/auth-bg.jpg'
}
}
}
\ No newline at end of file
import { environment } from "src/environments/environment"
import { TagModel } from "./tag.mmodel"
export interface ExcelModel { export interface ExcelModel {
logId: string logId: string
thumbnail: string thumbnail: string
...@@ -12,6 +15,7 @@ export interface ExcelModel { ...@@ -12,6 +15,7 @@ export interface ExcelModel {
engName: string engName: string
thDesc: string thDesc: string
engDesc: string engDesc: string
tags: TagModel[]
} }
export class ExcelModel implements ExcelModel { export class ExcelModel implements ExcelModel {
...@@ -28,6 +32,7 @@ export class ExcelModel implements ExcelModel { ...@@ -28,6 +32,7 @@ export class ExcelModel implements ExcelModel {
engName: string engName: string
thDesc: string thDesc: string
engDesc: string engDesc: string
tags: TagModel[]
constructor(data: Partial<any>) { constructor(data: Partial<any>) {
this.logId = data.logId?data.logId:'' this.logId = data.logId?data.logId:''
this.thumbnail = data.thumbnail?data.thumbnail:'' this.thumbnail = data.thumbnail?data.thumbnail:''
...@@ -42,7 +47,13 @@ export class ExcelModel implements ExcelModel { ...@@ -42,7 +47,13 @@ export class ExcelModel implements ExcelModel {
this.engName = data.engName?data.engName:'' this.engName = data.engName?data.engName:''
this.thDesc = data.thDesc?data.thDesc:'' this.thDesc = data.thDesc?data.thDesc:''
this.engDesc = data.engDesc?data.engDesc:'' this.engDesc = data.engDesc?data.engDesc:''
this.tags = data.tags?data.tags:[]
}
getImage(){
if(this.thumbnail){
return environment.url+"files/image/"+this.thumbnail
}else{
return 'assets/images/big/auth-bg.jpg'
}
} }
} }
\ No newline at end of file
export interface TagModel {
display: string
value: string
}
export class TagModel implements TagModel {
display: string
value: string
constructor(data: Partial<any>) {
this.display = data.display?data.display:''
this.value = data.value?data.value:''
}
}
\ No newline at end of file
...@@ -21,9 +21,12 @@ export class DocumentService { ...@@ -21,9 +21,12 @@ export class DocumentService {
} }
getDocById(logId:string): Observable<DocumentModel> { getDocById(logId:string): Observable<DocumentModel> {
return this.http.get<DocumentModel>(this.url + "document-center/upload/"+logId) return this.http.get<DocumentModel>(this.url + "document-center/upload/"+logId)
}
downloadFile(logId:string,lang:string):Observable<any>{
return this.http.get(this.url + "document-center/files/download/"+logId+'?lang='+lang, { responseType: 'blob' })
} }
downloadFile(logId:string){ downloadFileContent(logId:string):Observable<any>{
return this.http.get<DocumentModel>(this.url + "document-center/files/download/"+logId) return this.http.get(this.url + "document-center/files/download/content/"+logId, { responseType: 'blob' });
} }
createDoc(model: DocumentModel): Observable<boolean> { createDoc(model: DocumentModel): Observable<boolean> {
if (this.createStatus) { if (this.createStatus) {
......
...@@ -4,6 +4,7 @@ import { HttpClient, HttpHeaders } from '@angular/common/http'; ...@@ -4,6 +4,7 @@ import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Observable, of } from 'rxjs'; import { Observable, of } from 'rxjs';
import { ExcelModel } from '../model/excel.model'; import { ExcelModel } from '../model/excel.model';
import { map, tap } from 'rxjs/operators'; import { map, tap } from 'rxjs/operators';
import { ExcelContentModel } from '../model/excel-content.model';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
...@@ -20,12 +21,19 @@ export class ExcelService { ...@@ -20,12 +21,19 @@ export class ExcelService {
return this.http.get<ExcelModel[]>(this.url + "excel-center/upload/lists") return this.http.get<ExcelModel[]>(this.url + "excel-center/upload/lists")
} }
} }
getListExcelContent(status?: string): Observable<ExcelContentModel[]> {
return this.http.get<ExcelContentModel[]>(this.url + "excel-center/content/lists")
}
getExcelById(logId:string): Observable<ExcelModel> { getExcelById(logId:string): Observable<ExcelModel> {
return this.http.get<ExcelModel>(this.url + "excel-center/upload/"+logId) return this.http.get<ExcelModel>(this.url + "excel-center/upload/"+logId)
} }
downloadFile(logId:string){ downloadFile(logId:string):Observable<any>{
return this.http.get<ExcelModel>(this.url + "excel-center/files/download/"+logId) return this.http.get(this.url + "excel-center/files/download/"+logId, { responseType: 'blob' })
}
downloadFileContent(logId:string):Observable<any>{
return this.http.get(this.url + "excel-center/files/download/content/"+logId, { responseType: 'blob' });
} }
createExcel(model: ExcelModel): Observable<boolean> { createExcel(model: ExcelModel): Observable<boolean> {
if (this.createStatus) { if (this.createStatus) {
this.createStatus = false this.createStatus = false
......
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 UploadService {
url = environment.url
createStatus: boolean = true
constructor(private http: HttpClient) { }
uploadImage(file: any): Observable<any> {
return this.http.post<any>(this.url + 'files/upload/image', file, { observe: 'response' })
}
}
...@@ -3,7 +3,7 @@ import { RouteInfo } from "./vertical-sidebar.metadata"; ...@@ -3,7 +3,7 @@ import { RouteInfo } from "./vertical-sidebar.metadata";
export const ROUTES: RouteInfo[] = [ export const ROUTES: RouteInfo[] = [
{ {
path: '/apps/portal-create-category', path: '/apps/portal-category-list',
title: 'รายการเอกสาร', title: 'รายการเอกสาร',
icon: 'mdi mdi-adjust', icon: 'mdi mdi-adjust',
class: '', class: '',
...@@ -13,6 +13,16 @@ export const ROUTES: RouteInfo[] = [ ...@@ -13,6 +13,16 @@ export const ROUTES: RouteInfo[] = [
submenu: [] submenu: []
}, },
{ {
path: '/apps/portal-create-category',
title: 'รายการอัพโหลดเอกสาร',
icon: 'mdi mdi-adjust',
class: '',
label: "",
labelClass: "",
extralink: false,
submenu: []
},
{
path: '/apps/import-template', path: '/apps/import-template',
title: 'นำเข้า Template', title: 'นำเข้า Template',
icon: 'mdi mdi-adjust', icon: 'mdi mdi-adjust',
...@@ -51,16 +61,16 @@ export const ROUTES: RouteInfo[] = [ ...@@ -51,16 +61,16 @@ export const ROUTES: RouteInfo[] = [
extralink: false, extralink: false,
submenu: [] submenu: []
}, },
{ // {
path: '/apps/portal-category-list', // path: '/apps/portal-category-list',
title: 'รายการเอกสาร', // title: 'รายการเอกสาร',
icon: '', // icon: '',
class: '', // class: '',
label: "", // label: "",
labelClass: "", // labelClass: "",
extralink: false, // extralink: false,
submenu: [] // submenu: []
}, // },
] ]
}, },
......
...@@ -5,4 +5,72 @@ ...@@ -5,4 +5,72 @@
@import url("https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"); @import url("https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css");
body { body {
font-family: "Kanit", sans-serif !important; font-family: "Kanit", sans-serif !important;
} }
\ No newline at end of file .msg-detail{
width: 100%;
margin-top: 0.25rem;
font-size: 0.875em;
color: #f62d51;
}
.myhrcolor-1 .tooltip-inner {
background-color: #fff;
color: #2962ff;
font-weight: 400;
border-style: solid;
border-color: #2962ff;
border-width: 1px;
}
.myhrcolor-1 .arrow::before {
border-top-color: #2962ff;
}
.myhrcolor-2 .tooltip-inner {
background-color: #fff;
color: #36bea6;
font-weight: 400;
border-style: solid;
border-color: #36bea6;
border-width: 1px;
}
.myhrcolor-2 .arrow::before {
border-top-color: #36bea6;
}
.myhrcolor-3 .tooltip-inner {
background-color: #fff;
color: #f62d51;
font-weight: 400;
border-style: solid;
border-color: #f62d51;
border-width: 1px;
}
.myhrcolor-3 .arrow::before {
border-top-color: #f62d51;
}
.myhrcolor-4 .tooltip-inner {
background-color: #fff;
color: #ffbc34;
font-weight: 400;
border-style: solid;
border-color: #ffbc34;
border-width: 1px;
}
.myhrcolor-4 .arrow::before {
border-top-color: #ffbc34;
}
.myhrcolor-date .tooltip-inner {
background-color: #fff;
color: #a1aab2;
font-weight: 400;
border-style: solid;
border-color: #a1aab2;
border-width: 1px;
}
.myhrcolor-date .arrow::before {
border-top-color: #a1aab2;
}
.pointer{
cursor: pointer;
}
.pointer:hover{
color: #2962ff;
}
\ 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