Commit daa88ded by Nakarin Luankla

UPDATE รายการผ่านการอนุมัติ

parent 8750d346
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
"build": { "build": {
"builder": "@angular-devkit/build-angular:browser", "builder": "@angular-devkit/build-angular:browser",
"options": { "options": {
"outputPath": "dist/xtreme-admin-angular", "outputPath": "dist",
"index": "src/index.html", "index": "src/index.html",
"main": "src/main.ts", "main": "src/main.ts",
"polyfills": "src/polyfills.ts", "polyfills": "src/polyfills.ts",
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
</thead> </thead>
<tbody> <tbody>
<tr *ngIf="listCourse.length == 0"> <tr *ngIf="listCourse.length == 0">
<td colspan="8" class="text-center">ไม่พบข้อมูล</td> <td colspan="9" class="text-center">ไม่พบข้อมูล</td>
</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>
...@@ -52,6 +52,9 @@ ...@@ -52,6 +52,9 @@
<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>
<button type="button" 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>
</td> </td>
</tr> </tr>
</tbody> </tbody>
......
...@@ -84,6 +84,27 @@ export class ApproveCourseComponent implements OnInit { ...@@ -84,6 +84,27 @@ export class ApproveCourseComponent implements OnInit {
this.getListCourse(); this.getListCourse();
} }
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) { openAlertModal(message?: string) {
const modalRef = this.modalService.open(AlertModalComponent, { const modalRef = this.modalService.open(AlertModalComponent, {
centered: true, centered: true,
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
</thead> </thead>
<tbody> <tbody>
<tr *ngIf="listDoc.length == 0"> <tr *ngIf="listDoc.length == 0">
<td colspan="8" class="text-center">ไม่พบข้อมูล</td> <td colspan="9" class="text-center">ไม่พบข้อมูล</td>
</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>
...@@ -54,6 +54,9 @@ ...@@ -54,6 +54,9 @@
<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>
<button type="button" 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>
</td> </td>
</tr> </tr>
</tbody> </tbody>
......
...@@ -86,6 +86,25 @@ export class ApproveDocComponent implements OnInit { ...@@ -86,6 +86,25 @@ export class ApproveDocComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.getListDoc(); this.getListDoc();
} }
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 => { })
}
openAlertModal(message?: string) { openAlertModal(message?: string) {
const modalRef = this.modalService.open(AlertModalComponent, { const modalRef = this.modalService.open(AlertModalComponent, {
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
</thead> </thead>
<tbody> <tbody>
<tr *ngIf="listExcel.length == 0"> <tr *ngIf="listExcel.length == 0">
<td colspan="7" class="text-center">ไม่พบข้อมูล</td> <td colspan="8" class="text-center">ไม่พบข้อมูล</td>
</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>
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
<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>
<button type="button" 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>
</td> </td>
</tr> </tr>
</tbody> </tbody>
......
...@@ -83,6 +83,25 @@ export class ApproveExcelComponent implements OnInit { ...@@ -83,6 +83,25 @@ export class ApproveExcelComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.getListExcel(); this.getListExcel();
} }
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 => { })
}
openAlertModal(message?: string) { openAlertModal(message?: string) {
const modalRef = this.modalService.open(AlertModalComponent, { const modalRef = this.modalService.open(AlertModalComponent, {
......
<div class="row">
<div class="col-12">
<div class="card card-body">
<h4 class="card-title">รายการเอกสาร</h4>
<div class="row justify-content-center">
<div class="col-md-4 " *ngFor="let c of testdata|slice: (page-1) * pageSize : (page-1) * pageSize + pageSize">
<div class="card border border-2">
<div class="card-body text-center">
<img src="{{ c.img }}" class="rounded-circle border p-1" width="100">
<h3 class="card-title mt-3 mb-0">{{c.name}}</h3>
</div>
<div class="d-flex justify-content-between bg-light border-top p-3">
<div>
<span class="align-middle">จำนวนเอกสาร {{ c.document }} ฉบับ</span>
</div>
<div >
<button class="btn btn-info btn-sm text-nowrap" (click)="openView(c.id)">รายละเอียด</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
\ No newline at end of file
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ApprovedListComponent } from './approved-list.component';
describe('ApprovedListComponent', () => {
let component: ApprovedListComponent;
let fixture: ComponentFixture<ApprovedListComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ApprovedListComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(ApprovedListComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { CourseService } from 'src/app/service/course.service';
import { DocumentService } from 'src/app/service/document.service';
import { ExcelService } from 'src/app/service/excel.service';
@Component({
selector: 'app-approved-list',
templateUrl: './approved-list.component.html',
styleUrls: ['./approved-list.component.scss']
})
export class ApprovedListComponent implements OnInit {
constructor(
private routes: Router,
private excelService:ExcelService,private documentService:DocumentService,private courseService:CourseService
) {}
page = 1;
pageSize = 10;
testdata: {
id:string;
img: String;
name: String;
details: String;
document: String;
}[] = [];
ngOnInit() {
this.testdata = [
{
id:'1',
img: "assets/images/icon/excel.png",
name: "Excel",
details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
document: "0"
},
{
id:'2',
img: "assets/images/icon/document.png",
name: "Document",
details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
document: "0"
},
{
id:'3',
img: "assets/images/icon/course.png",
name: "Course",
details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
document: "0"
},
];
this.getListCount();
}
async getListCount(){
try {
const countExcel = await this.excelService.getCountContent().toPromise();
const countDoc = await this.documentService.getCountContent().toPromise();
const countCourse = await this.courseService.getCountContent().toPromise();
this.testdata.forEach((x ,i) => {
if(i == 0){
x.document = countExcel.toString()
}else if(i == 1){
x.document = countDoc.toString()
}else if(i == 2){
x.document = countCourse.toString()
}
})
} catch (error) {
console.error('Error loading data:', error);
}
}
openView(id:string){
if(id =='1'){
this.routes.navigate(['apps/view-list-excel/1']);
}else if(id =='2'){
this.routes.navigate(['apps/view-list-doc/1']);
}else if(id =='3'){
this.routes.navigate(['apps/view-list-course/1']);
}
}
}
...@@ -94,6 +94,7 @@ import { ViewListExcelComponent } from './view-list-excel/view-list-excel.compon ...@@ -94,6 +94,7 @@ import { ViewListExcelComponent } from './view-list-excel/view-list-excel.compon
import { ViewListDocComponent } from './view-list-doc/view-list-doc.component'; import { ViewListDocComponent } from './view-list-doc/view-list-doc.component';
import { ViewListCourseComponent } from './view-list-course/view-list-course.component'; import { ViewListCourseComponent } from './view-list-course/view-list-course.component';
import { TagInputModule } from 'ngx-chips'; import { TagInputModule } from 'ngx-chips';
import { ApprovedListComponent } from './approved-list/approved-list.component';
@NgModule({ @NgModule({
...@@ -165,7 +166,8 @@ import { TagInputModule } from 'ngx-chips'; ...@@ -165,7 +166,8 @@ import { TagInputModule } from 'ngx-chips';
ApproveCourseComponent, ApproveCourseComponent,
ViewListExcelComponent, ViewListExcelComponent,
ViewListDocComponent, ViewListDocComponent,
ViewListCourseComponent ViewListCourseComponent,
ApprovedListComponent
], ],
providers: [ providers: [
ContactService, ContactService,
......
...@@ -46,6 +46,7 @@ import { ApproveCourseComponent } from "./approve-course/approve-course.componen ...@@ -46,6 +46,7 @@ import { ApproveCourseComponent } from "./approve-course/approve-course.componen
import { ViewListCourseComponent } from "./view-list-course/view-list-course.component"; import { ViewListCourseComponent } from "./view-list-course/view-list-course.component";
import { ViewListExcelComponent } from "./view-list-excel/view-list-excel.component"; import { ViewListExcelComponent } from "./view-list-excel/view-list-excel.component";
import { ViewListDocComponent } from "./view-list-doc/view-list-doc.component"; import { ViewListDocComponent } from "./view-list-doc/view-list-doc.component";
import { ApprovedListComponent } from "./approved-list/approved-list.component";
export const AppsRoutes: Routes = [ export const AppsRoutes: Routes = [
{ {
path: "", path: "",
...@@ -231,6 +232,17 @@ export const AppsRoutes: Routes = [ ...@@ -231,6 +232,17 @@ export const AppsRoutes: Routes = [
}, },
}, },
{ {
path: "approved-list",
component: ApprovedListComponent,
data: {
title: "รายการเอกสารผ่านการอนุมัติ",
urls: [
{ title: "รายการเอกสารผ่านการอนุมัติ" ,url: "apps/portal-category-list-approve"},
{ title: "อนุมัติหลักสูตร" },
],
},
},
{
path: "portal-template-approve", path: "portal-template-approve",
component: PortalTemplateApproveComponent, component: PortalTemplateApproveComponent,
data: { data: {
...@@ -262,6 +274,17 @@ export const AppsRoutes: Routes = [ ...@@ -262,6 +274,17 @@ export const AppsRoutes: Routes = [
}, },
}, },
{ {
path: "view-list-excel/:type",
component: ViewListExcelComponent,
data: {
title: "รายการ Excel",
urls: [
{ title: "รายการเอกสาร" ,url: "apps/portal-category-list"},
{title:"รายการ Excel"}
],
},
},
{
path: "view-list-doc", path: "view-list-doc",
component: ViewListDocComponent, component: ViewListDocComponent,
data: { data: {
...@@ -273,6 +296,17 @@ export const AppsRoutes: Routes = [ ...@@ -273,6 +296,17 @@ export const AppsRoutes: Routes = [
}, },
}, },
{ {
path: "view-list-doc/:type",
component: ViewListDocComponent,
data: {
title: "รายการเอกสาร",
urls: [
{ title: "รายการเอกสาร" ,url: "apps/portal-category-list"},
{title:"รายการเอกสาร"}
],
},
},
{
path: "view-list-course", path: "view-list-course",
component: ViewListCourseComponent, component: ViewListCourseComponent,
data: { data: {
...@@ -284,6 +318,17 @@ export const AppsRoutes: Routes = [ ...@@ -284,6 +318,17 @@ export const AppsRoutes: Routes = [
}, },
}, },
{ {
path: "view-list-course/:type",
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: {
......
...@@ -94,7 +94,6 @@ export class ListDocComponent implements OnInit { ...@@ -94,7 +94,6 @@ export class ListDocComponent implements OnInit {
this.openAlertModal(error.message) this.openAlertModal(error.message)
}) })
}, reject => { }) }, reject => { })
} }
openAlertModal(message?: string) { openAlertModal(message?: string) {
const modalRef = this.modalService.open(AlertModalComponent, { const modalRef = this.modalService.open(AlertModalComponent, {
......
...@@ -102,7 +102,6 @@ export class ListExcelComponent implements OnInit { ...@@ -102,7 +102,6 @@ export class ListExcelComponent implements OnInit {
this.openAlertModal(error.message) this.openAlertModal(error.message)
}) })
}, reject => { }) }, reject => { })
} }
openAlertModal(message?: string) { openAlertModal(message?: string) {
const modalRef = this.modalService.open(AlertModalComponent, { const modalRef = this.modalService.open(AlertModalComponent, {
......
...@@ -55,6 +55,8 @@ export class PortalCategoryListApproveComponent implements OnInit { ...@@ -55,6 +55,8 @@ export class PortalCategoryListApproveComponent implements OnInit {
document: "0" document: "0"
}, },
]; ];
this.getListCount();
} }
openView(id:string){ openView(id:string){
if(id =='1'){ if(id =='1'){
...@@ -64,7 +66,6 @@ export class PortalCategoryListApproveComponent implements OnInit { ...@@ -64,7 +66,6 @@ export class PortalCategoryListApproveComponent implements OnInit {
}else if(id =='3'){ }else if(id =='3'){
this.router.navigate(['apps/approve-course']); this.router.navigate(['apps/approve-course']);
} }
this.getListCount();
} }
async getListCount(){ async getListCount(){
try { try {
......
...@@ -17,11 +17,12 @@ ...@@ -17,11 +17,12 @@
<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" *ngIf="checkType == '1'"></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr *ngIf="listCourse.length == 0"> <tr *ngIf="listCourse.length == 0">
<td colspan="8" class="text-center">ไม่พบข้อมูล</td> <td colspan="{{checkType == '1' ? '9' : '8'}}" class="text-center">ไม่พบข้อมูล</td>
</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>
...@@ -32,6 +33,9 @@ ...@@ -32,6 +33,9 @@
<td class="text-center"><i class="fas fa-link pointer" (click)="openLink(data.link1)"></i></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.courseId)"></i></td> <td class="text-center"> <i class="fas fa-download pointer" (click)="downloadFile(data.courseId)"></i></td>
<td class="text-center">{{data.dwTime}} ครั้ง</td> <td class="text-center">{{data.dwTime}} ครั้ง</td>
<td *ngIf="checkType == '1'">
<button type="button" 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>
</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
......
...@@ -4,6 +4,8 @@ import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; ...@@ -4,6 +4,8 @@ import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { CourseService } from 'src/app/service/course.service'; import { CourseService } from 'src/app/service/course.service';
import { CourseModel } from 'src/app/model/course.model'; import { CourseModel } from 'src/app/model/course.model';
import { CourseContentModel } from 'src/app/model/course-content.model'; import { CourseContentModel } from 'src/app/model/course-content.model';
import { ActivatedRoute } from '@angular/router';
import { ConfirmModalComponent } from '../confirm-modal/confirm-modal.component';
declare var require: any declare var require: any
const FileSaver = require('file-saver'); const FileSaver = require('file-saver');
@Component({ @Component({
...@@ -16,7 +18,11 @@ export class ViewListCourseComponent implements OnInit { ...@@ -16,7 +18,11 @@ export class ViewListCourseComponent implements OnInit {
pageSize = 10; pageSize = 10;
listCourse:CourseContentModel[]=[] listCourse:CourseContentModel[]=[]
search:string = '' search:string = ''
constructor(private modalService: NgbModal,private courseService:CourseService) { checkType:string = '0'
constructor(private modalService: NgbModal,private courseService:CourseService,private activatedRoute: ActivatedRoute) {
this.activatedRoute.paramMap.subscribe(result => {
this.checkType = result.get("type")!;
});
} }
async downloadFile(logId:string){ async downloadFile(logId:string){
try { try {
...@@ -40,7 +46,25 @@ export class ViewListCourseComponent implements OnInit { ...@@ -40,7 +46,25 @@ export class ViewListCourseComponent implements OnInit {
console.error('Error loading data:', error); console.error('Error loading data:', error);
} }
} }
deleteFile(item:CourseContentModel){
const modalRef = this.modalService.open(ConfirmModalComponent, {
centered: true,
backdrop: 'static',
})
modalRef.componentInstance.message = 'คุณต้องการลบข้อมูลหรือไม่'
modalRef.result.then(result => {
this.courseService.deleteCourseContent(item).subscribe(result => {
if (result) {
this.openAlertModal('ลบข้อมูลสำเร็จ')
this.getListCourse();
} else {
this.openAlertModal('ไม่สามารถลบข้อมูลได้')
}
}, error => {
this.openAlertModal(error.message)
})
}, reject => { })
}
ngOnInit() { ngOnInit() {
this.getListCourse(); this.getListCourse();
} }
......
...@@ -18,11 +18,12 @@ ...@@ -18,11 +18,12 @@
<th scope="col" class="text-center">ไฟล์ (ไทย)</th> <th scope="col" class="text-center">ไฟล์ (ไทย)</th>
<th scope="col" class="text-center">ไฟล์ (อังกฤษ)</th> <th scope="col" class="text-center">ไฟล์ (อังกฤษ)</th>
<th scope="col" class="text-center">จำนวนดาวน์โหลด</th> <th scope="col" class="text-center">จำนวนดาวน์โหลด</th>
<th scope="col" *ngIf="checkType == '1'"></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr *ngIf="listDoc.length == 0"> <tr *ngIf="listDoc.length == 0">
<td colspan="7" class="text-center">ไม่พบข้อมูล</td> <td colspan="{{checkType == '1' ? '9' : '10'}}" class="text-center">ไม่พบข้อมูล</td>
</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>
...@@ -34,6 +35,9 @@ ...@@ -34,6 +35,9 @@
<td class="text-center"> <i class="fas fa-download pointer" (click)="downloadFile(data.docId,'tha')"></i></td> <td class="text-center"> <i class="fas fa-download pointer" (click)="downloadFile(data.docId,'tha')"></i></td>
<td class="text-center"> <i class="fas fa-download pointer" (click)="downloadFile(data.docId,'eng')"></i></td> <td class="text-center"> <i class="fas fa-download pointer" (click)="downloadFile(data.docId,'eng')"></i></td>
<td class="text-center">{{data.dwTime}} ครั้ง</td> <td class="text-center">{{data.dwTime}} ครั้ง</td>
<td *ngIf="checkType == '1'">
<button type="button" 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>
</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
......
...@@ -3,6 +3,8 @@ import { AlertModalComponent } from '../alert-modal/alert-modal.component'; ...@@ -3,6 +3,8 @@ import { AlertModalComponent } from '../alert-modal/alert-modal.component';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { DocumentService } from 'src/app/service/document.service'; import { DocumentService } from 'src/app/service/document.service';
import { DocumentContentModel } from 'src/app/model/document-content.model'; import { DocumentContentModel } from 'src/app/model/document-content.model';
import { ActivatedRoute } from '@angular/router';
import { ConfirmModalComponent } from '../confirm-modal/confirm-modal.component';
declare var require: any declare var require: any
const FileSaver = require('file-saver'); const FileSaver = require('file-saver');
@Component({ @Component({
...@@ -15,8 +17,33 @@ export class ViewListDocComponent implements OnInit { ...@@ -15,8 +17,33 @@ export class ViewListDocComponent implements OnInit {
pageSize = 10; pageSize = 10;
listDoc:DocumentContentModel[]=[] listDoc:DocumentContentModel[]=[]
search:string = '' search:string = ''
constructor(private modalService: NgbModal,private documentService:DocumentService) { checkType:string = '0'
constructor(private modalService: NgbModal,private documentService:DocumentService,private activatedRoute: ActivatedRoute) {
this.activatedRoute.paramMap.subscribe(result => {
this.checkType = result.get("type")!;
});
} }
deleteFile(item:DocumentContentModel){
const modalRef = this.modalService.open(ConfirmModalComponent, {
centered: true,
backdrop: 'static',
})
modalRef.componentInstance.message = 'คุณต้องการลบข้อมูลหรือไม่'
modalRef.result.then(result => {
this.documentService.deleteExcelContent(item).subscribe(result => {
if (result) {
this.openAlertModal('ลบข้อมูลสำเร็จ')
this.getListDoc();
} else {
this.openAlertModal('ไม่สามารถลบข้อมูลได้')
}
}, error => {
this.openAlertModal(error.message)
})
}, reject => { })
}
async downloadFile(logId:string,lang:string){ async downloadFile(logId:string,lang:string){
try { try {
const data = await this.documentService.downloadFileContent(logId,lang).toPromise(); const data = await this.documentService.downloadFileContent(logId,lang).toPromise();
......
...@@ -17,11 +17,12 @@ ...@@ -17,11 +17,12 @@
<th scope="col" class="text-center">ลิงค์</th> <th scope="col" class="text-center">ลิงค์</th>
<th scope="col" class="text-center">ไฟล์</th> <th scope="col" class="text-center">ไฟล์</th>
<th scope="col" class="text-center">จำนวนดาวน์โหลด</th> <th scope="col" class="text-center">จำนวนดาวน์โหลด</th>
<th scope="col" *ngIf="checkType == '1'"></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr *ngIf="listExcel.length == 0"> <tr *ngIf="listExcel.length == 0">
<td colspan="7" class="text-center">ไม่พบข้อมูล</td> <td colspan="{{checkType == '1' ? '8' : '7'}}" class="text-center">ไม่พบข้อมูล</td>
</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>
...@@ -32,6 +33,9 @@ ...@@ -32,6 +33,9 @@
<td class="text-center"><i class="fas fa-link pointer" (click)="openLink(data.link1)"></i></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"> <i class="fas fa-download pointer" (click)="downloadFile(data.excelId)"></i></td>
<td class="text-center">{{data.dwTime}} ครั้ง</td> <td class="text-center">{{data.dwTime}} ครั้ง</td>
<td *ngIf="checkType == '1'">
<button type="button" 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>
</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
......
...@@ -4,6 +4,7 @@ import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; ...@@ -4,6 +4,7 @@ import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
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 { ExcelContentModel } from 'src/app/model/excel-content.model'; import { ExcelContentModel } from 'src/app/model/excel-content.model';
import { ActivatedRoute } from '@angular/router';
declare var require: any declare var require: any
const FileSaver = require('file-saver'); const FileSaver = require('file-saver');
@Component({ @Component({
...@@ -16,7 +17,30 @@ export class ViewListExcelComponent implements OnInit { ...@@ -16,7 +17,30 @@ export class ViewListExcelComponent implements OnInit {
pageSize = 10; pageSize = 10;
listExcel:ExcelContentModel[]=[] listExcel:ExcelContentModel[]=[]
search:string = '' search:string = ''
constructor(private modalService: NgbModal,private excelService:ExcelService) { checkType:string = '0'
constructor(private modalService: NgbModal,private excelService:ExcelService, private activatedRoute: ActivatedRoute,) {
this.activatedRoute.paramMap.subscribe(result => {
this.checkType = result.get("type")!;
});
}
deleteFile(item:ExcelContentModel){
const modalRef = this.modalService.open(ConfirmModalComponent, {
centered: true,
backdrop: 'static',
})
modalRef.componentInstance.message = 'คุณต้องการลบข้อมูลหรือไม่'
modalRef.result.then(result => {
this.excelService.deleteExcelContent(item).subscribe(result => {
if (result) {
this.openAlertModal('ลบข้อมูลสำเร็จ')
this.getListExcel();
} else {
this.openAlertModal('ไม่สามารถลบข้อมูลได้')
}
}, error => {
this.openAlertModal(error.message)
})
}, reject => { })
} }
async downloadFile(logId:string){ async downloadFile(logId:string){
try { try {
......
import { environment } from "src/environments/environment" import { environment } from "src/environments/environment"
export interface ExcelContentModel { excelId: string export interface ExcelContentModel {
excelId: string
thName: string thName: string
engName: string engName: string
thDesc: string thDesc: string
......
...@@ -57,6 +57,18 @@ export class CourseService { ...@@ -57,6 +57,18 @@ export class CourseService {
} }
return this.http.delete<any>(this.url + 'course-center/upload', option) return this.http.delete<any>(this.url + 'course-center/upload', option)
} }
deleteCourseContent(model: CourseContentModel): Observable<any> {
let body = {
courseId: model.courseId
}
let option = {
headers: new HttpHeaders({
"Content-Type": "application/json",
}),
body: body
}
return this.http.delete<any>(this.url + 'course-center/content', option)
}
approve(model: CourseModel): Observable<any> { approve(model: CourseModel): Observable<any> {
let body = { let body = {
logId: model.logId, logId: model.logId,
......
...@@ -57,6 +57,18 @@ export class DocumentService { ...@@ -57,6 +57,18 @@ export class DocumentService {
} }
return this.http.delete<any>(this.url + 'document-center/upload', option) return this.http.delete<any>(this.url + 'document-center/upload', option)
} }
deleteExcelContent(model: DocumentContentModel): Observable<any> {
let body = {
docId: model.docId
}
let option = {
headers: new HttpHeaders({
"Content-Type": "application/json",
}),
body: body
}
return this.http.delete<any>(this.url + 'document-center/content', option)
}
approve(model: DocumentModel): Observable<any> { approve(model: DocumentModel): Observable<any> {
let body = { let body = {
logId: model.logId, logId: model.logId,
......
...@@ -58,6 +58,18 @@ export class ExcelService { ...@@ -58,6 +58,18 @@ export class ExcelService {
} }
return this.http.delete<any>(this.url + 'excel-center/upload', option) return this.http.delete<any>(this.url + 'excel-center/upload', option)
} }
deleteExcelContent(model: ExcelContentModel): Observable<any> {
let body = {
excelId: model.excelId
}
let option = {
headers: new HttpHeaders({
"Content-Type": "application/json",
}),
body: body
}
return this.http.delete<any>(this.url + 'excel-center/content', option)
}
approve(model: ExcelModel): Observable<any> { approve(model: ExcelModel): Observable<any> {
let body = { let body = {
logId: model.logId, logId: model.logId,
......
...@@ -53,7 +53,17 @@ export const ROUTES: RouteInfo[] = [ ...@@ -53,7 +53,17 @@ export const ROUTES: RouteInfo[] = [
submenu: [ submenu: [
{ {
path: '/apps/portal-category-list-approve', path: '/apps/portal-category-list-approve',
title: 'รายการอนุมัติ', title: 'รายการรอการอนุมัติ',
icon: '',
class: '',
label: "",
labelClass: "",
extralink: false,
submenu: []
},
{
path: '/apps/approved-list',
title: 'รายการผ่านการอนุมัติ',
icon: '', icon: '',
class: '', class: '',
label: "", label: "",
......
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