Commit 8750d346 by Nakarin Luankla

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

parent 2a1273b8
......@@ -3,7 +3,7 @@
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve --host 192.168.68.85",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
......@@ -61,6 +61,7 @@
"ng2-archwizard": "^2.1.0",
"ng2-charts": "^2.3.2",
"ng2-search-filter": "^0.5.1",
"ngx-chips": "^2.2.2",
"ngx-custom-validators": "8.0.0",
"ngx-perfect-scrollbar": "^9.0.0",
"ngx-quill": "^12.0.1",
......
......@@ -38,7 +38,6 @@ import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import { HttpClient } from '@angular/common/http';
import { HttpRequestInterceptor } from './service/http-request.interceptor';
export function HttpLoaderFactory(http: HttpClient) {
return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}
......
......@@ -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" class="text-center">ลิงค์</th>
<th scope="col" class="text-center">ไฟล์</th>
<th scope="col" class="text-center">สถานะ</th>
<th scope="col"></th>
</tr>
</thead>
......@@ -28,9 +29,26 @@
<td><img width="100" class="border p-1" src="{{data.getImage()}}"></td>
<td>{{ data.thName }}</td>
<td class="text-wrap">{{ data.thDesc }}</td>
<td>{{data.ctype}}</td>
<td><a href="{{data.link1}}" target="_blank">คลิก</a></td>
<td>{{ getStatus(data.status) }}</td>
<td>{{data.courseType}}</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">
<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>
<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>
......
......@@ -4,7 +4,8 @@ import { CourseModel } from 'src/app/model/course.model';
import { CourseService } from 'src/app/service/course.service';
import { ConfirmModalComponent } from '../confirm-modal/confirm-modal.component';
import { AlertModalComponent } from '../alert-modal/alert-modal.component';
declare var require: any
const FileSaver = require('file-saver');
@Component({
selector: 'app-approve-course',
templateUrl: './approve-course.component.html',
......@@ -17,15 +18,16 @@ export class ApproveCourseComponent implements OnInit {
search:string = ''
constructor(private modalService: NgbModal,private courseService:CourseService) {
}
getStatus(status:string){
if(status == '0'){
return 'รออนุมัติ'
} else if(status == '1'){
return 'เปิดใช้งาน'
} else if(status == '2'){
return 'ไม่อนุมัติ'
async downloadFile(logId:string){
try {
const data = await this.courseService.downloadFile(logId).toPromise();
if(data){
FileSaver.saveAs(new Blob([data]), "file_download.json");
}
} catch (error) {
console.error('Error loading data:', error);
}
}
}
filterListCourse(){
return this.listCourse.filter(x => x.thName.toLowerCase().includes(this.search.toLowerCase())||x.engName.toLowerCase().includes(this.search.toLowerCase()))
}
......@@ -47,6 +49,7 @@ export class ApproveCourseComponent implements OnInit {
item.status = 1
this.courseService.approve(item).subscribe(result => {
if (result) {
this.modalService.dismissAll()
this.openAlertModal('บันทึกข้อมูลสำเร็จ')
this.getListCourse();
} else {
......@@ -88,10 +91,12 @@ export class ApproveCourseComponent implements OnInit {
})
modalRef.componentInstance.message = message ? message : ""
modalRef.result.then(result => {
this.modalService.dismissAll()
// this.modalService.dismissAll()
}, reason => {
this.modalService.dismissAll()
// this.modalService.dismissAll()
})
}
openLink(url:string){
window.open(url, "_blank");
}
}
......@@ -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" 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>
</tr>
</thead>
<tbody>
<tr *ngIf="listDoc.length == 0">
<td colspan="7" class="text-center">ไม่พบข้อมูล</td>
<td colspan="8" class="text-center">ไม่พบข้อมูล</td>
</tr>
<tr *ngFor="let data of filterListDoc() | slice: (page-1) * pageSize : (page-1) * pageSize + pageSize ; let i = index">
<td class="text-center">{{i+1}}</td>
......@@ -30,9 +31,26 @@
<!-- <td >{{data.id}}</td> -->
<td>{{ data.thName }}</td>
<td>{{ data.thDesc }}</td>
<td><a href="{{data.link1}}" target="_blank">คลิก</a></td>
<td>{{ getStatus(data.status) }}</td>
<!-- <td><a (click)="downloadFile(data.logId)">ดาวน์โหลด</a></td> -->
<td 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,'tha')"></i></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>
<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>
......
......@@ -4,7 +4,8 @@ import { DocumentModel } from 'src/app/model/document.model';
import { AlertModalComponent } from '../alert-modal/alert-modal.component';
import { DocumentService } from 'src/app/service/document.service';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
declare var require: any
const FileSaver = require('file-saver');
@Component({
selector: 'app-approve-doc',
templateUrl: './approve-doc.component.html',
......@@ -17,15 +18,19 @@ export class ApproveDocComponent implements OnInit {
search:string = ''
constructor(private modalService: NgbModal,private documentService:DocumentService) {
}
getStatus(status:string){
if(status == '0'){
return 'รออนุมัติ'
} else if(status == '1'){
return 'เปิดใช้งาน'
} else if(status == '2'){
return 'ไม่อนุมัติ'
async downloadFile(logId:string,lang:string){
try {
const data = await this.documentService.downloadFile(logId,lang).toPromise();
if(data){
FileSaver.saveAs(new Blob([data]), "file_download.doc");
}
} catch (error) {
console.error('Error loading data:', error);
}
}
openLink(url:string){
window.open(url, "_blank");
}
filterListDoc(){
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 {
item.status = 1
this.documentService.approve(item).subscribe(result => {
if (result) {
this.modalService.dismissAll()
this.openAlertModal('บันทึกข้อมูลสำเร็จ')
this.getListDoc();
} else {
......@@ -88,9 +94,9 @@ export class ApproveDocComponent implements OnInit {
})
modalRef.componentInstance.message = message ? message : ""
modalRef.result.then(result => {
this.modalService.dismissAll()
// this.modalService.dismissAll()
}, reason => {
this.modalService.dismissAll()
// this.modalService.dismissAll()
})
}
......
......@@ -15,8 +15,8 @@
<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"></th>
</tr>
</thead>
......@@ -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-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>
......
......@@ -69,6 +69,7 @@ export class ApproveExcelComponent implements OnInit {
item.status = 2
this.excelService.approve(item).subscribe(result => {
if (result) {
this.modalService.dismissAll()
this.openAlertModal('บันทึกข้อมูลสำเร็จ')
this.getListExcel();
} else {
......@@ -90,9 +91,9 @@ export class ApproveExcelComponent implements OnInit {
})
modalRef.componentInstance.message = message ? message : ""
modalRef.result.then(result => {
this.modalService.dismissAll()
// this.modalService.dismissAll()
}, reason => {
this.modalService.dismissAll()
// this.modalService.dismissAll()
})
}
openLink(url:string){
......
......@@ -93,10 +93,12 @@ import { ApproveCourseComponent } from './approve-course/approve-course.componen
import { ViewListExcelComponent } from './view-list-excel/view-list-excel.component';
import { ViewListDocComponent } from './view-list-doc/view-list-doc.component';
import { ViewListCourseComponent } from './view-list-course/view-list-course.component';
import { TagInputModule } from 'ngx-chips';
@NgModule({
imports: [
TagInputModule,
CommonModule,
FormsModule,
ReactiveFormsModule,
......
......@@ -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" class="text-center">ลิงค์</th>
<th scope="col" class="text-center">ไฟล์</th>
<th scope="col" class="text-center">สถานะ</th>
<th scope="col"></th>
</tr>
</thead>
......@@ -28,9 +29,26 @@
<td>{{ data.thName }}</td>
<td class="text-wrap">{{ data.thDesc }}</td>
<td>{{data.courseType}}</td>
<td><a href="{{data.link1}}" target="_blank">คลิก</a></td>
<td>{{ getStatus(data.status) }}</td>
<!-- <td><a (click)="downloadFile(data.logId)">ดาวน์โหลด</a></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">
<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>
<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>
......@@ -159,12 +177,14 @@
<label for="name" class="col-sm-4 col-form-label">ไฟล์อัพโหลด</label>
<div class="col-sm-8">
<input type="file" class="form-control" (change)="onSelectFile($event)">
<div class="msg-detail">ไฟล์ที่อนุญาต:*.json</div>
</div>
</div>
<div class="form-group row">
<label for="name" class="col-sm-4 col-form-label">รูปภาพตัวอย่าง</label>
<div class="col-sm-8">
<input type="file" class="form-control" (change)="onUploadImage($event)">
<div class="msg-detail">ไฟล์ที่อนุญาต:*.jpeg, *.jpg, *.png</div>
</div>
</div>
......@@ -174,7 +194,16 @@
<input type="text" class="form-control" id="nameeng" [(ngModel)]="modelCourse.link1">
</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">
<label for="position" class="col-sm-4 col-form-label">หมายเหตุ</label>
<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';
import { CourseModel } from 'src/app/model/course.model';
import { CourseService } from 'src/app/service/course.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({
selector: 'app-list-course',
templateUrl: './list-course.component.html',
......@@ -19,7 +22,8 @@ export class ListCourseComponent implements OnInit {
modelCourse:CourseModel = new CourseModel({});
checkEdit:boolean = false
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){
try{
......@@ -27,10 +31,15 @@ export class ListCourseComponent implements OnInit {
let fileData = event.target.files[0];
const formData = new FormData();
formData.append('file', fileData);
const data = await this.uploadService.uploadImage(formData).toPromise();
if(data){
this.modelCourse.thumbnail = data.body.fileId
}
const allowedTypes = ['image/png', 'image/jpeg', 'image/jpg'];
if (!allowedTypes.includes(fileData.type)) {
this.openAlertModal('อัพโหลดได้เฉพาะไฟล์ *.jpeg, *.jpg, *.png เท่านั้น')
} else {
const data = await this.uploadService.uploadImage(formData).toPromise();
if(data){
this.modelCourse.thumbnail = data.body.fileId
}
}
}
} catch (error) {
console.error('Error loading data:', error);
......@@ -38,22 +47,32 @@ export class ListCourseComponent implements OnInit {
}
onSelectFile(event:any) {
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.onload = (event) => { // called once readAsDataURL is completed
if(event){
let base64 = event.target!.result as string
this.modelCourse.courseObj = base64.split(',')[1];
const allowedTypes = ['application/json'];
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){
try {
const data = await this.courseService.downloadFile(logId).toPromise();
} catch (error) {
console.error('Error loading data:', error);
try {
const data = await this.courseService.downloadFile(logId).toPromise();
if(data){
FileSaver.saveAs(new Blob([data]), "file_download.json");
}
} catch (error) {
console.error('Error loading data:', error);
}
}
deleteFile(item:CourseModel){
const modalRef = this.modalService.open(ConfirmModalComponent, {
......@@ -82,9 +101,9 @@ export class ListCourseComponent implements OnInit {
})
modalRef.componentInstance.message = message ? message : ""
modalRef.result.then(result => {
this.modalService.dismissAll()
// this.modalService.dismissAll()
}, reason => {
this.modalService.dismissAll()
// this.modalService.dismissAll()
})
}
......@@ -98,6 +117,7 @@ export class ListCourseComponent implements OnInit {
console.log(this.modelCourse);
this.courseService.createCourse(this.modelCourse).subscribe(result => {
if (result) {
this.modalService.dismissAll()
this.openAlertModal('อัพเดทข้อมูลสำเร็จ')
this.getListCourse();
} else {
......@@ -117,6 +137,7 @@ export class ListCourseComponent implements OnInit {
modalRef.result.then(result => {
this.courseService.createCourse(this.modelCourse).subscribe(result => {
if (result) {
this.modalService.dismissAll()
this.openAlertModal('บันทึกข้อมูลสำเร็จ')
this.getListCourse();
} else {
......@@ -162,16 +183,6 @@ export class ListCourseComponent implements OnInit {
size: 'lg'
});
}
}
getStatus(status:string){
if(status == '0'){
return 'รออนุมัติ'
} else if(status == '1'){
return 'เปิดใช้งาน'
} else if(status == '2'){
return 'ไม่อนุมัติ'
}
}
async getListCourse(){
try {
......@@ -187,11 +198,22 @@ export class ListCourseComponent implements OnInit {
ngOnInit() {
this.getListCourse();
this.getListTag();
}
closeBtnClick() {
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 @@
<input type="text" class="form-control" id="nameeng" [(ngModel)]="modelDoc.link1">
</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">
<label for="position" class="col-sm-4 col-form-label">หมายเหตุ</label>
<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';
import { DocumentService } from 'src/app/service/document.service';
import { DocumentModel } from 'src/app/model/document.model';
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({
......@@ -19,7 +21,8 @@ export class ListDocComponent implements OnInit {
modelDoc:DocumentModel = new DocumentModel({});
checkEdit:boolean = false
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){
try{
......@@ -48,7 +51,7 @@ export class ListDocComponent implements OnInit {
reader.readAsDataURL(event.target.files[0]); // read file as data url
reader.onload = (event) => { // called once readAsDataURL is completed
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)) {
this.openAlertModal('อัพโหลดได้เฉพาะไฟล์ *.doc เท่านั้น')
} else {
......@@ -113,7 +116,6 @@ export class ListDocComponent implements OnInit {
})
modalRef.componentInstance.message = 'คุณต้องการอัพเดทข้อมูลหรือไม่'
modalRef.result.then(result => {
console.log(this.modelDoc);
this.documentService.createDoc(this.modelDoc).subscribe(result => {
if (result) {
this.modalService.dismissAll()
......@@ -207,9 +209,17 @@ export class ListDocComponent implements OnInit {
ngOnInit() {
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() {
this.modalService.dismissAll();
}
......
......@@ -146,6 +146,16 @@
<input type="text" class="form-control" id="nameeng" [(ngModel)]="modelExcel.link1">
</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">
<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';
import { ConfirmModalComponent } from '../confirm-modal/confirm-modal.component';
import { AlertModalComponent } from '../alert-modal/alert-modal.component';
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({
selector: 'app-list-excel',
templateUrl: './list-excell.component.html',
......@@ -19,11 +22,12 @@ export class ListExcelComponent implements OnInit {
modelExcel:ExcelModel = new ExcelModel({});
checkEdit:boolean = false
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){
try{
if (event.target.files.length > 0) {
let fileData = event.target.files[0];
const formData = new FormData();
......@@ -42,7 +46,14 @@ export class ListExcelComponent implements OnInit {
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) {
if (event.target.files && event.target.files[0]) {
const reader = new FileReader();
......@@ -210,6 +221,7 @@ export class ListExcelComponent implements OnInit {
ngOnInit() {
this.getListExcel();
this.getListTag();
}
......
......@@ -11,7 +11,7 @@
</div>
<div class="d-flex justify-content-between bg-light border-top p-3">
<div>
<span class="align-middle">{{ c.document }}</span>
<span class="align-middle">จำนวนเอกสาร {{ c.document }} ฉบับ</span>
</div>
<div >
<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";
import { FormBuilder, FormGroup, Validators } from "@angular/forms";
import { User } from "../users/user";
import { Router } from "@angular/router";
import { CourseService } from "src/app/service/course.service";
import { DocumentService } from "src/app/service/document.service";
import { ExcelService } from "src/app/service/excel.service";
@Component({
selector: "app-portal-category-list-approve",
......@@ -11,18 +14,10 @@ import { Router } from "@angular/router";
})
export class PortalCategoryListApproveComponent implements OnInit {
constructor(
private fb: FormBuilder,
private modalService: NgbModal,
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;
pageSize = 7;
......@@ -43,21 +38,21 @@ export class PortalCategoryListApproveComponent implements OnInit {
img: "assets/images/icon/excel.png",
name: "Excel",
details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
document: "จำนวนเอกสาร 8 ฉบับ"
document: "0"
},
{
id:'2',
img: "assets/images/icon/document.png",
name: "Document",
details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
document: "จำนวนเอกสาร 3 ฉบับ"
document: "0"
},
{
id:'3',
img: "assets/images/icon/course.png",
name: "Course",
details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
document: "จำนวนเอกสาร 5 ฉบับ"
document: "0"
},
];
}
......@@ -69,6 +64,25 @@ export class PortalCategoryListApproveComponent implements OnInit {
}else if(id =='3'){
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) {
this.modalService.open(targetModal, {
......@@ -79,7 +93,6 @@ export class PortalCategoryListApproveComponent implements OnInit {
closeBtnClick() {
this.modalService.dismissAll();
this.ngOnInit();
}
routerLink(path: String, type: String){
......
......@@ -11,7 +11,7 @@
</div>
<div class="d-flex justify-content-between bg-light border-top p-3">
<div>
<span class="align-middle">{{ c.document }}</span>
<span class="align-middle">จำนวนเอกสาร {{ c.document }} ฉบับ</span>
</div>
<div >
<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 { Router } from '@angular/router';
import { CourseService } from 'src/app/service/course.service';
import { DocumentService } from 'src/app/service/document.service';
import { ExcelService } from 'src/app/service/excel.service';
@Component({
selector: 'app-portal-category-list',
......@@ -9,12 +12,11 @@ import { Router } from '@angular/router';
export class PortalCategoryListComponent implements OnInit {
constructor(
private routes: Router
private routes: Router,
private excelService:ExcelService,private documentService:DocumentService,private courseService:CourseService
) {}
page = 1;
pageSize = 7;
pageSize = 10;
testdata: {
id:string;
img: String;
......@@ -31,25 +33,43 @@ export class PortalCategoryListComponent implements OnInit {
img: "assets/images/icon/excel.png",
name: "Excel",
details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
document: "จำนวนเอกสาร 8 ฉบับ"
document: "0"
},
{
id:'2',
img: "assets/images/icon/document.png",
name: "Document",
details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
document: "จำนวนเอกสาร 3 ฉบับ"
document: "0"
},
{
id:'3',
img: "assets/images/icon/course.png",
name: "Course",
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){
if(id =='1'){
this.routes.navigate(['apps/view-list-excel']);
......
......@@ -15,7 +15,7 @@
</div>
<div class="d-flex justify-content-between bg-light border-top p-3">
<div>
<span class="align-middle">{{ c.document }}</span>
<span class="align-middle">จำนวนเอกสาร {{ c.document }} ฉบับ</span>
</div>
<div >
<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";
import { FormBuilder, FormGroup, Validators } from "@angular/forms";
import { DatePipe } from "@angular/common";
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({
selector: 'app-portal-create-category',
......@@ -11,7 +14,7 @@ import { Router } from '@angular/router';
})
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;
pageSize = 10;
......@@ -30,25 +33,43 @@ export class PortalCreateCategoryComponent implements OnInit {
img: "assets/images/icon/excel.png",
name: "Excel",
details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
document: "จำนวนเอกสาร 8 ฉบับ"
document: "0"
},
{
id:'2',
img: "assets/images/icon/document.png",
name: "Document",
details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
document: "จำนวนเอกสาร 3 ฉบับ"
document: "0"
},
{
id:'3',
img: "assets/images/icon/course.png",
name: "Course",
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){
if(id =='1'){
this.routes.navigate(['apps/list-excel']);
......@@ -67,7 +88,6 @@ export class PortalCreateCategoryComponent implements OnInit {
closeBtnClick() {
this.modalService.dismissAll();
this.ngOnInit();
}
}
......@@ -16,6 +16,7 @@
<th scope="col">ประเภทหลักสูตร</th>
<th scope="col">ลิงค์</th>
<th scope="col">สถานะ</th>
<th scope="col" class="text-center">จำนวนดาวน์โหลด</th>
</tr>
</thead>
<tbody>
......@@ -24,12 +25,13 @@
</tr>
<tr *ngFor="let data of filterListCourse() | slice: (page-1) * pageSize : (page-1) * pageSize + pageSize ; let i = index">
<td class="text-center">{{i+1}}</td>
<td><img width="100" class="border p-1" src="{{data.thumbnail}}"></td>
<td><img width="100" class="border p-1" src="{{data.getImage()}}"></td>
<td>{{ data.thName }}</td>
<td class="text-wrap">{{ data.thDesc }}</td>
<td>{{data.ctype}}</td>
<td><a href="{{data.link1}}" target="_blank">คลิก</a></td>
<td>{{ getStatus(data.status) }}</td>
<td>{{data.courseType}}</td>
<td class="text-center"><i class="fas fa-link pointer" (click)="openLink(data.link1)"></i></td>
<td class="text-center"> <i class="fas fa-download pointer" (click)="downloadFile(data.courseId)"></i></td>
<td class="text-center">{{data.dwTime}} ครั้ง</td>
</tr>
</tbody>
</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';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { CourseService } from 'src/app/service/course.service';
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({
selector: 'app-view-list-course',
templateUrl: './view-list-course.component.html',
......@@ -12,17 +14,18 @@ import { CourseModel } from 'src/app/model/course.model';
export class ViewListCourseComponent implements OnInit {
page = 1;
pageSize = 10;
listCourse:CourseModel[]=[]
listCourse:CourseContentModel[]=[]
search:string = ''
constructor(private modalService: NgbModal,private courseService:CourseService) {
}
getStatus(status:string){
if(status == '0'){
return 'รออนุมัติ'
} else if(status == '1'){
return 'เปิดใช้งาน'
} else if(status == '2'){
return 'ไม่อนุมัติ'
async downloadFile(logId:string){
try {
const data = await this.courseService.downloadFileContent(logId).toPromise();
if(data){
FileSaver.saveAs(new Blob([data]), "file_download.json");
}
} catch (error) {
console.error('Error loading data:', error);
}
}
filterListCourse(){
......@@ -30,8 +33,9 @@ export class ViewListCourseComponent implements OnInit {
}
async getListCourse(){
try {
const data = await this.courseService.getListCourse('0').toPromise();
this.listCourse = data
const data = await this.courseService.getListCourseContent().toPromise();
this.listCourse = data.map(x => new CourseContentModel(x))
console.log("🚀 ~ ViewListCourseComponent ~ getListCourse ~ this.listCourse :", this.listCourse )
} catch (error) {
console.error('Error loading data:', error);
}
......@@ -40,7 +44,9 @@ export class ViewListCourseComponent implements OnInit {
ngOnInit() {
this.getListCourse();
}
openLink(url:string){
window.open(url, "_blank");
}
openAlertModal(message?: string) {
const modalRef = this.modalService.open(AlertModalComponent, {
centered: true,
......
......@@ -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" 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>
</tr>
</thead>
<tbody>
......@@ -25,13 +26,14 @@
</tr>
<tr *ngFor="let data of filterListDoc() | slice: (page-1) * pageSize : (page-1) * pageSize + pageSize ; let i = index">
<td class="text-center">{{i+1}}</td>
<td><img width="100" class="border p-1" src="{{data.thumbnail}}"></td>
<td><img width="100" class="border p-1" src="{{data.getImage()}}"></td>
<!-- <td >{{data.id}}</td> -->
<td>{{ data.thName }}</td>
<td>{{ data.thDesc }}</td>
<td><a href="{{data.link1}}" target="_blank">คลิก</a></td>
<td>{{ getStatus(data.status) }}</td>
<!-- <td><a (click)="downloadFile(data.logId)">ดาวน์โหลด</a></td> -->
<td 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.docId,'tha')"></i></td>
<td class="text-center"> <i class="fas fa-download pointer" (click)="downloadFile(data.docId,'eng')"></i></td>
<td class="text-center">{{data.dwTime}} ครั้ง</td>
</tr>
</tbody>
</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 { AlertModalComponent } from '../alert-modal/alert-modal.component';
import { ConfirmModalComponent } from '../confirm-modal/confirm-modal.component';
import { DocumentModel } from 'src/app/model/document.model';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { DocumentService } from 'src/app/service/document.service';
import { DocumentContentModel } from 'src/app/model/document-content.model';
declare var require: any
const FileSaver = require('file-saver');
@Component({
selector: 'app-view-list-doc',
templateUrl: './view-list-doc.component.html',
......@@ -13,17 +13,18 @@ import { DocumentService } from 'src/app/service/document.service';
export class ViewListDocComponent implements OnInit {
page = 1;
pageSize = 10;
listDoc:DocumentModel[]=[]
listDoc:DocumentContentModel[]=[]
search:string = ''
constructor(private modalService: NgbModal,private documentService:DocumentService) {
}
getStatus(status:string){
if(status == '0'){
return 'รออนุมัติ'
} else if(status == '1'){
return 'เปิดใช้งาน'
} else if(status == '2'){
return 'ไม่อนุมัติ'
async downloadFile(logId:string,lang:string){
try {
const data = await this.documentService.downloadFileContent(logId,lang).toPromise();
if(data){
FileSaver.saveAs(new Blob([data]), "file_download.doc");
}
} catch (error) {
console.error('Error loading data:', error);
}
}
filterListDoc(){
......@@ -31,8 +32,8 @@ export class ViewListDocComponent implements OnInit {
}
async getListDoc(){
try {
const data = await this.documentService.getListDoc('0').toPromise();
this.listDoc = data
const data = await this.documentService.getListExcelContent().toPromise();
this.listDoc = data.map(x => new DocumentContentModel(x))
} catch (error) {
console.error('Error loading data:', error);
}
......@@ -53,5 +54,7 @@ export class ViewListDocComponent implements OnInit {
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 { TagModel } from "./tag.mmodel"
export interface CourseModel {
logId: string
......@@ -20,6 +21,7 @@ export interface CourseModel {
courseTime: string
courseTrainer: string
courseTrainerDetail: string
tags: TagModel[]
}
export class CourseModel implements CourseModel {
......@@ -42,6 +44,7 @@ export class CourseModel implements CourseModel {
courseTime: string
courseTrainer: string
courseTrainerDetail: string
tags: TagModel[]
constructor(data: Partial<any>) {
this.logId = data.logId?data.logId:''
this.objective = data.objective?data.objective:''
......@@ -62,6 +65,7 @@ export class CourseModel implements CourseModel {
this.courseTime = data.courseTime?data.courseTime:''
this.courseTrainer = data.courseTrainer?data.courseTrainer:''
this.courseTrainerDetail = data.courseTrainerDetail?data.courseTrainerDetail:''
this.tags = data.tags?data.tags:[]
}
getImage(){
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 { TagModel } from "./tag.mmodel"
export interface DocumentModel {
logId: string
......@@ -15,6 +16,7 @@ export interface DocumentModel {
engName: string
thDesc: string
engDesc: string
tags: TagModel[]
}
export class DocumentModel implements DocumentModel {
......@@ -32,6 +34,7 @@ export class DocumentModel implements DocumentModel {
engName: string
thDesc: string
engDesc: string
tags: TagModel[]
constructor(data: Partial<any>) {
this.logId = data.logId?data.logId:''
this.thumbnail = data.thumbnail?data.thumbnail:''
......@@ -47,7 +50,7 @@ export class DocumentModel implements DocumentModel {
this.engName = data.engName?data.engName:''
this.thDesc = data.thDesc?data.thDesc:''
this.engDesc = data.engDesc?data.engDesc:''
this.tags = data.tags?data.tags:[]
}
getImage(){
......
......@@ -4,6 +4,7 @@ import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Observable, of } from 'rxjs';
import { map, tap } from 'rxjs/operators';
import { CourseModel } from '../model/course.model';
import { CourseContentModel } from '../model/course-content.model';
@Injectable({
providedIn: 'root'
......@@ -19,11 +20,18 @@ export class CourseService {
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> {
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> {
if (this.createStatus) {
......@@ -56,4 +64,10 @@ export class CourseService {
}
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';
import { Observable, of } from 'rxjs';
import { map, tap } from 'rxjs/operators';
import { DocumentModel } from '../model/document.model';
import { DocumentContentModel } from '../model/document-content.model';
@Injectable({
providedIn: 'root'
......@@ -19,14 +20,18 @@ export class DocumentService {
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> {
return this.http.get<DocumentModel>(this.url + "document-center/upload/"+logId)
}
downloadFile(logId:string,lang:string):Observable<any>{
return this.http.get(this.url + "document-center/files/download/"+logId+'?lang='+lang, { responseType: 'blob' })
}
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> {
if (this.createStatus) {
......@@ -59,4 +64,11 @@ export class DocumentService {
}
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 {
}
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[] = [
extralink: false,
submenu: []
},
{
path: '/apps/import-template',
title: 'นำเข้า Template',
icon: 'mdi mdi-adjust',
class: '',
label: "",
labelClass: "",
extralink: false,
submenu: []
},
{
path: '/apps/export-template',
title: 'ส่งออก Template',
icon: 'mdi mdi-adjust',
class: '',
label: "",
labelClass: "",
extralink: false,
submenu: []
},
// {
// path: '/apps/import-template',
// title: 'นำเข้า Template',
// icon: 'mdi mdi-adjust',
// class: '',
// label: "",
// labelClass: "",
// extralink: false,
// submenu: []
// },
// {
// path: '/apps/export-template',
// title: 'ส่งออก Template',
// icon: 'mdi mdi-adjust',
// class: '',
// label: "",
// labelClass: "",
// extralink: false,
// submenu: []
// },
{
path: "",
title: "การจัดการ",
......
export const environment = {
url:'http://192.168.40.35:30537/',
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