|
|
@ -22,13 +22,14 @@ export class AdminComponent implements OnInit { |
|
|
|
|
|
|
|
public selectedExhibitions: any = [] |
|
|
|
public selectedVideos: any = [] |
|
|
|
public selectedGallery: any = [] |
|
|
|
|
|
|
|
// ngModels
|
|
|
|
public title: string = '' |
|
|
|
public type: string = '' |
|
|
|
public content: string = '' |
|
|
|
public tags: string = '' |
|
|
|
public mainImage: string = '' |
|
|
|
public mainImage: any = null |
|
|
|
public videoType: string = '' |
|
|
|
public videoURL: string = '' |
|
|
|
|
|
|
@ -40,6 +41,19 @@ export class AdminComponent implements OnInit { |
|
|
|
) { } |
|
|
|
|
|
|
|
ngOnInit(): void { |
|
|
|
|
|
|
|
this.selectedGallery = [ |
|
|
|
{ |
|
|
|
main: true, |
|
|
|
title: '', |
|
|
|
url: 'http://unsplash.it/800/600' |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '', |
|
|
|
url: 'http://unsplash.it/800/700' |
|
|
|
} |
|
|
|
] |
|
|
|
|
|
|
|
const body = { token: window.sessionStorage.getItem('authToken') } |
|
|
|
this.authService.authCheck(body).toPromise().then((response) => { |
|
|
|
this.authCheck = response.status == 200 |
|
|
@ -58,7 +72,6 @@ export class AdminComponent implements OnInit { |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
login(): void { |
|
|
|
const body = { usr: this.userName, pwd: this.password } |
|
|
|
this.authService.login(body).toPromise().then((response) => { |
|
|
@ -102,4 +115,40 @@ export class AdminComponent implements OnInit { |
|
|
|
videoRemove(url): void { |
|
|
|
this.selectedVideos = this.selectedVideos.filter(item => item.url != url) |
|
|
|
} |
|
|
|
|
|
|
|
onFileChanged(e) { |
|
|
|
const file = (<HTMLInputElement>e.target).files[0] |
|
|
|
const uploadData = new FormData() |
|
|
|
uploadData.append('file', file, file.name) |
|
|
|
this.apisService.uploadImage(uploadData).toPromise().then((response) => { |
|
|
|
this.selectedGallery.push({ |
|
|
|
title: response.title || '', |
|
|
|
url: response.imageUrl |
|
|
|
}) |
|
|
|
},(error) => { |
|
|
|
console.error(error) |
|
|
|
}).catch((e) => { |
|
|
|
console.error(e) |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
gallerySetMain(url): void { |
|
|
|
this.selectedGallery.forEach((e) => { |
|
|
|
if(e.url == url) { |
|
|
|
e.main = true |
|
|
|
} else { |
|
|
|
delete e.main |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
galleryRemove(url): void { |
|
|
|
this.apisService.removeImage(url).toPromise().then((response) => { |
|
|
|
this.selectedGallery = this.selectedGallery.filter(item => item.url != url) |
|
|
|
},(error) => { |
|
|
|
console.error(error) |
|
|
|
}).catch((e) => { |
|
|
|
console.error(e) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|