Files
doneit-web/src/app/pages/events/attachments/attachments.page.ts
T

51 lines
1.5 KiB
TypeScript
Raw Normal View History

import { Component, OnInit } from '@angular/core';
import { AttachmentsService } from 'src/app/services/attachments.service';
import { Attachment } from 'src/app/models/attachment.model';
import { ActivatedRoute, Router } from '@angular/router';
import { InAppBrowser } from '@ionic-native/in-app-browser/ngx';
@Component({
selector: 'app-attachments',
templateUrl: './attachments.page.html',
styleUrls: ['./attachments.page.scss'],
})
export class AttachmentsPage implements OnInit {
loadedEventAttachments: Attachment[];
pageId: string;
2020-08-28 12:43:19 +01:00
constructor(private attachamentsService: AttachmentsService, private activatedRoute: ActivatedRoute, private iab: InAppBrowser, private route: Router) { }
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;
this.pageId = eventid;
});
}
2020-08-27 15:59:51 +01:00
async viewDocument(documenturl:string)
{
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");
browser.show();
}
navigateBack(){
2020-09-07 15:50:36 +01:00
console.log(this.pageId);
this.route.navigate(['/home/events',this.pageId]);
}
}