diff --git a/AstuteClient2/src/app/customer/customer.component.ts b/AstuteClient2/src/app/customer/customer.component.ts index eed5a98..683d4d3 100644 --- a/AstuteClient2/src/app/customer/customer.component.ts +++ b/AstuteClient2/src/app/customer/customer.component.ts @@ -1,5 +1,6 @@ import {Component, OnInit} from '@angular/core'; import {AstuteClientService} from '../services/astute-client-service'; +import {ToastManagerService} from "../services/toast-manager/toast-service.service"; @Component({ selector: 'app-customer', @@ -109,7 +110,7 @@ export class CustomerComponent implements OnInit { // title: "Manager" // workPhone: 1231231233 - constructor(protected astuteClientService: AstuteClientService) { + constructor(protected astuteClientService: AstuteClientService, protected toastService: ToastManagerService) { } ngOnInit() { @@ -124,11 +125,11 @@ export class CustomerComponent implements OnInit { // wrappers for customer service methods addCustomer(customerId, name, billTo, add1, add2, city, state, zip, zip4, email, phone, phExt, fax, ref) { if (fax.length > 0 && fax.length < 14) { - alert('Invalid fax.'); + this.notif('Invalid fax.'); } else if (phone.length > 0 && phone.length < 14) { - alert('Invalid phone.'); + this.notif('Invalid phone.'); } else if (email.length > 0 && /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email) === false) { - alert('You have entered an invalid email address!'); + this.notif('You have entered an invalid email address!'); } else { const customerData = { 'customerId': customerId, @@ -150,20 +151,20 @@ export class CustomerComponent implements OnInit { this.refreshData(); ref.close(); } else { - alert('Customer Creation Failed, Check Input Fields'); + this.notif('Customer Creation Failed, Check Input Fields'); } }, (reason) => { - alert('Add customer failed: ' + reason); + this.notif('Add customer failed: ' + reason); }); } } editCustomer(id, name, billTo, add1, add2, city, state, zip, zip4, email, phone, phExt, fax, ref) { if (fax.length > 0 && fax.length < 14) { - alert('Invalid fax.'); + this.notif('Invalid fax.'); } else if (phone.length > 0 && phone.length < 14) { - alert('Invalid phone.'); + this.notif('Invalid phone.'); } else if (email.length > 0 && /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email) === false) { - alert('You have entered an invalid email address!'); + this.notif('You have entered an invalid email address!'); } else { const customerData = { 'customerId': id, @@ -186,10 +187,10 @@ export class CustomerComponent implements OnInit { this.refreshData(); ref.close(); } else { - alert('Customer Updating Failed, Check Input Fields'); + this.notif('Customer Updating Failed, Check Input Fields'); } }, (reason) => { - alert('Update customer failed: ' + reason); + this.notif('Update customer failed: ' + reason); }); } } @@ -201,12 +202,12 @@ export class CustomerComponent implements OnInit { console.log('Customer, ' + customerId + ' successfully deleted'); this.refreshData(); } else { - alert('Error in deleting; Customer, ' + customerId + ' has not been deleted'); + this.notif('Error in deleting; Customer, ' + customerId + ' has not been deleted'); } }); } } else { - alert('Choose a customer first!'); + this.notif('Choose a customer first!'); } } @@ -226,12 +227,12 @@ export class CustomerComponent implements OnInit { console.log(newContactData); this.astuteClientService.createCustomerContact(newContactData).then ((data) => { if (!data) { - alert('Contact Creation Failed, Check Input Fields'); + this.notif('Contact Creation Failed, Check Input Fields'); } else { this.refreshContactData(this.selected.customerId); } }, (reason) => { - alert('Create customer failed: ' + reason); + this.notif('Create customer failed: ' + reason); }); } deleteContact() { @@ -243,14 +244,14 @@ export class CustomerComponent implements OnInit { if (data) { this.refreshContactData(selec.customerId); } else { - alert('Contact Deletion Failed, Check Input Fields'); + this.notif('Contact Deletion Failed, Check Input Fields'); } }, (reason) => { - alert('Delete customer failed: ' + reason); + this.notif('Delete customer failed: ' + reason); }); } } else { - alert('Choose a contact first!'); + this.notif('Choose a contact first!'); } } @@ -260,21 +261,21 @@ export class CustomerComponent implements OnInit { console.log(eventData); if (eventData.fax.length > 0 && eventData.fax.length < 14) { this.refreshData(); - alert('Invalid fax.'); + this.notif('Invalid fax.'); } else if (eventData.phone.length > 0 && eventData.phone.length < 14) { this.refreshData(); - alert('Invalid phone.'); + this.notif('Invalid phone.'); } else if (eventData.email.length > 0 && /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(eventData.email) === false) { this.refreshData(); - alert('You have entered an invalid email address!'); + this.notif('You have entered an invalid email address!'); } else { this.astuteClientService.updateCustomer(eventData.customerId, eventData).then((data) => { if (!data) { this.refreshData(); - alert('Customer Updating Failed, Check Input Fields'); + this.notif('Customer Updating Failed, Check Input Fields'); } }, (reason) => { - alert('Update customer failed: ' + reason); + this.notif('Update customer failed: ' + reason); }); } } @@ -283,23 +284,23 @@ export class CustomerComponent implements OnInit { const eventData = event.data; // if (eventData.fax % 10 < 14) { - // alert('Invalid fax.'); + // this.notif('Invalid fax.'); // } else if (eventData.mobile % 10 < 14) { - // alert('Invalid phone.'); + // this.notif('Invalid phone.'); // } else if (eventData.workPhone % 10 < 14) { - // alert('Invalid work phone.'); + // this.notif('Invalid work phone.'); // } else if (eventData.email.length > 0 && /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(eventData.email) === false) { this.contactsData = this.astuteClientService.getCustomerContacts(eventData.customerId); - alert('You have entered an invalid email address!'); + this.notif('You have entered an invalid email address!'); } else { this.astuteClientService.updateCustomerContact(eventData.customerId, eventData).then((data) => { if (!data) { this.contactsData = this.astuteClientService.getCustomerContacts(eventData.customerId); - // alert('Customer Updating Failed, Check Input Fields'); + // this.notif('Customer Updating Failed, Check Input Fields'); } }, (reason) => { - alert('Update customer failed: ' + reason); + this.notif('Update customer failed: ' + reason); }); } } @@ -340,4 +341,10 @@ export class CustomerComponent implements OnInit { resizeColumns(evt) { evt.columnApi.autoSizeAllColumns(); } + + // ** toast notification method + notif(text: string) { + this.toastService.show(text, {classname: 'bg-danger text-light'}); + } + } diff --git a/AstuteClient2/src/app/invoice-gen/invoice-gen.component.ts b/AstuteClient2/src/app/invoice-gen/invoice-gen.component.ts index d944ab0..ead5c67 100644 --- a/AstuteClient2/src/app/invoice-gen/invoice-gen.component.ts +++ b/AstuteClient2/src/app/invoice-gen/invoice-gen.component.ts @@ -1,6 +1,7 @@ import {Component, ElementRef, OnInit, ViewChild} from '@angular/core'; import {AstuteClientService} from '../services/astute-client-service'; import {formatCurrency} from '@angular/common'; +import {ToastManagerService} from "../services/toast-manager/toast-service.service"; declare var html2pdf: any; declare var html2canvas: any; @@ -44,7 +45,7 @@ export class InvoiceGenComponent implements OnInit { notes; cert; - constructor(protected astuteClientService: AstuteClientService) { + constructor(protected astuteClientService: AstuteClientService, protected toastService: ToastManagerService) { // console.log('********** ' + this.astuteClientService.getInvoiceGen('123').then()); } @@ -411,8 +412,12 @@ export class InvoiceGenComponent implements OnInit { // $.get('http://localhost/ws/service.asmx/HelloWord', function(response) { // data = response; // }).error(function(){ - // alert('Sorry could not proceed'); + // this.notif('Sorry could not proceed'); // }); + // ** toast notification method + notif(text: string) { + this.toastService.show(text, {classname: 'bg-danger text-light'}); + } } diff --git a/AstuteClient2/src/app/invoice-payment/invoice-payment.component.ts b/AstuteClient2/src/app/invoice-payment/invoice-payment.component.ts index f6ba0c9..13f322a 100644 --- a/AstuteClient2/src/app/invoice-payment/invoice-payment.component.ts +++ b/AstuteClient2/src/app/invoice-payment/invoice-payment.component.ts @@ -1,6 +1,7 @@ import {Component, OnInit, ViewChild} from '@angular/core'; import {AstuteClientService} from '../services/astute-client-service'; import {formatCurrency} from "@angular/common"; +import {ToastManagerService} from "../services/toast-manager/toast-service.service"; @Component({ selector: 'app-invoice-payment', @@ -27,7 +28,7 @@ export class InvoicePaymentComponent implements OnInit { ]; - constructor(protected astuteClientService: AstuteClientService) { + constructor(protected astuteClientService: AstuteClientService, protected toastService: ToastManagerService) { } ngOnInit() { @@ -66,10 +67,10 @@ export class InvoicePaymentComponent implements OnInit { this.refreshData(); ref.close(); } else { - alert("Adding Invoice Payment Failed, Check Input Fields") + this.notif("Adding Invoice Payment Failed, Check Input Fields") } }, (reason) => { - alert("Adding Invoice Payment failed for " + reason); + this.notif("Adding Invoice Payment failed for " + reason); }); } @@ -89,10 +90,10 @@ export class InvoicePaymentComponent implements OnInit { this.refreshData(); ref.close(); } else { - alert("Updating Invoice Payment Failed, Check Input Fields") + this.notif("Updating Invoice Payment Failed, Check Input Fields") } }, (reason) => { - alert("Updating Invoice Payment failed for " + reason); + this.notif("Updating Invoice Payment failed for " + reason); }); } @@ -125,4 +126,9 @@ export class InvoicePaymentComponent implements OnInit { this.invoicePaymentData = data; }); } + // ** toast notification method + notif(text: string) { + this.toastService.show(text, {classname: 'bg-danger text-light'}); + } + } diff --git a/AstuteClient2/src/app/invoice/invoice.component.ts b/AstuteClient2/src/app/invoice/invoice.component.ts index 6bd9cc2..1a36a38 100644 --- a/AstuteClient2/src/app/invoice/invoice.component.ts +++ b/AstuteClient2/src/app/invoice/invoice.component.ts @@ -2,6 +2,7 @@ import {Component, OnInit, ViewChild} from '@angular/core'; import {AstuteClientService} from '../services/astute-client-service'; import {formatCurrency} from "@angular/common"; import {PrintInvoiceService} from '../services/print-invoice.service'; +import {ToastManagerService} from "../services/toast-manager/toast-service.service"; declare var $: any; @@ -76,7 +77,8 @@ export class InvoiceComponent implements OnInit { constructor(protected astuteClientService: AstuteClientService, - protected printService: PrintInvoiceService) { + protected printService: PrintInvoiceService, + protected toastService: ToastManagerService) { } customerDropdownChange(index) { @@ -105,14 +107,14 @@ export class InvoiceComponent implements OnInit { // 'remainingQty': 0 // }; // } else { - // alert('get PO detail failed!'); + // this.notif('get PO detail failed!'); // } // }); this.astuteClientService.generateInvoiceNumber(ponum).then((data) => { if (data) { this.generatedInvoiceNumber = data; } else { - alert('gen inv num failed!'); + this.notif('gen inv num failed!'); } }); } @@ -125,10 +127,10 @@ export class InvoiceComponent implements OnInit { this.serviceNames.push(type.serviceTypeDesc); }); } else { - alert ('Get service types failed'); + this.notif ('Get service types failed'); } }, reason => { - alert('Get service type failed: ' + reason); + this.notif('Get service type failed: ' + reason); }); this.astuteClientService.getRateTypes().then((d) => { if (d) { @@ -137,19 +139,19 @@ export class InvoiceComponent implements OnInit { this.rateNames.push(type.feeTypeDesc); }); } else { - alert ('Get rate types failed'); + this.notif ('Get rate types failed'); } }, reason => { - alert('Get rate type failed: ' + reason); + this.notif('Get rate type failed: ' + reason); }); this.astuteClientService.getCustomers().then((customers) => { if (customers) { this.customers = customers; } else { - alert('Get Customers Failed!'); + this.notif('Get Customers Failed!'); } }, (reason) => { - alert('Get Customers Failed: ' + reason); + this.notif('Get Customers Failed: ' + reason); }); this.astuteClientService.getPOs().then((data) => { if (data) { @@ -162,18 +164,18 @@ export class InvoiceComponent implements OnInit { }); // console.log(this.allPODetails); } else { - alert('Get PO Detail for ' + po.ponum + ' failed!'); + this.notif('Get PO Detail for ' + po.ponum + ' failed!'); } }, (reason) => { - alert('Get PO Detail for ' + po.ponum + ' failed: ' + reason); + this.notif('Get PO Detail for ' + po.ponum + ' failed: ' + reason); }); }); } else { - alert ('Get PO failed'); + this.notif ('Get PO failed'); } }, (reason) => { - alert('Get SOs Failed: ' + reason); + this.notif('Get SOs Failed: ' + reason); }); this.refreshData(); } @@ -188,7 +190,7 @@ export class InvoiceComponent implements OnInit { row.outstandingBalanceString = formatCurrency(row.outstandingBalance, 'en-US', '$', 'USD'); }); } else { - alert('Get Invoices failed!'); + this.notif('Get Invoices failed!'); } }); } @@ -207,10 +209,10 @@ export class InvoiceComponent implements OnInit { this.astuteClientService.updateInvoice(eventData.invoiceNumber, eventData).then((data) => { if (!data) { this.refreshData(); - alert('Invoice Updating Failed, Check Input Fields'); + this.notif('Invoice Updating Failed, Check Input Fields'); } }, (reason) => { - alert('Update invoice failed: ' + reason); + this.notif('Update invoice failed: ' + reason); }); // this.refreshData(); } @@ -220,12 +222,12 @@ export class InvoiceComponent implements OnInit { this.astuteClientService.updateInvoiceDetail(eventData.invoiceNum, eventData.lineItemNum, eventData).then((data) => { if (!data) { this.refreshDetailsOfSelected(); - alert('Detail Updating Failed, Check Input Fields'); + this.notif('Detail Updating Failed, Check Input Fields'); } else { this.updateSelectedBillAmt(); } }, (reason) => { - alert('Update Detail failed: ' + reason); + this.notif('Update Detail failed: ' + reason); }); } @@ -268,7 +270,7 @@ export class InvoiceComponent implements OnInit { this.updateSelectedBillAmt(); return data; } else { - alert('get Inv detail failed!'); + this.notif('get Inv detail failed!'); } }); this.pos.forEach((po) => { @@ -361,11 +363,11 @@ export class InvoiceComponent implements OnInit { // } // }); // } else { - // alert("get Inv detail failed!"); + // this.notif("get Inv detail failed!"); // } // }); // } else { - // alert("get PO detail failed!") + // this.notif("get PO detail failed!") // } // }); // this.pos.forEach((po) => { @@ -445,7 +447,7 @@ export class InvoiceComponent implements OnInit { console.log('Invoice, ' + invoiceNum + ' successfully deleted'); this.refreshData(); } else { - alert ('Error in deleting; Invoice, ' + invoiceNum + ' has not been deleted'); + this.notif ('Error in deleting; Invoice, ' + invoiceNum + ' has not been deleted'); } }); } @@ -484,7 +486,7 @@ export class InvoiceComponent implements OnInit { // this.addInvoiceDetail(this.newInDetails); ref.close(); } else { - alert('Invoice Creation Failed, Check Input Fields'); + this.notif('Invoice Creation Failed, Check Input Fields'); } }); } @@ -516,12 +518,12 @@ export class InvoiceComponent implements OnInit { }) .then((data) => { if (data) { - alert("invoice " + invoiceNumber + " updated!"); + this.notif("invoice " + invoiceNumber + " updated!"); console.log("fulfilled: " + data); // this.source[this.chosenInv] = invData; this.refreshData(); } else { - alert("Invoice Update Failed, Check Input Fields") + this.notif("Invoice Update Failed, Check Input Fields") } }); } @@ -531,7 +533,7 @@ export class InvoiceComponent implements OnInit { if (data) { this.refreshData(); } else { - alert('void invoice failed.'); + this.notif('void invoice failed.'); } }); } @@ -541,7 +543,7 @@ export class InvoiceComponent implements OnInit { if (data) { this.refreshData(); } else { - alert('submit invoice failed.'); + this.notif('submit invoice failed.'); } }); } @@ -572,11 +574,11 @@ export class InvoiceComponent implements OnInit { this.astuteClientService.createInvoiceDetail(emptyData).then((data) => { if (!data) { - alert('Creating SO detailed failed!'); + this.notif('Creating SO detailed failed!'); } this.refreshDetailsOfSelected(); }, (reason) => { - alert('Creating SO detailed failed: ' + reason); + this.notif('Creating SO detailed failed: ' + reason); }); } @@ -589,7 +591,7 @@ export class InvoiceComponent implements OnInit { // details.splice(0, 1); // this.addInvoiceDetail(details); // } else { - // alert('add inv detail failed'); + // this.notif('add inv detail failed'); // } // }); // // } else { @@ -618,7 +620,7 @@ export class InvoiceComponent implements OnInit { // // if (d) { // // console.log (d); // // } else { - // // alert('create custom PO failed.'); + // // this.notif('create custom PO failed.'); // // } // // }); // // } @@ -683,4 +685,10 @@ export class InvoiceComponent implements OnInit { resizeColumns(evt) { evt.columnApi.autoSizeAllColumns(); } + + // ** toast notification method + notif(text: string) { + this.toastService.show(text, {classname: 'bg-danger text-light'}); + } + } diff --git a/AstuteClient2/src/app/login/login.component.ts b/AstuteClient2/src/app/login/login.component.ts index 3978ca2..52ba8a4 100644 --- a/AstuteClient2/src/app/login/login.component.ts +++ b/AstuteClient2/src/app/login/login.component.ts @@ -2,6 +2,7 @@ import {Component, OnInit, ViewEncapsulation} from '@angular/core'; import {NgForm} from '@angular/forms'; import {Router} from '@angular/router'; import {AstuteClientService} from '../services/astute-client-service'; +import {ToastManagerService} from "../services/toast-manager/toast-service.service"; @Component({ selector: 'app-login', @@ -11,7 +12,7 @@ import {AstuteClientService} from '../services/astute-client-service'; }) export class LoginComponent implements OnInit { - constructor(protected astuteClientService: AstuteClientService, + constructor(protected astuteClientService: AstuteClientService, protected toastService: ToastManagerService, private router: Router) {} ngOnInit() { @@ -27,8 +28,14 @@ export class LoginComponent implements OnInit { if (data) { this.router.navigate(['/homepage']); } else { - alert('login failed, checked credentials'); + this.notif('login failed, checked credentials'); } }) } + + // ** toast notification method + notif(text: string) { + this.toastService.show(text, {classname: 'bg-danger text-light'}); + } + } diff --git a/AstuteClient2/src/app/sales-order/sales-order.component.ts b/AstuteClient2/src/app/sales-order/sales-order.component.ts index 06449d5..80068be 100644 --- a/AstuteClient2/src/app/sales-order/sales-order.component.ts +++ b/AstuteClient2/src/app/sales-order/sales-order.component.ts @@ -1,6 +1,7 @@ import {Component, OnInit, ViewChild} from '@angular/core'; import {AstuteClientService} from '../services/astute-client-service'; import {formatCurrency} from '@angular/common'; +import {ToastManagerService} from "../services/toast-manager/toast-service.service"; @Component({ selector: 'app-sales-order', @@ -63,7 +64,7 @@ export class SalesOrderComponent implements OnInit { ]; contractAmount = 0; // used to show total amount - constructor(private astuteClientService: AstuteClientService) { + constructor(private astuteClientService: AstuteClientService, protected toastService: ToastManagerService) { } ngOnInit() { @@ -75,10 +76,10 @@ export class SalesOrderComponent implements OnInit { }); // console.log(this.serviceNames); } else { - alert ('Get service types failed'); + this.notif ('Get service types failed'); } }, reason => { - alert('Get service type failed: ' + reason); + this.notif('Get service type failed: ' + reason); }); this.astuteClientService.getRateTypes().then((d) => { if (d) { @@ -87,19 +88,19 @@ export class SalesOrderComponent implements OnInit { this.rateNames.push(type.feeTypeDesc); }); } else { - alert ('Get rate types failed'); + this.notif ('Get rate types failed'); } }, reason => { - alert('Get rate type failed: ' + reason); + this.notif('Get rate type failed: ' + reason); }); this.astuteClientService.getCustomers().then((customers) => { if (customers) { this.customers = customers; } else { - alert('Get Customers Failed!'); + this.notif('Get Customers Failed!'); } }, (reason) => { - alert('Get Customers Failed: ' + reason); + this.notif('Get Customers Failed: ' + reason); }); this.refreshData(); } @@ -120,10 +121,10 @@ export class SalesOrderComponent implements OnInit { this.updateContractAmt(); return data; } else { - alert('Get SO detail failed!'); + this.notif('Get SO detail failed!'); } }, (reason) => { - alert('Get SO detail failed: ' + reason); + this.notif('Get SO detail failed: ' + reason); }); } @@ -134,11 +135,11 @@ export class SalesOrderComponent implements OnInit { this.astuteClientService.updatePO(eventData.poNum, eventData).then((data) => { if (!data) { - alert('SO updating failed, check input fields'); + this.notif('SO updating failed, check input fields'); this.refreshData(); } }, (reason) => { - alert('Update SO failed: ' + reason); + this.notif('Update SO failed: ' + reason); }); // this.refreshData(); } @@ -148,19 +149,19 @@ export class SalesOrderComponent implements OnInit { event.data.serviceTypeId = this.getServiceIdFromName(event.data.serviceTypeName); event.data.feeTypeId = this.getFeeIdFromName(event.data.rateTypeName); if (event.data.feeTypeId === 1 && event.data.qty > 1) { // fixed fee and qty > 1 - alert('Cannot have a quantity greater than 1 for fixed fee rate type.'); + this.notif('Cannot have a quantity greater than 1 for fixed fee rate type.'); this.refreshDetailsOfSelected(); } else { // console.log(event.data.serviceTypeId); this.astuteClientService.updatePODetail(eventData.poNum, eventData.lineItemNo, eventData).then((data) => { if (!data) { - alert('SO Detail updating failed, check input fields'); + this.notif('SO Detail updating failed, check input fields'); this.refreshDetailsOfSelected(); } else { this.updateContractAmt(); } }, (reason) => { - alert('Update SO Detail failed: ' + reason); + this.notif('Update SO Detail failed: ' + reason); }); // this.refreshData(); } @@ -185,10 +186,10 @@ export class SalesOrderComponent implements OnInit { // this.addPODetail(this.newPODetail); ref.close(); } else { - alert('SO Creation failed, check input fields'); + this.notif('SO Creation failed, check input fields'); } }, (reason) => { - alert('Add SO failed for ' + reason); + this.notif('Add SO failed for ' + reason); }); } editPo(projNum, ponum, podate, contractnum, contractamt, title, notes, ref) { @@ -208,22 +209,22 @@ export class SalesOrderComponent implements OnInit { // this.editPODetail(this.selectedPODetail); ref.close(); } else { - alert('SO updating failed, check input fields'); + this.notif('SO updating failed, check input fields'); } }, (reason) => { - alert('Update SO failed for ' + reason); + this.notif('Update SO failed for ' + reason); }); } finalizePO(ponum) { this.astuteClientService.finalizePO(ponum).then((data) => { if (data) { this.refreshData(); - alert('SO is now final and ready to be used, you can\'t delete it anymore!'); + this.notif('SO is now final and ready to be used, you can\'t delete it anymore!'); } else { - alert('Finalizing SO failed, check input fields'); + this.notif('Finalizing SO failed, check input fields'); } }, reason => { - alert('Finalizing SO failed: ' + reason); + this.notif('Finalizing SO failed: ' + reason); }); } deletePO(ponum) { @@ -232,10 +233,10 @@ export class SalesOrderComponent implements OnInit { if (data) { this.refreshData(); } else { - alert('Deleting SO failed, check input fields'); + this.notif('Deleting SO failed, check input fields'); } }, (reason) => { - alert('Deleting SO failed: ' + reason); + this.notif('Deleting SO failed: ' + reason); }); } @@ -264,11 +265,11 @@ export class SalesOrderComponent implements OnInit { // Double remainingQuantity; this.astuteClientService.createPODetail(emptyData).then((data) => { if (!data) { - alert('Creating SO detailed failed!'); + this.notif('Creating SO detailed failed!'); } this.refreshDetailsOfSelected(); }, (reason) => { - alert('Creating SO detailed failed: ' + reason); + this.notif('Creating SO detailed failed: ' + reason); }); } @@ -304,10 +305,10 @@ export class SalesOrderComponent implements OnInit { // this.updateNewContractAmt(); // this.updateEditContractAmt(); // } else { - // alert('Get SO\'s Failed!'); + // this.notif('Get SO\'s Failed!'); // } // }, (reason) => { - // alert('Get SO\'s Failed: ' + reason); + // this.notif('Get SO\'s Failed: ' + reason); // }); this.rowData = this.astuteClientService.getPOs().then((data) => { if (data) { @@ -321,10 +322,10 @@ export class SalesOrderComponent implements OnInit { this.contractAmount = 0; return data; } else { - alert('Get SO\'s Failed!'); + this.notif('Get SO\'s Failed!'); } }, (reason) => { - alert('Get SO\'s Failed: ' + reason); + this.notif('Get SO\'s Failed: ' + reason); }); } refreshDetailsOfSelected() { @@ -400,4 +401,10 @@ export class SalesOrderComponent implements OnInit { resizeColumns(evt) { evt.columnApi.autoSizeAllColumns(); } + + // ** toast notification method + notif(text: string) { + this.toastService.show(text, {classname: 'bg-danger text-light'}); + } + } diff --git a/AstuteClient2/src/app/services/astute-client-service.ts b/AstuteClient2/src/app/services/astute-client-service.ts index 1951469..c893470 100644 --- a/AstuteClient2/src/app/services/astute-client-service.ts +++ b/AstuteClient2/src/app/services/astute-client-service.ts @@ -108,13 +108,13 @@ export class AstuteClientService { } else if (message.includes('login')) { this.notif('Please login again!'); } else { - alert('Update Customer Failed: ' + message); + this.notif('Update Customer Failed: ' + message); } }, (reason) => { - alert('Update Customer Failed: ' + reason); + this.notif('Update Customer Failed: ' + reason); }) .catch( error => { - alert(error); + this.notif(error); }); } public createCustomer(data: any): Promise { @@ -129,15 +129,15 @@ export class AstuteClientService { console.log(response['entity']); return response['entity']; } else if (message.includes('login')) { - alert('Please login again!'); + this.notif('Please login again!'); } else { - alert('Create Customer Failed: ' + message); + this.notif('Create Customer Failed: ' + message); } }, (reason) => { - alert('Create Customer Failed: ' + reason); + this.notif('Create Customer Failed: ' + reason); }) .catch( error => { - alert(error); + this.notif(error); }); } public deleteCustomer(customerId) { @@ -152,15 +152,15 @@ export class AstuteClientService { console.log(response['entity']); return response['entity']; } else if (message.includes('login')) { - alert('Please login again!'); + this.notif('Please login again!'); } else { - alert('Delete Customer Failed: ' + message); + this.notif('Delete Customer Failed: ' + message); } }, (reason) => { - alert('Delete Customer Failed: ' + reason); + this.notif('Delete Customer Failed: ' + reason); }) .catch( error => { - alert(error); + this.notif(error); }); } @@ -177,15 +177,15 @@ export class AstuteClientService { console.log(response['entity']); return response['entity']; } else if (message.includes('login')) { - alert('Please login again!'); + this.notif('Please login again!'); } else { - alert('Get Customer Contacts Failed: ' + message); + this.notif('Get Customer Contacts Failed: ' + message); } }, (reason) => { - alert('Get Customer Contacts Failed: ' + reason); + this.notif('Get Customer Contacts Failed: ' + reason); }) .catch( error => { - alert(error); + this.notif(error); }); } public updateCustomerContact(customerId: string, data: any): Promise { @@ -200,15 +200,15 @@ export class AstuteClientService { console.log(response['entity']); return response['entity']; } else if (message.includes('login')) { - alert('Please login again!'); + this.notif('Please login again!'); } else { - alert('Update Customer Contacts Failed: ' + message); + this.notif('Update Customer Contacts Failed: ' + message); } }, (reason) => { - alert('Update Customer Contacts Failed: ' + reason); + this.notif('Update Customer Contacts Failed: ' + reason); }) .catch( error => { - alert(error); + this.notif(error); }); } public deleteCustomerContact(customerId: string, contactId: number): Promise { @@ -223,15 +223,15 @@ export class AstuteClientService { console.log(response['entity']); return response['entity']; } else if (message.includes('login')) { - alert('Please login again!'); + this.notif('Please login again!'); } else { - alert('Delete Customer Contacts Failed: ' + message); + this.notif('Delete Customer Contacts Failed: ' + message); } }, (reason) => { - alert('Delete Customer Contacts Failed: ' + reason); + this.notif('Delete Customer Contacts Failed: ' + reason); }) .catch( error => { - alert(error); + this.notif(error); }); } public createCustomerContact(data: any): Promise { @@ -246,15 +246,15 @@ export class AstuteClientService { console.log(response['entity']); return response['entity']; } else if (message.includes('login')) { - alert('Please login again!'); + this.notif('Please login again!'); } else { - alert('Create Customer Contacts Failed: ' + message); + this.notif('Create Customer Contacts Failed: ' + message); } }, (reason) => { - alert('Create Customer Contacts Failed: ' + reason); + this.notif('Create Customer Contacts Failed: ' + reason); }) .catch( error => { - alert(error); + this.notif(error); }); } @@ -317,15 +317,15 @@ export class AstuteClientService { console.log(response['entity']); return response['entity']; } else if (message.includes('login')) { - alert('Please login again!'); + this.notif('Please login again!'); } else { - alert('Get Customers Failed: ' + message); + this.notif('Get Customers Failed: ' + message); } }, (reason) => { - alert('Update Sales Order Failed: ' + reason); + this.notif('Update Sales Order Failed: ' + reason); }) .catch( error => { - alert(error); + this.notif(error); }); } public createPO(data: any): Promise { @@ -340,15 +340,15 @@ export class AstuteClientService { console.log(response['entity']); return response['entity']; } else if (message.includes('login')) { - alert('Please login again!'); + this.notif('Please login again!'); } else { - alert('Get Customers Failed: ' + message); + this.notif('Get Customers Failed: ' + message); } }, (reason) => { - alert('Create Sales Order Failed: ' + reason); + this.notif('Create Sales Order Failed: ' + reason); }) .catch( error => { - alert(error); + this.notif(error); }); } public updatePODetail(ponum, lineItemNo, data) { @@ -364,15 +364,15 @@ export class AstuteClientService { console.log(response['entity']); return response['entity']; } else if (message.includes('login')) { - alert('Please login again!'); + this.notif('Please login again!'); } else { - alert('Get Customers Failed: ' + message); + this.notif('Get Customers Failed: ' + message); } }, (reason) => { - alert('Update Sales Order Details Failed: ' + reason); + this.notif('Update Sales Order Details Failed: ' + reason); }) .catch( error => { - alert(error); + this.notif(error); }); } public createPODetail(data) { @@ -387,15 +387,15 @@ export class AstuteClientService { console.log(response['entity']); return response['entity']; } else if (message.includes('login')) { - alert('Please login again!'); + this.notif('Please login again!'); } else { - alert('Get Customers Failed: ' + message); + this.notif('Get Customers Failed: ' + message); } }, (reason) => { - alert('Create Sales Order Failed: ' + reason); + this.notif('Create Sales Order Failed: ' + reason); }) .catch( error => { - alert(error); + this.notif(error); }); } public finalizePO(ponum: string) { @@ -410,15 +410,15 @@ export class AstuteClientService { console.log(response['entity']); return response['entity']; } else if (message.includes('login')) { - alert('Please login again!'); + this.notif('Please login again!'); } else { - alert('Get Customers Failed: ' + message); + this.notif('Get Customers Failed: ' + message); } }, (reason) => { - alert('Finalize Sales Order Failed: ' + reason); + this.notif('Finalize Sales Order Failed: ' + reason); }) .catch( error => { - alert(error); + this.notif(error); }); } public deletePO(ponum: string) { @@ -433,15 +433,15 @@ export class AstuteClientService { console.log(response['entity']); return response['entity']; } else if (message.includes('login')) { - alert('Please login again!'); + this.notif('Please login again!'); } else { - alert('Get Customers Failed: ' + message); + this.notif('Get Customers Failed: ' + message); } }, (reason) => { - alert('Delete Sales Order Failed: ' + reason); + this.notif('Delete Sales Order Failed: ' + reason); }) .catch( error => { - alert(error); + this.notif(error); }); } public getRateTypes(): Promise { @@ -456,15 +456,15 @@ export class AstuteClientService { console.log(response['entity']); return response['entity']; } else if (message.includes('login')) { - alert('Please login again!'); + this.notif('Please login again!'); } else { - alert('Get Customers Failed: ' + message); + this.notif('Get Customers Failed: ' + message); } }, (reason) => { - alert('Get Rate Types Failed: ' + reason); + this.notif('Get Rate Types Failed: ' + reason); }) .catch( error => { - alert(error); + this.notif(error); }); } @@ -481,15 +481,15 @@ export class AstuteClientService { console.log(response['entity']); return response['entity']; } else if (message.includes('login')) { - alert('Please login again!'); + this.notif('Please login again!'); } else { - alert('Get Customers Failed: ' + message); + this.notif('Get Customers Failed: ' + message); } }, (reason) => { - alert('Submit Invoice Failed: ' + reason); + this.notif('Submit Invoice Failed: ' + reason); }) .catch( error => { - alert(error); + this.notif(error); }); } public voidInvoice (invoiceNumber) { @@ -504,15 +504,15 @@ export class AstuteClientService { console.log(response['entity']); return response['entity']; } else if (message.includes('login')) { - alert('Please login again!'); + this.notif('Please login again!'); } else { - alert('Get Customers Failed: ' + message); + this.notif('Get Customers Failed: ' + message); } }, (reason) => { - alert('Void Invoice Failed: ' + reason); + this.notif('Void Invoice Failed: ' + reason); }) .catch( error => { - alert(error); + this.notif(error); }); } public deleteInvoice (invoiceNumber) { @@ -527,15 +527,15 @@ export class AstuteClientService { console.log(response['entity']); return response['entity']; } else if (message.includes('login')) { - alert('Please login again!'); + this.notif('Please login again!'); } else { - alert('Get Customers Failed: ' + message); + this.notif('Get Customers Failed: ' + message); } }, (reason) => { - alert('Delete Invoice Failed: ' + reason); + this.notif('Delete Invoice Failed: ' + reason); }) .catch( error => { - alert(error); + this.notif(error); }); } public generateInvoiceNumber (ponum) { @@ -550,15 +550,15 @@ export class AstuteClientService { console.log(response['entity']); return response['entity']; } else if (message.includes('login')) { - alert('Please login again!'); + this.notif('Please login again!'); } else { - alert('Get Customers Failed: ' + message); + this.notif('Get Customers Failed: ' + message); } }, (reason) => { - alert('Generate Invoice Failed: ' + reason); + this.notif('Generate Invoice Failed: ' + reason); }) .catch( error => { - alert(error); + this.notif(error); }); } public getInvoices(): Promise { @@ -596,15 +596,15 @@ export class AstuteClientService { console.log(response['entity']); return response['entity']; } else if (message.includes('login')) { - alert('Please login again!'); + this.notif('Please login again!'); } else { - alert('Get Customers Failed: ' + message); + this.notif('Get Customers Failed: ' + message); } }, (reason) => { - alert('Get Invoice Details Failed: ' + reason); + this.notif('Get Invoice Details Failed: ' + reason); }) .catch( error => { - alert(error); + this.notif(error); }); } public getInvoiceGen (invoiceId: string): Promise { @@ -619,15 +619,15 @@ export class AstuteClientService { console.log(response['entity']); return response['entity']; } else if (message.includes('login')) { - alert('Please login again!'); + this.notif('Please login again!'); } else { - alert('Get Customers Failed: ' + message); + this.notif('Get Customers Failed: ' + message); } }, (reason) => { - alert('Get Generated Invoice Failed: ' + reason); + this.notif('Get Generated Invoice Failed: ' + reason); }) .catch( error => { - alert(error); + this.notif(error); }); } public updateInvoice(invoiceNumber: string, data: any): Promise { @@ -642,15 +642,15 @@ export class AstuteClientService { console.log(response['entity']); return response['entity']; } else if (message.includes('login')) { - alert('Please login again!'); + this.notif('Please login again!'); } else { - alert('Get Customers Failed: ' + message); + this.notif('Get Customers Failed: ' + message); } }, (reason) => { - alert('Update Invoice Failed: ' + reason); + this.notif('Update Invoice Failed: ' + reason); }) .catch( error => { - alert(error); + this.notif(error); }); } public createInvoice(data: any): Promise { @@ -665,15 +665,15 @@ export class AstuteClientService { console.log(response['entity']); return response['entity']; } else if (message.includes('login')) { - alert('Please login again!'); + this.notif('Please login again!'); } else { - alert('Get Customers Failed: ' + message); + this.notif('Get Customers Failed: ' + message); } }, (reason) => { - alert('Create Invoice Failed: ' + reason); + this.notif('Create Invoice Failed: ' + reason); }) .catch( error => { - alert(error); + this.notif(error); }); } public updateInvoiceDetail(invNum, lineItemNo, data) { @@ -688,15 +688,15 @@ export class AstuteClientService { console.log(response['entity']); return response['entity']; } else if (message.includes('login')) { - alert('Please login again!'); + this.notif('Please login again!'); } else { - alert('Get Customers Failed: ' + message); + this.notif('Get Customers Failed: ' + message); } }, (reason) => { - alert('Update Invoice Detail Failed: ' + reason); + this.notif('Update Invoice Detail Failed: ' + reason); }) .catch( error => { - alert(error); + this.notif(error); }); } public createInvoiceDetail(data) { @@ -711,15 +711,15 @@ export class AstuteClientService { console.log(response['entity']); return response['entity']; } else if (message.includes('login')) { - alert('Please login again!'); + this.notif('Please login again!'); } else { - alert('Get Customers Failed: ' + message); + this.notif('Get Customers Failed: ' + message); } }, (reason) => { - alert('Create Invoice Detail Failed: ' + reason); + this.notif('Create Invoice Detail Failed: ' + reason); }) .catch( error => { - alert(error); + this.notif(error); }); } @@ -737,15 +737,15 @@ export class AstuteClientService { console.log(response['entity']); return response['entity']; } else if (message.includes('login')) { - alert('Please login again!'); + this.notif('Please login again!'); } else { - alert('Get Customers Failed: ' + message); + this.notif('Get Customers Failed: ' + message); } }, (reason) => { - alert('Get Submitted Invoices Failed: ' + reason); + this.notif('Get Submitted Invoices Failed: ' + reason); }) .catch( error => { - alert(error); + this.notif(error); }); } public getInvoicePaymentTypes(): Promise { @@ -760,15 +760,15 @@ export class AstuteClientService { console.log(response['entity']); return response['entity']; } else if (message.includes('login')) { - alert('Please login again!'); + this.notif('Please login again!'); } else { - alert('Get Customers Failed: ' + message); + this.notif('Get Customers Failed: ' + message); } }, (reason) => { - alert('Get Invoice Payment Types Failed: ' + reason); + this.notif('Get Invoice Payment Types Failed: ' + reason); }) .catch( error => { - alert(error); + this.notif(error); }); } public getInvoicePayments(): Promise { @@ -783,15 +783,15 @@ export class AstuteClientService { console.log(response['entity']); return response['entity']; } else if (message.includes('login')) { - alert('Please login again!'); + this.notif('Please login again!'); } else { - alert('Get Customers Failed: ' + message); + this.notif('Get Customers Failed: ' + message); } }, (reason) => { - alert('Get Invoice Payments Failed: ' + reason); + this.notif('Get Invoice Payments Failed: ' + reason); }) .catch( error => { - alert(error); + this.notif(error); }); } public updateInvoicePayment(invoiceNumber: string, invoicePaymentId: string, data: any): Promise { @@ -807,15 +807,15 @@ export class AstuteClientService { console.log(response['entity']); return response['entity']; } else if (message.includes('login')) { - alert('Please login again!'); + this.notif('Please login again!'); } else { - alert('Get Customers Failed: ' + message); + this.notif('Get Customers Failed: ' + message); } }, (reason) => { - alert('Update Invoice Payment Failed: ' + reason); + this.notif('Update Invoice Payment Failed: ' + reason); }) .catch( error => { - alert(error); + this.notif(error); }); } public addInvoicePayment(data: any): Promise { @@ -830,15 +830,15 @@ export class AstuteClientService { console.log(response['entity']); return response['entity']; } else if (message.includes('login')) { - alert('Please login again!'); + this.notif('Please login again!'); } else { - alert('Get Customers Failed: ' + message); + this.notif('Get Customers Failed: ' + message); } }, (reason) => { - alert('Add Invoice Payment Failed: ' + reason); + this.notif('Add Invoice Payment Failed: ' + reason); }) .catch( error => { - alert(error); + this.notif(error); }); } @@ -855,15 +855,15 @@ export class AstuteClientService { console.log(response['entity']); return response['entity']; } else if (message.includes('login')) { - alert('Please login again!'); + this.notif('Please login again!'); } else { - alert('Get Customers Failed: ' + message); + this.notif('Get Customers Failed: ' + message); } }, (reason) => { - alert('Get Service Types Failed: ' + reason); + this.notif('Get Service Types Failed: ' + reason); }) .catch( error => { - alert(error); + this.notif(error); }); } public updateServiceType(serviceTypeId, data: any): Promise { @@ -879,15 +879,15 @@ export class AstuteClientService { console.log(response['entity']); return response['entity']; } else if (message.includes('login')) { - alert('Please login again!'); + this.notif('Please login again!'); } else { - alert('Get Customers Failed: ' + message); + this.notif('Get Customers Failed: ' + message); } }, (reason) => { - alert('Update Service Type Failed: ' + reason); + this.notif('Update Service Type Failed: ' + reason); }) .catch( error => { - alert(error); + this.notif(error); }); } public createServiceType(data: any): Promise { @@ -902,15 +902,15 @@ export class AstuteClientService { console.log(response['entity']); return response['entity']; } else if (message.includes('login')) { - alert('Please login again!'); + this.notif('Please login again!'); } else { - alert('Get Customers Failed: ' + message); + this.notif('Get Customers Failed: ' + message); } }, (reason) => { - alert('Create Service Type Failed: ' + reason); + this.notif('Create Service Type Failed: ' + reason); }) .catch( error => { - alert(error); + this.notif(error); }); }