Commit 8750d346 by Nakarin Luankla

UPDATE แก้เมนูใหม่ เพ่ิมapi tag Count แก้หน้าเพิ่มข้อมูลใหม่

parent 2a1273b8
...@@ -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 --host 192.168.68.85", "start": "ng serve",
"build": "ng build", "build": "ng build",
"test": "ng test", "test": "ng test",
"lint": "ng lint", "lint": "ng lint",
...@@ -61,6 +61,7 @@ ...@@ -61,6 +61,7 @@
"ng2-archwizard": "^2.1.0", "ng2-archwizard": "^2.1.0",
"ng2-charts": "^2.3.2", "ng2-charts": "^2.3.2",
"ng2-search-filter": "^0.5.1", "ng2-search-filter": "^0.5.1",
"ngx-chips": "^2.2.2",
"ngx-custom-validators": "8.0.0", "ngx-custom-validators": "8.0.0",
"ngx-perfect-scrollbar": "^9.0.0", "ngx-perfect-scrollbar": "^9.0.0",
"ngx-quill": "^12.0.1", "ngx-quill": "^12.0.1",
......
...@@ -38,7 +38,6 @@ import { TranslateHttpLoader } from '@ngx-translate/http-loader'; ...@@ -38,7 +38,6 @@ import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { HttpRequestInterceptor } from './service/http-request.interceptor'; import { HttpRequestInterceptor } from './service/http-request.interceptor';
export function HttpLoaderFactory(http: HttpClient) { export function HttpLoaderFactory(http: HttpClient) {
return new TranslateHttpLoader(http, './assets/i18n/', '.json'); return new TranslateHttpLoader(http, './assets/i18n/', '.json');
} }
......
...@@ -14,8 +14,9 @@ ...@@ -14,8 +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" class="text-center">สถานะ</th>
<th scope="col"></th> <th scope="col"></th>
</tr> </tr>
</thead> </thead>
...@@ -28,9 +29,26 @@ ...@@ -28,9 +29,26 @@
<td><img width="100" class="border p-1" src="{{data.getImage()}}"></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.courseType}}</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 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>
......
...@@ -4,7 +4,8 @@ import { CourseModel } from 'src/app/model/course.model'; ...@@ -4,7 +4,8 @@ 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 { 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';
declare var require: any
const FileSaver = require('file-saver');
@Component({ @Component({
selector: 'app-approve-course', selector: 'app-approve-course',
templateUrl: './approve-course.component.html', templateUrl: './approve-course.component.html',
...@@ -17,15 +18,16 @@ export class ApproveCourseComponent implements OnInit { ...@@ -17,15 +18,16 @@ export class ApproveCourseComponent implements OnInit {
search:string = '' search:string = ''
constructor(private modalService: NgbModal,private courseService:CourseService) { constructor(private modalService: NgbModal,private courseService:CourseService) {
} }
getStatus(status:string){ async downloadFile(logId:string){
if(status == '0'){ try {
return 'รออนุมัติ' const data = await this.courseService.downloadFile(logId).toPromise();
} else if(status == '1'){ if(data){
return 'เปิดใช้งาน' FileSaver.saveAs(new Blob([data]), "file_download.json");
} else if(status == '2'){ }
return 'ไม่อนุมัติ' } catch (error) {
console.error('Error loading data:', error);
}
} }
}
filterListCourse(){ filterListCourse(){
return this.listCourse.filter(x => x.thName.toLowerCase().includes(this.search.toLowerCase())||x.engName.toLowerCase().includes(this.search.toLowerCase())) return this.listCourse.filter(x => x.thName.toLowerCase().includes(this.search.toLowerCase())||x.engName.toLowerCase().includes(this.search.toLowerCase()))
} }
...@@ -47,6 +49,7 @@ export class ApproveCourseComponent implements OnInit { ...@@ -47,6 +49,7 @@ export class ApproveCourseComponent implements OnInit {
item.status = 1 item.status = 1
this.courseService.approve(item).subscribe(result => { this.courseService.approve(item).subscribe(result => {
if (result) { if (result) {
this.modalService.dismissAll()
this.openAlertModal('บันทึกข้อมูลสำเร็จ') this.openAlertModal('บันทึกข้อมูลสำเร็จ')
this.getListCourse(); this.getListCourse();
} else { } else {
...@@ -88,10 +91,12 @@ export class ApproveCourseComponent implements OnInit { ...@@ -88,10 +91,12 @@ export class ApproveCourseComponent 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()
}) })
} }
openLink(url:string){
window.open(url, "_blank");
}
} }
...@@ -14,15 +14,16 @@ ...@@ -14,15 +14,16 @@
<!-- <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 *ngIf="listDoc.length == 0"> <tr *ngIf="listDoc.length == 0">
<td colspan="7" class="text-center">ไม่พบข้อมูล</td> <td colspan="8" 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>
...@@ -30,9 +31,26 @@ ...@@ -30,9 +31,26 @@
<!-- <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" 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>
......
...@@ -4,7 +4,8 @@ import { DocumentModel } from 'src/app/model/document.model'; ...@@ -4,7 +4,8 @@ import { DocumentModel } from 'src/app/model/document.model';
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 { NgbModal } from '@ng-bootstrap/ng-bootstrap'; import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
declare var require: any
const FileSaver = require('file-saver');
@Component({ @Component({
selector: 'app-approve-doc', selector: 'app-approve-doc',
templateUrl: './approve-doc.component.html', templateUrl: './approve-doc.component.html',
...@@ -17,15 +18,19 @@ export class ApproveDocComponent implements OnInit { ...@@ -17,15 +18,19 @@ export class ApproveDocComponent implements OnInit {
search:string = '' search:string = ''
constructor(private modalService: NgbModal,private documentService:DocumentService) { constructor(private modalService: NgbModal,private documentService:DocumentService) {
} }
getStatus(status:string){ async downloadFile(logId:string,lang:string){
if(status == '0'){ try {
return 'รออนุมัติ' const data = await this.documentService.downloadFile(logId,lang).toPromise();
} else if(status == '1'){ if(data){
return 'เปิดใช้งาน' FileSaver.saveAs(new Blob([data]), "file_download.doc");
} else if(status == '2'){ }
return 'ไม่อนุมัติ' } catch (error) {
console.error('Error loading data:', error);
} }
} }
openLink(url:string){
window.open(url, "_blank");
}
filterListDoc(){ filterListDoc(){
return this.listDoc.filter(x => x.thName.toLowerCase().includes(this.search.toLowerCase())||x.engName.toLowerCase().includes(this.search.toLowerCase())) return this.listDoc.filter(x => x.thName.toLowerCase().includes(this.search.toLowerCase())||x.engName.toLowerCase().includes(this.search.toLowerCase()))
} }
...@@ -47,6 +52,7 @@ export class ApproveDocComponent implements OnInit { ...@@ -47,6 +52,7 @@ export class ApproveDocComponent implements OnInit {
item.status = 1 item.status = 1
this.documentService.approve(item).subscribe(result => { this.documentService.approve(item).subscribe(result => {
if (result) { if (result) {
this.modalService.dismissAll()
this.openAlertModal('บันทึกข้อมูลสำเร็จ') this.openAlertModal('บันทึกข้อมูลสำเร็จ')
this.getListDoc(); this.getListDoc();
} else { } else {
...@@ -88,9 +94,9 @@ export class ApproveDocComponent implements OnInit { ...@@ -88,9 +94,9 @@ export class ApproveDocComponent 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()
}) })
} }
......
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
<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>
<th scope="col" class="text-center">ไฟล์</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>
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
<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.logId)"></i></td> <td class="text-center"> <i class="fas fa-download pointer" (click)="downloadFile(data.logId)"></i></td>
<td class="text-center"> <td class="text-center">
<span class="fa-stack rt_anim" *ngIf="data.status == '0'" ngbTooltip="รออนุมัติ" container="body" tooltipClass="myhrcolor-1"> <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="fa fa-circle fa-stack-2x text-info"></i>
<i class=" fas fa-hourglass-half fa-stack-1x fa-inverse"></i> <i class=" fas fa-hourglass-half fa-stack-1x fa-inverse"></i>
......
...@@ -69,6 +69,7 @@ export class ApproveExcelComponent implements OnInit { ...@@ -69,6 +69,7 @@ export class ApproveExcelComponent implements OnInit {
item.status = 2 item.status = 2
this.excelService.approve(item).subscribe(result => { this.excelService.approve(item).subscribe(result => {
if (result) { if (result) {
this.modalService.dismissAll()
this.openAlertModal('บันทึกข้อมูลสำเร็จ') this.openAlertModal('บันทึกข้อมูลสำเร็จ')
this.getListExcel(); this.getListExcel();
} else { } else {
...@@ -90,9 +91,9 @@ export class ApproveExcelComponent implements OnInit { ...@@ -90,9 +91,9 @@ export class ApproveExcelComponent 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()
}) })
} }
openLink(url:string){ openLink(url:string){
......
...@@ -93,10 +93,12 @@ import { ApproveCourseComponent } from './approve-course/approve-course.componen ...@@ -93,10 +93,12 @@ import { ApproveCourseComponent } from './approve-course/approve-course.componen
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 { ViewListCourseComponent } from './view-list-course/view-list-course.component'; import { ViewListCourseComponent } from './view-list-course/view-list-course.component';
import { TagInputModule } from 'ngx-chips';
@NgModule({ @NgModule({
imports: [ imports: [
TagInputModule,
CommonModule, CommonModule,
FormsModule, FormsModule,
ReactiveFormsModule, ReactiveFormsModule,
......
...@@ -15,8 +15,9 @@ ...@@ -15,8 +15,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" class="text-center">สถานะ</th>
<th scope="col"></th> <th scope="col"></th>
</tr> </tr>
</thead> </thead>
...@@ -28,9 +29,26 @@ ...@@ -28,9 +29,26 @@
<td>{{ data.thName }}</td> <td>{{ data.thName }}</td>
<td class="text-wrap">{{ data.thDesc }}</td> <td class="text-wrap">{{ data.thDesc }}</td>
<td>{{data.courseType}}</td> <td>{{data.courseType}}</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>
...@@ -159,12 +177,14 @@ ...@@ -159,12 +177,14 @@
<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">ไฟล์ที่อนุญาต:*.json</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">รูปภาพตัวอย่าง</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)="onUploadImage($event)"> <input type="file" class="form-control" (change)="onUploadImage($event)">
<div class="msg-detail">ไฟล์ที่อนุญาต:*.jpeg, *.jpg, *.png</div>
</div> </div>
</div> </div>
...@@ -174,7 +194,16 @@ ...@@ -174,7 +194,16 @@
<input type="text" class="form-control" id="nameeng" [(ngModel)]="modelCourse.link1"> <input type="text" class="form-control" id="nameeng" [(ngModel)]="modelCourse.link1">
</div> </div>
</div> </div>
<div class="form-group row">
<label for="name" class="col-sm-4 col-form-label">แท็ก</label>
<div class="col-sm-8">
<tag-input [theme]="'bootstrap'" [(ngModel)]='modelCourse.tags' placeholder="+แท็ก" [onlyFromAutocomplete]="true"
secondaryPlaceholder="กดปุ่ม Enter เพื่อเพิ่มแท็กใหม่" [addOnBlur]="true" [clearOnBlur]="true">
<tag-input-dropdown [autocompleteItems]="listTag" [showDropdownIfEmpty]="true">
</tag-input-dropdown>
</tag-input>
</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">
......
::ng-deep ng2-dropdown-menu {
z-index: 9999 !important;
.ng2-dropdown-menu {
z-index: 9999 !important;
ng2-menu-item {
z-index: 9999 !important;
}
}
}
\ No newline at end of file
...@@ -6,7 +6,10 @@ import { AlertModalComponent } from '../alert-modal/alert-modal.component'; ...@@ -6,7 +6,10 @@ 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'; import { UploadService } from 'src/app/service/upload.service';
import { TagService } from 'src/app/service/tag.service';
import { TagModel } from 'src/app/model/tag.mmodel';
declare var require: any
const FileSaver = require('file-saver');
@Component({ @Component({
selector: 'app-list-course', selector: 'app-list-course',
templateUrl: './list-course.component.html', templateUrl: './list-course.component.html',
...@@ -19,7 +22,8 @@ export class ListCourseComponent implements OnInit { ...@@ -19,7 +22,8 @@ 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,private uploadService:UploadService) { listTag:TagModel[]=[]
constructor(private modalService: NgbModal,private courseService:CourseService,private uploadService:UploadService,private tagService:TagService) {
} }
async onUploadImage(event:any){ async onUploadImage(event:any){
try{ try{
...@@ -27,10 +31,15 @@ export class ListCourseComponent implements OnInit { ...@@ -27,10 +31,15 @@ export class ListCourseComponent implements OnInit {
let fileData = event.target.files[0]; let fileData = event.target.files[0];
const formData = new FormData(); const formData = new FormData();
formData.append('file', fileData); formData.append('file', fileData);
const data = await this.uploadService.uploadImage(formData).toPromise(); const allowedTypes = ['image/png', 'image/jpeg', 'image/jpg'];
if(data){ if (!allowedTypes.includes(fileData.type)) {
this.modelCourse.thumbnail = data.body.fileId this.openAlertModal('อัพโหลดได้เฉพาะไฟล์ *.jpeg, *.jpg, *.png เท่านั้น')
} } else {
const data = await this.uploadService.uploadImage(formData).toPromise();
if(data){
this.modelCourse.thumbnail = data.body.fileId
}
}
} }
} catch (error) { } catch (error) {
console.error('Error loading data:', error); console.error('Error loading data:', error);
...@@ -38,22 +47,32 @@ export class ListCourseComponent implements OnInit { ...@@ -38,22 +47,32 @@ export class ListCourseComponent implements OnInit {
} }
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/json'];
this.modelCourse.courseObj = base64.split(',')[1]; if (!allowedTypes.includes(file.type)) {
this.openAlertModal('อัพโหลดได้เฉพาะไฟล์ *.xlsx เท่านั้น')
} else {
let base64 = event.target!.result as string
this.modelCourse.courseObj = base64.split(',')[1];
}
} }
} }
} }
} }
async downloadFile(logId:string){ async downloadFile(logId:string){
try { try {
const data = await this.courseService.downloadFile(logId).toPromise(); const data = await this.courseService.downloadFile(logId).toPromise();
} catch (error) { if(data){
console.error('Error loading data:', error); FileSaver.saveAs(new Blob([data]), "file_download.json");
} }
} catch (error) {
console.error('Error loading data:', error);
}
} }
deleteFile(item:CourseModel){ deleteFile(item:CourseModel){
const modalRef = this.modalService.open(ConfirmModalComponent, { const modalRef = this.modalService.open(ConfirmModalComponent, {
...@@ -82,9 +101,9 @@ export class ListCourseComponent implements OnInit { ...@@ -82,9 +101,9 @@ export class ListCourseComponent 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()
}) })
} }
...@@ -98,6 +117,7 @@ export class ListCourseComponent implements OnInit { ...@@ -98,6 +117,7 @@ export class ListCourseComponent implements OnInit {
console.log(this.modelCourse); console.log(this.modelCourse);
this.courseService.createCourse(this.modelCourse).subscribe(result => { this.courseService.createCourse(this.modelCourse).subscribe(result => {
if (result) { if (result) {
this.modalService.dismissAll()
this.openAlertModal('อัพเดทข้อมูลสำเร็จ') this.openAlertModal('อัพเดทข้อมูลสำเร็จ')
this.getListCourse(); this.getListCourse();
} else { } else {
...@@ -117,6 +137,7 @@ export class ListCourseComponent implements OnInit { ...@@ -117,6 +137,7 @@ export class ListCourseComponent implements OnInit {
modalRef.result.then(result => { modalRef.result.then(result => {
this.courseService.createCourse(this.modelCourse).subscribe(result => { this.courseService.createCourse(this.modelCourse).subscribe(result => {
if (result) { if (result) {
this.modalService.dismissAll()
this.openAlertModal('บันทึกข้อมูลสำเร็จ') this.openAlertModal('บันทึกข้อมูลสำเร็จ')
this.getListCourse(); this.getListCourse();
} else { } else {
...@@ -162,16 +183,6 @@ export class ListCourseComponent implements OnInit { ...@@ -162,16 +183,6 @@ export class ListCourseComponent implements OnInit {
size: 'lg' size: 'lg'
}); });
} }
}
getStatus(status:string){
if(status == '0'){
return 'รออนุมัติ'
} else if(status == '1'){
return 'เปิดใช้งาน'
} else if(status == '2'){
return 'ไม่อนุมัติ'
}
} }
async getListCourse(){ async getListCourse(){
try { try {
...@@ -187,11 +198,22 @@ export class ListCourseComponent implements OnInit { ...@@ -187,11 +198,22 @@ export class ListCourseComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.getListCourse(); this.getListCourse();
this.getListTag();
} }
closeBtnClick() { closeBtnClick() {
this.modalService.dismissAll(); this.modalService.dismissAll();
} }
async getListTag(){
try{
const data = await this.tagService.getList().toPromise();
this.listTag = data.map(x => new TagModel(x))
}catch(error){
console.error('Error loading data:', error);
}
}
openLink(url:string){
window.open(url, "_blank");
}
} }
...@@ -153,7 +153,16 @@ ...@@ -153,7 +153,16 @@
<input type="text" class="form-control" id="nameeng" [(ngModel)]="modelDoc.link1"> <input type="text" class="form-control" id="nameeng" [(ngModel)]="modelDoc.link1">
</div> </div>
</div> </div>
<div class="form-group row">
<label for="name" class="col-sm-4 col-form-label">แท็ก</label>
<div class="col-sm-8">
<tag-input [theme]="'bootstrap'" [(ngModel)]='modelDoc.tags' placeholder="+แท็ก" [onlyFromAutocomplete]="true"
secondaryPlaceholder="กดปุ่ม Enter เพื่อเพิ่มแท็กใหม่" [addOnBlur]="true" [clearOnBlur]="true">
<tag-input-dropdown [autocompleteItems]="listTag" [showDropdownIfEmpty]="true">
</tag-input-dropdown>
</tag-input>
</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">
......
::ng-deep ng2-dropdown-menu {
z-index: 9999 !important;
.ng2-dropdown-menu {
z-index: 9999 !important;
ng2-menu-item {
z-index: 9999 !important;
}
}
}
\ No newline at end of file
...@@ -5,6 +5,8 @@ import { AlertModalComponent } from '../alert-modal/alert-modal.component'; ...@@ -5,6 +5,8 @@ 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'; import { UploadService } from 'src/app/service/upload.service';
import { TagService } from 'src/app/service/tag.service';
import { TagModel } from 'src/app/model/tag.mmodel';
declare var require: any declare var require: any
const FileSaver = require('file-saver'); const FileSaver = require('file-saver');
@Component({ @Component({
...@@ -19,7 +21,8 @@ export class ListDocComponent implements OnInit { ...@@ -19,7 +21,8 @@ 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, private uploadService:UploadService) { listTag:TagModel[]=[]
constructor(private modalService: NgbModal,private documentService:DocumentService, private uploadService:UploadService,private tagService:TagService) {
} }
async onUploadImage(event:any){ async onUploadImage(event:any){
try{ try{
...@@ -48,7 +51,7 @@ export class ListDocComponent implements OnInit { ...@@ -48,7 +51,7 @@ export class ListDocComponent implements OnInit {
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){
const allowedTypes = ['application/vnd.openxmlformats-officedocument.wordprocessingml.document']; const allowedTypes = ['application/vnd.openxmlformats-officedocument.wordprocessingml.document','application/msword'];
if (!allowedTypes.includes(file.type)) { if (!allowedTypes.includes(file.type)) {
this.openAlertModal('อัพโหลดได้เฉพาะไฟล์ *.doc เท่านั้น') this.openAlertModal('อัพโหลดได้เฉพาะไฟล์ *.doc เท่านั้น')
} else { } else {
...@@ -113,7 +116,6 @@ export class ListDocComponent implements OnInit { ...@@ -113,7 +116,6 @@ export class ListDocComponent implements OnInit {
}) })
modalRef.componentInstance.message = 'คุณต้องการอัพเดทข้อมูลหรือไม่' modalRef.componentInstance.message = 'คุณต้องการอัพเดทข้อมูลหรือไม่'
modalRef.result.then(result => { modalRef.result.then(result => {
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.modalService.dismissAll()
...@@ -207,9 +209,17 @@ export class ListDocComponent implements OnInit { ...@@ -207,9 +209,17 @@ export class ListDocComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.getListDoc(); this.getListDoc();
this.getListTag();
} }
async getListTag(){
try{
const data = await this.tagService.getList().toPromise();
this.listTag = data.map(x => new TagModel(x))
}catch(error){
console.error('Error loading data:', error);
}
}
closeBtnClick() { closeBtnClick() {
this.modalService.dismissAll(); this.modalService.dismissAll();
} }
......
...@@ -146,6 +146,16 @@ ...@@ -146,6 +146,16 @@
<input type="text" class="form-control" id="nameeng" [(ngModel)]="modelExcel.link1"> <input type="text" class="form-control" id="nameeng" [(ngModel)]="modelExcel.link1">
</div> </div>
</div> </div>
<div class="form-group row">
<label for="name" class="col-sm-4 col-form-label">แท็ก</label>
<div class="col-sm-8">
<tag-input [theme]="'bootstrap'" [(ngModel)]='modelExcel.tags' placeholder="+แท็ก" [onlyFromAutocomplete]="true"
secondaryPlaceholder="กดปุ่ม Enter เพื่อเพิ่มแท็กใหม่" [addOnBlur]="true" [clearOnBlur]="true">
<tag-input-dropdown [autocompleteItems]="listTag" [showDropdownIfEmpty]="true">
</tag-input-dropdown>
</tag-input>
</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>
......
::ng-deep ng2-dropdown-menu {
z-index: 9999 !important;
.ng2-dropdown-menu {
z-index: 9999 !important;
ng2-menu-item {
z-index: 9999 !important;
}
}
}
\ No newline at end of file
...@@ -5,8 +5,11 @@ import { ExcelService } from 'src/app/service/excel.service'; ...@@ -5,8 +5,11 @@ 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'; import { UploadService } from 'src/app/service/upload.service';
import { TagService } from 'src/app/service/tag.service';
import { TagModel } from 'src/app/model/tag.mmodel';
declare var require: any declare var require: any
const FileSaver = require('file-saver'); 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',
...@@ -19,11 +22,12 @@ export class ListExcelComponent implements OnInit { ...@@ -19,11 +22,12 @@ 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,private uploadService:UploadService) {
listTag:TagModel[]=[]
constructor(private modalService: NgbModal,private excelService:ExcelService,private uploadService:UploadService ,private tagService:TagService) {
} }
async onUploadImage(event:any){ async onUploadImage(event:any){
try{ try{
if (event.target.files.length > 0) { if (event.target.files.length > 0) {
let fileData = event.target.files[0]; let fileData = event.target.files[0];
const formData = new FormData(); const formData = new FormData();
...@@ -42,7 +46,14 @@ export class ListExcelComponent implements OnInit { ...@@ -42,7 +46,14 @@ export class ListExcelComponent implements OnInit {
console.error('Error loading data:', error); console.error('Error loading data:', error);
} }
} }
async getListTag(){
try{
const data = await this.tagService.getList().toPromise();
this.listTag = data.map(x => new TagModel(x))
}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]) {
const reader = new FileReader(); const reader = new FileReader();
...@@ -210,6 +221,7 @@ export class ListExcelComponent implements OnInit { ...@@ -210,6 +221,7 @@ export class ListExcelComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.getListExcel(); this.getListExcel();
this.getListTag();
} }
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
</div> </div>
<div class="d-flex justify-content-between bg-light border-top p-3"> <div class="d-flex justify-content-between bg-light border-top p-3">
<div> <div>
<span class="align-middle">{{ c.document }}</span> <span class="align-middle">จำนวนเอกสาร {{ c.document }} ฉบับ</span>
</div> </div>
<div > <div >
<button class="btn btn-info btn-sm text-nowrap" (click)="openView(c.id)">รายละเอียด</button> <button class="btn btn-info btn-sm text-nowrap" (click)="openView(c.id)">รายละเอียด</button>
......
/* tslint:disable:no-unused-variable */
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { DebugElement } from '@angular/core';
import { PortalCategoryListApproveComponent } from './portal-category-list-approve.component';
describe('PortalCategoryListApproveComponent', () => {
let component: PortalCategoryListApproveComponent;
let fixture: ComponentFixture<PortalCategoryListApproveComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ PortalCategoryListApproveComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(PortalCategoryListApproveComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
...@@ -3,6 +3,9 @@ import { NgbModal } from "@ng-bootstrap/ng-bootstrap"; ...@@ -3,6 +3,9 @@ import { NgbModal } from "@ng-bootstrap/ng-bootstrap";
import { FormBuilder, FormGroup, Validators } from "@angular/forms"; import { FormBuilder, FormGroup, Validators } from "@angular/forms";
import { User } from "../users/user"; import { User } from "../users/user";
import { Router } from "@angular/router"; 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({ @Component({
selector: "app-portal-category-list-approve", selector: "app-portal-category-list-approve",
...@@ -11,18 +14,10 @@ import { Router } from "@angular/router"; ...@@ -11,18 +14,10 @@ import { Router } from "@angular/router";
}) })
export class PortalCategoryListApproveComponent implements OnInit { export class PortalCategoryListApproveComponent implements OnInit {
constructor( constructor(
private fb: FormBuilder,
private modalService: NgbModal, private modalService: NgbModal,
private router:Router, private router:Router,
private excelService:ExcelService,private documentService:DocumentService,private courseService:CourseService
) {} ) {}
get searchTerm(): string {
return this._searchTerm;
}
set searchTerm(val: string) {
this._searchTerm = val;
}
_searchTerm = "";
page = 1; page = 1;
pageSize = 7; pageSize = 7;
...@@ -43,21 +38,21 @@ export class PortalCategoryListApproveComponent implements OnInit { ...@@ -43,21 +38,21 @@ export class PortalCategoryListApproveComponent implements OnInit {
img: "assets/images/icon/excel.png", img: "assets/images/icon/excel.png",
name: "Excel", name: "Excel",
details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx", details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
document: "จำนวนเอกสาร 8 ฉบับ" document: "0"
}, },
{ {
id:'2', id:'2',
img: "assets/images/icon/document.png", img: "assets/images/icon/document.png",
name: "Document", name: "Document",
details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx", details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
document: "จำนวนเอกสาร 3 ฉบับ" document: "0"
}, },
{ {
id:'3', id:'3',
img: "assets/images/icon/course.png", img: "assets/images/icon/course.png",
name: "Course", name: "Course",
details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx", details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
document: "จำนวนเอกสาร 5 ฉบับ" document: "0"
}, },
]; ];
} }
...@@ -69,6 +64,25 @@ export class PortalCategoryListApproveComponent implements OnInit { ...@@ -69,6 +64,25 @@ 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(){
try {
const countExcel = await this.excelService.getCount().toPromise();
const countDoc = await this.documentService.getCount().toPromise();
const countCourse = await this.courseService.getCount().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);
}
} }
openModal(targetModal: NgbModal) { openModal(targetModal: NgbModal) {
this.modalService.open(targetModal, { this.modalService.open(targetModal, {
...@@ -79,7 +93,6 @@ export class PortalCategoryListApproveComponent implements OnInit { ...@@ -79,7 +93,6 @@ export class PortalCategoryListApproveComponent implements OnInit {
closeBtnClick() { closeBtnClick() {
this.modalService.dismissAll(); this.modalService.dismissAll();
this.ngOnInit();
} }
routerLink(path: String, type: String){ routerLink(path: String, type: String){
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
</div> </div>
<div class="d-flex justify-content-between bg-light border-top p-3"> <div class="d-flex justify-content-between bg-light border-top p-3">
<div> <div>
<span class="align-middle">{{ c.document }}</span> <span class="align-middle">จำนวนเอกสาร {{ c.document }} ฉบับ</span>
</div> </div>
<div > <div >
<button class="btn btn-info btn-sm text-nowrap" (click)="openView(c.id)">รายละเอียด</button> <button class="btn btn-info btn-sm text-nowrap" (click)="openView(c.id)">รายละเอียด</button>
......
/* tslint:disable:no-unused-variable */
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { DebugElement } from '@angular/core';
import { PortalCategoryListComponent } from './portal-category-list.component';
describe('PortalCategoryListComponent', () => {
let component: PortalCategoryListComponent;
let fixture: ComponentFixture<PortalCategoryListComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ PortalCategoryListComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(PortalCategoryListComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router'; 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({ @Component({
selector: 'app-portal-category-list', selector: 'app-portal-category-list',
...@@ -9,12 +12,11 @@ import { Router } from '@angular/router'; ...@@ -9,12 +12,11 @@ import { Router } from '@angular/router';
export class PortalCategoryListComponent implements OnInit { export class PortalCategoryListComponent implements OnInit {
constructor( constructor(
private routes: Router private routes: Router,
private excelService:ExcelService,private documentService:DocumentService,private courseService:CourseService
) {} ) {}
page = 1; page = 1;
pageSize = 7; pageSize = 10;
testdata: { testdata: {
id:string; id:string;
img: String; img: String;
...@@ -31,25 +33,43 @@ export class PortalCategoryListComponent implements OnInit { ...@@ -31,25 +33,43 @@ export class PortalCategoryListComponent implements OnInit {
img: "assets/images/icon/excel.png", img: "assets/images/icon/excel.png",
name: "Excel", name: "Excel",
details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx", details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
document: "จำนวนเอกสาร 8 ฉบับ" document: "0"
}, },
{ {
id:'2', id:'2',
img: "assets/images/icon/document.png", img: "assets/images/icon/document.png",
name: "Document", name: "Document",
details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx", details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
document: "จำนวนเอกสาร 3 ฉบับ" document: "0"
}, },
{ {
id:'3', id:'3',
img: "assets/images/icon/course.png", img: "assets/images/icon/course.png",
name: "Course", name: "Course",
details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx", details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
document: "จำนวนเอกสาร 5 ฉบับ" document: "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){ openView(id:string){
if(id =='1'){ if(id =='1'){
this.routes.navigate(['apps/view-list-excel']); this.routes.navigate(['apps/view-list-excel']);
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
</div> </div>
<div class="d-flex justify-content-between bg-light border-top p-3"> <div class="d-flex justify-content-between bg-light border-top p-3">
<div> <div>
<span class="align-middle">{{ c.document }}</span> <span class="align-middle">จำนวนเอกสาร {{ c.document }} ฉบับ</span>
</div> </div>
<div > <div >
<button class="btn btn-info btn-sm text-nowrap" (click)="openView(c.id)">รายละเอียด</button> <button class="btn btn-info btn-sm text-nowrap" (click)="openView(c.id)">รายละเอียด</button>
......
...@@ -3,6 +3,9 @@ import { NgbModal } from "@ng-bootstrap/ng-bootstrap"; ...@@ -3,6 +3,9 @@ import { NgbModal } from "@ng-bootstrap/ng-bootstrap";
import { FormBuilder, FormGroup, Validators } from "@angular/forms"; import { FormBuilder, FormGroup, Validators } from "@angular/forms";
import { DatePipe } from "@angular/common"; import { DatePipe } from "@angular/common";
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { ExcelService } from 'src/app/service/excel.service';
import { DocumentService } from 'src/app/service/document.service';
import { CourseService } from 'src/app/service/course.service';
@Component({ @Component({
selector: 'app-portal-create-category', selector: 'app-portal-create-category',
...@@ -11,7 +14,7 @@ import { Router } from '@angular/router'; ...@@ -11,7 +14,7 @@ import { Router } from '@angular/router';
}) })
export class PortalCreateCategoryComponent implements OnInit { export class PortalCreateCategoryComponent implements OnInit {
constructor(private fb: FormBuilder, private modalService: NgbModal, private datePipe: DatePipe,private routes: Router,) {} constructor(private modalService: NgbModal,private routes: Router,private excelService:ExcelService,private documentService:DocumentService,private courseService:CourseService) {}
page = 1; page = 1;
pageSize = 10; pageSize = 10;
...@@ -30,25 +33,43 @@ export class PortalCreateCategoryComponent implements OnInit { ...@@ -30,25 +33,43 @@ export class PortalCreateCategoryComponent implements OnInit {
img: "assets/images/icon/excel.png", img: "assets/images/icon/excel.png",
name: "Excel", name: "Excel",
details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx", details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
document: "จำนวนเอกสาร 8 ฉบับ" document: "0"
}, },
{ {
id:'2', id:'2',
img: "assets/images/icon/document.png", img: "assets/images/icon/document.png",
name: "Document", name: "Document",
details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx", details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
document: "จำนวนเอกสาร 3 ฉบับ" document: "0"
}, },
{ {
id:'3', id:'3',
img: "assets/images/icon/course.png", img: "assets/images/icon/course.png",
name: "Course", name: "Course",
details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx", details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
document: "จำนวนเอกสาร 5 ฉบับ" document: "0"
}, },
]; ];
this.getListCount();
}
async getListCount(){
try {
const countExcel = await this.excelService.getCount().toPromise();
const countDoc = await this.documentService.getCount().toPromise();
const countCourse = await this.courseService.getCount().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){ openView(id:string){
if(id =='1'){ if(id =='1'){
this.routes.navigate(['apps/list-excel']); this.routes.navigate(['apps/list-excel']);
...@@ -67,7 +88,6 @@ export class PortalCreateCategoryComponent implements OnInit { ...@@ -67,7 +88,6 @@ export class PortalCreateCategoryComponent implements OnInit {
closeBtnClick() { closeBtnClick() {
this.modalService.dismissAll(); this.modalService.dismissAll();
this.ngOnInit();
} }
} }
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
<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>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
...@@ -24,12 +25,13 @@ ...@@ -24,12 +25,13 @@
</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.courseType}}</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.courseId)"></i></td>
<td class="text-center">{{data.dwTime}} ครั้ง</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
......
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ViewListCourseComponent } from './view-list-course.component';
describe('ViewListCourseComponent', () => {
let component: ViewListCourseComponent;
let fixture: ComponentFixture<ViewListCourseComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ViewListCourseComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(ViewListCourseComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
...@@ -3,7 +3,9 @@ import { AlertModalComponent } from '../alert-modal/alert-modal.component'; ...@@ -3,7 +3,9 @@ import { AlertModalComponent } from '../alert-modal/alert-modal.component';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; 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';
declare var require: any
const FileSaver = require('file-saver');
@Component({ @Component({
selector: 'app-view-list-course', selector: 'app-view-list-course',
templateUrl: './view-list-course.component.html', templateUrl: './view-list-course.component.html',
...@@ -12,17 +14,18 @@ import { CourseModel } from 'src/app/model/course.model'; ...@@ -12,17 +14,18 @@ import { CourseModel } from 'src/app/model/course.model';
export class ViewListCourseComponent implements OnInit { export class ViewListCourseComponent implements OnInit {
page = 1; page = 1;
pageSize = 10; pageSize = 10;
listCourse:CourseModel[]=[] listCourse:CourseContentModel[]=[]
search:string = '' search:string = ''
constructor(private modalService: NgbModal,private courseService:CourseService) { constructor(private modalService: NgbModal,private courseService:CourseService) {
} }
getStatus(status:string){ async downloadFile(logId:string){
if(status == '0'){ try {
return 'รออนุมัติ' const data = await this.courseService.downloadFileContent(logId).toPromise();
} else if(status == '1'){ if(data){
return 'เปิดใช้งาน' FileSaver.saveAs(new Blob([data]), "file_download.json");
} else if(status == '2'){ }
return 'ไม่อนุมัติ' } catch (error) {
console.error('Error loading data:', error);
} }
} }
filterListCourse(){ filterListCourse(){
...@@ -30,8 +33,9 @@ export class ViewListCourseComponent implements OnInit { ...@@ -30,8 +33,9 @@ export class ViewListCourseComponent implements OnInit {
} }
async getListCourse(){ async getListCourse(){
try { try {
const data = await this.courseService.getListCourse('0').toPromise(); const data = await this.courseService.getListCourseContent().toPromise();
this.listCourse = data this.listCourse = data.map(x => new CourseContentModel(x))
console.log("🚀 ~ ViewListCourseComponent ~ getListCourse ~ this.listCourse :", this.listCourse )
} catch (error) { } catch (error) {
console.error('Error loading data:', error); console.error('Error loading data:', error);
} }
...@@ -40,7 +44,9 @@ export class ViewListCourseComponent implements OnInit { ...@@ -40,7 +44,9 @@ export class ViewListCourseComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.getListCourse(); this.getListCourse();
} }
openLink(url:string){
window.open(url, "_blank");
}
openAlertModal(message?: string) { openAlertModal(message?: string) {
const modalRef = this.modalService.open(AlertModalComponent, { const modalRef = this.modalService.open(AlertModalComponent, {
centered: true, centered: true,
......
...@@ -14,9 +14,10 @@ ...@@ -14,9 +14,10 @@
<!-- <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>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
...@@ -25,13 +26,14 @@ ...@@ -25,13 +26,14 @@
</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>
<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.docId,'tha')"></i></td>
<!-- <td><a (click)="downloadFile(data.logId)">ดาวน์โหลด</a></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>
</tr> </tr>
</tbody> </tbody>
</table> </table>
......
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ViewListDocComponent } from './view-list-doc.component';
describe('ViewListDocComponent', () => {
let component: ViewListDocComponent;
let fixture: ComponentFixture<ViewListDocComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ViewListDocComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(ViewListDocComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
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 { DocumentModel } from 'src/app/model/document.model';
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';
declare var require: any
const FileSaver = require('file-saver');
@Component({ @Component({
selector: 'app-view-list-doc', selector: 'app-view-list-doc',
templateUrl: './view-list-doc.component.html', templateUrl: './view-list-doc.component.html',
...@@ -13,17 +13,18 @@ import { DocumentService } from 'src/app/service/document.service'; ...@@ -13,17 +13,18 @@ import { DocumentService } from 'src/app/service/document.service';
export class ViewListDocComponent implements OnInit { export class ViewListDocComponent implements OnInit {
page = 1; page = 1;
pageSize = 10; pageSize = 10;
listDoc:DocumentModel[]=[] listDoc:DocumentContentModel[]=[]
search:string = '' search:string = ''
constructor(private modalService: NgbModal,private documentService:DocumentService) { constructor(private modalService: NgbModal,private documentService:DocumentService) {
} }
getStatus(status:string){ async downloadFile(logId:string,lang:string){
if(status == '0'){ try {
return 'รออนุมัติ' const data = await this.documentService.downloadFileContent(logId,lang).toPromise();
} else if(status == '1'){ if(data){
return 'เปิดใช้งาน' FileSaver.saveAs(new Blob([data]), "file_download.doc");
} else if(status == '2'){ }
return 'ไม่อนุมัติ' } catch (error) {
console.error('Error loading data:', error);
} }
} }
filterListDoc(){ filterListDoc(){
...@@ -31,8 +32,8 @@ export class ViewListDocComponent implements OnInit { ...@@ -31,8 +32,8 @@ export class ViewListDocComponent implements OnInit {
} }
async getListDoc(){ async getListDoc(){
try { try {
const data = await this.documentService.getListDoc('0').toPromise(); const data = await this.documentService.getListExcelContent().toPromise();
this.listDoc = data this.listDoc = data.map(x => new DocumentContentModel(x))
} catch (error) { } catch (error) {
console.error('Error loading data:', error); console.error('Error loading data:', error);
} }
...@@ -53,5 +54,7 @@ export class ViewListDocComponent implements OnInit { ...@@ -53,5 +54,7 @@ export class ViewListDocComponent implements OnInit {
this.modalService.dismissAll() this.modalService.dismissAll()
}) })
} }
openLink(url:string){
window.open(url, "_blank");
}
} }
import { environment } from "src/environments/environment"
import { TagModel } from "./tag.mmodel"
export interface CourseContentModel {
courseId: string
thName: string
engName: string
thDesc: string
engDesc: string
objective: string
courseOutline: string
thumbnail: string
link1: string
courseType: string
courseLevel: string
courseTime: string
courseTrainer: string
courseTrainerDetail: string
courseObj: string
uploadBy: string
dwTime: number
remark: string
referId: string
approveBy: string
tags: TagModel[]
}
export class CourseContentModel implements CourseContentModel {
courseId: string
thName: string
engName: string
thDesc: string
engDesc: string
objective: string
courseOutline: string
thumbnail: string
link1: string
courseType: string
courseLevel: string
courseTime: string
courseTrainer: string
courseTrainerDetail: string
courseObj: string
uploadBy: string
dwTime: number
remark: string
referId: string
approveBy: string
tags: TagModel[]
constructor(data: Partial<any>) {
this.courseId = data.courseId?data.courseId:''
this.objective = data.objective?data.objective:''
this.thumbnail = data.thumbnail?data.thumbnail:''
this.link1 = data.link1?data.link1:''
this.courseObj = data.courseObj?data.courseObj:''
this.uploadBy = data.uploadBy?data.uploadBy:''
this.remark = data.remark?data.remark:''
this.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.courseOutline = data.courseOutline?data.courseOutline:''
this.courseType = data.courseType?data.courseType:''
this.courseLevel = data.courseLevel?data.courseLevel:''
this.courseTime = data.courseTime?data.courseTime:''
this.courseTrainer = data.courseTrainer?data.courseTrainer:''
this.courseTrainerDetail = data.courseTrainerDetail?data.courseTrainerDetail:''
this.referId = data.referId?data.referId:''
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
import { environment } from "src/environments/environment" import { environment } from "src/environments/environment"
import { TagModel } from "./tag.mmodel"
export interface CourseModel { export interface CourseModel {
logId: string logId: string
...@@ -20,6 +21,7 @@ export interface CourseModel { ...@@ -20,6 +21,7 @@ export interface CourseModel {
courseTime: string courseTime: string
courseTrainer: string courseTrainer: string
courseTrainerDetail: string courseTrainerDetail: string
tags: TagModel[]
} }
export class CourseModel implements CourseModel { export class CourseModel implements CourseModel {
...@@ -42,6 +44,7 @@ export class CourseModel implements CourseModel { ...@@ -42,6 +44,7 @@ export class CourseModel implements CourseModel {
courseTime: string courseTime: string
courseTrainer: string courseTrainer: string
courseTrainerDetail: string courseTrainerDetail: string
tags: TagModel[]
constructor(data: Partial<any>) { constructor(data: Partial<any>) {
this.logId = data.logId?data.logId:'' this.logId = data.logId?data.logId:''
this.objective = data.objective?data.objective:'' this.objective = data.objective?data.objective:''
...@@ -62,6 +65,7 @@ export class CourseModel implements CourseModel { ...@@ -62,6 +65,7 @@ export class CourseModel implements CourseModel {
this.courseTime = data.courseTime?data.courseTime:'' this.courseTime = data.courseTime?data.courseTime:''
this.courseTrainer = data.courseTrainer?data.courseTrainer:'' this.courseTrainer = data.courseTrainer?data.courseTrainer:''
this.courseTrainerDetail = data.courseTrainerDetail?data.courseTrainerDetail:'' this.courseTrainerDetail = data.courseTrainerDetail?data.courseTrainerDetail:''
this.tags = data.tags?data.tags:[]
} }
getImage(){ getImage(){
if(this.thumbnail){ if(this.thumbnail){
......
import { environment } from "src/environments/environment"
import { TagModel } from "./tag.mmodel"
export interface DocumentContentModel {
docId: string
thName: string
engName: string
thDesc: string
engDesc: string
thumbnail: string
link1: string
langSupport: string
thDocObj: string
engDocObj: string
uploadBy: string
dwTime: number
remark: string
referId: string
approveBy: string
tags: TagModel[]
}
export class DocumentContentModel implements DocumentContentModel {
docId: string
thName: string
engName: string
thDesc: string
engDesc: string
thumbnail: string
link1: string
langSupport: string
thDocObj: string
engDocObj: string
uploadBy: string
dwTime: number
remark: string
referId: string
approveBy: string
tags: TagModel[]
constructor(data: Partial<any>) {
this.docId = data.docId?data.docId:''
this.thumbnail = data.thumbnail?data.thumbnail:''
this.link1 = data.link1?data.link1:''
this.langSupport = data.langSupport?data.langSupport:''
this.thDocObj = data.thDocObj?data.thDocObj:''
this.engDocObj = data.engDocObj?data.engDocObj:''
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:''
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
import { environment } from "src/environments/environment" import { environment } from "src/environments/environment"
import { TagModel } from "./tag.mmodel"
export interface DocumentModel { export interface DocumentModel {
logId: string logId: string
...@@ -15,6 +16,7 @@ export interface DocumentModel { ...@@ -15,6 +16,7 @@ export interface DocumentModel {
engName: string engName: string
thDesc: string thDesc: string
engDesc: string engDesc: string
tags: TagModel[]
} }
export class DocumentModel implements DocumentModel { export class DocumentModel implements DocumentModel {
...@@ -32,6 +34,7 @@ export class DocumentModel implements DocumentModel { ...@@ -32,6 +34,7 @@ export class DocumentModel implements DocumentModel {
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:''
...@@ -47,7 +50,7 @@ export class DocumentModel implements DocumentModel { ...@@ -47,7 +50,7 @@ export class DocumentModel implements DocumentModel {
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(){ getImage(){
......
...@@ -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 { map, tap } from 'rxjs/operators'; import { map, tap } from 'rxjs/operators';
import { CourseModel } from '../model/course.model'; import { CourseModel } from '../model/course.model';
import { CourseContentModel } from '../model/course-content.model';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
...@@ -19,11 +20,18 @@ export class CourseService { ...@@ -19,11 +20,18 @@ export class CourseService {
return this.http.get<CourseModel[]>(this.url + "course-center/upload/lists") return this.http.get<CourseModel[]>(this.url + "course-center/upload/lists")
} }
} }
getListCourseContent(status?: string): Observable<CourseContentModel[]> {
return this.http.get<CourseContentModel[]>(this.url + "course-center/content/lists")
}
getCourseById(logId:string): Observable<CourseModel> { getCourseById(logId:string): Observable<CourseModel> {
return this.http.get<CourseModel>(this.url + "course-center/upload/"+logId) return this.http.get<CourseModel>(this.url + "course-center/upload/"+logId)
} }
downloadFile(logId:string){
return this.http.get<CourseModel>(this.url + "course-center/files/download/"+logId) downloadFile(logId:string):Observable<any>{
return this.http.get(this.url + "course-center/files/download/"+logId, { responseType: 'blob' })
}
downloadFileContent(logId:string):Observable<any>{
return this.http.get(this.url + "course-center/files/download/content/"+logId, { responseType: 'blob' });
} }
createCourse(model: CourseModel): Observable<boolean> { createCourse(model: CourseModel): Observable<boolean> {
if (this.createStatus) { if (this.createStatus) {
...@@ -56,4 +64,10 @@ export class CourseService { ...@@ -56,4 +64,10 @@ export class CourseService {
} }
return this.http.put<any>(this.url + "course-center/approve",body) return this.http.put<any>(this.url + "course-center/approve",body)
} }
getCount(status?: string): Observable<number> {
return this.http.get<number>(this.url + "course-center/upload/count")
}
getCountContent(status?: string): Observable<number> {
return this.http.get<number>(this.url + "course-center/content/count")
}
} }
...@@ -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 { map, tap } from 'rxjs/operators'; import { map, tap } from 'rxjs/operators';
import { DocumentModel } from '../model/document.model'; import { DocumentModel } from '../model/document.model';
import { DocumentContentModel } from '../model/document-content.model';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
...@@ -19,14 +20,18 @@ export class DocumentService { ...@@ -19,14 +20,18 @@ export class DocumentService {
return this.http.get<DocumentModel[]>(this.url + "document-center/upload/lists") return this.http.get<DocumentModel[]>(this.url + "document-center/upload/lists")
} }
} }
getListExcelContent(status?: string): Observable<DocumentContentModel[]> {
return this.http.get<DocumentContentModel[]>(this.url + "document-center/content/lists")
}
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>{ downloadFile(logId:string,lang:string):Observable<any>{
return this.http.get(this.url + "document-center/files/download/"+logId+'?lang='+lang, { responseType: 'blob' }) return this.http.get(this.url + "document-center/files/download/"+logId+'?lang='+lang, { responseType: 'blob' })
} }
downloadFileContent(logId:string):Observable<any>{
return this.http.get(this.url + "document-center/files/download/content/"+logId, { responseType: 'blob' }); downloadFileContent(logId:string,lang:string):Observable<any>{
return this.http.get(this.url + "document-center/files/download/content/"+logId+'?lang='+lang, { responseType: 'blob' });
} }
createDoc(model: DocumentModel): Observable<boolean> { createDoc(model: DocumentModel): Observable<boolean> {
if (this.createStatus) { if (this.createStatus) {
...@@ -59,4 +64,11 @@ export class DocumentService { ...@@ -59,4 +64,11 @@ export class DocumentService {
} }
return this.http.put<any>(this.url + "document-center/approve",body) return this.http.put<any>(this.url + "document-center/approve",body)
} }
getCount(status?: string): Observable<number> {
return this.http.get<number>(this.url + "document-center/upload/count")
}
getCountContent(status?: string): Observable<number> {
return this.http.get<number>(this.url + "document-center/content/count")
}
} }
...@@ -65,4 +65,11 @@ export class ExcelService { ...@@ -65,4 +65,11 @@ export class ExcelService {
} }
return this.http.put<any>(this.url + "excel-center/approve",body) return this.http.put<any>(this.url + "excel-center/approve",body)
} }
getCount(status?: string): Observable<number> {
return this.http.get<number>(this.url + "excel-center/upload/count")
}
getCountContent(status?: string): Observable<number> {
return this.http.get<number>(this.url + "excel-center/content/count")
}
} }
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';
import { TagModel } from '../model/tag.mmodel';
@Injectable({
providedIn: 'root'
})
export class TagService {
url = environment.url
createStatus: boolean = true
constructor(private http: HttpClient) { }
getList(): Observable<TagModel[]> {
return this.http.get<TagModel[]>(this.url + "tag/lists")
}
}
...@@ -22,26 +22,26 @@ export const ROUTES: RouteInfo[] = [ ...@@ -22,26 +22,26 @@ export const ROUTES: RouteInfo[] = [
extralink: false, extralink: false,
submenu: [] submenu: []
}, },
{ // {
path: '/apps/import-template', // path: '/apps/import-template',
title: 'นำเข้า Template', // title: 'นำเข้า Template',
icon: 'mdi mdi-adjust', // icon: 'mdi mdi-adjust',
class: '', // class: '',
label: "", // label: "",
labelClass: "", // labelClass: "",
extralink: false, // extralink: false,
submenu: [] // submenu: []
}, // },
{ // {
path: '/apps/export-template', // path: '/apps/export-template',
title: 'ส่งออก Template', // title: 'ส่งออก Template',
icon: 'mdi mdi-adjust', // icon: 'mdi mdi-adjust',
class: '', // class: '',
label: "", // label: "",
labelClass: "", // labelClass: "",
extralink: false, // extralink: false,
submenu: [] // submenu: []
}, // },
{ {
path: "", path: "",
title: "การจัดการ", title: "การจัดการ",
......
export const environment = { export const environment = {
url:'http://192.168.40.35:30537/',
production: true production: true
}; };
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