mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 12:37:53 +00:00
172 lines
4.6 KiB
TypeScript
172 lines
4.6 KiB
TypeScript
import { Component, OnInit } from '@angular/core';
|
|
import { AlertController, ModalController, NavParams } from '@ionic/angular';
|
|
import { AuthConnstants } from 'src/app/config/auth-constants';
|
|
import { Attachment } from 'src/app/models/attachment.model';
|
|
import { EventBody } from 'src/app/models/eventbody.model';
|
|
import { AttachmentsService } from 'src/app/services/attachments.service';
|
|
import { EventsService } from 'src/app/services/events.service';
|
|
import { Event } from '../../../models/event.model';
|
|
import { EditEventPage } from '../edit-event/edit-event.page';
|
|
import { InAppBrowser } from '@ionic-native/in-app-browser/ngx';
|
|
import { ProcessesService } from 'src/app/services/processes.service';
|
|
|
|
@Component({
|
|
selector: 'app-view-event',
|
|
templateUrl: './view-event.page.html',
|
|
styleUrls: ['./view-event.page.scss'],
|
|
})
|
|
|
|
export class ViewEventPage implements OnInit {
|
|
|
|
loadedEvent: Event;
|
|
isEventEdited: boolean;
|
|
eventBody: EventBody;
|
|
loadedAttachments:any;
|
|
loadedEventAttachments: Attachment[];
|
|
pageId: string;
|
|
showLoader: boolean;
|
|
|
|
minDate: Date;
|
|
|
|
profile:string;
|
|
eventId:string;
|
|
customDate:any;
|
|
today:any;
|
|
|
|
months = ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"];
|
|
days = ["Domingo", "Segunda-feira", "Terça-feira", "Quarta-feira", "Quinta-feira", "Sexta-feira", "Sábado"];
|
|
|
|
constructor(
|
|
private modalController: ModalController,
|
|
private navParams: NavParams,
|
|
private eventsService: EventsService,
|
|
private attachmentsService: AttachmentsService,
|
|
public alertController: AlertController,
|
|
private iab: InAppBrowser,
|
|
private processes: ProcessesService,
|
|
)
|
|
{
|
|
this.profile = this.navParams.get('profile');
|
|
this.isEventEdited = false;
|
|
this.loadedEvent = new Event();
|
|
this.eventBody = { BodyType : "1", Text : ""};
|
|
this.loadedEvent.Body = this.eventBody;
|
|
this.eventId = this.navParams.get('eventId');
|
|
}
|
|
|
|
ngOnInit() {
|
|
/* console.log(this.eventId); */
|
|
this.loadEvent();
|
|
this.getAttachments();
|
|
|
|
|
|
window.onresize = (event) => {
|
|
// if not mobile remove all component
|
|
if( window.innerWidth >= 1024){
|
|
this.modalController.dismiss(this.isEventEdited);
|
|
}
|
|
};
|
|
|
|
}
|
|
|
|
close(){
|
|
console.log(this.isEventEdited);
|
|
this.modalController.dismiss(this.isEventEdited);
|
|
}
|
|
|
|
loadEvent(){
|
|
this.eventsService.getEvent(this.eventId).subscribe(res => {
|
|
this.loadedEvent = res;
|
|
|
|
console.log(res);
|
|
|
|
this.today = new Date(res.StartDate);
|
|
console.log(new Date(this.today));
|
|
this.customDate = this.days[this.today.getDay()]+ ", " + this.today.getDate() +" de " + ( this.months[this.today.getMonth()]);
|
|
});
|
|
}
|
|
|
|
deleteEvent(){
|
|
this.eventsService.deleteEvent(this.loadedEvent.EventId, 0).subscribe(async () =>
|
|
{
|
|
const alert = await this.alertController.create({
|
|
cssClass: 'my-custom-class',
|
|
header: 'Evento removido',
|
|
buttons: ['OK']
|
|
});
|
|
|
|
await alert.present();
|
|
this.close();
|
|
});
|
|
}
|
|
|
|
getAttachments(){
|
|
this.attachmentsService.getAttachmentsById(this.eventId).subscribe(res=>{
|
|
this.loadedAttachments = res;
|
|
console.log(res);
|
|
});
|
|
}
|
|
|
|
async editEventDetail() {
|
|
|
|
let classs;
|
|
if( window.innerWidth <= 800){
|
|
classs = 'modal'
|
|
} else {
|
|
classs = 'modal modal-desktop'
|
|
}
|
|
|
|
const modal = await this.modalController.create({
|
|
component: EditEventPage,
|
|
componentProps: {
|
|
eventId: this.loadedEvent.EventId,
|
|
profile: this.profile,
|
|
},
|
|
cssClass: classs,
|
|
});
|
|
|
|
}
|
|
|
|
async editEvent() {
|
|
|
|
let classs;
|
|
if( window.innerWidth <= 800){
|
|
classs = 'modal'
|
|
} else {
|
|
classs = 'modal modal-desktop showAsideOptions'
|
|
}
|
|
|
|
const modal = await this.modalController.create({
|
|
component: EditEventPage,
|
|
componentProps:{
|
|
event: this.loadedEvent,
|
|
profile: this.profile,
|
|
},
|
|
cssClass: classs,
|
|
});
|
|
await modal.present();
|
|
modal.onDidDismiss().then((res) => {
|
|
console.log(res);
|
|
|
|
if(res){
|
|
setTimeout(() => {
|
|
/* this.loadEvent(); */
|
|
this.getAttachments();
|
|
}, 250);
|
|
this.isEventEdited = true;
|
|
}
|
|
});
|
|
}
|
|
|
|
viewDocument(sourceId){
|
|
this.processes.GetDocumentUrl(sourceId, '8').subscribe(res=>{
|
|
console.log(res);
|
|
const url: string = res.replace("webTRIX.Viewer","webTRIX.Viewer.Branch1");
|
|
const browser = this.iab.create(url,"_blank");
|
|
browser.show();
|
|
|
|
});
|
|
}
|
|
|
|
}
|