Fix multiples API calls and methods

This commit is contained in:
Tiago Kayaya
2020-11-25 11:25:08 +01:00
parent 029d1e3e28
commit d1214e0313
7 changed files with 41 additions and 19 deletions
@@ -27,7 +27,7 @@ export class AttachmentsPage implements OnInit {
loadAttachments(eventid:string)
{
this.attachamentsService.getEventAttachments(eventid).subscribe(attachments => {
this.attachamentsService.getAttachmentsById(eventid).subscribe(attachments => {
this.loadedEventAttachments = attachments;
this.pageId = eventid;
});
@@ -177,6 +177,10 @@ export class EventDetailModalPage implements OnInit {
/* this.attachamentsService.getEventAttachments(this.pageId).subscribe(attachments => {
this.loadedEventAttachments = attachments;
}); */
this.attachamentsService.getAttachmentsById(this.pageId).subscribe(res => {
console.log(res);
});
}
async viewDocument(documenturl:string)
{
@@ -186,10 +186,12 @@ export class EventDetailPage implements OnInit {
loadAttachments()
{
console.log(this.pageId);
/* console.log(this.pageId); */
this.attachamentsService.getEventAttachments(this.pageId).subscribe(attachments => {
this.loadedEventAttachments = attachments;
this.attachamentsService.getAttachmentsById(this.pageId).subscribe(res => {
this.loadedEventAttachments = res;
console.log(res);
});
}
async viewDocument(documenturl:string)
@@ -36,7 +36,7 @@ export class BookMeetingModalPage implements OnInit {
) {
this.task = this.navParams.get('task');
this.postData = new Event();
this.eventBody = new EventBody;
this.eventBody = { BodyType : "1", Text : ""};
this.postData.Body = this.eventBody;
/* Initialize 'Subject' with the title of the expedient */
@@ -63,7 +63,7 @@ export class BookMeetingModalPage implements OnInit {
}
saveTask(){
this.eventBody={
BodyType: '0',
BodyType: '1',
Text: this.postData.Body.Text,
}
this.postData = {
@@ -89,7 +89,7 @@ export class BookMeetingModalPage implements OnInit {
this.processes.FindTaskDocId(this.task.SerialNumber).subscribe(res =>{
if(res){
this.calendarService.postExpedientEvent(res, this.postData, "md");
this.calendarService.postExpedientEvent(res, this.postData, "md",this.task.SerialNumber);
}
});
this.distartExpedientModal();
@@ -100,8 +100,9 @@ export class BookMeetingModalPage implements OnInit {
const modal = await this.modalController.create({
component: AddParticipantsModalPage,
componentProps: {
eventPersons: this.eventAttendees
},
cssClass: 'add-participants-modal',
cssClass: 'book-meeting-modal',
backdropDismiss: false
});
@@ -110,8 +111,6 @@ export class BookMeetingModalPage implements OnInit {
modal.onDidDismiss().then((res) => {
this.taskParticipants = res.data;
let newattendees: EventPerson[] = res['data'];
if (newattendees != null)
{
newattendees.forEach(newattendee => {
@@ -135,6 +134,7 @@ export class BookMeetingModalPage implements OnInit {
const modal = await this.modalController.create({
component: AddParticipantsCcModalPage,
componentProps: {
eventPersons: this.eventAttendees
},
cssClass: 'add-participants-cc-modal',
backdropDismiss: false
@@ -57,7 +57,7 @@ export class ExpedienteDetailPage implements OnInit {
"DocumentURL": result.formURL
}
this.fulltask = result;
console.log(result);
/* console.log(result); */
});
}
@@ -66,14 +66,15 @@ export class ExpedienteDetailPage implements OnInit {
{
if (this.eventsList == null)
{
this.attachments.getAttachments(2, serial).subscribe(result => {
result.forEach(att =>{
if (this.eventsList == null)
{
this.attachments.getAttachmentsBySerial(serial).subscribe(res => {
console.log(res);
res.forEach(att =>{
if (this.eventsList == null){
this.eventsList = new Array();
}
this.events.getEvent(att.ParentId).subscribe(event => {
this.eventsList.push(event);
console.log(this.eventsList);
});
});
});
+16 -2
View File
@@ -20,11 +20,11 @@ export class AttachmentsService {
this.headers = this.headers.set('Authorization', this.loggeduser.BasicAuthKey);
}
getEventAttachments(eventid: string): Observable<Attachment[]>{
getAttachmentsBySerial(serialNumber: string): Observable<Attachment[]>{
let geturl = environment.apiURL + 'attachments/GetAttachments';
let params = new HttpParams();
params = params.set("ParentId", eventid);
params = params.set("SerialNumber", serialNumber);
let options = {
headers: this.headers,
@@ -45,6 +45,20 @@ export class AttachmentsService {
params: params
};
return this.http.get<Attachment[]>(`${geturl}`, options);
}
getAttachmentsById(eventId: string): Observable<Attachment[]>{
let geturl = environment.apiURL + 'attachments/GetAttachmentsByEventId';
let params = new HttpParams();
params = params.set("ParentId", eventId);
/* params = params.set("SourceId", sourceid); */
let options = {
headers: this.headers,
params: params
};
return this.http.get<Attachment[]>(`${geturl}`, options);
}
}
+3 -2
View File
@@ -178,7 +178,7 @@ export class EventsService {
deleteEvent(eventid:string, deletemode:number)
{
const puturl = environment.apiURL + 'calendar/PostEvent';
const puturl = environment.apiURL + 'calendar/DeleteEvent';
let params = new HttpParams();
params = params.set("EventId", eventid);
@@ -191,11 +191,12 @@ export class EventsService {
return this.http.delete(`${puturl}`, options)
}
postExpedientEvent(docId:any, body:any, sharedagenda:string){
postExpedientEvent(docId:any, body:any, sharedagenda:string, serialNumber:any){
const geturl = environment.apiURL + 'calendar/' + ((sharedagenda != '') ? sharedagenda : 'CreateEventExpediente');
let params = new HttpParams();
params = params.set("DocId", docId);
params = params.set("SerialNumber", serialNumber);
let options = {
headers: this.headers,