2020-08-24 23:41:15 +01:00
|
|
|
import { Component, OnInit } from '@angular/core';
|
|
|
|
|
import { AttachmentsService } from 'src/app/services/attachments.service';
|
|
|
|
|
import { Attachment } from 'src/app/models/attachment.model';
|
2020-08-27 12:36:09 +01:00
|
|
|
import { ActivatedRoute, Router } from '@angular/router';
|
2020-08-25 14:08:13 +01:00
|
|
|
import { InAppBrowser } from '@ionic-native/in-app-browser/ngx';
|
2020-08-24 23:41:15 +01:00
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'app-attachments',
|
|
|
|
|
templateUrl: './attachments.page.html',
|
|
|
|
|
styleUrls: ['./attachments.page.scss'],
|
|
|
|
|
})
|
|
|
|
|
export class AttachmentsPage implements OnInit {
|
|
|
|
|
|
|
|
|
|
loadedEventAttachments: Attachment[];
|
2020-08-27 12:36:09 +01:00
|
|
|
pageId: string;
|
2020-08-24 23:41:15 +01:00
|
|
|
|
2020-08-28 12:43:19 +01:00
|
|
|
constructor(private attachamentsService: AttachmentsService, private activatedRoute: ActivatedRoute, private iab: InAppBrowser, private route: Router) { }
|
2020-08-24 23:41:15 +01:00
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
|
/* Emit new data when something changes */
|
|
|
|
|
this.activatedRoute.paramMap.subscribe(paramMap =>{
|
|
|
|
|
if(!paramMap.has('eventId')){
|
|
|
|
|
//Redirect
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.loadAttachments(paramMap.get('eventId'));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
loadAttachments(eventid:string)
|
|
|
|
|
{
|
|
|
|
|
this.attachamentsService.getEventAttachments(eventid).subscribe(attachments => {
|
|
|
|
|
this.loadedEventAttachments = attachments;
|
2020-08-27 12:36:09 +01:00
|
|
|
this.pageId = eventid;
|
2020-08-24 23:41:15 +01:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-27 15:59:51 +01:00
|
|
|
async viewDocument(documenturl:string)
|
2020-08-25 14:08:13 +01:00
|
|
|
{
|
2020-08-28 12:53:37 +01:00
|
|
|
const url: string = documenturl.replace("webTRIX.Viewer","webTRIX.Viewer.Branch1");
|
2020-08-28 12:43:19 +01:00
|
|
|
const browser = this.iab.create(url,"_blank");
|
2020-08-25 14:08:13 +01:00
|
|
|
browser.show();
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-27 12:36:09 +01:00
|
|
|
navigateBack(){
|
2020-09-07 15:50:36 +01:00
|
|
|
console.log(this.pageId);
|
2020-08-27 12:36:09 +01:00
|
|
|
this.route.navigate(['/home/events',this.pageId]);
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-24 23:41:15 +01:00
|
|
|
}
|