Commit a9294f38 by DESKTOP-E3GSHH7\myhr

เเก้ไขอัพโหลดรูป

parent bedbea55
...@@ -103,10 +103,6 @@ ...@@ -103,10 +103,6 @@
</td> </td>
<td> <td>
<div class="flex flex-row items-center !gap-2 "> <div class="flex flex-row items-center !gap-2 ">
<a aria-label="anchor" (click)="viewArticleDetail(item.articleId)"
class="ti-btn ti-btn-wave !gap-0 !m-0 bg-info/10 text-info hover:bg-info hover:text-white hover:border-info">
<i class="ri-search-line"></i>
</a>
<a aria-label="anchor" (click)="view(item)" (click)="openDialog()" <a aria-label="anchor" (click)="view(item)" (click)="openDialog()"
class="ti-btn ti-btn-wave !gap-0 !m-0 bg-info/10 text-info hover:bg-info hover:text-white hover:border-info"> class="ti-btn ti-btn-wave !gap-0 !m-0 bg-info/10 text-info hover:bg-info hover:text-white hover:border-info">
<i class="ri-pencil-line"></i> <i class="ri-pencil-line"></i>
......
...@@ -105,7 +105,7 @@ export class ArticleManageComponent { ...@@ -105,7 +105,7 @@ export class ArticleManageComponent {
uploadConfig() { uploadConfig() {
this.uploaderProfile = new FileUploader({ this.uploaderProfile = new FileUploader({
url: environment.baseUrl + "/api/upload-image", url: environment.baseUrl + "/files/upload-image",
isHTML5: true, isHTML5: true,
authToken: this.tokenService.getToken()!, authToken: this.tokenService.getToken()!,
}); });
...@@ -144,8 +144,9 @@ export class ArticleManageComponent { ...@@ -144,8 +144,9 @@ export class ArticleManageComponent {
if (item.isSuccess) { if (item.isSuccess) {
const res = JSON.parse(response); const res = JSON.parse(response);
console.log("res", res); console.log("res", res);
this.selectModel.picture = res.filename; this.selectModel.picture = res.resultObject;
swal(res.message, "บันทึกสำเร็จ", "success"); swal(res.message, "บันทึกสำเร็จ", "success");
console.log('After Upload, selectModel is:', this.selectModel);
} else { } else {
this.uploadErrorMsg = "cannot upload file."; this.uploadErrorMsg = "cannot upload file.";
swal("Opp!!", "ไม่สามารถอัพโหลดได้", "info"); swal("Opp!!", "ไม่สามารถอัพโหลดได้", "info");
...@@ -228,6 +229,7 @@ export class ArticleManageComponent { ...@@ -228,6 +229,7 @@ export class ArticleManageComponent {
} }
save() { save() {
console.log('Before Save, selectModel is:', this.selectModel);
swal({ swal({
title: "คุณแน่ใจหรือไม่?", title: "คุณแน่ใจหรือไม่?",
text: "คุณต้องการบันทึกหรือไม่", text: "คุณต้องการบันทึกหรือไม่",
......
...@@ -197,7 +197,7 @@ ...@@ -197,7 +197,7 @@
<span class="avatar avatar-xxl avatar-rounded"> <span class="avatar avatar-xxl avatar-rounded">
<img [src]="selectModel.getPicture()" alt="" id="profile-img"> <img [src]="selectModel.getPicture()" alt="" id="profile-img">
<span class="badge rounded-full bg-primary avatar-badge"> <span class="badge rounded-full bg-primary avatar-badge">
<input ng2FileSelect [uploader]="uploaderProfile" type="file" name="photo" <input (click)="triggerFileInput()" ng2FileSelect [uploader]="uploaderProfile" type="file" name="photo"
class="absolute w-full h-full opacity-[0]" id="profile-change"> class="absolute w-full h-full opacity-[0]" id="profile-change">
<i class="fe fe-camera text-[.625rem]"></i> <i class="fe fe-camera text-[.625rem]"></i>
</span> </span>
......
...@@ -34,6 +34,7 @@ import { CompanyServiceS } from '../../services/companys.service'; ...@@ -34,6 +34,7 @@ import { CompanyServiceS } from '../../services/companys.service';
export class CompanyManageComponent { export class CompanyManageComponent {
@ViewChild('closeModal') public childModal?: ElementRef; @ViewChild('closeModal') public childModal?: ElementRef;
@ViewChild('modalDetail') public modalDetail?: ElementRef; @ViewChild('modalDetail') public modalDetail?: ElementRef;
@ViewChild('profileChangeInput') profileChangeInputRef!: ElementRef;
action = "new"; action = "new";
allSelected = false; allSelected = false;
someSelected = false; someSelected = false;
...@@ -69,7 +70,7 @@ export class CompanyManageComponent { ...@@ -69,7 +70,7 @@ export class CompanyManageComponent {
uploadConfig() { uploadConfig() {
this.uploaderProfile = new FileUploader({ this.uploaderProfile = new FileUploader({
url: environment.baseUrl + "/api/upload-image", url: environment.baseUrl + "/files/upload-image",
isHTML5: true, isHTML5: true,
authToken: this.tokenService.getToken()!, authToken: this.tokenService.getToken()!,
}); });
...@@ -108,7 +109,7 @@ export class CompanyManageComponent { ...@@ -108,7 +109,7 @@ export class CompanyManageComponent {
if (item.isSuccess) { if (item.isSuccess) {
const res = JSON.parse(response); const res = JSON.parse(response);
console.log("res", res); console.log("res", res);
this.selectModel.photoGraph = res.filename; this.selectModel.photoGraph = res.resultObject;
swal(res.message, "บันทึกสำเร็จ", "success"); swal(res.message, "บันทึกสำเร็จ", "success");
} else { } else {
this.uploadErrorMsg = "cannot upload file."; this.uploadErrorMsg = "cannot upload file.";
...@@ -343,6 +344,11 @@ export class CompanyManageComponent { ...@@ -343,6 +344,11 @@ export class CompanyManageComponent {
} }
}); });
} }
triggerFileInput(): void {
if (this.profileChangeInputRef) {
this.profileChangeInputRef.nativeElement.click();
}
}
} }
// import { Component, ElementRef, ViewChild } from '@angular/core'; // import { Component, ElementRef, ViewChild } from '@angular/core';
// import { DomSanitizer, SafeHtml } from '@angular/platform-browser'; // import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
......
...@@ -96,7 +96,12 @@ export class UserProfileModel extends BaseModel { ...@@ -96,7 +96,12 @@ export class UserProfileModel extends BaseModel {
} }
getPicture(): string { getPicture(): string {
return this.picture ? environment.baseUrl + '/images/' + this.picture : './assets/images/faces/1.jpg'; if (this.picture) {
return environment.baseUrl + "/files/image/" + this.picture
} else {
return ""
}
} }
getFullname(): string { getFullname(): string {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment