-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsample.component.ts
More file actions
97 lines (82 loc) · 2.32 KB
/
sample.component.ts
File metadata and controls
97 lines (82 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import { Component, OnInit } from '@angular/core';
import { ApiserviceService } from '../services/apiservice.service'
import { Subject } from 'rxjs/internal/Subject';
@Component({
selector: 'app-companyprofiles',
templateUrl: './companyprofiles.component.html',
styleUrls: ['./companyprofiles.component.css']
})
export class CompanyprofilesComponent implements OnInit {
//variable declarations and initializations
dtOptions: DataTables.Settings = {};
companyData: Object[] = [];
dtTrigger: Subject<Object[]> = new Subject();
display: string = "none"
company: Object
dataset: boolean
profileBlobUrl: any
profilePhoto: boolean = false
photoMessage: string
constructor(private apiservice:ApiserviceService) { }
ngOnInit() {
//angular datatbles options
this.dtOptions = {
pagingType: 'full_numbers',
pageLength: 10
};
this.apiservice.getAuth('companyP').subscribe(
(res)=>{
if(res.body.code === 200){
this.companyData = res.body.data
this.dtTrigger.next()
}
},
(err)=>{
}
)
}
//function that creates an image from blob
createImageFromBlob(image: Blob){
let reader = new FileReader();
reader.addEventListener("loadend", () => {
this.profileBlobUrl = reader.result;
}, false);
if(image){
reader.readAsDataURL(image)
}
}
//function that opens a modal and displays an image
openModal(company){
this.apiservice.getImages(company.profilePhotoUrl).subscribe((res)=>{
if(res == null){
this.photoMessage = "Unable to retrieve image or image is not available"
this.profilePhoto = true
}else{
this.profileBlobUrl = this.createImageFromBlob(res)
this.profilePhoto = true
}
},
(err)=>{
this.photoMessage = "Image not found"
this.profilePhoto = true
})
this.dataset = true
this.company = company
this.display="block";
}
//funtion that hides an element by setting its display to none
onCloseHandled(){
this.display='none';
}
//simple confirm dialog boxes
verify() {
if(confirm("Are you sure you want to verify this seller ")) {
alert('yeeey')
}
}
unverify() {
if(confirm("Are you sure you want to unverify this seller ")) {
alert('yeeey')
}
}
}