mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
Add faild and success message
This commit is contained in:
@@ -2,6 +2,8 @@ import { Component, OnInit } from '@angular/core';
|
||||
import { ModalController } from '@ionic/angular';
|
||||
import { PublicationFolder } from 'src/app/models/publicationfolder';
|
||||
import { PublicationsService } from 'src/app/services/publications.service';
|
||||
import { BadRequestComponent } from 'src/app/shared/popover/bad-request/bad-request.component';
|
||||
import { SuccessMessageComponent } from 'src/app/shared/popover/success-message/success-message.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-new-action',
|
||||
@@ -28,7 +30,7 @@ export class NewActionPage implements OnInit {
|
||||
console.log(ev.detail.value);
|
||||
}
|
||||
|
||||
save(){
|
||||
async save(){
|
||||
this.folder = {
|
||||
ProcessId: null,
|
||||
Description: this.folder.Description,
|
||||
@@ -39,11 +41,51 @@ export class NewActionPage implements OnInit {
|
||||
}
|
||||
console.log(this.folder);
|
||||
|
||||
this.publication.CreatePublicationFolder(this.folder);
|
||||
this.close();
|
||||
try {
|
||||
await this.publication.CreatePublicationFolder(this.folder).toPromise()
|
||||
this.successMessage()
|
||||
this.close();
|
||||
} catch (error) {
|
||||
this.badRequest()
|
||||
}
|
||||
|
||||
}
|
||||
close(){
|
||||
this.modalController.dismiss();
|
||||
}
|
||||
|
||||
async successMessage(message?: string) {
|
||||
|
||||
const modal = await this.modalController.create({
|
||||
component: SuccessMessageComponent,
|
||||
componentProps: {
|
||||
message: message || 'Processo efetuado' ,
|
||||
},
|
||||
cssClass: 'modal modal-desktop'
|
||||
});
|
||||
|
||||
modal.present()
|
||||
|
||||
setTimeout(()=>{
|
||||
modal.dismiss()
|
||||
},3000)
|
||||
|
||||
}
|
||||
|
||||
async badRequest() {
|
||||
const modal = await this.modalController.create({
|
||||
component: BadRequestComponent,
|
||||
componentProps: {
|
||||
message: 'Processo não realizado com sucesso',
|
||||
},
|
||||
cssClass: 'modal modal-desktop'
|
||||
});
|
||||
|
||||
modal.present()
|
||||
|
||||
setTimeout(()=>{
|
||||
modal.dismiss()
|
||||
},3000)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -43,9 +43,7 @@ export class PublicationsService {
|
||||
let options = {
|
||||
headers: this.headers,
|
||||
};
|
||||
return this.http.post<any>(`${geturl}`, body, options).toPromise().then(res =>{
|
||||
console.log(res);
|
||||
});
|
||||
return this.http.post<any>(`${geturl}`, body, options)
|
||||
}
|
||||
|
||||
UpdatePublicationFolder(body:any){
|
||||
@@ -110,9 +108,7 @@ export class PublicationsService {
|
||||
headers: this.headers,
|
||||
/* params: params */
|
||||
};
|
||||
return this.http.post<any>(`${geturl}`, body, options).toPromise().then(res =>{
|
||||
console.log(res);
|
||||
});
|
||||
return this.http.post<any>(`${geturl}`, body, options)
|
||||
}
|
||||
|
||||
UpdatePublication(folderId:any,body:any){
|
||||
@@ -123,9 +119,7 @@ export class PublicationsService {
|
||||
headers: this.headers,
|
||||
/* params: params */
|
||||
};
|
||||
return this.http.put<any>(`${geturl}`, body, options).toPromise().then(res =>{
|
||||
console.log(res);
|
||||
});
|
||||
return this.http.put<any>(`${geturl}`, body, options)
|
||||
}
|
||||
|
||||
DeletePublication(folderId:any,publicationId:any){
|
||||
|
||||
@@ -2,6 +2,8 @@ import { Component, EventEmitter, OnInit, Output } from '@angular/core';
|
||||
import { ModalController } from '@ionic/angular';
|
||||
import { PublicationFolder } from 'src/app/models/publicationfolder';
|
||||
import { PublicationsService } from 'src/app/services/publications.service';
|
||||
import { BadRequestComponent } from '../../popover/bad-request/bad-request.component';
|
||||
import { SuccessMessageComponent } from '../../popover/success-message/success-message.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-new-action',
|
||||
@@ -30,7 +32,7 @@ export class NewActionPage implements OnInit {
|
||||
console.log(ev.detail.value);
|
||||
}
|
||||
|
||||
save(){
|
||||
async save() {
|
||||
this.folder = {
|
||||
ProcessId: null,
|
||||
Description: this.folder.Description,
|
||||
@@ -41,12 +43,53 @@ export class NewActionPage implements OnInit {
|
||||
}
|
||||
console.log(this.folder);
|
||||
|
||||
this.publication.CreatePublicationFolder(this.folder);
|
||||
this.close();
|
||||
try {
|
||||
await this.publication.CreatePublicationFolder(this.folder).toPromise()
|
||||
this.close();
|
||||
this.successMessage()
|
||||
} catch (error) {
|
||||
this.badRequest()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
close(){
|
||||
this.closeDesktopComponent.emit();
|
||||
}
|
||||
|
||||
|
||||
async successMessage(message?: string) {
|
||||
|
||||
const modal = await this.modalController.create({
|
||||
component: SuccessMessageComponent,
|
||||
componentProps: {
|
||||
message: message || 'Processo efetuado' ,
|
||||
},
|
||||
cssClass: 'modal modal-desktop'
|
||||
});
|
||||
|
||||
modal.present()
|
||||
|
||||
setTimeout(()=>{
|
||||
modal.dismiss()
|
||||
},3000)
|
||||
|
||||
}
|
||||
|
||||
async badRequest() {
|
||||
const modal = await this.modalController.create({
|
||||
component: BadRequestComponent,
|
||||
componentProps: {
|
||||
message: 'Processo não realizado com sucesso',
|
||||
},
|
||||
cssClass: 'modal modal-desktop'
|
||||
});
|
||||
|
||||
modal.present()
|
||||
|
||||
setTimeout(()=>{
|
||||
modal.dismiss()
|
||||
},3000)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@ import { Camera, CameraOptions } from '@ionic-native/camera/ngx';
|
||||
import { PublicationFolder } from 'src/app/models/publicationfolder';
|
||||
import { ViewPublicationsPage } from '../view-publications/view-publications.page';
|
||||
import { LoadingService } from 'src/app/services/loading.service';
|
||||
import { BadRequestComponent } from '../../popover/bad-request/bad-request.component';
|
||||
import { SuccessMessageComponent } from '../../popover/success-message/success-message.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-new-publication',
|
||||
@@ -137,7 +139,7 @@ export class NewPublicationPage implements OnInit {
|
||||
async save(){
|
||||
if(this.publicationType == '3'){
|
||||
|
||||
if(this.capturedImage != ''){
|
||||
if(this.capturedImage != '') {
|
||||
this.publication = {
|
||||
DateIndex: this.publication.DateIndex,
|
||||
DocumentId:this.publication.DocumentId,
|
||||
@@ -151,8 +153,18 @@ export class NewPublicationPage implements OnInit {
|
||||
}
|
||||
console.log('Edit change image');
|
||||
console.log(this.publication);
|
||||
this.publications.UpdatePublication(this.publication.ProcessId, this.publication);
|
||||
this.goBack();
|
||||
|
||||
try {
|
||||
console.log(this.publication);
|
||||
|
||||
await this.publications.UpdatePublication(this.publication.ProcessId, this.publication).toPromise()
|
||||
this.successMessage()
|
||||
|
||||
this.goBack();
|
||||
} catch (error) {
|
||||
this.badRequest()
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
this.publication = {
|
||||
@@ -166,10 +178,17 @@ export class NewPublicationPage implements OnInit {
|
||||
FileBase64: this.publication.FileBase64,
|
||||
FileExtension: 'jpeg',
|
||||
}
|
||||
console.log('Edit - keep image');
|
||||
console.log(this.publication);
|
||||
this.publications.UpdatePublication(this.publication.ProcessId, this.publication);
|
||||
this.goBack();
|
||||
|
||||
try {
|
||||
console.log(this.publication);
|
||||
await this.publications.UpdatePublication(this.publication.ProcessId, this.publication).toPromise()
|
||||
this.successMessage()
|
||||
|
||||
this.goBack();
|
||||
} catch (error) {
|
||||
this.badRequest()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else{
|
||||
@@ -186,10 +205,16 @@ export class NewPublicationPage implements OnInit {
|
||||
FileExtension: 'jpeg',
|
||||
}
|
||||
|
||||
console.log(this.publication);
|
||||
this.publications.CreatePublication(this.folderId, this.publication);
|
||||
try {
|
||||
console.log(this.publication);
|
||||
await this.publications.CreatePublication(this.folderId, this.publication).toPromise()
|
||||
this.successMessage()
|
||||
|
||||
this.goBackToViewPublications.emit();
|
||||
} catch (error) {
|
||||
this.badRequest()
|
||||
}
|
||||
|
||||
this.goBackToViewPublications.emit();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -248,4 +273,39 @@ export class NewPublicationPage implements OnInit {
|
||||
this.photo = this.sanitizer.bypassSecurityTrustResourceUrl(image && (image.dataUrl));
|
||||
} */
|
||||
|
||||
|
||||
async successMessage(message?: string) {
|
||||
|
||||
const modal = await this.modalController.create({
|
||||
component: SuccessMessageComponent,
|
||||
componentProps: {
|
||||
message: message || 'Processo efetuado' ,
|
||||
},
|
||||
cssClass: 'modal modal-desktop'
|
||||
});
|
||||
|
||||
modal.present()
|
||||
|
||||
setTimeout(()=>{
|
||||
modal.dismiss()
|
||||
},3000)
|
||||
|
||||
}
|
||||
|
||||
async badRequest() {
|
||||
const modal = await this.modalController.create({
|
||||
component: BadRequestComponent,
|
||||
componentProps: {
|
||||
message: 'Processo não realizado com sucesso',
|
||||
},
|
||||
cssClass: 'modal modal-desktop'
|
||||
});
|
||||
|
||||
modal.present()
|
||||
|
||||
setTimeout(()=>{
|
||||
modal.dismiss()
|
||||
},3000)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user