check in display image using api now
This commit is contained in:
@@ -4,12 +4,14 @@ import { StaffComponent, StaffEditComponent } from './staff';
|
||||
import { AuthGuard } from './route-guard';
|
||||
import { FamilyTree, FamilyList} from './person';
|
||||
import { ImportCom } from './import.com/import.com';
|
||||
import { ImageDisplayComponent } from './pickperson/image.display';
|
||||
export const routes: Routes = [
|
||||
{ path: '', redirectTo: 'login', pathMatch: 'full' },
|
||||
// { path: 'approval', component: ApprovalComponent,canActivate: [AuthGuard], data: { roleAllowed: '1,2,3' }},},
|
||||
{ path: 'login', component: Login},
|
||||
{ path: 'staff', component: StaffComponent},
|
||||
{ path: 'person', component: FamilyList},
|
||||
{ path: 'imagedisplay/:id', component: ImageDisplayComponent},
|
||||
{ path: 'import', component: ImportCom},
|
||||
{ path: 'familytree', component: FamilyTree},
|
||||
{ path: 'staff/:id', component: StaffEditComponent},
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<label class="flex mb-2"> Import Excel File</label>
|
||||
<p-fileupload #fu mode="basic" chooseLabel="Choose"
|
||||
chooseIcon="pi pi-upload" name="file"
|
||||
url="http://localhost:5015/api/FileUpload/UploadFile"
|
||||
url='{{baseUrl}}'
|
||||
maxFileSize="10000000000" (onUpload)="onUpload($event)" />
|
||||
<p-button styleClass="mt-4" label="Upload" (onClick)="fu.upload()" severity="primary" />
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { Component, inject, OnInit } from '@angular/core';
|
||||
import { ButtonModule } from 'primeng/button';
|
||||
import { FileUploadEvent, FileUploadModule } from 'primeng/fileupload';
|
||||
import { MessageService } from 'primeng/api';
|
||||
import { FileUpload } from 'primeng/fileupload';
|
||||
import { ToastModule } from 'primeng/toast';
|
||||
import { AppSettingService } from '../shares';
|
||||
/*
|
||||
interface UploadEvent {
|
||||
originalEvent: Event;
|
||||
@@ -16,9 +17,17 @@ interface UploadEvent {
|
||||
templateUrl: './import.com.html',
|
||||
styleUrl: './import.com.css'
|
||||
})
|
||||
export class ImportCom {
|
||||
export class ImportCom implements OnInit {
|
||||
uploadedFiles: any[] = [];
|
||||
baseUrl = "";
|
||||
private appSetting = inject(AppSettingService);
|
||||
constructor(private messageService: MessageService) {}
|
||||
ngOnInit(): void
|
||||
{
|
||||
const cbaseUrl = this.appSetting.appSetting.baseUrl;
|
||||
//http://localhost:5015/api/FileUpload/UploadFile"
|
||||
this.baseUrl = cbaseUrl + "/api/FileUpload/UploadFile";
|
||||
}
|
||||
onUpload(event:FileUploadEvent) {
|
||||
for(let file of event.files) {
|
||||
this.uploadedFiles.push(file);
|
||||
|
||||
@@ -12,5 +12,6 @@ export enum ConfigureUrl
|
||||
logoutUrl ="api/Users/Logout",
|
||||
adminUserUrl = "api/Staff",
|
||||
lookupUrl = "api/Lookup",
|
||||
FileUploadUrl = "api/FileUpload",
|
||||
|
||||
}
|
||||
@@ -5,9 +5,7 @@ import { OrganizationChartModule } from 'primeng/organizationchart';
|
||||
|
||||
import { take } from 'rxjs/operators';
|
||||
import { Subscription } from 'rxjs';
|
||||
import { Router } from '@angular/router';
|
||||
import { PersonService } from './person.service';
|
||||
import { AuthenticationService } from '../user-services';
|
||||
import { TableModule } from 'primeng/table';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { CommonModule } from '@angular/common';
|
||||
@@ -41,15 +39,13 @@ export class FamilyOrga implements OnInit, OnDestroy{
|
||||
familyList:Person[] = [];
|
||||
msg ="[Person organise component]";
|
||||
private messageService = inject(MessageService);
|
||||
public ref = inject(DynamicDialogRef);
|
||||
public config = inject(DynamicDialogConfig);
|
||||
/*
|
||||
private store: Store<appValidationState>
|
||||
*/
|
||||
constructor(
|
||||
public dialogService: DialogService,
|
||||
private personService: PersonService,
|
||||
|
||||
public ref: DynamicDialogRef, public config: DynamicDialogConfig,
|
||||
) {}
|
||||
private personService = inject(PersonService);
|
||||
public dialogService = inject(DialogService);
|
||||
|
||||
ngOnInit(): void
|
||||
{
|
||||
|
||||
@@ -38,25 +38,25 @@ export class FamilyList implements OnInit, OnDestroy{
|
||||
//private cd = inject(ChangeDetectorRef);
|
||||
items: MenuItem[] | undefined;
|
||||
selectedPerson!: Person;
|
||||
firstname = '';
|
||||
email = '';
|
||||
lastname = '';
|
||||
_id = -10;
|
||||
selectId = -1;
|
||||
loading = false;
|
||||
familyList = signal<Person[]>([]);
|
||||
msg ="[Person component]";
|
||||
@ViewChild(Table) dt2!: Table;
|
||||
@ViewChild('rowmenu') popMenu?: Menu;
|
||||
private messageService = inject(MessageService);
|
||||
public dialogService= inject( DialogService);
|
||||
firstname = '';
|
||||
email = '';
|
||||
lastname = '';
|
||||
_id = -10;
|
||||
selectId = -1;
|
||||
loading = false;
|
||||
familyList = signal<Person[]>([]);
|
||||
msg ="[Person component]";
|
||||
@ViewChild(Table) dt2!: Table;
|
||||
@ViewChild('rowmenu') popMenu?: Menu;
|
||||
private messageService = inject(MessageService);
|
||||
public dialogService= inject( DialogService);
|
||||
private personService= inject( PersonService);
|
||||
private confirmationService = inject(ConfirmationService);
|
||||
private cd = inject(ChangeDetectorRef);
|
||||
private cdr = inject(ChangeDetectorRef);
|
||||
private authenticationService= inject( AuthenticationService);
|
||||
private router= inject( Router);
|
||||
constructor() {}
|
||||
getSearchCiteria(): StaffSearch {
|
||||
|
||||
getSearchCiteria(): StaffSearch {
|
||||
let criteria:StaffSearch = {
|
||||
email: this.email,
|
||||
firstName: this.firstname,
|
||||
@@ -182,7 +182,7 @@ export class FamilyList implements OnInit, OnDestroy{
|
||||
|
||||
console.log("the person from load", this.familyList());
|
||||
this.loading = false;
|
||||
this.cd.detectChanges();
|
||||
this.cdr.detectChanges();
|
||||
},
|
||||
error: e => {
|
||||
const message = e || e.message;
|
||||
@@ -250,6 +250,7 @@ export class FamilyList implements OnInit, OnDestroy{
|
||||
|
||||
const nlist = this.familyList().filter(d => d.id !== id);
|
||||
this.familyList.set(nlist);
|
||||
this.cdr.detectChanges();
|
||||
},
|
||||
error: e => console.error(e)
|
||||
});
|
||||
@@ -311,19 +312,21 @@ export class FamilyList implements OnInit, OnDestroy{
|
||||
}
|
||||
|
||||
updateList(item: Person) :void {
|
||||
const idx = this.familyList().findIndex( x => x.id == item.id);
|
||||
const list = this.familyList();
|
||||
const idx = list.findIndex( x => x.id === item.id);
|
||||
if (item.fatherId && item.fatherId > 0)
|
||||
item.fatherName = this.getName(item.fatherId);
|
||||
if (item.motherId && item.motherId > 0)
|
||||
item.motherName = this.getName(item.motherId);
|
||||
if (idx < 0)
|
||||
{
|
||||
const olist = [... this.familyList(), item];
|
||||
const olist = [... list, item];
|
||||
this.familyList.set(olist);
|
||||
}
|
||||
else
|
||||
{
|
||||
const oitem = this.familyList()[idx];
|
||||
|
||||
const oitem = list[idx];
|
||||
oitem.firstName = item.firstName;
|
||||
oitem.lastName = item.lastName;
|
||||
oitem.address = item.address;
|
||||
@@ -335,7 +338,9 @@ export class FamilyList implements OnInit, OnDestroy{
|
||||
oitem.motherId = item.motherId;
|
||||
oitem.fatherName = item.fatherName;
|
||||
oitem.motherName = item.motherName;
|
||||
this.familyList.set(list);
|
||||
}
|
||||
this.cdr.markForCheck();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -53,11 +53,15 @@
|
||||
|
||||
<div>
|
||||
<div class="field col-12 md:col-6 sm:col-8">
|
||||
<div class="shadow-md rounded-xl border-gray-100 border-1 p-4">
|
||||
@if (adminuserForm.value.image != "" && adminuserForm.value.image != null)
|
||||
{
|
||||
<div class="ml-6 file-upload">
|
||||
<a href="{{hostsite}}/{{adminuserForm.value.image}}" target="_blank" class="text-blue-400">View Attachment
|
||||
</a>
|
||||
<!--a href="{{hostsite}}/{{adminuserForm.value.image}}" target="_blank" class="text-blue-400">View Attachment
|
||||
</a-->
|
||||
<button pButton type="button" icon="pi pi-image"
|
||||
class ="p-ripple p-button p-button-raised p-button-text p-button-warn p-component"
|
||||
pTooltip="view Image" (click)="doViewImage(adminuserForm.value.image)"></button>
|
||||
<button pButton type="button" icon="pi pi-times" pTooltip="remove attach file"
|
||||
class="p-button-rounded p-button-text text-red-500 p-button-raised ml-2"
|
||||
(click)="deleteFile()"></button>
|
||||
@@ -65,7 +69,7 @@
|
||||
}
|
||||
@else
|
||||
{
|
||||
<div class="ml-6">
|
||||
<div class="ml-6 ">
|
||||
<input type="file" class="file-input" (change)="onFileSelected($event)" #fileUpload>
|
||||
<div class="file-upload">
|
||||
<label>{{ adminuserForm.value.image || "No attachment file uploaded yet."}}</label>
|
||||
@@ -75,11 +79,12 @@
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-2 w-full">
|
||||
<p-button class="flex justify-end mr-2" icon="pi pi-user" label="Add Partner"
|
||||
severity="warn" (onClick)="addPartner()"/>
|
||||
<p-button class="flex justify-end mr-2" icon="pi pi-user" [raised]="true" severity="info" label="Add Partner"
|
||||
(onClick)="addPartner()"/>
|
||||
<div class="shadow rounded mt-2 mb-2">
|
||||
<p-table [value]="partners()">
|
||||
<ng-template #header>
|
||||
|
||||
@@ -17,7 +17,8 @@ import moment from 'moment';
|
||||
import { HttpEvent } from '@angular/common/http';
|
||||
import { TableModule } from 'primeng/table';
|
||||
import { Pickperson } from '../pickperson/pickperson';
|
||||
|
||||
import { ImageDisplayComponent } from '../pickperson/image.display';
|
||||
import { TooltipModule } from 'primeng/tooltip';
|
||||
|
||||
export interface FileUploadEvent {
|
||||
originalEvent: HttpEvent<any>;
|
||||
@@ -30,7 +31,8 @@ export interface FileUploadHandlerEvent {
|
||||
@Component({
|
||||
templateUrl: 'person.edit.html',
|
||||
selector: 'person-edit',
|
||||
imports:[ButtonModule,TableModule,ReactiveFormsModule,SelectModule,CheckboxModule, InputTextModule,DatePickerModule],
|
||||
imports:[ButtonModule,TableModule,ReactiveFormsModule,TooltipModule,
|
||||
SelectModule,CheckboxModule, InputTextModule,DatePickerModule],
|
||||
styleUrls: ['person.edit.css'],
|
||||
providers: [DialogService]
|
||||
|
||||
@@ -233,8 +235,7 @@ populateSex(): void {
|
||||
name:"Male",
|
||||
status:'M'
|
||||
};
|
||||
this.sexList.push(item);
|
||||
|
||||
this.sexList.push(item);
|
||||
}
|
||||
|
||||
ngOnInit():void {
|
||||
@@ -275,10 +276,33 @@ ngOnInit():void {
|
||||
// this for disable submit button
|
||||
get isFieldsChange() {
|
||||
const chan = this.isChange || !this.adminuserForm.valid; // this disable so need true valid = true not
|
||||
//console.log(this.msg + 'is fields change', chan);
|
||||
console.log(this.msg + 'is fields change', chan);
|
||||
return chan;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
doViewImage(imageName:string): void {
|
||||
const ref = this.dialogService.open(ImageDisplayComponent, {
|
||||
data: {
|
||||
imageName,
|
||||
},
|
||||
|
||||
header: 'View Image',
|
||||
draggable: true,
|
||||
width: '70%',
|
||||
modal:true,
|
||||
maximizable: true
|
||||
});
|
||||
|
||||
ref.onClose.subscribe((item: Person) => {
|
||||
if (item) {
|
||||
//console.log("after close ward edit", item);
|
||||
this.messageService.add({severity:'success', summary: 'Select', detail: item.firstName!});
|
||||
//update the current list
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
assignValue(item:Person): void {
|
||||
this._id = item.id;
|
||||
this.fileName = item.image!;
|
||||
@@ -537,7 +561,7 @@ showPickPerson(title:string, callback:(id: Person) => void) :void {
|
||||
},
|
||||
header: title,
|
||||
width: '80%',
|
||||
|
||||
draggable: true,
|
||||
maximizable: true
|
||||
});
|
||||
|
||||
|
||||
@@ -77,6 +77,13 @@ export class PersonService {
|
||||
const baseUrl = this.appSetting.appSetting.baseUrl + "/" + ConfigureUrl.personUrl + "/UploadImage";
|
||||
return this.http.post<ResultModel<string>>(baseUrl, data);
|
||||
}
|
||||
downloadFile(imageName: string): Observable<ResultModel<string>> {
|
||||
const baseUrl = this.appSetting.appSetting.baseUrl + "/" + ConfigureUrl.FileUploadUrl + "/DownloadFile";
|
||||
const data = {
|
||||
fileName: imageName
|
||||
};
|
||||
return this.http.post<ResultModel<string>>(baseUrl, data);
|
||||
}
|
||||
deleteUploadFile(data: any): Observable<ResultModel<number>> {
|
||||
//data ={filename};
|
||||
const baseUrl = this.appSetting.appSetting.baseUrl + "/" + ConfigureUrl.personUrl + "/DeleteUploadFile";
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
<img [src]="imageDataUrl" alt="Person Image" width="400" height="300"/>
|
||||
<div class="flex justify-end">
|
||||
|
||||
<button pButton pRipple class="p-button-sm mr-2 p-button-secondary" type="button" icon="pi pi-sign-in" label="Close"
|
||||
(click)="close()"></button>
|
||||
</div>
|
||||
@@ -0,0 +1,64 @@
|
||||
import { Component, inject, OnDestroy, OnInit } from '@angular/core';
|
||||
import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';
|
||||
import { AppSettingService } from '../shares';
|
||||
import { PersonService } from '../person';
|
||||
import { Subscription } from 'rxjs';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { ButtonModule } from 'primeng/button';
|
||||
import { DynamicDialogConfig, DynamicDialogRef } from 'primeng/dynamicdialog';
|
||||
|
||||
@Component({
|
||||
selector: 'app-image-display',
|
||||
imports:[CommonModule, ButtonModule],
|
||||
templateUrl: './image.display.html',
|
||||
styleUrls: ['./image.display.css']
|
||||
})
|
||||
export class ImageDisplayComponent implements OnInit, OnDestroy {
|
||||
//base64ImageString: string = 'iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=='; // Example Base64 (a tiny red dot PNG)
|
||||
//imageDataUrl: SafeResourceUrl ={};
|
||||
imageDataUrl = "";
|
||||
private personService = inject(PersonService);
|
||||
private sanitizer = inject(DomSanitizer);
|
||||
//private route = inject(ActivatedRoute);
|
||||
public ref = inject(DynamicDialogRef);
|
||||
public config = inject(DynamicDialogConfig);
|
||||
private subscription:Subscription = new Subscription();
|
||||
|
||||
ngOnInit(): void {
|
||||
|
||||
const imageName = this.config.data.imageName;
|
||||
this.loadImage(imageName);
|
||||
|
||||
}
|
||||
loadImage(fileName: string| null): void {
|
||||
const download = this.personService.downloadFile(fileName!);
|
||||
this.subscription.add(download.subscribe({
|
||||
next: x => {
|
||||
if (x.statusCode == 1)
|
||||
{
|
||||
this.display(x.data);
|
||||
console.log("this is show image" , this.imageDataUrl, x);
|
||||
}
|
||||
else
|
||||
{
|
||||
console.log("error in download in api ", x.message);
|
||||
}
|
||||
},
|
||||
error: e => console.error("error in download image", e)
|
||||
}));
|
||||
}
|
||||
display(baseImage: string): void
|
||||
{
|
||||
const changeUrl = (this.sanitizer.bypassSecurityTrustResourceUrl(baseImage) as any).changingThisBreaksApplicationSecurity;
|
||||
console.log('this is bypassSecurityTrustResourceUrl', changeUrl);
|
||||
const fullDataUri = `data:image/png;base64,${changeUrl}`;
|
||||
this.imageDataUrl = fullDataUri
|
||||
}
|
||||
ngOnDestroy(): void {
|
||||
this.subscription.unsubscribe();
|
||||
}
|
||||
close() :void {
|
||||
this.ref.close(null);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user