mirror of
https://dev.azure.com/hugendubel/ISA/_git/ISA-Frontend
synced 2025-12-31 09:37:15 +01:00
Merge branch 'development' of https://bitbucket.org/umwerk/instore-ma-app into development
This commit is contained in:
12296
package-lock.json
generated
Normal file
12296
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
13
projects/feed-service/src/lib/dtos/address-dto.ts
Normal file
13
projects/feed-service/src/lib/dtos/address-dto.ts
Normal 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;
|
||||
};
|
||||
}
|
||||
23
projects/feed-service/src/lib/dtos/branch-info.dto.ts
Normal file
23
projects/feed-service/src/lib/dtos/branch-info.dto.ts
Normal 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;
|
||||
}
|
||||
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
51
projects/feed-service/src/lib/isa.service.spec.ts
Normal file
51
projects/feed-service/src/lib/isa.service.spec.ts
Normal 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');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
44
projects/feed-service/src/lib/isa.service.ts
Normal file
44
projects/feed-service/src/lib/isa.service.ts
Normal 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 }
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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';
|
||||
|
||||
@@ -89,6 +89,7 @@
|
||||
.recent-search-content {
|
||||
display: grid;
|
||||
grid-template-columns: auto;
|
||||
min-height: 50px;
|
||||
}
|
||||
|
||||
.recent-searches-label {
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user