Commit a9294f38 by DESKTOP-E3GSHH7\myhr

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

parent bedbea55
......@@ -103,10 +103,6 @@
</td>
<td>
<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()"
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>
......
......@@ -105,7 +105,7 @@ export class ArticleManageComponent {
uploadConfig() {
this.uploaderProfile = new FileUploader({
url: environment.baseUrl + "/api/upload-image",
url: environment.baseUrl + "/files/upload-image",
isHTML5: true,
authToken: this.tokenService.getToken()!,
});
......@@ -144,8 +144,9 @@ export class ArticleManageComponent {
if (item.isSuccess) {
const res = JSON.parse(response);
console.log("res", res);
this.selectModel.picture = res.filename;
this.selectModel.picture = res.resultObject;
swal(res.message, "บันทึกสำเร็จ", "success");
console.log('After Upload, selectModel is:', this.selectModel);
} else {
this.uploadErrorMsg = "cannot upload file.";
swal("Opp!!", "ไม่สามารถอัพโหลดได้", "info");
......@@ -228,6 +229,7 @@ export class ArticleManageComponent {
}
save() {
console.log('Before Save, selectModel is:', this.selectModel);
swal({
title: "คุณแน่ใจหรือไม่?",
text: "คุณต้องการบันทึกหรือไม่",
......
......@@ -197,7 +197,7 @@
<span class="avatar avatar-xxl avatar-rounded">
<img [src]="selectModel.getPicture()" alt="" id="profile-img">
<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">
<i class="fe fe-camera text-[.625rem]"></i>
</span>
......
......@@ -34,6 +34,7 @@ import { CompanyServiceS } from '../../services/companys.service';
export class CompanyManageComponent {
@ViewChild('closeModal') public childModal?: ElementRef;
@ViewChild('modalDetail') public modalDetail?: ElementRef;
@ViewChild('profileChangeInput') profileChangeInputRef!: ElementRef;
action = "new";
allSelected = false;
someSelected = false;
......@@ -69,7 +70,7 @@ export class CompanyManageComponent {
uploadConfig() {
this.uploaderProfile = new FileUploader({
url: environment.baseUrl + "/api/upload-image",
url: environment.baseUrl + "/files/upload-image",
isHTML5: true,
authToken: this.tokenService.getToken()!,
});
......@@ -108,7 +109,7 @@ export class CompanyManageComponent {
if (item.isSuccess) {
const res = JSON.parse(response);
console.log("res", res);
this.selectModel.photoGraph = res.filename;
this.selectModel.photoGraph = res.resultObject;
swal(res.message, "บันทึกสำเร็จ", "success");
} else {
this.uploadErrorMsg = "cannot upload file.";
......@@ -343,6 +344,11 @@ export class CompanyManageComponent {
}
});
}
triggerFileInput(): void {
if (this.profileChangeInputRef) {
this.profileChangeInputRef.nativeElement.click();
}
}
}
// import { Component, ElementRef, ViewChild } from '@angular/core';
// import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
......
......@@ -96,7 +96,12 @@ export class UserProfileModel extends BaseModel {
}
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 {
......
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