mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +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 { ModalController } from '@ionic/angular';
|
||||||
import { PublicationFolder } from 'src/app/models/publicationfolder';
|
import { PublicationFolder } from 'src/app/models/publicationfolder';
|
||||||
import { PublicationsService } from 'src/app/services/publications.service';
|
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({
|
@Component({
|
||||||
selector: 'app-new-action',
|
selector: 'app-new-action',
|
||||||
@@ -28,7 +30,7 @@ export class NewActionPage implements OnInit {
|
|||||||
console.log(ev.detail.value);
|
console.log(ev.detail.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
save(){
|
async save(){
|
||||||
this.folder = {
|
this.folder = {
|
||||||
ProcessId: null,
|
ProcessId: null,
|
||||||
Description: this.folder.Description,
|
Description: this.folder.Description,
|
||||||
@@ -39,11 +41,51 @@ export class NewActionPage implements OnInit {
|
|||||||
}
|
}
|
||||||
console.log(this.folder);
|
console.log(this.folder);
|
||||||
|
|
||||||
this.publication.CreatePublicationFolder(this.folder);
|
try {
|
||||||
|
await this.publication.CreatePublicationFolder(this.folder).toPromise()
|
||||||
|
this.successMessage()
|
||||||
this.close();
|
this.close();
|
||||||
|
} catch (error) {
|
||||||
|
this.badRequest()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
close(){
|
close(){
|
||||||
this.modalController.dismiss();
|
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 = {
|
let options = {
|
||||||
headers: this.headers,
|
headers: this.headers,
|
||||||
};
|
};
|
||||||
return this.http.post<any>(`${geturl}`, body, options).toPromise().then(res =>{
|
return this.http.post<any>(`${geturl}`, body, options)
|
||||||
console.log(res);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdatePublicationFolder(body:any){
|
UpdatePublicationFolder(body:any){
|
||||||
@@ -110,9 +108,7 @@ export class PublicationsService {
|
|||||||
headers: this.headers,
|
headers: this.headers,
|
||||||
/* params: params */
|
/* params: params */
|
||||||
};
|
};
|
||||||
return this.http.post<any>(`${geturl}`, body, options).toPromise().then(res =>{
|
return this.http.post<any>(`${geturl}`, body, options)
|
||||||
console.log(res);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdatePublication(folderId:any,body:any){
|
UpdatePublication(folderId:any,body:any){
|
||||||
@@ -123,9 +119,7 @@ export class PublicationsService {
|
|||||||
headers: this.headers,
|
headers: this.headers,
|
||||||
/* params: params */
|
/* params: params */
|
||||||
};
|
};
|
||||||
return this.http.put<any>(`${geturl}`, body, options).toPromise().then(res =>{
|
return this.http.put<any>(`${geturl}`, body, options)
|
||||||
console.log(res);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DeletePublication(folderId:any,publicationId:any){
|
DeletePublication(folderId:any,publicationId:any){
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ import { Component, EventEmitter, OnInit, Output } from '@angular/core';
|
|||||||
import { ModalController } from '@ionic/angular';
|
import { ModalController } from '@ionic/angular';
|
||||||
import { PublicationFolder } from 'src/app/models/publicationfolder';
|
import { PublicationFolder } from 'src/app/models/publicationfolder';
|
||||||
import { PublicationsService } from 'src/app/services/publications.service';
|
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({
|
@Component({
|
||||||
selector: 'app-new-action',
|
selector: 'app-new-action',
|
||||||
@@ -30,7 +32,7 @@ export class NewActionPage implements OnInit {
|
|||||||
console.log(ev.detail.value);
|
console.log(ev.detail.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
save(){
|
async save() {
|
||||||
this.folder = {
|
this.folder = {
|
||||||
ProcessId: null,
|
ProcessId: null,
|
||||||
Description: this.folder.Description,
|
Description: this.folder.Description,
|
||||||
@@ -41,12 +43,53 @@ export class NewActionPage implements OnInit {
|
|||||||
}
|
}
|
||||||
console.log(this.folder);
|
console.log(this.folder);
|
||||||
|
|
||||||
this.publication.CreatePublicationFolder(this.folder);
|
try {
|
||||||
|
await this.publication.CreatePublicationFolder(this.folder).toPromise()
|
||||||
this.close();
|
this.close();
|
||||||
|
this.successMessage()
|
||||||
|
} catch (error) {
|
||||||
|
this.badRequest()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
close(){
|
close(){
|
||||||
this.closeDesktopComponent.emit();
|
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 { PublicationFolder } from 'src/app/models/publicationfolder';
|
||||||
import { ViewPublicationsPage } from '../view-publications/view-publications.page';
|
import { ViewPublicationsPage } from '../view-publications/view-publications.page';
|
||||||
import { LoadingService } from 'src/app/services/loading.service';
|
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({
|
@Component({
|
||||||
selector: 'app-new-publication',
|
selector: 'app-new-publication',
|
||||||
@@ -137,7 +139,7 @@ export class NewPublicationPage implements OnInit {
|
|||||||
async save(){
|
async save(){
|
||||||
if(this.publicationType == '3'){
|
if(this.publicationType == '3'){
|
||||||
|
|
||||||
if(this.capturedImage != ''){
|
if(this.capturedImage != '') {
|
||||||
this.publication = {
|
this.publication = {
|
||||||
DateIndex: this.publication.DateIndex,
|
DateIndex: this.publication.DateIndex,
|
||||||
DocumentId:this.publication.DocumentId,
|
DocumentId:this.publication.DocumentId,
|
||||||
@@ -151,8 +153,18 @@ export class NewPublicationPage implements OnInit {
|
|||||||
}
|
}
|
||||||
console.log('Edit change image');
|
console.log('Edit change image');
|
||||||
console.log(this.publication);
|
console.log(this.publication);
|
||||||
this.publications.UpdatePublication(this.publication.ProcessId, this.publication);
|
|
||||||
|
try {
|
||||||
|
console.log(this.publication);
|
||||||
|
|
||||||
|
await this.publications.UpdatePublication(this.publication.ProcessId, this.publication).toPromise()
|
||||||
|
this.successMessage()
|
||||||
|
|
||||||
this.goBack();
|
this.goBack();
|
||||||
|
} catch (error) {
|
||||||
|
this.badRequest()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
this.publication = {
|
this.publication = {
|
||||||
@@ -166,10 +178,17 @@ export class NewPublicationPage implements OnInit {
|
|||||||
FileBase64: this.publication.FileBase64,
|
FileBase64: this.publication.FileBase64,
|
||||||
FileExtension: 'jpeg',
|
FileExtension: 'jpeg',
|
||||||
}
|
}
|
||||||
console.log('Edit - keep image');
|
|
||||||
|
try {
|
||||||
console.log(this.publication);
|
console.log(this.publication);
|
||||||
this.publications.UpdatePublication(this.publication.ProcessId, this.publication);
|
await this.publications.UpdatePublication(this.publication.ProcessId, this.publication).toPromise()
|
||||||
|
this.successMessage()
|
||||||
|
|
||||||
this.goBack();
|
this.goBack();
|
||||||
|
} catch (error) {
|
||||||
|
this.badRequest()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
@@ -186,10 +205,16 @@ export class NewPublicationPage implements OnInit {
|
|||||||
FileExtension: 'jpeg',
|
FileExtension: 'jpeg',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
console.log(this.publication);
|
console.log(this.publication);
|
||||||
this.publications.CreatePublication(this.folderId, this.publication);
|
await this.publications.CreatePublication(this.folderId, this.publication).toPromise()
|
||||||
|
this.successMessage()
|
||||||
|
|
||||||
this.goBackToViewPublications.emit();
|
this.goBackToViewPublications.emit();
|
||||||
|
} catch (error) {
|
||||||
|
this.badRequest()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -248,4 +273,39 @@ export class NewPublicationPage implements OnInit {
|
|||||||
this.photo = this.sanitizer.bypassSecurityTrustResourceUrl(image && (image.dataUrl));
|
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