Skip to content

Commit

Permalink
Removing the flashed messages module since it is incompatible with cu…
Browse files Browse the repository at this point in the history
…rrent Angular. Different solution incoming soon.
  • Loading branch information
fabian-marquardt committed Nov 19, 2017
1 parent 8236e0d commit f814ab9
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 51 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"@angular/platform-browser-dynamic": "^5.0.2",
"@angular/router": "^5.0.2",
"@types/csv-parse": "^1.1.11",
"angular2-flash-messages": "^1.0.8",
"bootstrap": "^4.0.0-beta.2",
"class-transformer": "^0.1.6",
"core-js": "^2.4.1",
Expand Down
2 changes: 1 addition & 1 deletion src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Component } from '@angular/core';

@Component({
selector: 'app-root',
template: '<flash-messages></flash-messages><router-outlet></router-outlet>'
template: '<router-outlet></router-outlet>'
})
export class AppComponent {
version = "1.0"
Expand Down
2 changes: 0 additions & 2 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { RouterModule } from '@angular/router';
import { FlashMessagesModule } from 'angular2-flash-messages';

import { AppComponent } from './app.component';
import { BackendServiceProvider } from "app/providers";
Expand Down Expand Up @@ -40,7 +39,6 @@ import { ConfigService } from "app/services";
BrowserModule,
FormsModule,
HttpModule,
FlashMessagesModule,
RouterModule.forRoot([
{
path: 'products',
Expand Down
18 changes: 8 additions & 10 deletions src/app/components/cash-point.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Component, OnInit, OnDestroy } from "@angular/core";
import { FlashMessagesService } from "angular2-flash-messages/module";

import { GlobalInput, KeyCode } from "app/utils";
import { BackendService } from "app/services";
Expand All @@ -19,8 +18,7 @@ export class CashPointComponent extends GlobalInput implements OnInit, OnDestroy
withdraw_custom: number;

constructor(
private backend_service: BackendService,
private flash_messages_service: FlashMessagesService
private backend_service: BackendService
) {
super();
}
Expand Down Expand Up @@ -58,15 +56,15 @@ export class CashPointComponent extends GlobalInput implements OnInit, OnDestroy
},
error => {
this.wait_identifier = false;
this.flash_messages_service.show('Unkown barcode.', { cssClass: 'alert-danger' });
//this.flash_messages_service.show('Unkown barcode.', { cssClass: 'alert-danger' });
}
);
this.identifier_input = '';
}

processItem(item: Identifiable): void {
if(item instanceof Product){
this.flash_messages_service.show('This is not a user barcode.', { cssClass: 'alert-danger' });
//this.flash_messages_service.show('This is not a user barcode.', { cssClass: 'alert-danger' });
}
else if(item instanceof User){
this.user = item;
Expand All @@ -76,25 +74,25 @@ export class CashPointComponent extends GlobalInput implements OnInit, OnDestroy

deposit(amount: number): void {
if(!amount) {
this.flash_messages_service.show('Please specify the transaction amount!', { cssClass: 'alert-warning' });
//this.flash_messages_service.show('Please specify the transaction amount!', { cssClass: 'alert-warning' });
return;
}
this.wait_checkout = true;
this.backend_service.deposit(this.user, amount).subscribe(
transaction => {
this.flash_messages_service.show('Transaction created!', { cssClass: 'alert-success' });
//this.flash_messages_service.show('Transaction created!', { cssClass: 'alert-success' });
this.wait_checkout = false;
this.reset();
},
error => {
this.flash_messages_service.show('Failed to create the transaction!', { cssClass: 'alert-danger' });
//this.flash_messages_service.show('Failed to create the transaction!', { cssClass: 'alert-danger' });
console.log(error);
}
);
}

abort(): void {
this.flash_messages_service.show('Transaction aborted.', { cssClass: 'alert-warning' });
//this.flash_messages_service.show('Transaction aborted.', { cssClass: 'alert-warning' });
this.reset();
}

Expand All @@ -104,4 +102,4 @@ export class CashPointComponent extends GlobalInput implements OnInit, OnDestroy
this.user = null;
this.startCaptureInput();
}
}
}
10 changes: 4 additions & 6 deletions src/app/components/product-edit.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Component, OnInit } from "@angular/core";
import { ActivatedRoute, Router } from "@angular/router";
import { FlashMessagesService } from "angular2-flash-messages";

import { Product, Identifier, Pricing, Tag } from "app/models";
import { BackendService } from "app/services";
Expand All @@ -17,7 +16,6 @@ export class ProductEditComponent implements OnInit {

constructor(
private backend_service: BackendService,
private flash_messages_service: FlashMessagesService,
private route: ActivatedRoute,
private router: Router
) { }
Expand Down Expand Up @@ -56,7 +54,7 @@ export class ProductEditComponent implements OnInit {
this.backend_service.getProduct(+product_id)
.subscribe(
product => this.product = product,
error => this.flash_messages_service.show('Failed to load product!', { cssClass: 'alert-danger' })
error => console.log(error) //this.flash_messages_service.show('Failed to load product!', { cssClass: 'alert-danger' })
);
}
});
Expand All @@ -67,14 +65,14 @@ export class ProductEditComponent implements OnInit {
this.backend_service.saveProduct(this.product)
.subscribe(
product => {
this.flash_messages_service.show('Product saved!', { cssClass: 'alert-success' });
//this.flash_messages_service.show('Product saved!', { cssClass: 'alert-success' });
this.router.navigate(['/products']);
},
error => {
this.flash_messages_service.show('Failed to save product!', { cssClass: 'alert-danger' });
//this.flash_messages_service.show('Failed to save product!', { cssClass: 'alert-danger' });
this.wait_save = false;
console.log(error);
}
);
}
}
}
14 changes: 6 additions & 8 deletions src/app/components/sales-point.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Component, OnInit, OnDestroy } from "@angular/core";
import { FlashMessagesService } from "angular2-flash-messages/module";

import { Cart, User, Identifiable, Product } from "app/models";
import { GlobalInput, KeyCode } from "app/utils";
Expand All @@ -20,7 +19,6 @@ export class SalesPointComponent extends GlobalInput implements OnInit, OnDestro

constructor(
private backend_service: BackendService,
private flash_messages_service: FlashMessagesService
) {
super();
this.cart = new Cart();
Expand Down Expand Up @@ -59,7 +57,7 @@ export class SalesPointComponent extends GlobalInput implements OnInit, OnDestro
},
error => {
this.wait_identifier = false;
this.flash_messages_service.show('Unkown barcode.', { cssClass: 'alert-danger' });
//this.flash_messages_service.show('Unkown barcode.', { cssClass: 'alert-danger' });
}
);
this.identifier_input = '';
Expand Down Expand Up @@ -92,7 +90,7 @@ export class SalesPointComponent extends GlobalInput implements OnInit, OnDestro
cart => this.cart = cart,
error => {
console.log(error);
this.flash_messages_service.show('Cart update failed.', { cssClass: 'alert-danger' });
//this.flash_messages_service.show('Cart update failed.', { cssClass: 'alert-danger' });
}
);
}
Expand All @@ -102,23 +100,23 @@ export class SalesPointComponent extends GlobalInput implements OnInit, OnDestro
this.backend_service.payCart(this.cart).subscribe(
transaction => {
this.wait_checkout = false;
this.flash_messages_service.show('Transaction created!', { cssClass: 'alert-success' });
//this.flash_messages_service.show('Transaction created!', { cssClass: 'alert-success' });
this.reset();
},
error => {
console.log(error);
this.flash_messages_service.show('Cart payment failed.', { cssClass: 'alert-danger' });
//this.flash_messages_service.show('Cart payment failed.', { cssClass: 'alert-danger' });
}
);
}

abort(): void {
this.flash_messages_service.show('Transaction aborted.', { cssClass: 'alert-warning' });
//this.flash_messages_service.show('Transaction aborted.', { cssClass: 'alert-warning' });
this.reset();
}

reset(): void {
this.cart = new Cart();
this.user = null;
}
}
}
18 changes: 8 additions & 10 deletions src/app/components/self-service-point.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Component, OnInit, OnDestroy, ViewChild, ElementRef } from "@angular/core";
import { FlashMessagesService } from "angular2-flash-messages/module";

declare var jQuery:any;

Expand Down Expand Up @@ -28,8 +27,7 @@ export class SelfServicePointComponent extends GlobalInput implements OnInit, On

constructor(
private backend_service: BackendService,
private config_service: ConfigService,
private flash_messages_service: FlashMessagesService
private config_service: ConfigService
) {
super();
this.cart = new Cart();
Expand Down Expand Up @@ -79,7 +77,7 @@ export class SelfServicePointComponent extends GlobalInput implements OnInit, On
error => {
this.wait_identifier = false;
console.error(error);
this.flash_messages_service.show('Not found! No product or user with this barcode exists.', { cssClass: 'alert-danger' });
//this.flash_messages_service.show('Not found! No product or user with this barcode exists.', { cssClass: 'alert-danger' });
}
);
this.identifier_input = '';
Expand All @@ -88,15 +86,15 @@ export class SelfServicePointComponent extends GlobalInput implements OnInit, On
processItem(item: Identifiable): void {
if(item instanceof Product){
if(!this.user){
this.flash_messages_service.show('Please scan your ID card first! You have scanned a product, but you need to scan your ID card.', { cssClass: 'alert-danger' });
//this.flash_messages_service.show('Please scan your ID card first! You have scanned a product, but you need to scan your ID card.', { cssClass: 'alert-danger' });
return;
}
this.cart.addToCart(item.name, item.pricings[0]); // hackedyhack ... select proper pricing instead
this.updateCart();
}
else if(item instanceof User){
if(this.user){
this.flash_messages_service.show('Already logged in! You have already scanned an ID card. If you want to change the user, please abort this transaction.', { cssClass: 'alert-danger' });
//this.flash_messages_service.show('Already logged in! You have already scanned an ID card. If you want to change the user, please abort this transaction.', { cssClass: 'alert-danger' });
return;
}
this.user = item;
Expand All @@ -111,7 +109,7 @@ export class SelfServicePointComponent extends GlobalInput implements OnInit, On
cart => this.cart = cart,
error => {
console.error(error);
this.flash_messages_service.show('Cart update failed! The cart could not be updated, probably because the product is no longer available.', { cssClass: 'alert-danger' });
//this.flash_messages_service.show('Cart update failed! The cart could not be updated, probably because the product is no longer available.', { cssClass: 'alert-danger' });
}
);
}
Expand All @@ -125,7 +123,7 @@ export class SelfServicePointComponent extends GlobalInput implements OnInit, On
},
error => {
console.error(error);
this.flash_messages_service.show('Cart payment failed! The server did not accept the transaction, probably because your account balance is insufficient.', { cssClass: 'alert-danger' });
//this.flash_messages_service.show('Cart payment failed! The server did not accept the transaction, probably because your account balance is insufficient.', { cssClass: 'alert-danger' });
}
);
}
Expand All @@ -142,7 +140,7 @@ export class SelfServicePointComponent extends GlobalInput implements OnInit, On
}

abort(): void {
this.flash_messages_service.show('The checkout process has been aborted.', { cssClass: 'alert-warning' });
//this.flash_messages_service.show('The checkout process has been aborted.', { cssClass: 'alert-warning' });
this.cart = new Cart();
this.user = null;
this.mode = 0;
Expand All @@ -169,4 +167,4 @@ export class SelfServicePointComponent extends GlobalInput implements OnInit, On
}, 4000);
}
*/
}
}
10 changes: 4 additions & 6 deletions src/app/components/user-edit.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Component, OnInit } from "@angular/core";
import { ActivatedRoute, Router } from "@angular/router";
import { FlashMessagesService } from "angular2-flash-messages";

import { User, Tag, Identifier } from "app/models";
import { BackendService } from "app/services";
Expand All @@ -17,7 +16,6 @@ export class UserEditComponent implements OnInit {

constructor(
private backend_service: BackendService,
private flashMessagesService: FlashMessagesService,
private route: ActivatedRoute,
private router: Router
) { }
Expand Down Expand Up @@ -48,7 +46,7 @@ export class UserEditComponent implements OnInit {
this.backend_service.getUser(+user_id)
.subscribe(
user => this.user = user,
error => this.flashMessagesService.show('Failed to load user!', { cssClass: 'alert-danger' })
error => console.log(error) //this.flashMessagesService.show('Failed to load user!', { cssClass: 'alert-danger' })
);
}
});
Expand All @@ -59,14 +57,14 @@ export class UserEditComponent implements OnInit {
this.backend_service.saveUser(this.user)
.subscribe(
user => {
this.flashMessagesService.show('User saved!', { cssClass: 'alert-success' });
//this.flashMessagesService.show('User saved!', { cssClass: 'alert-success' });
this.router.navigate(['/users']);
},
error => {
this.flashMessagesService.show('Failed to save user!', { cssClass: 'alert-danger' });
//this.flashMessagesService.show('Failed to save user!', { cssClass: 'alert-danger' });
this.wait_save = false;
console.log(error);
}
);
}
}
}
4 changes: 1 addition & 3 deletions src/app/components/user-import.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Component, OnInit } from "@angular/core";
import { User, Tag, Identifier } from "app/models";
import { BackendService } from "app/services/backend.service";
import { FlashMessagesService } from "angular2-flash-messages";
import { Parser } from "csv-parse";

@Component({
Expand All @@ -17,8 +16,7 @@ export class UserImportComponent implements OnInit{
importProgress: number;

constructor(
private backendService: BackendService,
private flashMessagesService: FlashMessagesService
private backendService: BackendService
) { }

ngOnInit() {
Expand Down
4 changes: 0 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,6 @@ amdefine@>=0.0.4:
version "1.0.1"
resolved "https://registry.yarnpkg.com/amdefine/-/amdefine-1.0.1.tgz#4a5282ac164729e93619bcfd3ad151f817ce91f5"

angular2-flash-messages@^1.0.8:
version "1.0.8"
resolved "https://registry.yarnpkg.com/angular2-flash-messages/-/angular2-flash-messages-1.0.8.tgz#21e10833a8c044c1ea7c709480154949c2723463"

[email protected]:
version "0.0.7"
resolved "https://registry.yarnpkg.com/ansi-html/-/ansi-html-0.0.7.tgz#813584021962a9e9e6fd039f940d12f56ca7859e"
Expand Down

0 comments on commit f814ab9

Please sign in to comment.