Commit 115771a8 by DESKTOP-E3GSHH7\myhr

ใบงาน 43990 เเละ รายการเอกสาร

parent d7ffdab5
...@@ -47,8 +47,9 @@ ...@@ -47,8 +47,9 @@
<th scope="col" class="text-start">รูปภาพ</th> <th scope="col" class="text-start">รูปภาพ</th>
<th scope="col" class="text-start">หัวข้อบทความ</th> <th scope="col" class="text-start">หัวข้อบทความ</th>
<th scope="col" class="text-start">ผู้เขียนบทความ</th> <th scope="col" class="text-start">ผู้เขียนบทความ</th>
<!-- <th scope="col" class="text-start">{{"Status" | translate}}</th> --> <th scope="col" class="text-start">{{"Status" | translate}}</th>
<th scope="col" class="text-start">วันที่สร้าง</th> <th scope="col" class="text-start">วันที่เผยเเพร่</th>
<!-- <th scope="col" class="text-start">วันที่สิ้นสุดการเผยเเพร่</th> -->
<th scope="col" class="text-start">วันที่เเก้ไขล่าสุด</th> <th scope="col" class="text-start">วันที่เเก้ไขล่าสุด</th>
<!-- <th scope="col" class="text-start">{{"Update Date" | translate}}</th> --> <!-- <th scope="col" class="text-start">{{"Update Date" | translate}}</th> -->
<th scope="col" class="text-start">การจัดการ</th> <th scope="col" class="text-start">การจัดการ</th>
...@@ -64,8 +65,10 @@ ...@@ -64,8 +65,10 @@
</td> </td>
<td> <td>
<div class="flex items-center"> <div class="flex items-center">
<span class="p-3 me-1"> <span class="p-3 me-1" style="width: 200px;">
<img [src]="item.getPicture()" alt="" id="profile-img" class="border-radius-1" <!-- <img [src]="item.getPicture()" alt="" id="profile-img" class="border-radius-1"
style="width: 180px; height: 120px; object-fit: cover;"> -->
<img [src]="item.getPicture() === '' ? 'assets/images/media/media-1.jpg' : item.getPicture()" id="profile-img" class="border-radius-1"
style="width: 180px; height: 120px; object-fit: cover;"> style="width: 180px; height: 120px; object-fit: cover;">
</span> </span>
</div> </div>
...@@ -84,6 +87,18 @@ ...@@ -84,6 +87,18 @@
</span> </span>
</div> </div>
</td> </td>
<td>
<div>
<ng-container *ngIf="item.publish === 1">
<span class="badge bg-success text-white">
เผยแพร่ </span>
</ng-container>
<ng-container *ngIf="item.publish === 0">
<span class="badge bg-amber-300 text-white">
ไม่เผยแพร่ </span>
</ng-container>
</div>
</td>
<!-- <td> <!-- <td>
<span class="badge bg-{{ item.status == 1 ? 'primary' : 'danger'}} text-white"> <span class="badge bg-{{ item.status == 1 ? 'primary' : 'danger'}} text-white">
{{item.getStatus()}} {{item.getStatus()}}
...@@ -95,6 +110,12 @@ ...@@ -95,6 +110,12 @@
{{item.createdDate | date : 'dd/MM/yyyy HH:mm'}} {{item.createdDate | date : 'dd/MM/yyyy HH:mm'}}
</span> </span>
</td> </td>
<!-- <td>
<span class="badge bg-info/10 text-primary">
<i class="bi bi-clock me-1"></i>
{{item.endDate | date : 'dd/MM/yyyy HH:mm'}}
</span>
</td> -->
<td> <td>
<span class="badge bg-info/10 text-primary"> <span class="badge bg-info/10 text-primary">
<i class="bi bi-clock me-1"></i> <i class="bi bi-clock me-1"></i>
...@@ -197,13 +218,15 @@ ...@@ -197,13 +218,15 @@
<div class="xl:col-span-12 col-span-12 justify-items-center"> <div class="xl:col-span-12 col-span-12 justify-items-center">
<div class="relative w-[300px] h-[200px] overflow-hidden rounded-md group mx-auto"> <div class="relative w-[300px] h-[200px] overflow-hidden rounded-md group mx-auto">
<img [src]="selectModel.getPicture()" alt="Profile Picture" <img [src]="selectModel.getPicture() === '' ? 'assets/images/media/media-1.jpg' : selectModel.getPicture()"
alt="Profile Picture"
class="w-full h-full block transition-all duration-300 ease-in-out group-hover:blur-md border-color"> class="w-full h-full block transition-all duration-300 ease-in-out group-hover:blur-md border-color">
<div <div
class="absolute inset-0 flex items-center justify-center bg-black bg-opacity-30 opacity-0 transition-opacity duration-300 ease-in-out group-hover:opacity-100 cursor-pointer" class="absolute inset-0 flex items-center justify-center bg-black bg-opacity-30 opacity-0 transition-opacity duration-300 ease-in-out group-hover:opacity-100 cursor-pointer"
(click)="triggerFileInput()"> <input #profileChangeInput ng2FileSelect [uploader]="uploaderProfile" (click)="triggerFileInput()">
type="file" name="photo" class="hidden" id="profile-change-input"> <input #profileChangeInput ng2FileSelect [uploader]="uploaderProfile" type="file" name="photo"
class="hidden" id="profile-change-input">
<button <button
class="bg-blue-500 hover:bg-blue-600 text-white font-bold py-2 px-4 rounded-lg opacity-100 transition-opacity duration-300 ease-in-out"> class="bg-blue-500 hover:bg-blue-600 text-white font-bold py-2 px-4 rounded-lg opacity-100 transition-opacity duration-300 ease-in-out">
...@@ -212,42 +235,112 @@ ...@@ -212,42 +235,112 @@
</div> </div>
</div> </div>
</div> </div>
<div class="xl:col-span-6 col-span-12">
<!-- <div class="xl:col-span-6 col-span-12">
<label for="articleId" class="text-primary mt-4 font-bold font-14">{{'รหัสบทความ' | translate}}</label> <label for="articleId" class="text-primary mt-4 font-bold font-14">{{'รหัสบทความ' | translate}}</label>
<input type="text" class="form-control" id="articleId" placeholder="" [(ngModel)]="selectModel.articleId" <input type="text" class="form-control" id="articleId" placeholder="" [(ngModel)]="selectModel.articleId"
[readonly]="action === 'edit'" [ngClass]="{ '!bg-input-readonly': action === 'edit' }"> [readonly]="action === 'edit'" [ngClass]="{ '!bg-input-readonly': action === 'edit' }">
<div class="text-danger" *ngIf="!selectModel.articleId && action === 'add'"> <div class="text-danger" *ngIf="!selectModel.articleId && action === 'add'">
{{'Please fill in information' | translate}} {{'Please fill in information' | translate}}
</div> </div>
</div> </div> -->
<div class="xl:col-span-6 col-span-12"> <div class="xl:col-span-6 col-span-12">
<label for="title" class="text-primary mt-4 font-bold font-14">{{'ชื่อหัวข้อบทความ' | translate}}</label>
<input type="text" class="form-control" id="title" placeholder="" [(ngModel)]="selectModel.title">
<div class="text-danger" *ngIf="!selectModel.title">
{{'Please fill in information' | translate}}
</div>
</div>
<div class="xl:col-span-12 col-span-12">
<label for="author" class="text-primary mt-4 font-bold font-14">{{'ผู้เขียนบทความ' | translate}}</label> <label for="author" class="text-primary mt-4 font-bold font-14">{{'ผู้เขียนบทความ' | translate}}</label>
<input type="text" class="form-control" id="author" placeholder="" [(ngModel)]="selectModel.author"> <input type="text" class="form-control" id="author" placeholder="" [(ngModel)]="selectModel.author">
<div class="text-danger" *ngIf="!selectModel.author"> <div class="text-danger" *ngIf="!selectModel.author">
{{'Please fill in information' | translate}} {{'Please fill in information' | translate}}
</div> </div>
</div> </div>
<!-- <div class="xl:col-span-6 col-span-12">
<label for="lastModifiedDate" class="mt-4 font-bold font-14 text-primary">{{'วันที่เเก้ไขล่าสุด' |
translate}}</label>
<input type="datetime-local" class="form-control" id="lastModifiedDate" placeholder=""
[(ngModel)]="selectModel.lastModifiedDate" [min]="selectModel.createdDate" disabled>
<div class="text-danger" *ngIf="!selectModel.lastModifiedDate">
{{'Please fill in information' | translate}}
</div>
</div> -->
<div class="xl:col-span-6 col-span-12"> <div class="xl:col-span-6 col-span-12">
<label for="createdDate" class="mt-4 font-bold font-14 text-primary">{{'วันที่สร้าง' | translate}}</label> <label for="createdDate" class="mt-4 font-bold font-14 text-primary">{{'วันที่เผยเเพร่' | translate}}</label>
<input type="datetime-local" class="form-control" id="createdDate" placeholder="" <input type="datetime-local" class="form-control" id="createdDate" placeholder=""
[(ngModel)]="selectModel.createdDate" (ngModelChange)="updateMinDate()"> [(ngModel)]="selectModel.createdDate" (ngModelChange)="updateMinDate()" max="9999-12-31T23:59">
<div class="text-danger" *ngIf="!selectModel.createdDate"> <div class="text-danger" *ngIf="!selectModel.createdDate">
{{'Please fill in information' | translate}} {{'Please fill in information' | translate}}
</div> </div>
</div> </div>
<div class="xl:col-span-6 col-span-12"> <div class="xl:col-span-6 col-span-12">
<label for="endDate" class="mt-4 font-bold font-14 text-primary">{{'วันที่สิ้นสุดการเผยเเพร่' |
translate}}</label>
<input type="datetime-local" class="form-control" id="endDate" placeholder=""
[(ngModel)]="selectModel.endDate" [min]="selectModel.createdDate" max="9999-12-31T23:59">
<div class="text-danger" *ngIf="!selectModel.endDate">
{{'Please fill in information' | translate}}
</div>
</div>
<div class="xl:col-span-12 col-span-12">
<label class="mt-4 font-bold font-14 text-primary" for="Detail_content">{{ "ชื่อหัวข้อบทความ" | translate }}:
<span class="text-danger">*</span></label>
<nav class="flex rtl:space-x-reverse space-x-2 border-b border-gray-200 mt-3">
<a (click)="currentarticleIdTab = 1" [class.active]="currentarticleIdTab === 1"
[class.hs-tab-active]="currentarticleIdTab === 1"
class="border w-32 justify-center rounded-4px -mb-px py-2 px-3 inline-flex items-center gap-2 font-size-16px font-weight-500 text-center text-gray-600 hover:text-gray-900"
href="javascript:void(0);" id="card-type-item-con-content-1" aria-controls="card-type-con-content-1">
ไทย
</a>
<a (click)="currentarticleIdTab = 2" [class.active]="currentarticleIdTab === 2"
[class.hs-tab-active]="currentarticleIdTab === 2"
class="border w-32 justify-center rounded-4px -mb-px py-2 px-3 inline-flex items-center gap-2 font-size-16px font-weight-500 text-center text-gray-600 hover:text-gray-900"
href="javascript:void(0);" id="card-type-item-con-content-2" aria-controls="card-type-con-content-2">
อังกฤษ
</a>
<a (click)="currentarticleIdTab = 3" [class.active]="currentarticleIdTab === 3"
[class.hs-tab-active]="currentarticleIdTab === 3"
class="border w-32 justify-center rounded-4px -mb-px py-2 px-3 inline-flex items-center gap-2 font-size-16px font-weight-500 text-center text-gray-600 hover:text-gray-900"
href="javascript:void(0);" id="card-type-item-con-content-3" aria-controls="card-type-con-content-3">
จีน
</a>
</nav>
<div *ngIf="currentarticleIdTab === 1" id="card-type-con-title-1" role="tabpanel"
aria-labelledby="card-type-item-con-title-1" class="" style="background-color: rgb(255, 255, 255);">
<textarea [(ngModel)]="selectModel.title" rows="5" cols="50"
style="max-height: 200px; overflow-y: auto; width: 100%;">
</textarea>
<div class="text-danger" *ngIf="!selectModel.title">
{{'Please fill in information' | translate}}
</div>
</div>
<div *ngIf="currentarticleIdTab === 2" id="card-type-con-titleEng-2" role="tabpanel"
aria-labelledby="card-type-item-con-titleEng-2" class="" style="background-color: rgb(255, 255, 255);">
<textarea [(ngModel)]="selectModel.titleEng" rows="5" cols="50"
style="max-height: 200px; overflow-y: auto; width: 100%;">
</textarea>
<div class="text-danger" *ngIf="!selectModel.titleEng">
{{'Please fill in information' | translate}}
</div>
</div>
<div *ngIf="currentarticleIdTab === 3" id="card-type-con-titleChina-3" role="tabpanel"
aria-labelledby="card-type-item-con-titleChina-3" class="" style="background-color: rgb(255, 255, 255);">
<textarea [(ngModel)]="selectModel.titleChina" rows="5" cols="50"
style="max-height: 200px; overflow-y: auto; width: 100%;">
</textarea>
<div class="text-danger" *ngIf="!selectModel.titleChina">
{{'Please fill in information' | translate}}
</div>
</div>
</div>
<!-- <div class="xl:col-span-6 col-span-12">
<label for="title" class="text-primary mt-4 font-bold font-14">{{'ชื่อหัวข้อบทความ' | translate}}</label>
<input type="text" class="form-control" id="title" placeholder="" [(ngModel)]="selectModel.title">
<div class="text-danger" *ngIf="!selectModel.title">
{{'Please fill in information' | translate}}
</div>
</div> -->
<!-- <div class="xl:col-span-6 col-span-12">
<label for="lastModifiedDate" class="mt-4 font-bold font-14 text-primary">{{'วันที่เเก้ไขล่าสุด' | <label for="lastModifiedDate" class="mt-4 font-bold font-14 text-primary">{{'วันที่เเก้ไขล่าสุด' |
translate}}</label> translate}}</label>
<input type="datetime-local" class="form-control" id="lastModifiedDate" placeholder="" <input type="datetime-local" class="form-control" id="lastModifiedDate" placeholder=""
...@@ -255,7 +348,7 @@ ...@@ -255,7 +348,7 @@
<div class="text-danger" *ngIf="!selectModel.lastModifiedDate"> <div class="text-danger" *ngIf="!selectModel.lastModifiedDate">
{{'Please fill in information' | translate}} {{'Please fill in information' | translate}}
</div> </div>
</div> </div> -->
<!-- ย่อความ --> <!-- ย่อความ -->
<div class="xl:col-span-12 col-span-12"> <div class="xl:col-span-12 col-span-12">
...@@ -286,18 +379,27 @@ ...@@ -286,18 +379,27 @@
<textarea [(ngModel)]="selectModel.excerpt" rows="5" cols="50" <textarea [(ngModel)]="selectModel.excerpt" rows="5" cols="50"
style="max-height: 200px; overflow-y: auto; width: 100%;"> style="max-height: 200px; overflow-y: auto; width: 100%;">
</textarea> </textarea>
<div class="text-danger" *ngIf="!selectModel.excerpt">
{{'Please fill in information' | translate}}
</div>
</div> </div>
<div *ngIf="currentExcerptTab === 2" id="card-type-con-excerpt-2" role="tabpanel" <div *ngIf="currentExcerptTab === 2" id="card-type-con-excerpt-2" role="tabpanel"
aria-labelledby="card-type-item-con-excerpt-2" class="" style="background-color: rgb(255, 255, 255);"> aria-labelledby="card-type-item-con-excerpt-2" class="" style="background-color: rgb(255, 255, 255);">
<textarea [(ngModel)]="selectModel.engexcerpt" rows="5" cols="50" <textarea [(ngModel)]="selectModel.excerptEng" rows="5" cols="50"
style="max-height: 200px; overflow-y: auto; width: 100%;"> style="max-height: 200px; overflow-y: auto; width: 100%;">
</textarea> </textarea>
<div class="text-danger" *ngIf="!selectModel.excerptEng">
{{'Please fill in information' | translate}}
</div>
</div> </div>
<div *ngIf="currentExcerptTab === 3" id="card-type-con-excerpt-3" role="tabpanel" <div *ngIf="currentExcerptTab === 3" id="card-type-con-excerpt-3" role="tabpanel"
aria-labelledby="card-type-item-con-excerpt-3" class="" style="background-color: rgb(255, 255, 255);"> aria-labelledby="card-type-item-con-excerpt-3" class="" style="background-color: rgb(255, 255, 255);">
<textarea [(ngModel)]="selectModel.zhexcerpt" rows="5" cols="50" <textarea [(ngModel)]="selectModel.excerptChina" rows="5" cols="50"
style="max-height: 200px; overflow-y: auto; width: 100%;"> style="max-height: 200px; overflow-y: auto; width: 100%;">
</textarea> </textarea>
<div class="text-danger" *ngIf="!selectModel.excerptChina">
{{'Please fill in information' | translate}}
</div>
</div> </div>
</div> </div>
...@@ -330,18 +432,27 @@ ...@@ -330,18 +432,27 @@
<quill-editor [(ngModel)]="selectModel.content" [modules]="quillConfig" <quill-editor [(ngModel)]="selectModel.content" [modules]="quillConfig"
[styles]="{'max-height': '200px','overflow-y': 'auto'}" theme="snow"> [styles]="{'max-height': '200px','overflow-y': 'auto'}" theme="snow">
</quill-editor> </quill-editor>
<div class="text-danger" *ngIf="!selectModel.content">
{{'Please fill in information' | translate}}
</div>
</div> </div>
<div *ngIf="currentContentTab === 2" id="card-type-con-content-2" role="tabpanel" <div *ngIf="currentContentTab === 2" id="card-type-con-content-2" role="tabpanel"
aria-labelledby="card-type-item-con-content-2" class="" style="background-color: rgb(255, 255, 255);"> aria-labelledby="card-type-item-con-content-2" class="" style="background-color: rgb(255, 255, 255);">
<quill-editor [(ngModel)]="selectModel.engcontent" [modules]="quillConfig" <quill-editor [(ngModel)]="selectModel.contentEng" [modules]="quillConfig"
[styles]="{'max-height': '200px','overflow-y': 'auto'}" theme="snow"> [styles]="{'max-height': '200px','overflow-y': 'auto'}" theme="snow">
</quill-editor> </quill-editor>
<div class="text-danger" *ngIf="!selectModel.contentEng">
{{'Please fill in information' | translate}}
</div>
</div> </div>
<div *ngIf="currentContentTab === 3" id="card-type-con-content-3" role="tabpanel" <div *ngIf="currentContentTab === 3" id="card-type-con-content-3" role="tabpanel"
aria-labelledby="card-type-item-con-content-3" class="" style="background-color: rgb(255, 255, 255);"> aria-labelledby="card-type-item-con-content-3" class="" style="background-color: rgb(255, 255, 255);">
<quill-editor [(ngModel)]="selectModel.zhcontent" [modules]="quillConfig" <quill-editor [(ngModel)]="selectModel.contentChina" [modules]="quillConfig"
[styles]="{'max-height': '200px','overflow-y': 'auto'}" theme="snow"> [styles]="{'max-height': '200px','overflow-y': 'auto'}" theme="snow">
</quill-editor> </quill-editor>
<div class="text-danger" *ngIf="!selectModel.contentChina">
{{'Please fill in information' | translate}}
</div>
</div> </div>
</div> </div>
...@@ -353,8 +464,10 @@ ...@@ -353,8 +464,10 @@
(click)="closeDialog()"> (click)="closeDialog()">
{{'Cancel' | translate}} {{'Cancel' | translate}}
</button> </button>
<button type="button" (click)="save()" class="ti-btn bg-primary text-white !font-medium">{{'Save' | <button type="button" (click)="save()" class="ti-btn bg-primary text-white !font-medium"
translate}} [class.ti-btn-disabled]="!selectModel.title||!selectModel.author||!selectModel.content||!selectModel.excerpt||!selectModel.endDate"
[disabled]="!selectModel.title||!selectModel.author||!selectModel.content||!selectModel.excerpt||!selectModel.endDate">
{{'Save'| translate}}
</button> </button>
</mat-dialog-actions> </mat-dialog-actions>
</ng-template> </ng-template>
......
...@@ -11,7 +11,7 @@ import { CommonModule } from '@angular/common'; ...@@ -11,7 +11,7 @@ import { CommonModule } from '@angular/common';
import { FileUploadModule } from 'ng2-file-upload'; import { FileUploadModule } from 'ng2-file-upload';
import { FileItem, FileUploader, ParsedResponseHeaders } from "ng2-file-upload"; import { FileItem, FileUploader, ParsedResponseHeaders } from "ng2-file-upload";
import { environment } from '../../../../environments/environment'; import { environment } from '../../../../environments/environment';
import { TokenService } from '../../../shared/services/token.service' import { TokenService } from '../../../shared/services/token.service';
import { ArticleModel } from '../../models/article.model'; import { ArticleModel } from '../../models/article.model';
import { ArticleService } from '../../services/article.service'; import { ArticleService } from '../../services/article.service';
import { QuillModule } from 'ngx-quill'; import { QuillModule } from 'ngx-quill';
...@@ -30,7 +30,7 @@ import { MatDialog, MatDialogModule } from '@angular/material/dialog'; ...@@ -30,7 +30,7 @@ import { MatDialog, MatDialogModule } from '@angular/material/dialog';
RouterModule, RouterModule,
FileUploadModule, FileUploadModule,
QuillModule, QuillModule,
MatDialogModule MatDialogModule,
], ],
templateUrl: './article-manage.component.html', templateUrl: './article-manage.component.html',
styleUrl: './article-manage.component.css', styleUrl: './article-manage.component.css',
...@@ -38,24 +38,19 @@ import { MatDialog, MatDialogModule } from '@angular/material/dialog'; ...@@ -38,24 +38,19 @@ import { MatDialog, MatDialogModule } from '@angular/material/dialog';
export class ArticleManageComponent { export class ArticleManageComponent {
quillConfig = { quillConfig = {
toolbar: [ toolbar: [
['link'], // เพิ่มปุ่มลิงก์ ['link'],
['bold', 'italic', 'underline', 'strike'], // toggled buttons ['bold', 'italic', 'underline', 'strike'],
['blockquote', 'code-block'], ['blockquote', 'code-block'],
[{ 'header': 1 }, { 'header': 2 }],
[{ 'header': 1 }, { 'header': 2 }], // custom button values
[{ 'list': 'ordered' }, { 'list': 'bullet' }], [{ 'list': 'ordered' }, { 'list': 'bullet' }],
[{ 'script': 'sub' }, { 'script': 'super' }], // superscript/subscript [{ 'script': 'sub' }, { 'script': 'super' }],
[{ 'indent': '-1' }, { 'indent': '+1' }], // outdent/indent [{ 'indent': '-1' }, { 'indent': '+1' }],
[{ 'direction': 'rtl' }], // text direction [{ 'direction': 'rtl' }],
[{ 'size': ['small', false, 'large', 'huge'] }],
[{ 'size': ['small', false, 'large', 'huge'] }], // custom dropdown
[{ 'header': [1, 2, 3, 4, 5, 6, false] }], [{ 'header': [1, 2, 3, 4, 5, 6, false] }],
[{ 'color': [] }, { 'background': [] }],
[{ 'color': [] }, { 'background': [] }], // dropdown with defaults from theme
[{ 'align': [] }], [{ 'align': [] }],
['clean'], // remove formatting button ['clean'],
] ]
}; };
...@@ -63,9 +58,10 @@ export class ArticleManageComponent { ...@@ -63,9 +58,10 @@ export class ArticleManageComponent {
@ViewChild('modalDetail') public modalDetail?: ElementRef; @ViewChild('modalDetail') public modalDetail?: ElementRef;
@ViewChild("articleModel") articleModel: any; @ViewChild("articleModel") articleModel: any;
@ViewChild('profileChangeInput') profileChangeInputRef!: ElementRef; @ViewChild('profileChangeInput') profileChangeInputRef!: ElementRef;
dialogRef: any dialogRef: any;
currentContentTab: number = 1; currentContentTab: number = 1;
currentExcerptTab: number = 1; currentExcerptTab: number = 1;
currentarticleIdTab: number = 1;
action = "new"; action = "new";
allSelected = false; allSelected = false;
...@@ -74,8 +70,6 @@ export class ArticleManageComponent { ...@@ -74,8 +70,6 @@ export class ArticleManageComponent {
filterList: ArticleModel[] = []; filterList: ArticleModel[] = [];
selectModel: ArticleModel = new ArticleModel(); selectModel: ArticleModel = new ArticleModel();
selectedItems = new Map<string, boolean>(); selectedItems = new Map<string, boolean>();
// empList: ArticleModel[] = [];
// descName = 'engName';
pageIndex = 0; pageIndex = 0;
uploaderProfile: FileUploader | undefined; uploaderProfile: FileUploader | undefined;
uploadErrorMsg: string = ""; uploadErrorMsg: string = "";
...@@ -96,12 +90,16 @@ export class ArticleManageComponent { ...@@ -96,12 +90,16 @@ export class ArticleManageComponent {
_searchTerm = ""; _searchTerm = "";
constructor(private articleService: ArticleService, public translate: TranslateService, private tokenService: TokenService, private router: Router, private dialog: MatDialog,) { constructor(
private articleService: ArticleService,
public translate: TranslateService,
private tokenService: TokenService,
private router: Router,
private dialog: MatDialog,
) {
this.uploadConfig(); this.uploadConfig();
} }
uploadConfig() { uploadConfig() {
this.uploaderProfile = new FileUploader({ this.uploaderProfile = new FileUploader({
...@@ -138,7 +136,7 @@ export class ArticleManageComponent { ...@@ -138,7 +136,7 @@ export class ArticleManageComponent {
this.uploaderProfile.onCompleteItem = ( this.uploaderProfile.onCompleteItem = (
item: FileItem, item: FileItem,
response: string, response: string,
status: number, publish: number,
headers: ParsedResponseHeaders headers: ParsedResponseHeaders
) => { ) => {
if (item.isSuccess) { if (item.isSuccess) {
...@@ -154,30 +152,26 @@ export class ArticleManageComponent { ...@@ -154,30 +152,26 @@ export class ArticleManageComponent {
}; };
} }
// getArticle() {
// this.articleService.getList().subscribe({
// next: (response: ArticleModel[]) => {
// this.itemsList = response.map((x: any) => new ArticleModel(x, this.translate));
// console.log('ข้อมูลบริษัท (itemsList)', this.itemsList);
// this.updatePagedItems();
// },
// error: (error) => {
// console.error('error cant get company', error);
// swal("ข้อผิดพลาด", "ไม่สามารถดึงข้อมูลบริษัทได้", "error");
// }
// });
// }
getArticle() { getArticle() {
this.articleService.getList().subscribe({ this.articleService.getList().subscribe({
next: (response: ArticleModel[]) => { next: (response: ArticleModel[]) => {
this.itemsList = response.map((x: any) => { this.itemsList = response.map((x: any) => {
const article = new ArticleModel(x, this.translate); const article = new ArticleModel(x, this.translate);
// แปลง createdDate
if (x.createdDate) { if (x.createdDate) {
article.createdDate = this.formatDateToISOString(new Date(x.createdDate)); article.createdDate = this.formatDateToISOString(new Date(x.createdDate));
} }
// แปลง lastModifiedDate
if (x.lastModifiedDate) { if (x.lastModifiedDate) {
article.lastModifiedDate = this.formatDateToISOString(new Date(x.lastModifiedDate)); article.lastModifiedDate = this.formatDateToISOString(new Date(x.lastModifiedDate));
} }
// แปลง endDate ที่มาจาก Backend (ISOZ) ให้เป็น YYYY-MM-DDTHH:mm สำหรับ Input
if (x.endDate) {
const endDateObj = new Date(x.endDate);
article.endDate = this.formatDateToISOString(endDateObj);
} else {
article.endDate = '';
}
return article; return article;
}); });
console.log('ข้อมูลบทความ (itemsList)', this.itemsList); console.log('ข้อมูลบทความ (itemsList)', this.itemsList);
...@@ -202,8 +196,9 @@ export class ArticleManageComponent { ...@@ -202,8 +196,9 @@ export class ArticleManageComponent {
x.title?.toLowerCase().indexOf(v.toLowerCase()) !== -1 || x.title?.toLowerCase().indexOf(v.toLowerCase()) !== -1 ||
x.content?.toLowerCase().indexOf(v.toLowerCase()) !== -1 || x.content?.toLowerCase().indexOf(v.toLowerCase()) !== -1 ||
x.excerpt?.toLowerCase().indexOf(v.toLowerCase()) !== -1 || x.excerpt?.toLowerCase().indexOf(v.toLowerCase()) !== -1 ||
x.author?.toLowerCase().indexOf(v.toLowerCase()) !== -1 x.author?.toLowerCase().indexOf(v.toLowerCase()) !== -1 ||
// x.getStatus().toLowerCase().indexOf(v.toLowerCase()) !== -1 x.publish.toString().indexOf(v.toLowerCase()) !== -1 ||
x.endDate?.toLowerCase().indexOf(v.toLowerCase()) !== -1 // เพิ่ม filter สำหรับ endDate ด้วย
); );
} }
...@@ -230,39 +225,50 @@ export class ArticleManageComponent { ...@@ -230,39 +225,50 @@ export class ArticleManageComponent {
new() { new() {
this.action = 'add'; this.action = 'add';
this.selectModel = new ArticleModel(); this.selectModel = new ArticleModel(); // Constructor จะตั้งค่าเริ่มต้นให้ properties ต่างๆ
// this.selectModel.status = 1;
this.selectModel.excerpt = ""; this.selectModel.excerpt = "";
this.selectModel.picture = ""; this.selectModel.picture = "";
this.selectModel.title = ""; this.selectModel.title = "";
this.selectModel.articleId = ""; this.selectModel.articleId = "";
this.selectModel.content = ""; this.selectModel.content = "";
this.selectModel.author = ""; this.selectModel.author = "";
this.selectModel.createdDate = new Date().toISOString(); this.selectModel.publish = 0; // ตั้งค่าเริ่มต้น publish เป็น 0 (unactive)
const now = new Date(); const now = new Date();
this.selectModel.createdDate = this.formatDateToISOString(now); this.selectModel.createdDate = this.formatDateToISOString(now); // ตั้งค่า createdDate เป็นเวลาปัจจุบัน (YYYY-MM-DDTHH:mm)
this.selectModel.lastModifiedDate = this.formatDateToISOString(now); this.selectModel.lastModifiedDate = this.formatDateToISOString(now); // ตั้งค่า lastModifiedDate เป็นเวลาปัจจุบัน (YYYY-MM-DDTHH:mm)
this.selectModel.endDate = ''; // ตั้งค่า endDate เป็น string ว่าง เพื่อให้ Input ว่างเปล่าตอนสร้างใหม่
} }
view(item: ArticleModel) { view(item: ArticleModel) {
this.action = 'edit'; this.action = 'edit';
this.selectModel = new ArticleModel(item); this.selectModel = new ArticleModel(item); // โหลดค่า raw string จาก item
console.log(this.selectModel); console.log(this.selectModel);
// แปลง createdDate
if (this.selectModel.createdDate) { if (this.selectModel.createdDate) {
const createdDateObj = new Date(this.selectModel.createdDate); const createdDateObj = new Date(this.selectModel.createdDate);
this.selectModel.createdDate = this.formatDateToISOString(createdDateObj); this.selectModel.createdDate = this.formatDateToISOString(createdDateObj);
} }
// แปลง lastModifiedDate
if (this.selectModel.lastModifiedDate) { if (this.selectModel.lastModifiedDate) {
const lastModifiedDateObj = new Date(this.selectModel.lastModifiedDate); const lastModifiedDateObj = new Date(this.selectModel.lastModifiedDate);
this.selectModel.lastModifiedDate = this.formatDateToISOString(lastModifiedDateObj); this.selectModel.lastModifiedDate = this.formatDateToISOString(lastModifiedDateObj);
} else { } else {
if (this.selectModel.createdDate) { if (this.selectModel.createdDate) {
this.selectModel.lastModifiedDate = this.selectModel.createdDate; this.selectModel.lastModifiedDate = this.selectModel.createdDate;
} }
}
// แปลง endDate ที่มาจาก Backend (ISOZ) ให้เป็น YYYY-MM-DDTHH:mm สำหรับ Input
if (this.selectModel.endDate) {
const endDateObj = new Date(this.selectModel.endDate);
this.selectModel.endDate = this.formatDateToISOString(endDateObj);
} else {
this.selectModel.endDate = ''; // หาก Backend ส่ง null หรือไม่มี endDate มา ให้ตั้งค่าเป็น string ว่าง
} }
} }
// เมธอดนี้ไม่ได้ถูกเรียกใช้แล้ว (หรือควรจะถูกลบ)
private formatDatesForDatetimeLocal(articleModel: ArticleModel): void { private formatDatesForDatetimeLocal(articleModel: ArticleModel): void {
if (articleModel.createdDate) { if (articleModel.createdDate) {
articleModel.createdDate = articleModel.createdDate.substring(0, 16); articleModel.createdDate = articleModel.createdDate.substring(0, 16);
...@@ -280,22 +286,63 @@ export class ArticleManageComponent { ...@@ -280,22 +286,63 @@ export class ArticleManageComponent {
icon: "warning", icon: "warning",
dangerMode: false, dangerMode: false,
buttons: ["ยกเลิก", "ยืนยัน"], buttons: ["ยกเลิก", "ยืนยัน"],
}) }).then((willSave: any) => {
.then((willSave: any) => { if (willSave) {
if (willSave) { // --- ส่วนสำคัญ: แปลงวันที่ก่อนส่งไป Backend (ให้เป็น ISOZ) ---
this.articleService.postArticle(this.selectModel).subscribe(result => { let createdDateToSend: string | null = null;
console.log(result); if (this.selectModel.createdDate) {
swal("บันทึกสำเร็จ!!", "บันทึกข้อมูลสมาชิก", "success"); createdDateToSend = new Date(this.selectModel.createdDate).toISOString();
this.ngOnInit();
this.childModal?.nativeElement.click();
this.updateMinDate();
this.closeDialog();
}, error => {
console.error("เกิดข้อผิดพลาดในการบันทึก/อัปเดต:", error);
swal("ข้อผิดพลาด!!", "ไม่สามารถบันทึก/อัปเดตข้อมูลได้", "error");
});
} }
});
let lastModifiedDateToSend: string | null = null;
if (this.selectModel.lastModifiedDate) {
lastModifiedDateToSend = new Date(this.selectModel.lastModifiedDate).toISOString();
}
let endDateToSend: string | null = null;
if (this.selectModel.endDate) {
if (this.selectModel.endDate !== '') { // ตรวจสอบว่าไม่ใช่ string ว่าง ก่อนแปลง
endDateToSend = new Date(this.selectModel.endDate).toISOString();
}
}
const articleDataToSave: Partial<ArticleModel> = {
articleId: this.selectModel.articleId,
title: this.selectModel.title,
titleEng: this.selectModel.titleEng,
titleChina: this.selectModel.titleChina,
content: this.selectModel.content,
contentEng: this.selectModel.contentEng,
contentChina: this.selectModel.contentChina,
excerpt: this.selectModel.excerpt,
excerptEng: this.selectModel.excerptEng,
excerptChina: this.selectModel.excerptChina,
category: this.selectModel.category,
author: this.selectModel.author,
picture: this.selectModel.picture,
createdDate: createdDateToSend, // <--- ใช้ค่าที่แปลงแล้ว
lastModifiedDate: lastModifiedDateToSend, // <--- ใช้ค่าที่แปลงแล้ว
endDate: endDateToSend, // <--- ใช้ค่าที่แปลงแล้ว
publish: this.selectModel.publish,
viewCount: this.selectModel.viewCount,
companyId: this.selectModel.companyId.map(company => ({
id: company.companyId, // สมมติว่า CompanyModel มี property ชื่อ companyId ที่เป็น ID
})) as any
};
this.articleService.postArticle(articleDataToSave).subscribe(result => {
console.log(result);
swal("บันทึกสำเร็จ!!", "บันทึกข้อมูลสมาชิก", "success");
this.ngOnInit();
this.childModal?.nativeElement.click();
this.updateMinDate(); // เรียกเพื่อให้ lastModifiedDate อัปเดตหลังจากบันทึก
this.closeDialog();
}, error => {
console.error("เกิดข้อผิดพลาดในการบันทึก/อัปเดต:", error);
swal("ข้อผิดพลาด!!", "ไม่สามารถบันทึก/อัปเดตข้อมูลได้", "error");
});
}
});
} }
updatePagedItems() { updatePagedItems() {
...@@ -374,41 +421,122 @@ export class ArticleManageComponent { ...@@ -374,41 +421,122 @@ export class ArticleManageComponent {
}); });
} }
adjustSelect(status: number) { // เพิ่ม status เข้ามาในพารามิเตอร์ openDialog() {
this.dialogRef = this.dialog.open(this.articleModel, {
width: '1100px',
disableClose: false,
});
}
closeDialog() {
this.dialogRef.close();
}
triggerFileInput(): void {
if (this.profileChangeInputRef) {
this.profileChangeInputRef.nativeElement.click();
}
}
// ฟังก์ชันแปลง Date object เป็น YYYY-MM-DDTHH:mm สำหรับ input type="datetime-local"
private formatDateToISOString(date: Date): string {
const year = date.getFullYear();
const month = (date.getMonth() + 1).toString().padStart(2, '0');
const day = date.getDate().toString().padStart(2, '0');
const hours = date.getHours().toString().padStart(2, '0');
const minutes = date.getMinutes().toString().padStart(2, '0');
return `${year}-${month}-${day}T${hours}:${minutes}`;
}
updateMinDate() {
if (this.selectModel.createdDate) {
const created = new Date(this.selectModel.createdDate);
let modified = this.selectModel.lastModifiedDate ? new Date(this.selectModel.lastModifiedDate) : null;
if (modified && modified < created) {
this.selectModel.lastModifiedDate = this.formatDateToISOString(created);
} else if (!modified) {
this.selectModel.lastModifiedDate = this.formatDateToISOString(created);
}
// ลบ logic สำหรับ endDate ออกแล้ว
}
}
adjustSelect(statusValue: number): void {
let title = "คุณแน่ใจหรือไม่?"; let title = "คุณแน่ใจหรือไม่?";
let companyInfo = ''; let articlesInfo = '';
const selectedCompanies: ArticleModel[] = []; const selectedArticles: ArticleModel[] = [];
this.selectedItems.forEach((isSelected, articleId) => { this.selectedItems.forEach((isSelected, articleId) => {
if (isSelected) { if (isSelected) {
const company = this.itemsList.find(c => c.articleId === articleId); const article = this.itemsList.find(a => a.articleId === articleId);
if (company) { if (article) {
companyInfo += `${this.translate.instant('ชื่อบริษัท')}: ${company.title}\n`; articlesInfo += `${this.translate.instant('ชื่อบทความ')}: ${article.title}\n`;
selectedCompanies.push(company); selectedArticles.push(article);
} }
} }
}); });
if (selectedCompanies.length === 0) { if (selectedArticles.length === 0) {
swal("ข้อผิดพลาด", "กรุณาเลือกบริษัทที่ต้องการปรับสถานะ", "warning"); swal("ข้อผิดพลาด", "กรุณาเลือกบทความที่ต้องการปรับสถานะ", "warning");
return; return;
} }
swal({ swal({
title: title, title: title,
text: companyInfo, text: articlesInfo,
icon: "warning", icon: "warning",
dangerMode: false, dangerMode: false,
buttons: ["ยกเลิก", "ยืนยัน"], buttons: ["ยกเลิก", "ยืนยัน"],
}) })
.then((willAdjust: any) => { .then((willAdjust: any) => {
if (willAdjust) { if (willAdjust) {
const updatePromises = selectedCompanies.map(company => { const updatePromises = selectedArticles.map(article => {
company.publish = status; // เปลี่ยนจาก publish เป็น status // --- ส่วนสำคัญ: แปลงวันที่ก่อนส่งไป Backend (ให้เป็น ISOZ) ---
return this.articleService.postArticle(company).toPromise() let createdDateToSend: string | null = null;
if (article.createdDate) {
createdDateToSend = new Date(article.createdDate).toISOString();
}
let lastModifiedDateToSend: string | null = null;
if (article.lastModifiedDate) {
lastModifiedDateToSend = new Date(article.lastModifiedDate).toISOString();
}
let endDateToSend: string | null = null;
if (article.endDate) {
if (article.endDate !== '') { // ตรวจสอบว่าไม่ใช่ string ว่าง ก่อนแปลง
endDateToSend = new Date(article.endDate).toISOString();
}
}
const articleDataToSend: Partial<ArticleModel> = {
articleId: article.articleId,
title: article.title,
titleEng: article.titleEng,
titleChina: article.titleChina,
content: article.content,
contentEng: article.contentEng,
contentChina: article.contentChina,
excerpt: article.excerpt,
excerptEng: article.excerptEng,
excerptChina: article.excerptChina,
category: article.category,
author: article.author,
picture: article.picture,
createdDate: createdDateToSend, // <--- ใช้ค่าที่แปลงแล้ว
lastModifiedDate: lastModifiedDateToSend, // <--- ใช้ค่าที่แปลงแล้ว
endDate: endDateToSend, // <--- ใช้ค่าที่แปลงแล้ว
publish: statusValue, // อัปเดตค่า publish ที่นี่
viewCount: article.viewCount,
companyId: article.companyId.map(company => ({
id: company.companyId, // สมมติว่า CompanyModel มี property ชื่อ companyId ที่เป็น ID
})) as any
};
return this.articleService.postArticle(articleDataToSend).toPromise()
.then(() => true) .then(() => true)
.catch(error => { .catch(error => {
console.error(`Error updating publish for company ${company.articleId}:`, error); console.error(`Error updating publish for article ${article.articleId}:`, error);
return false; return false;
}); });
}); });
...@@ -429,41 +557,4 @@ export class ArticleManageComponent { ...@@ -429,41 +557,4 @@ export class ArticleManageComponent {
} }
}); });
} }
openDialog() { }
this.dialogRef = this.dialog.open(this.articleModel, { \ No newline at end of file
width: '1100px',
disableClose: false,
});
}
closeDialog() {
this.dialogRef.close()
}
triggerFileInput(): void {
if (this.profileChangeInputRef) {
this.profileChangeInputRef.nativeElement.click();
}
}
private formatDateToISOString(date: Date): string {
const year = date.getFullYear();
const month = (date.getMonth() + 1).toString().padStart(2, '0');
const day = date.getDate().toString().padStart(2, '0');
const hours = date.getHours().toString().padStart(2, '0');
const minutes = date.getMinutes().toString().padStart(2, '0');
return `${year}-${month}-${day}T${hours}:${minutes}`;
}
updateMinDate() {
if (this.selectModel.createdDate) {
const created = new Date(this.selectModel.createdDate);
let modified = this.selectModel.lastModifiedDate ? new Date(this.selectModel.lastModifiedDate) : null;
if (modified && modified < created) {
// เมื่อมีการปรับค่า ให้แน่ใจว่าถูกจัดรูปแบบเป็น 24 ชั่วโมง
this.selectModel.lastModifiedDate = this.formatDateToISOString(created);
} else if (!modified) {
// เมื่อมีการตั้งค่าเริ่มต้น ให้แน่ใจว่าถูกจัดรูปแบบเป็น 24 ชั่วโมง
this.selectModel.lastModifiedDate = this.formatDateToISOString(created);
}
}
}
}
...@@ -84,6 +84,31 @@ export const admin: Routes = [ ...@@ -84,6 +84,31 @@ export const admin: Routes = [
}, },
//////////////MyPortal///////////////// //////////////MyPortal/////////////////
{ {
path: 'portal-category-list',
loadComponent: () =>
import('./myportal/portal-category-list/portal-category-list.component').then((m) => m.PortalCategoryListComponent),
},
{
path: 'view-list-excel',
loadComponent: () =>
import('./myportal/view-list-excel/view-list-excel.component').then((m) => m.ViewListExcelComponent),
},
{
path: 'view-list-doc',
loadComponent: () =>
import('./myportal/view-list-doc/view-list-doc.component').then((m) => m.ViewListDocComponent),
},
{
path: 'view-list-course',
loadComponent: () =>
import('./myportal/view-list-course/view-list-course.component').then((m) => m.ViewListCourseComponent),
},
{
path: 'view-list-widgets',
loadComponent: () =>
import('./myportal/view-list-widgets/view-list-widgets.component').then((m) => m.ViewListWidgetsComponent),
},
{
path: 'excel-report', path: 'excel-report',
loadComponent: () => loadComponent: () =>
import('./myportal/excel-report/excel-report.component').then((m) => m.ExcelReportComponent), import('./myportal/excel-report/excel-report.component').then((m) => m.ExcelReportComponent),
......
<div class="modal-header">
<h5 class="modal-title" id="editLabel">ข้อความแจ้งเตือน</h5>
<button type="button" class="close" (click)="activeModal.dismiss('dismiss')" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<ng-container *ngIf="innerHTML!=undefined then InnerHTML else Message"></ng-container>
<ng-template #Message>
<div class="modal-body">
{{message}}
</div>
</ng-template>
<ng-template #InnerHTML>
<div class="modal-body" [innerHTML]="innerHTML">
</div>
</ng-template>
\ No newline at end of file
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AlertModalComponent } from './alert-modal.component';
describe('AlertModalComponent', () => {
let component: AlertModalComponent;
let fixture: ComponentFixture<AlertModalComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ AlertModalComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(AlertModalComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, Input, OnInit } from '@angular/core';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
@Component({
selector: 'app-alert-modal',
templateUrl: './alert-modal.component.html',
styleUrls: ['./alert-modal.component.scss']
})
export class AlertModalComponent implements OnInit {
@Input() message: string = ""
@Input() innerHTML?: string
constructor(public activeModal: NgbActiveModal) { }
ngOnInit(): void {
}
}
<div class="modal-header">
<h5 class="modal-title" id="editLabel">ข้อความแจ้งเตือน</h5>
<button type="button" class="close" (click)="activeModal.dismiss('dismiss')" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
{{message}}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-info" (click)="activeModal.close('close')">
ยืนยัน
</button>
<button type="button" class="btn btn-danger" (click)="activeModal.dismiss('dismiss')">
ยกเลิก
</button>
</div>
\ No newline at end of file
import { Component, Input, OnInit } from '@angular/core';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
@Component({
selector: 'app-confirm-modal',
templateUrl: './confirm-modal.component.html',
styleUrls: ['./confirm-modal.component.scss']
})
export class ConfirmModalComponent implements OnInit {
@Input() message: string = "";
constructor(public activeModal: NgbActiveModal) { }
ngOnInit(): void {
}
}
<div class="p-4">
<img [src]="linkImage" alt="Image Preview" class="w-full h-auto max-w-full block mx-auto" />
<div class="mt-4 text-right">
<button
(click)="onClose()"
class="px-4 py-2 bg-gray-200 text-gray-800 rounded-md hover:bg-gray-300 transition-colors duration-200"
>
ปิด
</button>
</div>
</div>
\ No newline at end of file
import { Component, OnInit, Inject } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; // นำเข้า MAT_DIALOG_DATA และ MatDialogRef
@Component({
selector: 'app-open-image',
templateUrl: './open-image.component.html',
styleUrls: ['./open-image.component.scss']
})
export class OpenImageComponent implements OnInit {
linkImage: string = '';
constructor(
@Inject(MAT_DIALOG_DATA) public data: { linkImage: string },
public dialogRef: MatDialogRef<OpenImageComponent>
) { }
ngOnInit(): void {
if (this.data && this.data.linkImage) {
this.linkImage = this.data.linkImage;
}
}
onClose(): void {
this.dialogRef.close();
}
}
\ No newline at end of file
<app-page-header [title]="'รายการเอกสาร'" [activeTitle]="'ผู้ดูแลระบบ'" [title1]="'รายการเอกสาร'"></app-page-header>
<!-- <div class="row">
<div class="col-12">
<div class="card card-body">
<h4 class="card-title">รายการเอกสาร</h4>
<div class="row justify-content-center">
<div class="col-lg-4 col-md-6 col-sm-6 col-12" *ngFor="let c of testdata|slice: (page-1) * pageSize : (page-1) * pageSize + pageSize">
<div class="card border-border-2">
<div class="card-body text-center">
<img src="{{ c.img }}" class="rounded-circle border p-1" width="100">
<h3 class="card-title mt-3 mb-0">{{c.name}}</h3>
</div>
<div class="d-flex justify-content-between bg-light border-top p-3">
<div>
<span class="align-middle">จำนวนเอกสาร {{ c.document }} ฉบับ</span>
</div>
<div >
<button class="btn btn-info btn-sm text-nowrap" (click)="openView(c.id)">รายละเอียด</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div> -->
<div class="max-w-7xl mx-auto">
<div class="box p-4">
<h4 class="text-xl font-semibold text-gray-800 mb-6">รายการเอกสาร</h4>
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6">
<div class="bg-white rounded-xl shadow-lg overflow-hidden transform hover:scale-105 transition duration-300 ease-in-out"
*ngFor="let c of testdata|slice: (page-1) * pageSize : (page-1) * pageSize + pageSize">
<div class="p-8 text-center">
<div class="w-24 h-24 mx-auto rounded-full bg-green-100 flex items-center justify-center shadow-inner">
<img src="{{ c.img }}" class="" alt="">
</div>
<h3 class="text-2xl font-bold text-gray-800 mt-6 mb-2">{{c.name}}</h3>
</div>
<div class="flex justify-between items-center bg-gray-50 border-t border-gray-200 p-4">
<div>
<span class="text-sm text-gray-700">จำนวนเอกสาร {{ c.document }} ฉบับ</span>
</div>
<div>
<button
class="bg-primary inline-flex items-center px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white text-sm font-medium rounded-md shadow-md transition duration-150 ease-in-out focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-opacity-50"
(click)="openView(c.id)">
รายละเอียด
</button>
</div>
</div>
</div>
</div>
</div>
</div>
\ No newline at end of file
import { Component, OnInit } from '@angular/core';
import { Router, RouterModule } from '@angular/router';
import { ExcelService } from '../../../services/excel.service';
import { DocumentService } from '../../../services/document.service';
import { CourseService } from '../../../services/course.service';
import { WidgetService } from '../../../services/widgets.service';
import { CommonModule } from '@angular/common';
import { TranslateModule } from '@ngx-translate/core';
import { FormsModule } from '@angular/forms';
import { NgSelectModule } from '@ng-select/ng-select';
import { SharedModule } from '../../../../shared/shared.module';
@Component({
selector: 'app-portal-category-list',
templateUrl: './portal-category-list.component.html',
styleUrls: ['./portal-category-list.component.scss'],
standalone: true,
imports: [
CommonModule,
FormsModule,
RouterModule,
TranslateModule,
SharedModule,
],
})
export class PortalCategoryListComponent implements OnInit {
constructor(
private routes: Router,
private excelService: ExcelService, private documentService: DocumentService, private courseService: CourseService, private widgetService: WidgetService
) { }
page = 1;
pageSize = 10;
testdata: {
id: string;
img: String;
name: String;
details: String;
document: String;
}[] = [];
ngOnInit() {
this.testdata = [
{
id: '1',
img: "assets/images/icons/excel.png",
name: "Excel",
details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
document: "0"
},
{
id: '2',
img: "assets/images/icons/document.png",
name: "Document",
details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
document: "0"
},
{
id: '3',
img: "assets/images/icons/course.png",
name: "Course",
details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
document: "0"
},
{
id: '4',
img: "assets/images/icons/widget.png",
name: "Widgets",
details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
document: "0"
},
{
id: '5',
img: "assets/images/faces/1.jpg",
name: "BI",
details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
document: "0"
},
];
this.getListCount();
}
async getListCount() {
try {
const countExcel = await this.excelService.getCountContent().toPromise();
const countDoc = await this.documentService.getCountContent().toPromise();
const countCourse = await this.courseService.getCountContent().toPromise();
const countWidgets = await this.widgetService.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()
} else if (i == 3) {
x.document = countWidgets!.toString()
}
})
} catch (error) {
console.error('Error loading data:', error);
}
}
openView(id: string) {
if (id == '1') {
this.routes.navigate(['/admin/view-list-excel']);
} else if (id == '2') {
this.routes.navigate(['/admin/view-list-doc']);
} else if (id == '3') {
this.routes.navigate(['/admin/view-list-course']);
} else if (id == '4') {
this.routes.navigate(['/admin/view-list-widgets']);
}
}
}
<app-page-header [title]="'รายการหลักสูตร'" [activeTitle]="'ผู้ดูแลระบบ'"
[title1]="'รายการหลักสูตร'"></app-page-header>
<!-- <div class="row" *ngIf="checkType == '1'">
<div class="col-12">
<div class="card card-body">
<h4 class="card-title">รายการหลักสูตร</h4>
<div class="d-flex mb-3 mt-3">
<input type="text" class="form-control w-25" placeholder="ค้นหา" [(ngModel)]="search" >
</div>
<div class="table-responsive">
<table class="table table-striped mb-0 no-wrap v-middle ">
<thead class="bg-info text-white">
<tr>
<th class="text-center" scope="col">#</th>
<th scope="col">รูปภาพ</th>
<th scope="col">ชื่อ</th>
<th scope="col">รายละเอียด</th>
<th scope="col">ประเภทหลักสูตร</th>
<th scope="col">ลิงค์</th>
<th scope="col">สถานะ</th>
<th scope="col" class="text-center">วันที่อัพโหลด</th>
<th scope="col" class="text-center">วันล่าสุดดาวน์โหลด</th>
<th scope="col" class="text-center">จำนวนดาวน์โหลด</th>
<th scope="col" *ngIf="checkType == '1'"></th>
</tr>
</thead>
<tbody>
<tr *ngIf="listCourse.length == 0">
<td colspan="{{checkType == '1' ? '9' : '8'}}" class="text-center">ไม่พบข้อมูล</td>
</tr>
<tr *ngFor="let data of filterListCourse() | slice: (page-1) * pageSize : (page-1) * pageSize + pageSize ; let i = index">
<td class="text-center">{{i+1}}</td>
<td><img width="100" class="border p-1" src="{{data.getImage()}}" (click)="openDialog(data.getImage())"></td>
<td>{{ data.thName }}</td>
<td class="text-wrap">{{ data.thDesc }}</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.uploadDate}} {{data.uploadTime}}</td>
<td class="text-center">{{data.downloadDate}} {{data.downloadTime}}</td>
<td class="text-center">{{data.dwTime}} ครั้ง</td>
<td *ngIf="checkType == '1'">
<button type="button" class="btn btn-circle btn-danger rounded-circle btn-sm mr-2" (click)="deleteFile(data)" placement="top" ngbTooltip="ลบ"><i class="fas fa-trash-alt"></i></button>
</td>
</tr>
</tbody>
</table>
</div>
<div class="d-flex justify-content-end py-2">
<select class="custom-select m-r-5" style="width: auto" [(ngModel)]="pageSize" (ngModelChange)="page">
<option [ngValue]="10">รายการต่อหน้า: 10</option>
<option [ngValue]="50">รายการต่อหน้า: 50</option>
<option [ngValue]="100">รายการต่อหน้า: 100</option>
</select>
<ngb-pagination [(page)]="page" [pageSize]="pageSize" [collectionSize]="listCourse.length" [maxSize]="3" [rotate]="true">
<ng-template ngbPaginationPrevious>ก่อนหน้า</ng-template>
<ng-template ngbPaginationNext>ถัดไป</ng-template>
</ngb-pagination>
</div>
</div>
</div>
</div> -->
<!-- <div class="row" *ngIf="checkType != '1'">
<div class="col-12">
<div class="py-3">
<input type="text" class="form-control w-25" placeholder="ค้นหา" [(ngModel)]="search">
</div>
</div>
<div class="col-sm-6 col-md-4 col-lg-4 mb-3" *ngFor="let data of filterListCourse()">
<div class="card border-5 border border-course h-100 shadow">
<div class=" p-2 border-5">
<img width="100" class="card-img-top cover" src="{{data.getImage()}}" (click)="openDialog(data.getImage())">
</div>
<div class="card-body">
<h4 class="card-title">{{ data.thName }}</h4>
<p class="card-text ">{{ data.thDesc }}</p>
<p class="text-info pointer mb-0" (click)="downloadFile(data.courseId)"><i class="fas fa-download mr-1"></i>
ดาวน์โหลด <small class="text-muted" *ngIf="data.dwTime > 0">{{coverDate(data.downloadDate)}}
{{data.downloadTime}} ( {{data.dwTime}} ครั้ง)</small></p>
<p class="text-info pointer mb-0" (click)="openLink(data.link1)"><i class="fas fa-link mr-1"></i>
ตัวอย่างวิธีใช้งาน</p>
</div>
<div class="card-footer border-bottom-5">
<small class="text-muted">วันที่อัพโหลด {{coverDate(data.uploadDate)}} {{data.uploadTime}}</small>
</div>
</div>
</div>
</div> -->
<div class="box p-4">
<div *ngIf="checkType != '1'" class="flex flex-wrap -mx-2">
<div class="w-full">
<div class="py-3 px-2">
<input type="text"
class="block w-full md:w-1/4 px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition-all duration-200 shadow-sm"
placeholder="ค้นหา" [(ngModel)]="search" />
</div>
</div>
<div class="w-full sm:w-1/2 lg:w-1/3 xl:w-1/3 px-2 mb-4" *ngFor="let data of filterListCourse()">
<div
class="group bg-white rounded-lg overflow-hidden shadow-lg border-4 border-blue-600 h-full flex flex-col transform transition-all duration-300 ease-in-out hover:scale-[1.02] hover:shadow-xl">
<div class="p-4 flex justify-center items-center flex-shrink-0">
<img
class="w-full h-full object-cover rounded-md shadow-md transform transition-transform duration-300 group-hover:scale-105 cursor-pointer"
style="width: 400px; height: 200px; max-width: 100%;" src="{{ data.getImage() }}" alt="{{ data.thName }}"
(click)="openDialog(data.getImage())" />
</div>
<div class="p-4 flex-grow">
<span class="text-xl font-semibold text-gray-800 mb-2" style="font-size: 18px;">
{{ data.thName }}
</span>
<p class="text-gray-700 text-sm mb-3">{{ data.thDesc }}</p>
<div class="mb-0 flex items-center justify-center sm:justify-start gap-2 w-1/2 mt-5">
<i class="fa fa-link text-blue-600 text-base flex-shrink-0" aria-hidden="true"></i>
<input type="text" [value]="'ตัวอย่างวิธีใช้งาน'" (click)="openLink(data.link1)"
style="background-color: rgb(76, 117, 207, 1); color: #FFF;"
class="flex-grow border border-gray-300 rounded-md px-2 py-1 text-blue-600 cursor-pointer hover:underline focus:outline-none focus:ring-1 focus:ring-blue-500 transition-all duration-200"
readonly />
</div>
<div class="mb-2 flex items-center justify-center sm:justify-start gap-2 w-1/2">
<i class="fa fa-download text-blue-600 text-base flex-shrink-0" aria-hidden="true"></i>
<input type="text" [value]="'ดาวน์โหลด'" (click)="downloadFile(data.courseId)"
style="background-color: rgb(34, 197, 94, 1); color: #FFF;"
class="flex-grow border border-gray-300 rounded-md px-2 py-1 text-blue-600 cursor-pointer hover:underline focus:outline-none focus:ring-1 focus:ring-blue-500 transition-all duration-200"
readonly />
<small class="text-gray-500 text-xs ml-auto hidden sm:block flex-shrink-0" *ngIf="data.dwTime > 0">{{
coverDate(data.downloadDate) }} {{ data.downloadTime }} (
{{ data.dwTime }} ครั้ง)</small>
</div>
</div>
<div class="px-4 py-3 border-t border-gray-200 text-right flex-shrink-0">
<small class="text-gray-500 text-xs">วันที่อัพโหลด {{ coverDate(data.uploadDate) }}
{{ data.uploadTime }}</small>
</div>
</div>
</div>
</div>
</div>
\ No newline at end of file
import { Component, OnInit } from '@angular/core';
import { AlertModalComponent } from '../alert-modal/alert-modal.component';
import { NgbModal, NgbPaginationModule } from '@ng-bootstrap/ng-bootstrap';
import { CourseContentModel } from '../../../models/course-content.model';
import { CourseService } from '../../../services/course.service';
import { ActivatedRoute, RouterModule } from '@angular/router';
import { ConfirmModalComponent } from '../confirm-modal/confirm-modal.component';
import { OpenImageComponent } from '../open-image/open-image.component';
import { MatDialog, MatDialogModule } from '@angular/material/dialog';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { NgSelectModule } from '@ng-select/ng-select';
import { SharedModule } from '../../../../shared/shared.module';
import { TranslateModule } from '@ngx-translate/core';
import saveAs from 'file-saver';
@Component({
selector: 'app-view-list-course',
templateUrl: './view-list-course.component.html',
styleUrls: ['./view-list-course.component.scss'],
standalone: true,
imports: [
CommonModule,
FormsModule,
RouterModule,
NgSelectModule,
SharedModule,
MatDialogModule,
NgbPaginationModule,
TranslateModule,
],
})
export class ViewListCourseComponent implements OnInit {
page = 1;
pageSize = 10;
listCourse: CourseContentModel[] = []
dialogRef: any;
search: string = ''
checkType: string = '0'
constructor(private modalService: NgbModal, private courseService: CourseService, private activatedRoute: ActivatedRoute, private dialog: MatDialog,) {
this.activatedRoute.paramMap.subscribe(result => {
this.checkType = result.get("type")!;
});
}
openDialog(image: string) {
const dialogConfig = {
width: '750px',
disableClose: false,
data: {
linkImage: image
},
panelClass: 'my-dialog-img-preview',
};
this.dialogRef = this.dialog.open(OpenImageComponent, dialogConfig);
this.dialogRef.afterClosed().subscribe((result: any) => {
console.log('The dialog was closed', result);
}, (reason: any) => {
});
}
// openEmployeeModal(image: string) {
// const modalRef = this.modalService.open(OpenImageComponent, {
// centered: true,
// windowClass: 'my-dialog-img-preview'
// })
// modalRef.componentInstance.linkImage = image
// modalRef.result.then(result => {
// }, reason => {
// this.modalService.dismissAll()
// })
// }
async downloadFile(logId: string) {
try {
const data = await this.courseService.downloadFileContent(logId).toPromise();
if (data) {
saveAs(new Blob([data]), "file_download.json");
}
} catch (error) {
console.error('Error loading data:', error);
}
}
// 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() {
return this.listCourse.filter(x => x.thName.toLowerCase().includes(this.search.toLowerCase()) || x.engName.toLowerCase().includes(this.search.toLowerCase()))
}
async getListCourse() {
try {
const data = await this.courseService.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);
}
}
deleteFile(item: CourseContentModel) {
const modalRef = this.modalService.open(ConfirmModalComponent, {
centered: true,
backdrop: 'static',
})
modalRef.componentInstance.message = 'คุณต้องการลบข้อมูลหรือไม่'
modalRef.result.then(result => {
this.courseService.deleteCourseContent(item).subscribe(result => {
if (result) {
this.openAlertModal('ลบข้อมูลสำเร็จ')
this.getListCourse();
} else {
this.openAlertModal('ไม่สามารถลบข้อมูลได้')
}
}, error => {
this.openAlertModal(error.message)
})
}, reject => { })
}
ngOnInit() {
this.getListCourse();
}
openLink(url: string) {
window.open(url, "_blank");
}
openAlertModal(message?: string) {
const modalRef = this.modalService.open(AlertModalComponent, {
centered: true,
backdrop: 'static'
})
modalRef.componentInstance.message = message ? message : ""
modalRef.result.then(result => {
this.modalService.dismissAll()
}, reason => {
this.modalService.dismissAll()
})
}
coverDate(date: string) {
return date.split('-').reverse().join('/')
}
}
<app-page-header [title]="'รายการเอกสาร'" [activeTitle]="'ผู้ดูแลระบบ'"
[title1]="'รายการเอกสาร'"></app-page-header>
<!-- <div class="row" *ngIf="checkType == '1'">
<div class="col-12">
<div class="card card-body">
<h4 class="card-title">รายการเอกสาร</h4>
<div class="d-flex mb-3 mt-3">
<input type="text" class="form-control w-25" placeholder="ค้นหา" [(ngModel)]="search">
</div>
<div class="table-responsive">
<table class="table table-striped mb-0 no-wrap v-middle ">
<thead class="bg-info text-white">
<tr>
<th class="text-center" scope="col">#</th>
<th scope="col">รูปภาพ</th>
<th scope="col">ชื่อ</th>
<th scope="col">รายละเอียด</th>
<th scope="col" class="text-center">ลิงค์</th>
<th scope="col" class="text-center">ไฟล์ (ไทย)</th>
<th scope="col" class="text-center">ไฟล์ (อังกฤษ)</th>
<th scope="col" class="text-center">วันที่อัพโหลด</th>
<th scope="col" class="text-center">วันล่าสุดดาวน์โหลด</th>
<th scope="col" class="text-center">จำนวนดาวน์โหลด</th>
<th scope="col" *ngIf="checkType == '1'"></th>
</tr>
</thead>
<tbody>
<tr *ngIf="listDoc.length == 0">
<td colspan="{{checkType == '1' ? '9' : '10'}}" class="text-center">ไม่พบข้อมูล</td>
</tr>
<tr
*ngFor="let data of filterListDoc() | slice: (page-1) * pageSize : (page-1) * pageSize + pageSize ; let i = index">
<td class="text-center">{{i+1}}</td>
<td><img width="100" class="border p-1" src="{{data.getImage()}}" (click)="openDialog(data.getImage())">
</td>
<td>{{ data.thName }}</td>
<td>{{ data.thDesc }}</td>
<td class="text-center"><i class="fas fa-link pointer" (click)="openLink(data.link1)"></i></td>
<td class="text-center"> <i class="fas fa-download pointer" (click)="downloadFile(data.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.uploadDate}} {{data.uploadTime}}</td>
<td class="text-center">{{data.downloadDate}} {{data.downloadTime}}</td>
<td class="text-center">{{data.dwTime}} ครั้ง</td>
<td *ngIf="checkType == '1'">
<button type="button" class="btn btn-circle btn-danger rounded-circle btn-sm mr-2"
(click)="deleteFile(data)" placement="top" ngbTooltip="ลบ"><i class="fas fa-trash-alt"></i></button>
</td>
</tr>
</tbody>
</table>
</div>
<div class="d-flex justify-content-end py-2">
<select class="custom-select m-r-5" style="width: auto" [(ngModel)]="pageSize" (ngModelChange)="page">
<option [ngValue]="10">รายการต่อหน้า: 10</option>
<option [ngValue]="50">รายการต่อหน้า: 50</option>
<option [ngValue]="100">รายการต่อหน้า: 100</option>
</select>
<ngb-pagination [(page)]="page" [pageSize]="pageSize" [collectionSize]="listDoc.length" [maxSize]="3"
[rotate]="true">
<ng-template ngbPaginationPrevious>ก่อนหน้า</ng-template>
<ng-template ngbPaginationNext>ถัดไป</ng-template>
</ngb-pagination>
</div>
</div>
</div>
</div> -->
<!-- <div class="row" *ngIf="checkType != '1'">
<div class="col-12">
<div class="py-3">
<input type="text" class="form-control w-25" placeholder="ค้นหา" [(ngModel)]="search">
</div>
</div>
<div class="col-sm-6 col-md-4 col-lg-4 mb-3" *ngFor="let data of filterListDoc()">
<div class="card border-5 border border-doc h-100 shadow">
<div class=" p-2 border-5">
<img width="100" class="card-img-top cover" src="{{data.getImage()}}" (click)="openDialog(data.getImage())">
</div>
<div class="card-body">
<h4 class="card-title">{{ data.thName }}</h4>
<p class="card-text ">{{ data.thDesc }}</p>
<p class="text-info pointer mb-0" (click)="downloadFile(data.docId,'tha')"><i class="fas fa-download mr-1"></i>
ดาวน์โหลด (ไทย) <small class="text-muted" *ngIf="data.dwTime > 0">{{coverDate(data.downloadDate)}}
{{data.downloadTime}} ( {{data.dwTime}} ครั้ง)</small></p>
<p class="text-info pointer mb-0" (click)="downloadFile(data.docId,'eng')"><i class="fas fa-download mr-1"></i>
ดาวน์โหลด (อังกฤษ) <small class="text-muted" *ngIf="data.dwTime > 0">{{coverDate(data.downloadDate)}}
{{data.downloadTime}} ( {{data.dwTime}} ครั้ง)</small></p>
<p class="text-info pointer mb-0" (click)="openLink(data.link1)"><i class="fas fa-link mr-1"></i>
ตัวอย่างวิธีใช้งาน</p>
</div>
<div class="card-footer border-bottom-5">
<small class="text-muted">วันที่อัพโหลด {{coverDate(data.uploadDate)}} {{data.uploadTime}}</small>
</div>
</div>
</div>
</div> -->
<div class="box p-4">
<div *ngIf="checkType != '1'" class="flex flex-wrap -mx-2">
<div class="w-full">
<div class="py-3 px-2">
<input type="text"
class="block w-full md:w-1/4 px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition-all duration-200 shadow-sm"
placeholder="ค้นหา" [(ngModel)]="search" />
</div>
</div>
<div class="w-full sm:w-1/2 lg:w-1/3 xl:w-1/3 px-2 mb-4" *ngFor="let data of filterListDoc()">
<div
class="group bg-white rounded-lg overflow-hidden shadow-lg border-4 border-blue-600 h-full flex flex-col transform transition-all duration-300 ease-in-out hover:scale-[1.02] hover:shadow-xl">
<div class="p-4 flex justify-center items-center flex-shrink-0">
<img
class="w-full h-full object-cover rounded-md shadow-md transform transition-transform duration-300 group-hover:scale-105 cursor-pointer"
style="width: 400px; height: 200px; max-width: 100%;" src="{{ data.getImage() }}" alt="{{ data.thName }}"
(click)="openDialog(data.getImage())" />
</div>
<div class="p-4 flex-grow">
<span class="text-xl font-semibold text-gray-800 mb-2" style="font-size: 18px;">
{{ data.thName }}
</span>
<p class="text-gray-700 text-sm mb-3">{{ data.thDesc }}</p>
<div class="mb-0 flex items-center justify-center sm:justify-start gap-2 w-1/2 mt-5">
<i class="fa fa-link text-blue-600 text-base flex-shrink-0" aria-hidden="true"></i>
<input type="text" [value]="'ตัวอย่างวิธีใช้งาน'" (click)="openLink(data.link1)"
style="background-color: rgb(76, 117, 207, 1); color: #FFF;"
class="flex-grow border border-gray-300 rounded-md px-2 py-1 text-blue-600 cursor-pointer hover:underline focus:outline-none focus:ring-1 focus:ring-blue-500 transition-all duration-200"
readonly />
</div>
<div class="mb-2 flex items-center justify-center sm:justify-start gap-2 w-full mt-2">
<i class="fa fa-download text-blue-600 text-base flex-shrink-0" aria-hidden="true"></i>
<input type="text" [value]="'ดาวน์โหลด (ไทย)'" (click)="downloadFile(data.docId, 'tha')"
style="background-color: rgb(34, 197, 94, 1); color: #FFF;"
class="flex-grow border border-gray-300 rounded-md px-2 py-1 cursor-pointer hover:opacity-90 focus:outline-none focus:ring-1 focus:ring-green-700 transition-all duration-200"
readonly />
<small class="text-gray-500 text-xs ml-auto hidden sm:block flex-shrink-0" *ngIf="data.dwTime > 0">
{{coverDate(data.downloadDate)}} {{data.downloadTime}} ( {{data.dwTime}} ครั้ง)
</small>
</div>
<div class="mb-2 flex items-center justify-center sm:justify-start gap-2 w-full">
<i class="fa fa-download text-blue-600 text-base flex-shrink-0" aria-hidden="true"></i>
<input type="text" [value]="'ดาวน์โหลด (อังกฤษ)'" (click)="downloadFile(data.docId, 'eng')"
style="background-color: rgb(34, 197, 94, 1); color: #FFF;"
class="flex-grow border border-gray-300 rounded-md px-2 py-1 cursor-pointer hover:opacity-90 focus:outline-none focus:ring-1 focus:ring-green-700 transition-all duration-200"
readonly />
<small class="text-gray-500 text-xs ml-auto hidden sm:block flex-shrink-0" *ngIf="data.dwTime > 0">
{{coverDate(data.downloadDate)}} {{data.downloadTime}} ( {{data.dwTime}} ครั้ง)
</small>
</div>
</div>
<div class="px-4 py-3 border-t border-gray-200 text-right flex-shrink-0">
<small class="text-gray-500 text-xs">วันที่อัพโหลด {{ coverDate(data.uploadDate) }}
{{ data.uploadTime }}</small>
</div>
</div>
</div>
</div>
</div>
\ No newline at end of file
import { Component, OnInit } from '@angular/core';
import { AlertModalComponent } from '../alert-modal/alert-modal.component';
import { NgbModal, NgbPaginationModule } from '@ng-bootstrap/ng-bootstrap';
import { DocumentContentModel } from '../../../models/document-content.model';
import { ActivatedRoute, RouterModule } from '@angular/router';
import { ConfirmModalComponent } from '../confirm-modal/confirm-modal.component';
import { OpenImageComponent } from '../open-image/open-image.component';
import { DocumentService } from '../../../services/document.service';
import { MatDialog, MatDialogModule } from '@angular/material/dialog';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { NgSelectModule } from '@ng-select/ng-select';
import { SharedModule } from '../../../../shared/shared.module';
import { saveAs } from 'file-saver';
import { TranslateModule } from '@ngx-translate/core';
@Component({
selector: 'app-view-list-doc',
templateUrl: './view-list-doc.component.html',
styleUrls: ['./view-list-doc.component.scss'],
standalone: true,
imports: [
CommonModule,
FormsModule,
RouterModule,
NgSelectModule,
SharedModule,
MatDialogModule,
NgbPaginationModule,
TranslateModule,
],
})
export class ViewListDocComponent implements OnInit {
page = 1;
pageSize = 10;
listDoc: DocumentContentModel[] = []
search: string = ''
dialogRef: any;
checkType: string = '0'
constructor(private modalService: NgbModal, private documentService: DocumentService, private activatedRoute: ActivatedRoute, private dialog: MatDialog,) {
this.activatedRoute.paramMap.subscribe(result => {
this.checkType = result.get("type")!;
});
}
openDialog(image: string) {
const dialogConfig = {
width: '750px',
disableClose: false,
data: {
linkImage: image
},
panelClass: 'my-dialog-img-preview',
};
this.dialogRef = this.dialog.open(OpenImageComponent, dialogConfig);
this.dialogRef.afterClosed().subscribe((result: any) => {
console.log('The dialog was closed', result);
}, (reason: any) => {
});
}
deleteFile(item: DocumentContentModel) {
const modalRef = this.modalService.open(ConfirmModalComponent, {
centered: true,
backdrop: 'static',
})
modalRef.componentInstance.message = 'คุณต้องการลบข้อมูลหรือไม่'
modalRef.result.then(result => {
this.documentService.deleteExcelContent(item).subscribe(result => {
if (result) {
this.openAlertModal('ลบข้อมูลสำเร็จ')
this.getListDoc();
} else {
this.openAlertModal('ไม่สามารถลบข้อมูลได้')
}
}, error => {
this.openAlertModal(error.message)
})
}, reject => { })
}
async downloadFile(logId: string, lang: string) {
try {
const data = await this.documentService.downloadFileContent(logId, lang).toPromise();
if (data) {
saveAs(new Blob([data]), "file_download.doc");
}
} catch (error) {
console.error('Error loading data:', error);
}
}
filterListDoc() {
return this.listDoc.filter(x => x.thName.toLowerCase().includes(this.search.toLowerCase()) || x.engName.toLowerCase().includes(this.search.toLowerCase()))
}
async getListDoc() {
try {
const data = await this.documentService.getListExcelContent().toPromise();
this.listDoc = data!.map(x => new DocumentContentModel(x))
} catch (error) {
console.error('Error loading data:', error);
}
}
ngOnInit() {
this.getListDoc();
}
openAlertModal(message?: string) {
const modalRef = this.modalService.open(AlertModalComponent, {
centered: true,
backdrop: 'static'
})
modalRef.componentInstance.message = message ? message : ""
modalRef.result.then(result => {
this.modalService.dismissAll()
}, reason => {
this.modalService.dismissAll()
})
}
openLink(url: string) {
window.open(url, "_blank");
}
coverDate(date: string) {
return date.split('-').reverse().join('/')
}
}
<app-page-header [title]="'รายการเอกสาร Excel'" [activeTitle]="'ผู้ดูแลระบบ'"
[title1]="'รายการเอกสาร Excel'"></app-page-header>
<div class="row" *ngIf="checkType == '1'">
<div class="col-12">
<div class="card card-body">
<h4 class="card-title">รายการ Excel</h4>
<div class="d-flex mb-3 mt-3">
<input type="text" class="form-control w-25" placeholder="ค้นหา" [(ngModel)]="search">
</div>
<div class="table-responsive">
<table class="table table-striped mb-0 no-wrap v-middle ">
<thead class="bg-info text-white">
<tr>
<th class="text-center" scope="col">#</th>
<th scope="col">รูปภาพ</th>
<th scope="col">ชื่อ</th>
<th scope="col">รายละเอียด</th>
<th scope="col" class="text-center">ลิงค์</th>
<th scope="col" class="text-center">ไฟล์</th>
<th scope="col" class="text-center">วันที่อัพโหลด</th>
<th scope="col" class="text-center">วันล่าสุดดาวน์โหลด</th>
<th scope="col" class="text-center">จำนวนดาวน์โหลด</th>
<th scope="col" *ngIf="checkType == '1'"></th>
</tr>
</thead>
<tbody>
<tr *ngIf="listExcel.length == 0">
<td [colSpan]="checkType == '1' ? 8 : 7" class="text-center">ไม่พบข้อมูล</td>
</tr>
<tr
*ngFor="let data of filterListExcel() | slice: (page-1) * pageSize : (page-1) * pageSize + pageSize ; let i = index">
<td class="text-center">{{i+1}}</td>
<td><img width="100" class="border p-1" src="{{data.getImage()}}"
(click)="openDialog(data.getImage())"></td>
<td>{{ data.thName }}</td>
<td>{{ data.thDesc }}</td>
<td class="text-center"><i class="fas fa-link pointer" (click)="openLink(data.link1)"></i></td>
<td class="text-center"> <i class="fas fa-download pointer" (click)="downloadFile(data.excelId)"></i></td>
<td class="text-center">{{data.uploadDate}} {{data.uploadTime}}</td>
<td class="text-center">{{data.downloadDate}} {{data.downloadTime}}</td>
<td class="text-center">{{data.dwTime}} ครั้ง</td>
<td *ngIf="checkType == '1'">
<button type="button" class="btn btn-circle btn-danger rounded-circle btn-sm mr-2"
(click)="deleteFile(data)" placement="top" ngbTooltip="ลบ"><i class="fas fa-trash-alt"></i></button>
</td>
</tr>
</tbody>
</table>
</div>
<div class="d-flex justify-content-end py-2">
<select class="custom-select m-r-5" style="width: auto" [(ngModel)]="pageSize" (ngModelChange)="page">
<option [ngValue]="10">รายการต่อหน้า: 10</option>
<option [ngValue]="50">รายการต่อหน้า: 50</option>
<option [ngValue]="100">รายการต่อหน้า: 100</option>
</select>
<ngb-pagination [(page)]="page" [pageSize]="pageSize" [collectionSize]="listExcel.length" [maxSize]="3"
[rotate]="true">
<ng-template ngbPaginationPrevious>ก่อนหน้า</ng-template>
<ng-template ngbPaginationNext>ถัดไป</ng-template>
</ngb-pagination>
</div>
</div>
</div>
</div>
<!-- <div class="row" *ngIf="checkType != '1'">
<div class="col-12">
<div class="py-3">
<input type="text" class="form-control w-25" placeholder="ค้นหา" [(ngModel)]="search">
</div>
</div>
<div class="col-sm-6 col-md-4 col-lg-4 mb-3" *ngFor="let data of filterListExcel()">
<div class="card border-5 border border-excel h-100 shadow">
<div class=" p-2 border-5">
<img width="100" class="card-img-top cover" src="{{data.getImage()}}"
(click)="openEmployeeModal(data.getImage())">
</div>
<div class="card-body">
<h4 class="card-title">{{ data.thName }}</h4>
<p class="card-text ">{{ data.thDesc }}</p>
<p class="text-info pointer mb-0" (click)="downloadFile(data.excelId)"><i class="fas fa-download mr-1"></i>
ดาวน์โหลด <small class="text-muted" *ngIf="data.dwTime > 0">{{coverDate(data.downloadDate)}}
{{data.downloadTime}} ( {{data.dwTime}} ครั้ง)</small></p>
<p class="text-info pointer mb-0" (click)="openLink(data.link1)"><i class="fas fa-link mr-1"></i>
ตัวอย่างวิธีใช้งาน</p>
</div>
<div class="card-footer border-bottom-5">
<small class="text-muted">วันที่อัพโหลด {{coverDate(data.uploadDate)}} {{data.uploadTime}}</small>
</div>
</div>
</div>
</div> -->
<div class="box p-4">
<div *ngIf="checkType != '1'" class="flex flex-wrap -mx-2">
<div class="w-full">
<div class="py-3 px-2">
<input type="text"
class="block w-full md:w-1/4 px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition-all duration-200 shadow-sm"
placeholder="ค้นหา" [(ngModel)]="search" />
</div>
</div>
<div class="w-full sm:w-1/2 lg:w-1/3 xl:w-1/3 px-2 mb-4" *ngFor="let data of filterListExcel()">
<div
class="group bg-white rounded-lg overflow-hidden shadow-lg border-4 border-blue-600 h-full flex flex-col transform transition-all duration-300 ease-in-out hover:scale-[1.02] hover:shadow-xl">
<div class="p-4 flex justify-center items-center flex-shrink-0">
<img
class="w-full h-full object-cover rounded-md shadow-md transform transition-transform duration-300 group-hover:scale-105 cursor-pointer"
style="width: 400px; height: 200px; max-width: 100%;" src="{{ data.getImage() }}" alt="{{ data.thName }}"
(click)="openDialog(data.getImage())" />
</div>
<div class="p-4 flex-grow">
<span class="text-xl font-semibold text-gray-800 mb-2" style="font-size: 18px;">
{{ data.thName }}
</span>
<p class="text-gray-700 text-sm mb-3">{{ data.thDesc }}</p>
<div class="mb-0 flex items-center justify-center sm:justify-start gap-2 w-1/2 mt-5">
<i class="fa fa-link text-blue-600 text-base flex-shrink-0" aria-hidden="true"></i>
<input type="text" [value]="'ตัวอย่างวิธีใช้งาน'" (click)="openLink(data.link1)" style="background-color: rgb(76, 117, 207, 1); color: #FFF;"
class="flex-grow border border-gray-300 rounded-md px-2 py-1 text-blue-600 cursor-pointer hover:underline focus:outline-none focus:ring-1 focus:ring-blue-500 transition-all duration-200"
readonly />
</div>
<div class="mb-2 flex items-center justify-center sm:justify-start gap-2 w-1/2">
<i class="fa fa-download text-blue-600 text-base flex-shrink-0" aria-hidden="true"></i>
<input type="text" [value]="'ดาวน์โหลด'" (click)="downloadFile(data.excelId)" style="background-color: rgb(34, 197, 94, 1); color: #FFF;"
class="flex-grow border border-gray-300 rounded-md px-2 py-1 text-blue-600 cursor-pointer hover:underline focus:outline-none focus:ring-1 focus:ring-blue-500 transition-all duration-200"
readonly />
<small class="text-gray-500 text-xs ml-auto hidden sm:block flex-shrink-0" *ngIf="data.dwTime > 0">{{
coverDate(data.downloadDate) }} {{ data.downloadTime }} (
{{ data.dwTime }} ครั้ง)</small>
</div>
</div>
<div class="px-4 py-3 border-t border-gray-200 text-right flex-shrink-0">
<small class="text-gray-500 text-xs">วันที่อัพโหลด {{ coverDate(data.uploadDate) }}
{{ data.uploadTime }}</small>
</div>
</div>
</div>
</div>
</div>
\ No newline at end of file
import { Component, OnInit } from '@angular/core';
import { ExcelService } from '../../../services/excel.service';
import { NgbModal, NgbPaginationModule } from '@ng-bootstrap/ng-bootstrap';
import { ActivatedRoute, RouterModule } from '@angular/router';
import { ExcelContentModel } from '../../../models/excel-content.model';
import { OpenImageComponent } from '../open-image/open-image.component';
import { ConfirmModalComponent } from '../confirm-modal/confirm-modal.component';
import { AlertModalComponent } from '../alert-modal/alert-modal.component';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { NgSelectModule } from '@ng-select/ng-select';
import { SharedModule } from '../../../../shared/shared.module';
import { MatDialog, MatDialogModule } from '@angular/material/dialog';
import { TranslateModule } from '@ngx-translate/core';
import { saveAs } from 'file-saver';
@Component({
selector: 'app-view-list-excel',
templateUrl: './view-list-excel.component.html',
styleUrls: ['./view-list-excel.component.scss'],
standalone: true,
imports: [
CommonModule,
FormsModule,
RouterModule,
NgSelectModule,
SharedModule,
MatDialogModule,
TranslateModule,
NgbPaginationModule,
],
})
export class ViewListExcelComponent implements OnInit {
page = 1;
pageSize = 10;
listExcel: ExcelContentModel[] = [];
search: string = '';
checkType: string = '0';
dialogRef: any;
constructor(
private modalService: NgbModal,
private excelService: ExcelService,
private activatedRoute: ActivatedRoute,
private dialog: MatDialog,
) {
this.activatedRoute.paramMap.subscribe(result => {
this.checkType = result.get("type")!;
});
}
openDialog(image: string) {
const dialogConfig = {
width: '750px',
disableClose: false,
data: {
linkImage: image
},
panelClass: 'my-dialog-img-preview',
};
this.dialogRef = this.dialog.open(OpenImageComponent, dialogConfig);
this.dialogRef.afterClosed().subscribe((result: any) => {
console.log('The dialog was closed', result);
}, (reason: any) => {
});
}
// openEmployeeModal(image: string) {
// const modalRef = this.modalService.open(OpenImageComponent, {
// centered: true,
// windowClass: 'my-dialog-img-preview'
// });
// modalRef.componentInstance.linkImage = image;
// modalRef.result.then(result => {
// }, reason => {
// this.modalService.dismissAll();
// });
// }
deleteFile(item: ExcelContentModel) {
const modalRef = this.modalService.open(ConfirmModalComponent, {
centered: true,
backdrop: 'static',
});
modalRef.componentInstance.message = 'คุณต้องการลบข้อมูลหรือไม่';
modalRef.result.then(result => {
this.excelService.deleteExcelContent(item).subscribe(result => {
if (result) {
this.openAlertModal('ลบข้อมูลสำเร็จ');
this.getListExcel();
} else {
this.openAlertModal('ไม่สามารถลบข้อมูลได้');
}
}, error => {
this.openAlertModal(error.message);
});
}, reject => { });
}
async downloadFile(logId: string) {
try {
const data = await this.excelService.downloadFileContent(logId).toPromise();
if (data) {
saveAs(new Blob([data]), "file_download.xlsx");
}
} catch (error) {
console.error('Error loading data:', error);
}
}
getStatus(status: string): string {
if (status == '0') {
return 'รออนุมัติ';
} else if (status == '1') {
return 'เปิดใช้งาน';
} else if (status == '2') {
return 'ไม่อนุมัติ';
}
return '';
}
filterListExcel() {
return this.listExcel.filter(x => x.thName.toLowerCase().includes(this.search.toLowerCase()) || x.engName.toLowerCase().includes(this.search.toLowerCase()));
}
async getListExcel() {
try {
const data = await this.excelService.getListExcelContent().toPromise();
this.listExcel = data!.map(x => new ExcelContentModel(x));
} catch (error) {
console.error('Error loading data:', error);
}
}
ngOnInit() {
this.getListExcel();
}
openLink(url: string) {
window.open(url, "_blank");
}
openAlertModal(message?: string) {
const modalRef = this.modalService.open(AlertModalComponent, {
centered: true,
backdrop: 'static'
});
modalRef.componentInstance.message = message ? message : "";
modalRef.result.then(result => {
this.modalService.dismissAll();
}, reason => {
this.modalService.dismissAll();
});
}
coverDate(date: string) {
return date.split('-').reverse().join('/');
}
}
\ No newline at end of file
<app-page-header [title]="'รายการวิทเจ็ท'" [activeTitle]="'ผู้ดูแลระบบ'"
[title1]="'รายการวิทเจ็ท'"></app-page-header>
<!-- <div class="row">
<div class="col-12">
<div class="py-3">
<input type="text" class="form-control w-25" placeholder="ค้นหา" [(ngModel)]="search">
</div>
</div>
<div class="col-sm-6 col-md-4 col-lg-4 mb-3" *ngFor="let data of filterListWidget()">
<div class="card border-5 border border-widget h-100 shadow">
<div class=" p-2 border-5">
<img width="100" class="card-img-top cover" src="{{data.getImage()}}"
(click)="openEmployeeModal(data.getImage())">
</div>
<div class="card-body">
<h4 class="card-title">{{ data.widgetTname }}</h4>
<p class="card-text ">{{ data.thDesc }}</p>
<p class="text-info pointer mb-0" (click)="downloadFile(data.widgetId)"><i class="fas fa-download mr-1"></i>
ดาวน์โหลด <small class="text-muted" *ngIf="data.dwTime > 0">{{coverDate(data.downloadDate)}}
{{data.downloadTime}} ( {{data.dwTime}} ครั้ง)</small></p>
<p class="text-info pointer mb-0" (click)="openLink(data.link1)"><i class="fas fa-link mr-1"></i>
ตัวอย่างวิธีใช้งาน</p>
</div>
<div class="card-footer border-bottom-5">
<small class="text-muted">วันที่อัพโหลด {{coverDate(data.uploadDate)}} {{data.uploadTime}}</small>
</div>
</div>
</div>
</div> -->
<div class="box p-4">
<div class="flex flex-wrap -mx-2">
<div class="w-full">
<div class="py-3 px-2">
<input type="text"
class="block w-full md:w-1/4 px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition-all duration-200 shadow-sm"
placeholder="ค้นหา" [(ngModel)]="search" />
</div>
</div>
<div class="w-full sm:w-1/2 lg:w-1/3 xl:w-1/3 px-2 mb-4" *ngFor="let data of filterListWidget()">
<div
class="group bg-white rounded-lg overflow-hidden shadow-lg border-4 border-blue-600 h-full flex flex-col transform transition-all duration-300 ease-in-out hover:scale-[1.02] hover:shadow-xl">
<div class="p-4 flex justify-center items-center flex-shrink-0">
<img
class="w-full h-full object-cover rounded-md shadow-md transform transition-transform duration-300 group-hover:scale-105 cursor-pointer"
style="width: 400px; height: 200px; max-width: 100%;" src="{{ data.getImage() }}" alt="{{ data.widgetTname }}"
(click)="openDialog(data.getImage())" />
</div>
<div class="p-4 flex-grow">
<span class="text-xl font-semibold text-gray-800 mb-2" style="font-size: 18px;">
{{ data.widgetTname }}
</span>
<p class="text-gray-700 text-sm mb-3">{{ data.thDesc }}</p>
<div class="mb-0 flex items-center justify-center sm:justify-start gap-2 w-1/2 mt-5">
<i class="fa fa-link text-blue-600 text-base flex-shrink-0" aria-hidden="true"></i>
<input type="text" [value]="'ตัวอย่างวิธีใช้งาน'" (click)="openLink(data.link1)"
style="background-color: rgb(76, 117, 207, 1); color: #FFF;"
class="flex-grow border border-gray-300 rounded-md px-2 py-1 text-blue-600 cursor-pointer hover:underline focus:outline-none focus:ring-1 focus:ring-blue-500 transition-all duration-200"
readonly />
</div>
<div class="mb-2 flex items-center justify-center sm:justify-start gap-2 w-1/2">
<i class="fa fa-download text-blue-600 text-base flex-shrink-0" aria-hidden="true"></i>
<input type="text" [value]="'ดาวน์โหลด'" (click)="downloadFile(data.widgetId)"
style="background-color: rgb(34, 197, 94, 1); color: #FFF;"
class="flex-grow border border-gray-300 rounded-md px-2 py-1 text-blue-600 cursor-pointer hover:underline focus:outline-none focus:ring-1 focus:ring-blue-500 transition-all duration-200"
readonly />
</div>
</div>
<div class="px-4 py-3 border-t border-gray-200 text-right flex-shrink-0">
<small class="text-gray-500 text-xs">วันที่อัพโหลด {{ coverDate(data.uploadDate) }}
{{ data.uploadTime }}</small>
</div>
</div>
</div>
</div>
</div>
\ No newline at end of file
import { Component, OnInit } from '@angular/core';
import { NgbModal, NgbPaginationModule } from '@ng-bootstrap/ng-bootstrap';
import { AlertModalComponent } from '../alert-modal/alert-modal.component';
import { OpenImageComponent } from '../open-image/open-image.component';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { MatDialog, MatDialogModule } from '@angular/material/dialog';
import { SharedModule } from '../../../../shared/shared.module';
import { TranslateModule } from '@ngx-translate/core';
import { NgSelectModule } from '@ng-select/ng-select';
import saveAs from 'file-saver';
import { WidgetModel } from '../../../models/widgets.model';
import { WidgetService } from '../../../services/widgets.service';
@Component({
selector: 'app-view-list-widgets',
templateUrl: './view-list-widgets.component.html',
styleUrls: ['./view-list-widgets.component.scss'],
standalone: true,
imports: [
CommonModule,
FormsModule,
NgSelectModule,
SharedModule,
MatDialogModule,
NgbPaginationModule,
TranslateModule,
],
})
export class ViewListWidgetsComponent implements OnInit {
page = 1;
pageSize = 10;
listWidget:WidgetModel[]=[]
search:string = ''
dialogRef: any;
constructor(private modalService: NgbModal,private widgetService:WidgetService, private dialog: MatDialog,) {
}
openDialog(image: string) {
const dialogConfig = {
width: '750px',
disableClose: false,
data: {
linkImage: image
},
panelClass: 'my-dialog-img-preview',
};
this.dialogRef = this.dialog.open(OpenImageComponent, dialogConfig);
this.dialogRef.afterClosed().subscribe((result: any) => {
console.log('The dialog was closed', result);
}, (reason: any) => {
});
}
async downloadFile(logId: string) {
try {
const data = await this.widgetService.downloadFile(logId).toPromise();
if (data) {
saveAs(new Blob([data]), "file_download.xlsx");
}
} catch (error) {
console.error('Error loading data:', error);
}
}
// getStatus(status: string) {
// if (status == '0') {
// return 'Private'
// } else if (status == '1') {
// return 'Public'
// }
// }
filterListWidget(){
return this.listWidget.filter(x => x.widgetTname.toLowerCase().includes(this.search.toLowerCase())||x.widgetEname.toLowerCase().includes(this.search.toLowerCase()))
}
async getListExcel(){
try {
const data = await this.widgetService.getListWidgets().toPromise();
this.listWidget = data!.map(x => new WidgetModel(x))
} catch (error) {
console.error('Error loading data:', error);
}
}
ngOnInit() {
this.getListExcel();
}
openLink(url:string){
window.open(url, "_blank");
}
openAlertModal(message?: string) {
const modalRef = this.modalService.open(AlertModalComponent, {
centered: true,
backdrop: 'static'
})
modalRef.componentInstance.message = message ? message : ""
modalRef.result.then(result => {
this.modalService.dismissAll()
}, reason => {
this.modalService.dismissAll()
})
}
coverDate(date:string){
return date.split('-').reverse().join('/')
}
}
...@@ -7,17 +7,20 @@ export interface ArticleModel { ...@@ -7,17 +7,20 @@ export interface ArticleModel {
articleId: string articleId: string
companyId: CompanyModel[] companyId: CompanyModel[]
title: string title: string
titleEng: string
titleChina: string
content: string content: string
engcontent: string contentEng: string
zhcontent: string contentChina: string
excerpt: string excerpt: string
engexcerpt: string excerptEng: string
zhexcerpt: string excerptChina: string
category: string category: string
author: string author: string
picture: string picture: string
createdDate: string createdDate: string | null
lastModifiedDate: string lastModifiedDate: string | null
endDate: string | null
publish: number publish: number
viewCount: number viewCount: number
} }
...@@ -26,18 +29,21 @@ export class ArticleModel extends BaseModel implements ArticleModel { ...@@ -26,18 +29,21 @@ export class ArticleModel extends BaseModel implements ArticleModel {
articleId: string articleId: string
companyId: CompanyModel[] companyId: CompanyModel[]
title: string title: string
titleEng:string
titleChina: string
content: string content: string
engcontent: string contentEng: string
zhcontent: string contentChina: string
excerpt: string excerpt: string
engexcerpt: string excerptEng: string
zhexcerpt: string excerptChina: string
category: string category: string
author: string author: string
picture: string picture: string
createdDate: string createdDate: string | null
lastModifiedDate: string lastModifiedDate: string | null
publish: number endDate: string | null
publish: number = 0;
viewCount: number viewCount: number
constructor(data?: Partial<ArticleModel>, translateService?: TranslateService) { constructor(data?: Partial<ArticleModel>, translateService?: TranslateService) {
super(data, translateService) super(data, translateService)
...@@ -45,19 +51,22 @@ export class ArticleModel extends BaseModel implements ArticleModel { ...@@ -45,19 +51,22 @@ export class ArticleModel extends BaseModel implements ArticleModel {
this.articleId = data?.articleId! this.articleId = data?.articleId!
this.companyId = dataToArray(data?.companyId).map((x:CompanyModel) => new CompanyModel(x,translateService)) this.companyId = dataToArray(data?.companyId).map((x:CompanyModel) => new CompanyModel(x,translateService))
this.title = data?.title! this.title = data?.title!
this.titleEng = data?.titleEng!
this.titleChina = data?.titleChina!
this.content = data?.content! this.content = data?.content!
this.engcontent = data?.engcontent! this.contentEng = data?.contentEng!
this.zhcontent = data?.zhcontent! this.contentChina = data?.contentChina!
this.excerpt = data?.excerpt! this.excerpt = data?.excerpt!
this.engexcerpt = data?.engexcerpt! this.excerptEng = data?.excerptEng!
this.zhexcerpt = data?.zhexcerpt! this.excerptChina = data?.excerptChina!
this.category = data?.category! this.category = data?.category!
this.author = data?.author! this.author = data?.author!
this.picture = data?.picture! this.picture = data?.picture!
this.createdDate = data?.createdDate! this.createdDate = data?.createdDate?? null
this.lastModifiedDate = data?.lastModifiedDate! this.lastModifiedDate = data?.lastModifiedDate?? null
this.publish = data?.publish! this.endDate = data?.endDate?? null
this.viewCount = data?.viewCount! this.publish = data?.publish?? 0;
this.viewCount = data?.viewCount?? 0;
} }
getPicture(): string { getPicture(): string {
......
import { environment } from "../../../environments/environment";
import { TagModel } from "./tag.mmodel"
import { GroupModel } from "./group.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
uploadDate: string
uploadTime: string
dwTime: number
downloadDate: string
downloadTime: string
remark: string
referId: string
approveBy: string
approveDate: string
approveTime: string
tags: TagModel[]
group: GroupModel
}
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
uploadDate: string
uploadTime: string
dwTime: number
downloadDate: string
downloadTime: string
remark: string
referId: string
approveBy: string
approveDate: string
approveTime: string
tags: TagModel[]
group: GroupModel
constructor(data: Partial<CourseContentModel>) {
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:[]
this.uploadDate = data.uploadDate?data.uploadDate:''
this.uploadTime = data.uploadTime?data.uploadTime:''
this.downloadDate = data.downloadDate?data.downloadDate:''
this.downloadTime = data.downloadTime?data.downloadTime:''
this.approveDate = data.approveDate?data.approveDate:''
this.approveTime = data.approveTime?data.approveTime:''
this.group = data.group?new GroupModel(data.group):new GroupModel({})
}
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 "../../../environments/environment";
import { TagModel } from "./tag.mmodel"
import { GroupModel } from "./group.mmodel"
export interface CourseModel {
logId: 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
uploadDate: string
uploadTime: string
remark: string
status: number
approveBy: string
approveDate: string
approveTime: string
tags: TagModel[]
group: GroupModel
}
export class CourseModel implements CourseModel {
logId: 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
uploadDate: string
uploadTime: string
remark: string
status: number
approveBy: string
approveDate: string
approveTime: string
tags: TagModel[]
group: GroupModel
constructor(data: Partial<CourseModel>) {
this.logId = data.logId?data.logId:''
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.status = data.status?data.status: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.tags = data.tags?data.tags:[]
this.uploadDate = data.uploadDate?data.uploadDate:''
this.uploadTime = data.uploadTime?data.uploadTime:''
this.approveDate = data.approveDate?data.approveDate:''
this.approveTime = data.approveTime?data.approveTime:''
this.group = data.group?new GroupModel(data.group):new GroupModel({})
}
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 "../../../environments/environment";
import { TagModel } from "./tag.mmodel"
import { GroupModel } from "./group.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
uploadDate: string
uploadTime: string
dwTime: number
downloadDate: string
downloadTime: string
remark: string
referId: string
approveBy: string
approveDate: string
approveTime: string
tags: TagModel[]
group: GroupModel
}
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
uploadDate: string
uploadTime: string
dwTime: number
downloadDate: string
downloadTime: string
remark: string
referId: string
approveBy: string
approveDate: string
approveTime: string
tags: TagModel[]
group: GroupModel
constructor(data: Partial<DocumentContentModel>) {
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:[]
this.uploadDate = data.uploadDate?data.uploadDate:''
this.uploadTime = data.uploadTime?data.uploadTime:''
this.downloadDate = data.downloadDate?data.downloadDate:''
this.downloadTime = data.downloadTime?data.downloadTime:''
this.approveDate = data.approveDate?data.approveDate:''
this.approveTime = data.approveTime?data.approveTime:''
this.group = data.group?new GroupModel(data.group):new GroupModel({})
}
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 "../../../environments/environment";
import { TagModel } from "./tag.mmodel"
import { GroupModel } from "./group.mmodel"
export interface DocumentModel {
logId: string
thName: string
engName: string
thDesc: string
engDesc: string
thumbnail: string
link1: string
langSupport: string
thDocObj: string
engDocObj: string
uploadBy: string
uploadDate: string
uploadTime: string
remark: string
status: number
approveBy: string
approveDate: string
approveTime: string
tags: TagModel[]
group: GroupModel
}
export class DocumentModel implements DocumentModel {
logId: string
thName: string
engName: string
thDesc: string
engDesc: string
thumbnail: string
link1: string
langSupport: string
thDocObj: string
engDocObj: string
uploadBy: string
uploadDate: string
uploadTime: string
remark: string
status: number
approveBy: string
approveDate: string
approveTime: string
tags: TagModel[]
group: GroupModel
constructor(data: Partial<DocumentModel>) {
this.logId = data.logId?data.logId:''
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.status = data.status?data.status: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.tags = data.tags?data.tags:[]
this.uploadDate = data.uploadDate?data.uploadDate:''
this.uploadTime = data.uploadTime?data.uploadTime:''
this.approveDate = data.approveDate?data.approveDate:''
this.approveTime = data.approveTime?data.approveTime:''
this.group = data.group?new GroupModel(data.group):new GroupModel({})
}
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 "../../../environments/environment";
import { GroupModel } from "./group.mmodel";
import { TagModel } from "./tag.mmodel";
export interface ExcelContentModel {
excelId: string
thName: string
engName: string
thDesc: string
engDesc: string
thumbnail: string
link1: string
dbSupport: string
excelObj: string
isPivot: number
isDataGrid: number
uploadBy: string
uploadDate: string
uploadTime: string
dwTime: number
downloadDate: string
downloadTime: string
remark: string
referId: string
approveBy: string
approveDate: string
approveTime: string
tags: TagModel[]
group: GroupModel
}
export class ExcelContentModel implements ExcelContentModel {
excelId: string
thName: string
engName: string
thDesc: string
engDesc: string
thumbnail: string
link1: string
dbSupport: string
excelObj: string
isPivot: number
isDataGrid: number
uploadBy: string
uploadDate: string
uploadTime: string
dwTime: number
downloadDate: string
downloadTime: string
remark: string
referId: string
approveBy: string
approveDate: string
approveTime: string
tags: TagModel[]
group: GroupModel
constructor(data: Partial<ExcelContentModel>) {
this.excelId = data.excelId ?? ''
this.thumbnail = data.thumbnail ?? ''
this.link1 = data.link1 ?? ''
this.dbSupport = data.dbSupport ?? ''
this.excelObj = data.excelObj ?? ''
this.uploadBy = data.uploadBy ?? ''
this.remark = data.remark ?? ''
this.dwTime = data.dwTime ?? 0
this.approveBy = data.approveBy ?? ''
this.thName = data.thName ?? ''
this.engName = data.engName ?? ''
this.thDesc = data.thDesc ?? ''
this.engDesc = data.engDesc ?? ''
this.referId = data.referId ?? ''
this.isPivot = data.isPivot ?? 0
this.isDataGrid = data.isDataGrid ?? 0
this.uploadDate = data.uploadDate ?? ''
this.uploadTime = data.uploadTime ?? ''
this.downloadDate = data.downloadDate ?? ''
this.downloadTime = data.downloadTime ?? ''
this.approveDate = data.approveDate ?? ''
this.approveTime = data.approveTime ?? ''
this.tags = data.tags ? data.tags : []
this.group = data.group ? new GroupModel(data.group) : new GroupModel({})
}
getImage(): string {
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 "../../../environments/environment";
import { GroupModel } from "./group.mmodel";
import { TagModel } from "./tag.mmodel";
export interface ExcelModel {
logId: string
thName: string
engName: string
thDesc: string
engDesc: string
thumbnail: string
link1: string
dbSupport: string
excelObj: string
isPivot: number
isDataGrid: number
uploadBy: string
uploadDate: string
uploadTime: string
remark: string
status: number
approveBy: string
approveDate: string
approveTime: string
tags: TagModel[]
group: GroupModel
fileType: string
}
export class ExcelModel implements ExcelModel {
logId: string
thName: string
engName: string
thDesc: string
engDesc: string
thumbnail: string
link1: string
dbSupport: string
excelObj: string
isPivot: number
isDataGrid: number
uploadBy: string
uploadDate: string
uploadTime: string
remark: string
status: number
approveBy: string
approveDate: string
approveTime: string
tags: TagModel[]
group: GroupModel
fileType: string
constructor(data: Partial<ExcelModel>) {
this.logId = data.logId?data.logId:''
this.thumbnail = data.thumbnail?data.thumbnail:''
this.link1 = data.link1?data.link1:''
this.dbSupport = data.dbSupport?data.dbSupport:''
this.excelObj = data.excelObj?data.excelObj:''
this.uploadBy = data.uploadBy?data.uploadBy:''
this.remark = data.remark?data.remark:''
this.status = data.status?data.status: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.tags = data.tags?data.tags:[]
this.isPivot = data.isPivot?data.isPivot:0
this.isDataGrid = data.isDataGrid?data.isDataGrid:0
this.uploadDate = data.uploadDate?data.uploadDate:''
this.uploadTime = data.uploadTime?data.uploadTime:''
this.approveDate = data.approveDate?data.approveDate:''
this.approveTime = data.approveTime?data.approveTime:''
this.group = data.group?new GroupModel(data.group):new GroupModel({})
this.fileType = data.fileType?data.fileType:''
}
getImage(){
if(this.thumbnail){
return environment.url+"files/image/"+this.thumbnail
}else{
return 'assets/images/big/auth-bg.jpg'
}
}
}
\ No newline at end of file
export interface GroupModel {
groupId: string
thName: string
engName: string
groupType: number
}
export class GroupModel implements GroupModel {
groupId: string
thName: string
engName: string
groupType: number
constructor(data: Partial<GroupModel>) {
this.groupId = data.groupId?data.groupId:''
this.thName = data.thName?data.thName:''
this.engName = data.engName?data.engName:''
this.groupType = data.groupType?data.groupType:0
}
}
\ No newline at end of file
export interface TagModel {
display: string
value: string
}
export class TagModel implements TagModel {
display: string
value: string
constructor(data: Partial<TagModel>) {
this.display = data.display?data.display:''
this.value = data.value?data.value:''
}
}
\ No newline at end of file
import { environment } from "../../../environments/environment";
import { TagModel } from "./tag.mmodel"
import { GroupModel } from "./group.mmodel"
export interface WidgetModel {
widgetId: string
widgetTname: string
widgetEname: string
thDesc: string
engDesc: string
chartType: string
widgetHeight: number
widgetWidth: number
seriesColumn: string
picture: string
remark: string
status: number
link1: string
dbSupport: string
widgetObj: string
fileType: string
isPivot: number
isDataGrid: number
uploadBy: string
uploadDate: string
uploadTime: string
group: GroupModel
tags: TagModel[]
}
export class WidgetModel implements WidgetModel {
widgetId: string
widgetTname: string
widgetEname: string
thDesc: string
engDesc: string
chartType: string
widgetHeight: number
widgetWidth: number
seriesColumn: string
picture: string
remark: string
status: number
link1: string
dbSupport: string
widgetObj: string
fileType: string
isPivot: number
isDataGrid: number
uploadBy: string
uploadDate: string
uploadTime: string
group: GroupModel
tags: TagModel[]
constructor(data: Partial<WidgetModel>) {
this.widgetId = data.widgetId ?? ''
this.widgetTname = data.widgetTname ?? ''
this.widgetEname = data.widgetEname ?? ''
this.thDesc = data.thDesc ?? ''
this.engDesc = data.engDesc ?? ''
this.chartType = data.chartType ?? ''
this.widgetHeight = data.widgetHeight ?? 0
this.widgetWidth = data.widgetWidth ?? 0
this.status = data.status ?? 0
this.seriesColumn = data.seriesColumn ?? ''
this.picture = data.picture ?? ''
this.remark = data.remark ?? ''
this.link1 = data.link1 ?? ''
this.widgetObj = data.widgetObj ?? ''
this.dbSupport = data.dbSupport ?? ''
this.tags = data.tags ?? []
this.fileType = data.fileType ?? ''
this.isPivot = data.isPivot ?? 0
this.isDataGrid = data.isDataGrid ?? 0
this.uploadBy = data.uploadBy ?? ''
this.uploadDate = data.uploadDate ?? ''
this.uploadTime = data.uploadTime ?? ''
this.group = data.group ? new GroupModel(data.group) : new GroupModel({})
}
getImage(): string {
if (this.picture) {
return environment.url + "files/image/" + this.picture
} else {
return 'assets/images/big/auth-bg.jpg'
}
}
}
\ No newline at end of file
...@@ -27,7 +27,7 @@ export class ArticleService { ...@@ -27,7 +27,7 @@ export class ArticleService {
return this.http.get<ArticleModel[]>(this.urlApi + "/lists/" + companyId); return this.http.get<ArticleModel[]>(this.urlApi + "/lists/" + companyId);
} }
postArticle(body: ArticleModel): Observable<any> { postArticle(body: Partial<ArticleModel>): Observable<any> {
return this.http.post(this.urlApi, body) return this.http.post(this.urlApi, body)
} }
......
import { Injectable } from '@angular/core';
import { environment } from "../../../environments/environment";
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Observable, of } from 'rxjs';
import { map, tap } from 'rxjs/operators';
import { CourseModel } from '../models/course.model';
import { CourseContentModel } from '../models/course-content.model';
@Injectable({
providedIn: 'root'
})
export class CourseService {
url = environment.url
createStatus: boolean = true
constructor(private http: HttpClient) { }
getListCourse(status?:string): Observable<CourseModel[]> {
if(status){
return this.http.get<CourseModel[]>(this.url + "course-center/upload/lists?status="+status)
}else{
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):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<any> {
let body : any = model
if (body.group.groupId=='') {
body.group = undefined
}
return this.http.post(this.url + 'course-center', body)
}
deleteCourse(model: CourseModel): Observable<any> {
let body = {
logId: model.logId
}
let option = {
headers: new HttpHeaders({
"Content-Type": "application/json",
}),
body: body
}
return this.http.delete<any>(this.url + 'course-center/upload', option)
}
deleteCourseContent(model: CourseContentModel): Observable<any> {
let body = {
courseId: model.courseId
}
let option = {
headers: new HttpHeaders({
"Content-Type": "application/json",
}),
body: body
}
return this.http.delete<any>(this.url + 'course-center/content', option)
}
approve(model: CourseModel): Observable<any> {
let body = {
logId: model.logId,
status: model.status
}
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")
}
}
import { Injectable } from '@angular/core';
import { environment } from "../../../environments/environment";
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Observable, of } from 'rxjs';
import { map, tap } from 'rxjs/operators';
import { DocumentModel } from '../models/document.model';
import { DocumentContentModel } from '../models/document-content.model';
@Injectable({
providedIn: 'root'
})
export class DocumentService {
url = environment.url
createStatus: boolean = true
constructor(private http: HttpClient) { }
getListDoc(status?: string): Observable<DocumentModel[]> {
if (status) {
return this.http.get<DocumentModel[]>(this.url + "document-center/upload/lists?status=" + status)
} else {
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, lang: string): Observable<any> {
return this.http.get(this.url + "document-center/files/download/content/" + logId + '?lang=' + lang, { responseType: 'blob' });
}
createDoc(model: DocumentModel): Observable<any> {
let body : any = model
if (body.group.groupId=='') {
body.group = undefined
}
return this.http.post(this.url + 'document-center', body)
}
deleteExcel(model: DocumentModel): Observable<any> {
let body = {
logId: model.logId
}
let option = {
headers: new HttpHeaders({
"Content-Type": "application/json",
}),
body: body
}
return this.http.delete<any>(this.url + 'document-center/upload', option)
}
deleteExcelContent(model: DocumentContentModel): Observable<any> {
let body = {
docId: model.docId
}
let option = {
headers: new HttpHeaders({
"Content-Type": "application/json",
}),
body: body
}
return this.http.delete<any>(this.url + 'document-center/content', option)
}
approve(model: DocumentModel): Observable<any> {
let body = {
logId: model.logId,
status: model.status
}
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")
}
}
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Observable, of } from 'rxjs';
import { environment } from "../../../environments/environment";
import { ExcelModel } from '../models/excel.model';
import { ExcelContentModel } from '../models/excel-content.model';
@Injectable({
providedIn: 'root'
})
export class ExcelService {
url = environment.url
createStatus: boolean = true
constructor(private http: HttpClient) { }
getListExcel(status?: string): Observable<ExcelModel[]> {
if(status){
return this.http.get<ExcelModel[]>(this.url + "excel-center/upload/lists?status="+status)
}else{
return this.http.get<ExcelModel[]>(this.url + "excel-center/upload/lists")
}
}
getListExcelContent(status?: string): Observable<ExcelContentModel[]> {
return this.http.get<ExcelContentModel[]>(this.url + "excel-center/content/lists")
}
getExcelById(logId:string): Observable<ExcelModel> {
return this.http.get<ExcelModel>(this.url + "excel-center/upload/"+logId)
}
downloadFile(logId:string):Observable<any>{
return this.http.get(this.url + "excel-center/files/download/"+logId, { responseType: 'blob' })
}
downloadFileContent(logId:string):Observable<any>{
return this.http.get(this.url + "excel-center/files/download/content/"+logId, { responseType: 'blob' });
}
createExcel(model: ExcelModel): Observable<any> {
let body : any = model
if (body.group.groupId=='') {
body.group = undefined
}
return this.http.post(this.url + 'excel-center', body)
}
deleteExcel(model: ExcelModel): Observable<any> {
let body = {
logId: model.logId
}
let option = {
headers: new HttpHeaders({
"Content-Type": "application/json",
}),
body: body
}
return this.http.delete<any>(this.url + 'excel-center/upload', option)
}
deleteExcelContent(model: ExcelContentModel): Observable<any> {
let body = {
excelId: model.excelId
}
let option = {
headers: new HttpHeaders({
"Content-Type": "application/json",
}),
body: body
}
return this.http.delete<any>(this.url + 'excel-center/content', option)
}
approve(model: ExcelModel): Observable<any> {
let body = {
logId: model.logId,
status: model.status
}
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 "../../../environments/environment";
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Observable, of } from 'rxjs';
import { map, tap } from 'rxjs/operators';
import { WidgetModel } from '../models/widgets.model';
import { DocumentContentModel } from '../models/document-content.model';
@Injectable({
providedIn: 'root'
})
export class WidgetService {
url = environment.url
createStatus: boolean = true
constructor(private http: HttpClient) { }
getListWidgets(status?: string): Observable<WidgetModel[]> {
if (status) {
return this.http.get<WidgetModel[]>(this.url + "widget/lists?status=" + status)
} else {
return this.http.get<WidgetModel[]>(this.url + "widget/lists")
}
}
getListExcelContent(status?: string): Observable<DocumentContentModel[]> {
return this.http.get<DocumentContentModel[]>(this.url + "document-center/content/lists")
}
getWidgetById(widgetId: string): Observable<WidgetModel> {
return this.http.get<WidgetModel>(this.url + "widget/" + widgetId)
}
downloadFile(logId:string):Observable<any>{
return this.http.get(this.url + "widget/files/download/"+logId, { responseType: 'blob' })
}
createWidget(model: WidgetModel): Observable<any> {
let body : any = model
return this.http.post(this.url + 'widget', body)
}
deleteWidget(model: WidgetModel): Observable<any> {
let body = {
widgetId: model.widgetId
}
let option = {
headers: new HttpHeaders({
"Content-Type": "application/json",
}),
body: body
}
return this.http.delete<any>(this.url + 'widget', option)
}
deleteExcelContent(model: DocumentContentModel): Observable<any> {
let body = {
docId: model.docId
}
let option = {
headers: new HttpHeaders({
"Content-Type": "application/json",
}),
body: body
}
return this.http.delete<any>(this.url + 'document-center/content', option)
}
getCount(status?: string): Observable<number> {
return this.http.get<number>(this.url + "widget/count")
}
getCountContent(status?: string): Observable<number> {
return this.http.get<number>(this.url + "document-center/content/count")
}
}
...@@ -133,6 +133,12 @@ export class NavService implements OnDestroy { ...@@ -133,6 +133,12 @@ export class NavService implements OnDestroy {
}, },
{ headTitle: 'MyPortal' }, { headTitle: 'MyPortal' },
{ {
icon: 'receipt',
path: '/admin/portal-category-list',
title: 'รายการเอกสาร',
type: 'link',
},
{
icon: 'user', icon: 'user',
path: '/admin/set-excel-reports', path: '/admin/set-excel-reports',
title: 'ตั้งรายงานเอ็กเซล', title: 'ตั้งรายงานเอ็กเซล',
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// The list of file replacements can be found in `angular.json`. // The list of file replacements can be found in `angular.json`.
export const environment = { export const environment = {
production: false, production: false,
baseUrl: 'https://myjob.myhr.co.th/api', baseUrl: 'https://myjob-uat.myhr.co.th/api',
url: 'https://portal.myhr.co.th/api/', url: 'https://portal.myhr.co.th/api/',
portalFixedToken: 'eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJBdXRoIiwidWlkIjoiOGFhNDUzMzAtMzE0Yy0xMWU3LWJhZjMtMmQ3ZDA5ODc3NzQ0Iiwicm9sZSI6InVzZXIiLCJpc3MiOiJDb21wdXRlciBTY2llbmNlIENvcnBvcmF0aW9uIExpbWl0ZWQiLCJmdWxsTmFtZSI6InRlZXJhZGFjaCBrdWhhdGFuYXNhdGllbiIsIm1lbWJlcklkIjoiOGFhNDUzMzAtMzE0Yy0xMWU3LWJhZjMtMmQ3ZDA5ODc3NzQ0In0.FO7u8g7KfzkmZFTuuniBCEQxduPjcvzMbH7iug3DT90', portalFixedToken: 'eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJBdXRoIiwidWlkIjoiOGFhNDUzMzAtMzE0Yy0xMWU3LWJhZjMtMmQ3ZDA5ODc3NzQ0Iiwicm9sZSI6InVzZXIiLCJpc3MiOiJDb21wdXRlciBTY2llbmNlIENvcnBvcmF0aW9uIExpbWl0ZWQiLCJmdWxsTmFtZSI6InRlZXJhZGFjaCBrdWhhdGFuYXNhdGllbiIsIm1lbWJlcklkIjoiOGFhNDUzMzAtMzE0Yy0xMWU3LWJhZjMtMmQ3ZDA5ODc3NzQ0In0.FO7u8g7KfzkmZFTuuniBCEQxduPjcvzMbH7iug3DT90',
firebase: { firebase: {
......
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