Add loader and notification message

This commit is contained in:
Peter Maquiran
2021-07-14 11:37:31 +01:00
parent db89f78de8
commit 732fff2025
8 changed files with 162 additions and 197 deletions
+2 -2
View File
@@ -5,12 +5,12 @@
"homepage": "https://ionicframework.com/",
"scripts": {
"ng": "ng",
"start": "ng serve",
"start": "ng serve --port 4200",
"build": "ng build",
"lint": "ng lint",
"e2e": "ng e2e",
"nice": "node server.js",
"test": "jest --detectOpenHandles --runInBand"
"test": "jest --runInBand"
},
"private": true,
"dependencies": {
+1 -1
View File
@@ -58,7 +58,7 @@
<ion-icon class="right-icons" src="assets/images/icons-received-event.svg"></ion-icon>
</button>
<button class="btn-no-color" (click)="clearContact();openAddEvent();">
<button class="btn-no-color cy-add-event" (click)="clearContact();openAddEvent();">
<ion-icon class="right-icons" src="assets/images/icons-add-new-event.svg" ></ion-icon>
</button>
@@ -255,120 +255,11 @@ export class ExpedientTaskModalPage implements OnInit {
this.dispatchFolder.SubjectTypes = this.selectedTypes;
switch (this.loggeduser.Profile) {
case 'MDGPR':
if(this.taskParticipants.length > 0) {
switch (this.taskType) {
case '0':
this.postData = {
DistributionType: "Paralelo",
CountryCode: 'AO',
Priority: this.postData.Priority,
UserEmail: this.loggeduser.Email,
UsersSelected: attendees,
DispatchFolder: this.dispatchFolder,
AttachmentList: docs,
}
const loader = this.toastService.loading()
const loader = this.toastService.loading()
try {
let action_despacho = {
"serialNumber": this.task.serialNumber,
"action": "Tratado",
"ActionTypeId": 94,
"dataFields": {
"Note": "",
}
}
console.log(this.postData);
this.taskResult = await this.processes.postDespatcho(this.postData).toPromise();
loader.remove()
await this.toastService.successMessage('Processo efetuado');
this.modalController.dismiss();
} catch (error) {
loader.remove()
await this.toastService.badRequest('Processo não efetuado')
} finally {
loader.remove()
}
console.log('this.taskResult', this.taskResult);
break;
case '1':
this.postData = {
DistributionType: "Paralelo",
CountryCode: 'AO',
Priority: this.postData.Priority,
UserEmail: this.loggeduser.Email,
UsersSelected: attendees,
DispatchFolder: this.dispatchFolder,
AttachmentList: docs
}
try {
let action_parecer = {
"serialNumber": this.task.serialNumber,
"action": "Tratado",
"ActionTypeId": 92,
"dataFields": {
"Note": "",
}
}
this.taskResult = await this.processes.postParecer(this.postData).toPromise();
loader.remove()
await this.toastService.successMessage('Pedido enviado');
this.modalController.dismiss(action_parecer);
} catch (error) {
loader.remove()
await this.toastService.badRequest('Processo não efetuado')
}
break;
case '2':
this.postData = {
DistributionType: "Paralelo",
CountryCode: 'AO',
Priority: this.postData.Priority,
UserEmail: this.loggeduser.Email,
UsersSelected: attendees,
DispatchFolder: this.dispatchFolder,
AttachmentList: docs
}
//console.log(this.postData);
const loader1 = this.toastService.loading()
try {
let action_deferimento = {
"serialNumber": this.task.serialNumber,
"action": "Tratado",
"ActionTypeId": 93,
"dataFields": {
"Note": "",
}
}
this.taskResult = await this.processes.postDeferimento(this.postData).toPromise();
await this.toastService.successMessage('Processo efetuado');
this.modalController.dismiss(action_deferimento);
} catch (error) {
await this.toastService.badRequest('Processo não efetuado')
} finally {
loader1.remove()
}
console.log('this.taskResult', this.taskResult);
break;
}
}
else {
this.alertController.presentAlert("Lista de i-ntervenientes vazia. Por favor, adicione 1 ou mais intervenientes.");
}
break;
case 'PR':
switch (this.loggeduser.Profile) {
case 'MDGPR':
if(this.taskParticipants.length > 0) {
switch (this.taskType) {
case '0':
this.postData = {
@@ -380,27 +271,16 @@ export class ExpedientTaskModalPage implements OnInit {
DispatchFolder: this.dispatchFolder,
AttachmentList: docs,
}
console.log(this.postData);
const loader = this.toastService.loading()
try {
let action_despacho_pr = {
"serialNumber": this.task.serialNumber,
"action": "Tratado",
"ActionTypeId": 99999881 ,
"dataFields": {
"Note": "",
}
}
loader.remove()
this.taskResult = await this.processes.postDespatchoPr(this.postData).toPromise();
this.taskResult = await this.processes.postDespatcho(this.postData).toPromise();
await this.toastService.successMessage('Processo efetuado');
this.modalController.dismiss(action_despacho_pr);
this.modalController.dismiss();
} catch (error) {
loader.remove()
await this.toastService.badRequest('Processo não efetuado')
} finally {
loader.remove()
@@ -420,33 +300,136 @@ export class ExpedientTaskModalPage implements OnInit {
AttachmentList: docs
}
const loader2 = this.toastService.loading()
let action_parecer = {
"serialNumber": this.task.serialNumber,
"action": "Tratado",
"ActionTypeId": 92,
"dataFields": {
"Note": "",
}
}
try {
let action_parecer_pr = {
"serialNumber": this.task.serialNumber,
"action": "Tratado",
"ActionTypeId": 99999881,
"dataFields": {
"Note": "",
}
}
this.taskResult = await this.processes.postParecerPr(this.postData).toPromise();
this.taskResult = await this.processes.postParecer(this.postData).toPromise();
await this.toastService.successMessage('Pedido enviado');
this.modalController.dismiss(action_parecer);
await this.toastService.badRequest('Processo não efetuado');
this.modalController.dismiss(action_parecer_pr);
} catch (error) {
await this.toastService.badRequest('Processo não efetuado')
} finally {
loader2.remove()
loader.remove()
}
break;
case '2':
this.postData = {
DistributionType: "Paralelo",
CountryCode: 'AO',
Priority: this.postData.Priority,
UserEmail: this.loggeduser.Email,
UsersSelected: attendees,
DispatchFolder: this.dispatchFolder,
AttachmentList: docs
}
//console.log(this.postData);
let action_deferimento = {
"serialNumber": this.task.serialNumber,
"action": "Tratado",
"ActionTypeId": 93,
"dataFields": {
"Note": "",
}
}
try {
this.taskResult = await this.processes.postDeferimento(this.postData).toPromise();
this.toastService.successMessage('Processo efetuado');
this.modalController.dismiss(action_deferimento);
} catch (error) {
await this.toastService.badRequest('Processo não efetuado')
} finally {
loader.remove()
}
console.log('this.taskResult', this.taskResult);
break;
}
}
else {
this.alertController.presentAlert("Lista de i-ntervenientes vazia. Por favor, adicione 1 ou mais intervenientes.");
}
break;
case 'PR':
switch (this.taskType) {
case '0':
this.postData = {
DistributionType: "Paralelo",
CountryCode: 'AO',
Priority: this.postData.Priority,
UserEmail: this.loggeduser.Email,
UsersSelected: attendees,
DispatchFolder: this.dispatchFolder,
AttachmentList: docs,
}
console.log(this.postData);
let action_despacho_pr = {
"serialNumber": this.task.serialNumber,
"action": "Tratado",
"ActionTypeId": 99999881 ,
"dataFields": {
"Note": "",
}
}
try {
this.taskResult = await this.processes.postDespatchoPr(this.postData).toPromise();
await this.toastService.successMessage('Processo efetuado');
this.modalController.dismiss(action_despacho_pr);
} catch (error) {
await this.toastService.badRequest('Processo não efetuado')
} finally {
loader.remove()
}
console.log('this.taskResult', this.taskResult);
break;
case '1':
this.postData = {
DistributionType: "Paralelo",
CountryCode: 'AO',
Priority: this.postData.Priority,
UserEmail: this.loggeduser.Email,
UsersSelected: attendees,
DispatchFolder: this.dispatchFolder,
AttachmentList: docs
}
let action_parecer_pr = {
"serialNumber": this.task.serialNumber,
"action": "Tratado",
"ActionTypeId": 99999881,
"dataFields": {
"Note": "",
}
}
try {
this.taskResult = await this.processes.postParecerPr(this.postData).toPromise();
await this.toastService.badRequest('Processo não efetuado');
this.modalController.dismiss(action_parecer_pr);
} catch (error) {
await this.toastService.badRequest('Processo não efetuado')
} finally {
loader.remove()
}
break;
}
break;
}
}
getAttachments() {
@@ -181,8 +181,6 @@
<div class="ion-icon-class">
<ion-icon slot="start" src="assets/images/icons-refresh.svg"></ion-icon>
</div>
{{ this.postEvent.EventRecurrence.Type }}
<div class="ion-input-class flex-grow-1" [class.input-error]="Form?.get('dateOccurrence')?.invalid && validateFrom ">
<mat-form-field appearance="none" floatLabel="never" class="width-100" value="false" interface="action-sheet" required>
@@ -134,8 +134,8 @@ export class NewEventPage implements OnInit {
this.dateAdapter.setLocale('pt');
this.loggeduser = userService.ValidatedUser;
this.dateControlStart = new FormControl(moment(new Date()));
this.dateControlEnd = new FormControl(moment(new Date(new Date().getTime() + 15 * 60000)));
this.postEvent.StartDate = new Date();
this.postEvent.EndDate = new Date(new Date().getTime() + 15 * 60000);
}
ngOnInit() {
@@ -342,8 +342,6 @@ export class NewEventPage implements OnInit {
restoreDatepickerData() {
if (this.postEvent) {
this.dateControlStart = new FormControl(moment(this.postEvent.StartDate, "DD MM YYYY hh:mm"));
this.dateControlEnd = new FormControl(moment(this.postEvent.EndDate, "DD MM YYYY hh:mm"));
this.dateControlOccurrence = new FormControl(moment(this.postEvent.EventRecurrence.LastOccurrence, "DD MM YYYY hh:mm"))
}
}
+1 -27
View File
@@ -4,36 +4,10 @@ describe('Puppeteer tests', () => {
beforeAll(async () => {
// await page.goto(process.env.PUPPETEER_HOST)
})
test('[table] login', async () => {
// const browser = await puppeteer.launch({headless: false});
await page.setViewport({width: 1200, height: 720});
await page.goto(process.env.PUPPETEER_HOST); // wait until page load
await page.waitForSelector('.btn-ok')
await page.evaluate( () => {
let a: HTMLInputElement = document.querySelector('input[type="text"]')
a.value = ''
let b: HTMLInputElement = document.querySelector('input[type="password"')
b.value = ''
})
await page.type('input[type="text"]', environment.defaultuser);
await page.type('input[type="password"]', environment.defaultuserpwd);
// click and wait for navigation
await Promise.all([
page.click('.btn-ok'),
// page.waitForNavigation({ waitUntil: 'networkidle0' }),
]);
await page.waitForSelector('.circle')
expect(3 + 2).toBe(5);
},30000);
test('[table] Clear Code button and set pin', async () => {
+29
View File
@@ -0,0 +1,29 @@
import { environment } from '../src/environments/environment'
describe('Puppeteer tests', () => {
beforeAll(async () => {
// await page.goto(process.env.PUPPETEER_HOST)
})
test('[table] create event', async () => {
// const browser = await puppeteer.launch({headless: false});
await page.setViewport({width: 1200, height: 720});
await page.goto(process.env.PUPPETEER_HOST); // wait until page load
await page.waitForSelector('ion-tab-bar ion-tab-button:nth-child(3)')
await page.click('ion-tab-bar ion-tab-button:nth-child(3)')
await page.waitForSelector('ion-content ion-row .cy-add-event')
await page.waitForSelector('app-new-event')
expect(3 + 2).toBe(5);
},30000);
});
-17
View File
@@ -1,17 +0,0 @@
import { environment } from './../src/environments/environment'
describe('Puppeteer tests', () => {
beforeAll(async () => {
// await page.goto(process.env.PUPPETEER_HOST)
})
test('login', async () => {
expect(3 + 2).toBe(5);
}, 30000);
});