Merge branch 'development' of bitbucket.org:umwerk/instore-ma-app into development

This commit is contained in:
Peter Skrlj
2019-02-13 18:44:31 +01:00
16 changed files with 12482 additions and 14 deletions

12296
package-lock.json generated Normal file
View File

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,13 @@
export interface AddressDTO {
city: string;
street: string;
streetNumber: string;
zipCode: string;
country: string;
region: string;
geoLoaction: {
longitude: number;
latitude: number;
altitude: number;
};
}

View File

@@ -0,0 +1,23 @@
import { AddressDTO } from './address-dto';
export interface BranchInfoDTO {
/**
* Branch Id
*/
id: number;
/**
* Branch Name
*/
name: string;
/**
* Branch Key
*/
key: string;
/**
* Address
*/
address: AddressDTO;
}

View File

@@ -1,4 +1,6 @@
// start:ng42.barrel
export * from './address-dto';
export * from './branch-info.dto';
export * from './event-info.dto';
export * from './feed.dto';
export * from './info.dto';

View File

@@ -2,6 +2,7 @@
export * from './feed-service.module';
export * from './feed-mock.service';
export * from './feed.service';
export * from './isa.service';
export * from './response';
export * from './tokens';
export * from './dtos';

View File

@@ -0,0 +1,51 @@
import { TestBed } from '@angular/core/testing';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { FEED_SERVICE_ENDPOINT } from './tokens';
import { IsaService } from './isa.service';
describe('IsaService', () => {
const endpoint = 'http://test-feed.com';
let service: IsaService;
let httpMock: HttpTestingController;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
providers: [
{ provide: FEED_SERVICE_ENDPOINT, useValue: endpoint },
IsaService
]
});
service = TestBed.get(IsaService);
httpMock = TestBed.get(HttpTestingController);
});
describe('#branches', () => {
it('should issue an get /isa/branches request ', () => {
service.branches().subscribe();
httpMock.expectOne({ method: 'GET', url: `${endpoint}/isa/branches` });
});
it('should set skip as query parameter', () => {
service.branches({ skip: 12 }).subscribe();
const req = httpMock.expectOne(r => r.method === 'GET' && r.url === `${endpoint}/isa/branches`);
expect(req.request.params.get('skip')).toBe('12');
});
it('should set take as query parameter', () => {
service.branches({ take: 10 }).subscribe();
const req = httpMock.expectOne(r => r.method === 'GET' && r.url === `${endpoint}/isa/branches`);
expect(req.request.params.get('take')).toBe('10');
});
});
});

View File

@@ -0,0 +1,44 @@
import { Injectable, Inject } from '@angular/core';
import { FEED_SERVICE_ENDPOINT } from './tokens';
import { PagedApiResponse } from './response';
import { Observable, isObservable } from 'rxjs';
import { HttpClient } from '@angular/common/http';
import { StringDictionary } from './models';
import { isNumber } from 'util';
import { BranchInfoDTO } from './dtos';
@Injectable({ providedIn: 'root' })
export class IsaService {
endpoint = '';
constructor(
private http: HttpClient,
@Inject(FEED_SERVICE_ENDPOINT) endpoint: string | Observable<string>
) {
if (isObservable(endpoint)) {
endpoint.subscribe(e => this.endpoint = e);
} else {
this.endpoint = endpoint;
}
}
branches(options?: { skip?: number; take?: number; }): Observable<PagedApiResponse<BranchInfoDTO>> {
const params: StringDictionary<string | string[]> = {};
if (!!options) {
if (isNumber(options.skip)) {
params['skip'] = String(options.skip);
}
if (isNumber(options.take)) {
params['take'] = String(options.take);
}
}
return this.http.get<PagedApiResponse<BranchInfoDTO>>(
`${this.endpoint}/isa/branches`,
{ params }
);
}
}

View File

@@ -5,6 +5,7 @@
export * from './lib/feed-service.module';
export * from './lib/feed-mock.service';
export * from './lib/feed.service';
export * from './lib/isa.service';
export * from './lib/response';
export * from './lib/tokens';
export * from './lib/dtos';

View File

@@ -242,7 +242,14 @@
align-items: center;
position: relative;
bottom: 22px;
right: 10px;
// right: 10px;
margin-top: 1px;
align-self: right;
background-color: white;
width: 10%;
position: relative;
right: -91%;
img {
padding-left: 8px;

View File

@@ -259,7 +259,7 @@ export class ProcessState {
return { ...process, users: users };
} else {
// If users found, add new breadcrumb for searched term
let currentBreadcrumbs = [...process.breadcrumbs];
const currentBreadcrumbs = [...process.breadcrumbs];
const missingBreadcrumb = currentBreadcrumbs.filter((breadcrumb: Breadcrumb) => breadcrumb.path === '/customer-search');
if (missingBreadcrumb.length === 0) {
currentBreadcrumbs.push(
@@ -271,14 +271,14 @@ export class ProcessState {
name: payload,
path: '/customer-search-result'
}
)
);
} else {
currentBreadcrumbs.push(
{
name: payload,
path: '/customer-search-result'
}
)
);
}
if (users.length > 0 && currentBreadcrumbs.length > 1) {
@@ -659,7 +659,7 @@ export class ProcessState {
console.log(indexOfCurrentBreadcrumb);
for (let x = breadcrumbs.length - 1; x >= 0; x--) {
if (indexOfCurrentBreadcrumb < x) {
ctx.dispatch(new actions.ChangeCurrentRoute(breadcrumbs[x-1].path));
ctx.dispatch(new actions.ChangeCurrentRoute(breadcrumbs[x - 1].path));
breadcrumbs.pop();
}
}

View File

@@ -89,6 +89,7 @@
.recent-search-content {
display: grid;
grid-template-columns: auto;
min-height: 50px;
}
.recent-searches-label {

View File

@@ -4,6 +4,7 @@
Scannen Sie den Artikel um Informationen zu erhalten.
</caption>
<app-barcode-scanner-scandit
#scanner
(scan)="triggerSearch($event)"
></app-barcode-scanner-scandit>

View File

@@ -7,6 +7,7 @@
border-radius: 5px;
box-shadow: 0px -2px 24px 0px rgba(220, 226, 233, 0.8);
user-select: none;
margin-bottom: 90px;
h1 {
font-family: 'Open Sans';

View File

@@ -1,16 +1,21 @@
import { BarcodeScannerScanditComponent } from './components/barcode-scanner-scandit/barcode-scanner-scandit.component';
import { ProductMapping } from './../../core/mappings/product.mapping';
import { Product } from 'src/app/core/models/product.model';
import {
AllowProductLoad,
AddSearch,
ChangeCurrentRoute,
AddProcess
} from '../../core/store/actions/process.actions';
import { Component, OnInit } from '@angular/core';
import { Component, OnInit, ViewChild } from '@angular/core';
import { Search } from 'src/app/core/models/search.model';
import { Router } from '@angular/router';
import { Store } from '@ngxs/store';
import { Process } from 'src/app/core/models/process.model';
import { getRandomPic } from 'src/app/core/utils/process.util';
import { Breadcrumb } from 'src/app/core/models/breadcrumb.model';
import { ProductService } from 'src/app/core/services/product.service';
import { AddSelectedProduct } from 'src/app/core/store/actions/product.actions';
@Component({
selector: 'app-barcode-search',
@@ -18,7 +23,12 @@ import { Breadcrumb } from 'src/app/core/models/breadcrumb.model';
styleUrls: ['barcode-search.component.scss']
})
export class BarcodeSearchComponent implements OnInit {
constructor(private store: Store, private router: Router) {}
@ViewChild('scanner') scanner: BarcodeScannerScanditComponent;
constructor(
private store: Store,
private router: Router,
protected productService: ProductService
) {}
ngOnInit() {}
@@ -31,10 +41,17 @@ export class BarcodeSearchComponent implements OnInit {
skip: 0,
firstLoad: true
};
this.store.dispatch(new AllowProductLoad());
this.store.dispatch(new AddSearch(search));
this.store.dispatch(new ChangeCurrentRoute('/search-results#start'));
this.router.navigate(['/search-results#start']);
this.productService.searchItems(search).subscribe(items => {
if (items.length > 0) {
const product = new ProductMapping().fromItemDTO(items[0]);
this.store.dispatch(new AddSelectedProduct(items[0]));
const currentRoute = 'product-details/' + product.id;
this.store.dispatch(new ChangeCurrentRoute(currentRoute));
this.router.navigate([currentRoute]);
} else {
this.scanner.scanToggle();
}
});
}
createProcess() {

View File

@@ -4,7 +4,8 @@ import {
ViewChild,
EventEmitter,
Output,
AfterViewInit
AfterViewInit,
ChangeDetectorRef
} from '@angular/core';
import { BarcodeFormat, Result } from '@zxing/library';
import { ZXingScannerComponent } from '@zxing/ngx-scanner';
@@ -34,7 +35,10 @@ export class BarcodeScannerScanditComponent implements AfterViewInit {
@ViewChild('scanner') scanner: ScanditSdkBarcodePickerComponent;
log = 'tst';
constructor(private cameraError: CameraErrorHandler) {}
constructor(
private cameraError: CameraErrorHandler,
private cdRef: ChangeDetectorRef
) {}
ngAfterViewInit() {
this.cameraError.notAllowed.subscribe(v => (this.errorAccess = v));
@@ -54,12 +58,15 @@ export class BarcodeScannerScanditComponent implements AfterViewInit {
if (result.barcodes.length > 0) {
this.code = result.barcodes[0].data;
this.enabled = false;
this.search();
}
}
scanToggle() {
this.enabled = !this.enabled;
this.enabled = true;
this.ready = false;
this.cdRef.detectChanges();
setTimeout(() => this.cdRef.detectChanges(), 200);
}
search() {
@@ -72,6 +79,7 @@ export class BarcodeScannerScanditComponent implements AfterViewInit {
.picker as any;
this.errorOther = !picker.scanner.isReadyToWork;
picker.cameraManager.cameraSwitcherEnabled = false;
picker.barcodePickerGui.cameraSwitcherElement = null;
picker.cameraManager.triggerFatalError = e => {
console.error(e);
this.errorOther = true;
@@ -82,6 +90,8 @@ export class BarcodeScannerScanditComponent implements AfterViewInit {
const imageElement = element.childNodes[0].childNodes[0]
.childNodes[6] as any;
imageElement.src = '';
this.cdRef.detectChanges();
}
scanErrorHandler($event) {