Commit 956b2d7e by Natthaphat

swal alert เพิ่ม

parent 7830ab69
...@@ -140,7 +140,7 @@ ...@@ -140,7 +140,7 @@
<td class="!text-center">{{data.downloadDate}} {{data.downloadTime}}</td> <td class="!text-center">{{data.downloadDate}} {{data.downloadTime}}</td>
<td class="!text-center">{{data.dwTime}} ครั้ง</td> <td class="!text-center">{{data.dwTime}} ครั้ง</td>
<td *ngIf="checkType == '1'"> <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> <button type="button" class="bg-danger hover:bg-danger text-white text-sm ml-5 w-10 h-10 flex items-center justify-center rounded-full" (click)="deleteFile(data)" placement="top" ngbTooltip="ลบ"><i class="fas fa-trash-alt"></i></button>
</td> </td>
</tr> </tr>
<tr *ngIf="filterListCourse().length === 0"> <tr *ngIf="filterListCourse().length === 0">
......
...@@ -16,6 +16,7 @@ import { CourseContentModel } from '../../../../../models/course-content.model'; ...@@ -16,6 +16,7 @@ import { CourseContentModel } from '../../../../../models/course-content.model';
import { CourseService } from '../../../../../services/course.service'; import { CourseService } from '../../../../../services/course.service';
declare var require: any declare var require: any
import FileSaver from 'file-saver'; import FileSaver from 'file-saver';
import swal from 'sweetalert';
@Component({ @Component({
selector: 'app-view-list-course', selector: 'app-view-list-course',
templateUrl: './view-list-course.component.html', templateUrl: './view-list-course.component.html',
...@@ -103,23 +104,26 @@ export class ViewListCourseComponent implements OnInit { ...@@ -103,23 +104,26 @@ export class ViewListCourseComponent implements OnInit {
} }
} }
deleteFile(item: CourseContentModel) { deleteFile(item: CourseContentModel) {
const modalRef = this.modalService.open(ConfirmModalComponent, { swal({
centered: true, title: "คุณแน่ใจหรือไม่?",
backdrop: 'static', text: "คุณต้องการลบข้อมูลนี้หรือไม่",
icon: "warning",
dangerMode: true,
buttons: ["ยกเลิก", "ยืนยัน"],
}).then((willDelete: boolean) => {
if (willDelete) {
this.courseService.deleteCourseContent(item).subscribe(result => {
if (result) {
this.openAlertModal('ลบข้อมูลสำเร็จ', 'success')
this.getListCourse();
} else {
this.openAlertModal('ไม่สามารถลบข้อมูลได้', 'error')
}
}, error => {
this.openAlertModal(error.message, 'error')
})
}
}) })
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();
...@@ -127,17 +131,8 @@ export class ViewListCourseComponent implements OnInit { ...@@ -127,17 +131,8 @@ export class ViewListCourseComponent implements OnInit {
openLink(url: string) { openLink(url: string) {
window.open(url, "_blank"); window.open(url, "_blank");
} }
openAlertModal(message?: string) { openAlertModal(text: string, type: 'success' | 'error') {
const modalRef = this.modalService.open(AlertModalComponent, { swal("แจ้งเตือน", text, type);
centered: true,
backdrop: 'static'
})
modalRef.componentInstance.message = message ? message : ""
modalRef.result.then(result => {
this.modalService.dismissAll()
}, reason => {
this.modalService.dismissAll()
})
} }
coverDate(date: string) { coverDate(date: string) {
......
...@@ -16,6 +16,7 @@ import { DocumentContentModel } from '../../../../../models/document-content.mod ...@@ -16,6 +16,7 @@ import { DocumentContentModel } from '../../../../../models/document-content.mod
import { DocumentService } from '../../../../../services/document.service'; import { DocumentService } from '../../../../../services/document.service';
declare var require: any declare var require: any
import FileSaver from 'file-saver'; import FileSaver from 'file-saver';
import swal from 'sweetalert';
@Component({ @Component({
selector: 'app-view-list-doc', selector: 'app-view-list-doc',
templateUrl: './view-list-doc.component.html', templateUrl: './view-list-doc.component.html',
...@@ -81,23 +82,26 @@ export class ViewListDocComponent implements OnInit { ...@@ -81,23 +82,26 @@ export class ViewListDocComponent implements OnInit {
}) })
} }
deleteFile(item: DocumentContentModel) { deleteFile(item: DocumentContentModel) {
const modalRef = this.modalService.open(ConfirmModalComponent, { swal({
centered: true, title: "คุณแน่ใจหรือไม่?",
backdrop: 'static', text: "คุณต้องการลบข้อมูลนี้หรือไม่",
icon: "warning",
dangerMode: true,
buttons: ["ยกเลิก", "ยืนยัน"],
}).then((willDelete: boolean) => {
if (willDelete) {
this.documentService.deleteExcelContent(item).subscribe(result => {
if (result) {
this.openAlertModal('ลบข้อมูลสำเร็จ','success')
this.getListDoc();
} else {
this.openAlertModal('ไม่สามารถลบข้อมูลได้','error')
}
}, error => {
this.openAlertModal(error.message,'error')
})
}
}) })
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) {
...@@ -125,17 +129,8 @@ export class ViewListDocComponent implements OnInit { ...@@ -125,17 +129,8 @@ export class ViewListDocComponent implements OnInit {
this.getListDoc(); this.getListDoc();
} }
openAlertModal(message?: string) { openAlertModal(text: string, type: 'success' | 'error') {
const modalRef = this.modalService.open(AlertModalComponent, { swal("แจ้งเตือน", text, type);
centered: true,
backdrop: 'static'
})
modalRef.componentInstance.message = message ? message : ""
modalRef.result.then(result => {
this.modalService.dismissAll()
}, reason => {
this.modalService.dismissAll()
})
} }
openLink(url: string) { openLink(url: string) {
window.open(url, "_blank"); window.open(url, "_blank");
......
...@@ -16,6 +16,7 @@ import { MatDialogModule } from '@angular/material/dialog'; ...@@ -16,6 +16,7 @@ import { MatDialogModule } from '@angular/material/dialog';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
declare var require: any declare var require: any
import FileSaver from 'file-saver'; import FileSaver from 'file-saver';
import swal from 'sweetalert';
@Component({ @Component({
selector: 'app-view-list-excel', selector: 'app-view-list-excel',
templateUrl: './view-list-excel.component.html', templateUrl: './view-list-excel.component.html',
...@@ -81,23 +82,26 @@ export class ViewListExcelComponent implements OnInit { ...@@ -81,23 +82,26 @@ export class ViewListExcelComponent implements OnInit {
}) })
} }
deleteFile(item: ExcelContentModel) { deleteFile(item: ExcelContentModel) {
const modalRef = this.modalService.open(ConfirmModalComponent, { swal({
centered: true, title: "คุณแน่ใจหรือไม่?",
backdrop: 'static', text: "คุณต้องการลบข้อมูลนี้หรือไม่",
icon: "warning",
dangerMode: true,
buttons: ["ยกเลิก", "ยืนยัน"],
}).then((willDelete: boolean) => {
if (willDelete) {
this.excelService.deleteExcelContent(item).subscribe(result => {
if (result) {
this.openAlertModal('ลบข้อมูลสำเร็จ', 'success')
this.getListExcel();
} else {
this.openAlertModal('ไม่สามารถลบข้อมูลได้', 'error')
}
}, error => {
this.openAlertModal(error.message, 'error')
})
}
}) })
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 {
...@@ -140,17 +144,8 @@ export class ViewListExcelComponent implements OnInit { ...@@ -140,17 +144,8 @@ export class ViewListExcelComponent implements OnInit {
} }
openAlertModal(message?: string) { openAlertModal(text: string, type: 'success' | 'error') {
const modalRef = this.modalService.open(AlertModalComponent, { swal("แจ้งเตือน", text, type);
centered: true,
backdrop: 'static'
})
modalRef.componentInstance.message = message ? message : ""
modalRef.result.then(result => {
this.modalService.dismissAll()
}, reason => {
this.modalService.dismissAll()
})
} }
coverDate(date: string) { coverDate(date: string) {
return date.split('-').reverse().join('/') return date.split('-').reverse().join('/')
......
...@@ -15,6 +15,7 @@ import { TranslateModule } from '@ngx-translate/core'; ...@@ -15,6 +15,7 @@ import { TranslateModule } from '@ngx-translate/core';
import { firstValueFrom } from 'rxjs'; import { firstValueFrom } from 'rxjs';
declare var require: any declare var require: any
import FileSaver from 'file-saver'; import FileSaver from 'file-saver';
import swal from 'sweetalert';
@Component({ @Component({
selector: 'app-approve-course', selector: 'app-approve-course',
templateUrl: './approve-course.component.html', templateUrl: './approve-course.component.html',
...@@ -97,82 +98,82 @@ export class ApproveCourseComponent implements OnInit { ...@@ -97,82 +98,82 @@ export class ApproveCourseComponent implements OnInit {
} }
} }
onApprove(item: CourseModel) { onApprove(item: CourseModel) {
const modalRef = this.modalService.open(ConfirmModalComponent, { swal({
centered: true, title: "คุณแน่ใจหรือไม่?",
backdrop: 'static', text: "คุณต้องการอนุมัติข้อมูลหรือไม่",
icon: "warning",
dangerMode: false,
buttons: ["ยกเลิก", "ยืนยัน"],
}).then((willSave: boolean) => {
if (willSave) {
item.status = 1
this.courseService.approve(item).subscribe(result => {
if (result) {
this.modalService.dismissAll()
this.openAlertModal('บันทึกข้อมูลสำเร็จ','error')
this.getListCourse();
} else {
this.openAlertModal('ไม่สามารถบันทึกข้อมูลได้','success')
}
}, error => {
this.openAlertModal(error.message,'error')
})
}
}) })
modalRef.componentInstance.message = 'คุณต้องการอนุมัติข้อมูลหรือไม่'
modalRef.result.then(result => {
item.status = 1
this.courseService.approve(item).subscribe(result => {
if (result) {
this.modalService.dismissAll()
this.openAlertModal('บันทึกข้อมูลสำเร็จ')
this.getListCourse();
} else {
this.openAlertModal('ไม่สามารถบันทึกข้อมูลได้')
}
}, error => {
this.openAlertModal(error.message)
})
}, reject => { })
} }
onCancelApprove(item: CourseModel) { onCancelApprove(item: CourseModel) {
const modalRef = this.modalService.open(ConfirmModalComponent, { swal({
centered: true, title: "คุณแน่ใจหรือไม่?",
backdrop: 'static', text: "คุณต้องการไม่อนุมัติข้อมูลหรือไม่",
icon: "warning",
dangerMode: false,
buttons: ["ยกเลิก", "ยืนยัน"],
}).then((willSave: boolean) => {
if (willSave) {
item.status = 2
this.courseService.approve(item).subscribe(result => {
if (result) {
this.openAlertModal('บันทึกข้อมูลสำเร็จ','success')
this.getListCourse();
} else {
this.openAlertModal('ไม่สามารถบันทึกข้อมูลได้','error')
}
}, error => {
this.openAlertModal(error.message,'error')
})
}
}) })
modalRef.componentInstance.message = 'คุณต้องการไม่อนุมัติข้อมูลหรือไม่'
modalRef.result.then(result => {
item.status = 2
this.courseService.approve(item).subscribe(result => {
if (result) {
this.openAlertModal('บันทึกข้อมูลสำเร็จ')
this.getListCourse();
} else {
this.openAlertModal('ไม่สามารถบันทึกข้อมูลได้')
}
}, error => {
this.openAlertModal(error.message)
})
}, reject => { })
} }
ngOnInit() { ngOnInit() {
this.getListCourse(); this.getListCourse();
} }
deleteFile(item: CourseModel) { deleteFile(item: CourseModel) {
const modalRef = this.modalService.open(ConfirmModalComponent, { swal({
centered: true, title: "คุณแน่ใจหรือไม่?",
backdrop: 'static', text: "คุณต้องการลบข้อมูลนี้หรือไม่",
icon: "warning",
dangerMode: true,
buttons: ["ยกเลิก", "ยืนยัน"],
}).then((willDelete: boolean) => {
if (willDelete) {
this.courseService.deleteCourse(item).subscribe(result => {
if (result) {
this.openAlertModal('ลบข้อมูลสำเร็จ','success')
this.getListCourse();
} else {
this.openAlertModal('ไม่สามารถลบข้อมูลได้','error')
}
}, error => {
this.openAlertModal(error.message,'error')
})
}
}) })
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(text: string, type: 'success' | 'error') {
const modalRef = this.modalService.open(AlertModalComponent, { swal("แจ้งเตือน", text, type);
centered: true,
backdrop: 'static'
})
modalRef.componentInstance.message = message ? message : ""
modalRef.result.then(result => {
// this.modalService.dismissAll()
}, reason => {
// this.modalService.dismissAll()
})
} }
openLink(url: string) { openLink(url: string) {
window.open(url, "_blank"); window.open(url, "_blank");
......
...@@ -15,6 +15,7 @@ import { DocumentService } from '../../../../../services/document.service'; ...@@ -15,6 +15,7 @@ import { DocumentService } from '../../../../../services/document.service';
import { firstValueFrom } from 'rxjs'; import { firstValueFrom } from 'rxjs';
declare var require: any declare var require: any
import FileSaver from 'file-saver'; import FileSaver from 'file-saver';
import swal from 'sweetalert';
@Component({ @Component({
selector: 'app-approve-doc', selector: 'app-approve-doc',
templateUrl: './approve-doc.component.html', templateUrl: './approve-doc.component.html',
...@@ -100,80 +101,80 @@ export class ApproveDocComponent implements OnInit { ...@@ -100,80 +101,80 @@ export class ApproveDocComponent implements OnInit {
} }
} }
onApprove(item: DocumentModel) { onApprove(item: DocumentModel) {
const modalRef = this.modalService.open(ConfirmModalComponent, { swal({
centered: true, title: "คุณแน่ใจหรือไม่?",
backdrop: 'static', text: "คุณต้องการอนุมัติข้อมูลหรือไม่",
icon: "warning",
dangerMode: false,
buttons: ["ยกเลิก", "ยืนยัน"],
}).then((willSave: boolean) => {
if (willSave) {
item.status = 1
this.documentService.approve(item).subscribe(result => {
if (result) {
this.modalService.dismissAll()
this.openAlertModal('บันทึกข้อมูลสำเร็จ','success')
this.getListDoc();
} else {
this.openAlertModal('ไม่สามารถบันทึกข้อมูลได้','error')
}
}, error => {
this.openAlertModal(error.message,'error')
})
}
}) })
modalRef.componentInstance.message = 'คุณต้องการอนุมัติข้อมูลหรือไม่'
modalRef.result.then(result => {
item.status = 1
this.documentService.approve(item).subscribe(result => {
if (result) {
this.modalService.dismissAll()
this.openAlertModal('บันทึกข้อมูลสำเร็จ')
this.getListDoc();
} else {
this.openAlertModal('ไม่สามารถบันทึกข้อมูลได้')
}
}, error => {
this.openAlertModal(error.message)
})
}, reject => { })
} }
onCancelApprove(item: DocumentModel) { onCancelApprove(item: DocumentModel) {
const modalRef = this.modalService.open(ConfirmModalComponent, { swal({
centered: true, title: "คุณแน่ใจหรือไม่?",
backdrop: 'static', text: "คุณต้องการไม่อนุมัติข้อมูลหรือไม่",
icon: "warning",
dangerMode: false,
buttons: ["ยกเลิก", "ยืนยัน"],
}).then((willSave: boolean) => {
if (willSave) {
item.status = 2
this.documentService.approve(item).subscribe(result => {
if (result) {
this.openAlertModal('บันทึกข้อมูลสำเร็จ','success')
this.getListDoc();
} else {
this.openAlertModal('ไม่สามารถบันทึกข้อมูลได้','error')
}
}, error => {
this.openAlertModal(error.message,'error')
})
}
}) })
modalRef.componentInstance.message = 'คุณต้องการไม่อนุมัติข้อมูลหรือไม่'
modalRef.result.then(result => {
item.status = 2
this.documentService.approve(item).subscribe(result => {
if (result) {
this.openAlertModal('บันทึกข้อมูลสำเร็จ')
this.getListDoc();
} else {
this.openAlertModal('ไม่สามารถบันทึกข้อมูลได้')
}
}, error => {
this.openAlertModal(error.message)
})
}, reject => { })
} }
ngOnInit() { ngOnInit() {
this.getListDoc(); this.getListDoc();
} }
deleteFile(item: DocumentModel) { deleteFile(item: DocumentModel) {
const modalRef = this.modalService.open(ConfirmModalComponent, { swal({
centered: true, title: "คุณแน่ใจหรือไม่?",
backdrop: 'static', text: "คุณต้องการลบข้อมูลนี้หรือไม่",
icon: "warning",
dangerMode: true,
buttons: ["ยกเลิก", "ยืนยัน"],
}).then((willDelete: boolean) => {
if (willDelete) {
this.documentService.deleteExcel(item).subscribe(result => {
if (result) {
this.openAlertModal('ลบข้อมูลสำเร็จ','success')
this.getListDoc();
} else {
this.openAlertModal('ไม่สามารถลบข้อมูลได้','error')
}
}, error => {
this.openAlertModal(error.message,'error')
})
}
}) })
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(text: string, type: 'success' | 'error') {
const modalRef = this.modalService.open(AlertModalComponent, { swal("แจ้งเตือน", text, type);
centered: true,
backdrop: 'static'
})
modalRef.componentInstance.message = message ? message : ""
modalRef.result.then(result => {
// this.modalService.dismissAll()
}, reason => {
// this.modalService.dismissAll()
})
} }
} }
...@@ -15,6 +15,7 @@ import { ExcelService } from '../../../../../services/excel.service'; ...@@ -15,6 +15,7 @@ import { ExcelService } from '../../../../../services/excel.service';
import { firstValueFrom } from 'rxjs'; import { firstValueFrom } from 'rxjs';
declare var require: any declare var require: any
import FileSaver from 'file-saver'; import FileSaver from 'file-saver';
import swal from 'sweetalert';
import { TemplateModel } from '../../../../../models/template.model'; import { TemplateModel } from '../../../../../models/template.model';
@Component({ @Component({
selector: 'app-approve-excel', selector: 'app-approve-excel',
...@@ -99,45 +100,51 @@ export class ApproveExcelComponent implements OnInit { ...@@ -99,45 +100,51 @@ export class ApproveExcelComponent implements OnInit {
} }
} }
onApprove(item: ExcelModel) { onApprove(item: ExcelModel) {
const modalRef = this.modalService.open(ConfirmModalComponent, { swal({
centered: true, title: "คุณแน่ใจหรือไม่?",
backdrop: 'static', text: "คุณต้องการอนุมัติข้อมูลหรือไม่",
icon: "warning",
dangerMode: false,
buttons: ["ยกเลิก", "ยืนยัน"],
}).then((willSave: boolean) => {
if (willSave) {
item.status = 1
this.excelService.approve(item).subscribe(result => {
if (result) {
this.openAlertModal('บันทึกข้อมูลสำเร็จ', 'success')
this.getListExcel();
} else {
this.openAlertModal('ไม่สามารถบันทึกข้อมูลได้', 'error')
}
}, error => {
this.openAlertModal(error.message, 'error')
})
}
}) })
modalRef.componentInstance.message = 'คุณต้องการอนุมัติข้อมูลหรือไม่'
modalRef.result.then(result => {
item.status = 1
this.excelService.approve(item).subscribe(result => {
if (result) {
this.openAlertModal('บันทึกข้อมูลสำเร็จ')
this.getListExcel();
} else {
this.openAlertModal('ไม่สามารถบันทึกข้อมูลได้')
}
}, error => {
this.openAlertModal(error.message)
})
}, reject => { })
} }
onCancelApprove(item: ExcelModel) { onCancelApprove(item: ExcelModel) {
const modalRef = this.modalService.open(ConfirmModalComponent, { swal({
centered: true, title: "คุณแน่ใจหรือไม่?",
backdrop: 'static', text: "คุณต้องการไม่อนุมัติข้อมูลหรือไม่",
icon: "warning",
dangerMode: false,
buttons: ["ยกเลิก", "ยืนยัน"],
}).then((willSave: boolean) => {
if (willSave) {
item.status = 2
this.excelService.approve(item).subscribe(result => {
if (result) {
this.modalService.dismissAll()
this.openAlertModal('บันทึกข้อมูลสำเร็จ', 'success')
this.getListExcel();
} else {
this.openAlertModal('ไม่สามารถบันทึกข้อมูลได้', 'error')
}
}, error => {
this.openAlertModal(error.message, 'error')
})
}
}) })
modalRef.componentInstance.message = 'คุณต้องการไม่อนุมัติข้อมูลหรือไม่'
modalRef.result.then(result => {
item.status = 2
this.excelService.approve(item).subscribe(result => {
if (result) {
this.modalService.dismissAll()
this.openAlertModal('บันทึกข้อมูลสำเร็จ')
this.getListExcel();
} else {
this.openAlertModal('ไม่สามารถบันทึกข้อมูลได้')
}
}, error => {
this.openAlertModal(error.message)
})
}, reject => { })
} }
ngOnInit() { ngOnInit() {
this.getListExcel(); this.getListExcel();
...@@ -145,36 +152,30 @@ export class ApproveExcelComponent implements OnInit { ...@@ -145,36 +152,30 @@ export class ApproveExcelComponent implements OnInit {
} }
deleteFile(item: ExcelModel) { deleteFile(item: ExcelModel) {
const modalRef = this.modalService.open(ConfirmModalComponent, { swal({
centered: true, title: "คุณแน่ใจหรือไม่?",
backdrop: 'static', text: "คุณต้องการลบข้อมูลนี้หรือไม่",
icon: "warning",
dangerMode: true,
buttons: ["ยกเลิก", "ยืนยัน"],
}).then((willDelete: boolean) => {
if (willDelete) {
this.excelService.deleteExcel(item).subscribe(result => {
if (result) {
this.openAlertModal('ลบข้อมูลสำเร็จ', 'success')
this.getListExcel();
} else {
this.openAlertModal('ไม่สามารถลบข้อมูลได้', 'error')
}
}, error => {
this.openAlertModal(error.message, 'error')
})
}
}) })
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(text: string, type: 'success' | 'error') {
const modalRef = this.modalService.open(AlertModalComponent, { swal("แจ้งเตือน", text, type);
centered: true,
backdrop: 'static'
})
modalRef.componentInstance.message = message ? message : ""
modalRef.result.then(result => {
// this.modalService.dismissAll()
}, reason => {
// this.modalService.dismissAll()
})
} }
openLink(url: string) { openLink(url: string) {
window.open(url, "_blank"); window.open(url, "_blank");
......
...@@ -13,6 +13,7 @@ import { NgSelectModule } from '@ng-select/ng-select'; ...@@ -13,6 +13,7 @@ import { NgSelectModule } from '@ng-select/ng-select';
import { SharedModule } from '../../../../shared/shared.module'; import { SharedModule } from '../../../../shared/shared.module';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import saveAs from 'file-saver'; import saveAs from 'file-saver';
import swal from 'sweetalert';
@Component({ @Component({
selector: 'app-view-list-course', selector: 'app-view-list-course',
...@@ -101,23 +102,26 @@ export class ViewListCourseComponent implements OnInit { ...@@ -101,23 +102,26 @@ export class ViewListCourseComponent implements OnInit {
} }
} }
deleteFile(item: CourseContentModel) { deleteFile(item: CourseContentModel) {
const modalRef = this.modalService.open(ConfirmModalComponent, { swal({
centered: true, title: "คุณแน่ใจหรือไม่?",
backdrop: 'static', text: "คุณต้องการลบข้อมูลนี้หรือไม่",
icon: "warning",
dangerMode: true,
buttons: ["ยกเลิก", "ยืนยัน"],
}).then((willDelete: boolean) => {
if (willDelete) {
this.courseService.deleteCourseContent(item).subscribe(result => {
if (result) {
this.openAlertModal('ลบข้อมูลสำเร็จ', 'success')
this.getListCourse();
} else {
this.openAlertModal('ไม่สามารถลบข้อมูลได้', 'error')
}
}, error => {
this.openAlertModal(error.message, 'error')
})
}
}) })
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();
...@@ -125,17 +129,8 @@ export class ViewListCourseComponent implements OnInit { ...@@ -125,17 +129,8 @@ export class ViewListCourseComponent implements OnInit {
openLink(url: string) { openLink(url: string) {
window.open(url, "_blank"); window.open(url, "_blank");
} }
openAlertModal(message?: string) { openAlertModal(text: string, type: 'success' | 'error') {
const modalRef = this.modalService.open(AlertModalComponent, { swal("แจ้งเตือน", text, type);
centered: true,
backdrop: 'static'
})
modalRef.componentInstance.message = message ? message : ""
modalRef.result.then(result => {
this.modalService.dismissAll()
}, reason => {
this.modalService.dismissAll()
})
} }
coverDate(date: string) { coverDate(date: string) {
......
...@@ -11,7 +11,7 @@ import { CommonModule } from '@angular/common'; ...@@ -11,7 +11,7 @@ import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms'; import { FormsModule } from '@angular/forms';
import { NgSelectModule } from '@ng-select/ng-select'; import { NgSelectModule } from '@ng-select/ng-select';
import { SharedModule } from '../../../../shared/shared.module'; import { SharedModule } from '../../../../shared/shared.module';
import swal from 'sweetalert';
import { saveAs } from 'file-saver'; import { saveAs } from 'file-saver';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
...@@ -60,23 +60,26 @@ export class ViewListDocComponent implements OnInit { ...@@ -60,23 +60,26 @@ export class ViewListDocComponent implements OnInit {
} }
deleteFile(item: DocumentContentModel) { deleteFile(item: DocumentContentModel) {
const modalRef = this.modalService.open(ConfirmModalComponent, { swal({
centered: true, title: "คุณแน่ใจหรือไม่?",
backdrop: 'static', text: "คุณต้องการลบข้อมูลนี้หรือไม่",
icon: "warning",
dangerMode: true,
buttons: ["ยกเลิก", "ยืนยัน"],
}).then((willDelete: boolean) => {
if (willDelete) {
this.documentService.deleteExcelContent(item).subscribe(result => {
if (result) {
this.openAlertModal('ลบข้อมูลสำเร็จ','success')
this.getListDoc();
} else {
this.openAlertModal('ไม่สามารถลบข้อมูลได้','error')
}
}, error => {
this.openAlertModal(error.message,'error')
})
}
}) })
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 => { })
} }
...@@ -105,17 +108,8 @@ export class ViewListDocComponent implements OnInit { ...@@ -105,17 +108,8 @@ export class ViewListDocComponent implements OnInit {
this.getListDoc(); this.getListDoc();
} }
openAlertModal(message?: string) { openAlertModal(text: string, type: 'success' | 'error') {
const modalRef = this.modalService.open(AlertModalComponent, { swal("แจ้งเตือน", text, type);
centered: true,
backdrop: 'static'
})
modalRef.componentInstance.message = message ? message : ""
modalRef.result.then(result => {
this.modalService.dismissAll()
}, reason => {
this.modalService.dismissAll()
})
} }
openLink(url: string) { openLink(url: string) {
window.open(url, "_blank"); window.open(url, "_blank");
......
...@@ -12,7 +12,7 @@ import { NgSelectModule } from '@ng-select/ng-select'; ...@@ -12,7 +12,7 @@ import { NgSelectModule } from '@ng-select/ng-select';
import { SharedModule } from '../../../../shared/shared.module'; import { SharedModule } from '../../../../shared/shared.module';
import { MatDialog, MatDialogModule } from '@angular/material/dialog'; import { MatDialog, MatDialogModule } from '@angular/material/dialog';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import swal from 'sweetalert';
import { saveAs } from 'file-saver'; import { saveAs } from 'file-saver';
@Component({ @Component({
...@@ -59,7 +59,7 @@ export class ViewListExcelComponent implements OnInit { ...@@ -59,7 +59,7 @@ export class ViewListExcelComponent implements OnInit {
panelClass: 'my-dialog-img-preview', panelClass: 'my-dialog-img-preview',
}; };
this.dialogRef = this.dialog.open(OpenImageComponent, dialogConfig); this.dialogRef = this.dialog.open(OpenImageComponent, dialogConfig);
this.dialogRef.afterClosed().subscribe((result: any) => { this.dialogRef.afterClosed().subscribe((result: any) => {
console.log('The dialog was closed', result); console.log('The dialog was closed', result);
}, (reason: any) => { }, (reason: any) => {
}); });
...@@ -78,23 +78,26 @@ export class ViewListExcelComponent implements OnInit { ...@@ -78,23 +78,26 @@ export class ViewListExcelComponent implements OnInit {
// } // }
deleteFile(item: ExcelContentModel) { deleteFile(item: ExcelContentModel) {
const modalRef = this.modalService.open(ConfirmModalComponent, { swal({
centered: true, title: "คุณแน่ใจหรือไม่?",
backdrop: 'static', text: "คุณต้องการลบข้อมูลนี้หรือไม่",
icon: "warning",
dangerMode: true,
buttons: ["ยกเลิก", "ยืนยัน"],
}).then((willDelete: boolean) => {
if (willDelete) {
this.excelService.deleteExcelContent(item).subscribe(result => {
if (result) {
this.openAlertModal('ลบข้อมูลสำเร็จ','success');
this.getListExcel();
} else {
this.openAlertModal('ไม่สามารถลบข้อมูลได้','error');
}
}, error => {
this.openAlertModal(error.message,'error');
});
}
}); });
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) {
...@@ -140,17 +143,8 @@ export class ViewListExcelComponent implements OnInit { ...@@ -140,17 +143,8 @@ export class ViewListExcelComponent implements OnInit {
window.open(url, "_blank"); window.open(url, "_blank");
} }
openAlertModal(message?: string) { openAlertModal(text: string, type: 'success' | 'error') {
const modalRef = this.modalService.open(AlertModalComponent, { swal("แจ้งเตือน", text, type);
centered: true,
backdrop: 'static'
});
modalRef.componentInstance.message = message ? message : "";
modalRef.result.then(result => {
this.modalService.dismissAll();
}, reason => {
this.modalService.dismissAll();
});
} }
coverDate(date: string) { coverDate(date: string) {
......
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