build: update dependencies

Additionally adjust the code after the latest
rebase.
This commit is contained in:
Jovan Krunić
2019-04-08 11:28:43 +02:00
parent 3e697b17b4
commit 75ca8c8a73
10 changed files with 566 additions and 561 deletions

View File

@@ -0,0 +1,27 @@
/*
* Copyright (C) 2019 StApps
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* An error that can occur in the StApps app
*/
export class AppError extends Error {
/**
* Instantiate a new error
*/
constructor(name: string, message: string) {
super(message);
this.name = name;
}
}

View File

@@ -15,89 +15,150 @@
import {HTTP_INTERCEPTORS, HttpClient,
HttpEvent, HttpHandler, HttpInterceptor, HttpRequest, HttpResponse} from '@angular/common/http';
import {Injectable} from '@angular/core';
import {Observable} from 'rxjs';
// import {SCThing} from '@openstapps/core';
// import {Observable, of} from 'rxjs';
import {SCIndexResponse, SCThingType} from '@openstapps/core';
import {Observable, of} from 'rxjs';
import {map} from 'rxjs/operators';
import {SampleThings} from './data/sample-things';
const sampleIndexResponse: SCIndexResponse = {
app: {
campusPolygon: {
coordinates: [
[
[
13.31916332244873,
52.50796756998264,
],
[
13.336544036865234,
52.50796756998264,
],
[
13.336544036865234,
52.51726547416385,
],
[
13.31916332244873,
52.51726547416385,
],
[
13.31916332244873,
52.50796756998264,
],
],
],
type: 'Polygon',
},
features: {
widgets: true,
},
menus: [],
name: 'StApps - Technische Universität Berlin',
privacyPolicyUrl: 'https://stappsbe01.innocampus.tu-berlin.de/_static/privacy.md',
settings: [],
},
backend: {
SCVersion: '1.0.0',
hiddenTypes: [
SCThingType.DateSeries,
SCThingType.Diff,
SCThingType.Floor,
],
maxMultiSearchRouteQueries: 5,
maxRequestBodySize: 512 * 1024,
name: 'Technische Universität Berlin',
namespace: '909a8cbc-8520-456c-b474-ef1525f14209',
sortableFields: [
{
fieldName: 'name',
sortTypes: ['ducet'],
},
{
fieldName: 'type',
sortTypes: ['ducet'],
},
{
fieldName: 'categories',
onlyOnTypes: [
SCThingType.AcademicEvent,
SCThingType.Building,
SCThingType.Catalog,
SCThingType.Dish,
SCThingType.PointOfInterest,
SCThingType.Room,
],
sortTypes: ['ducet'],
},
{
fieldName: 'geo.point.coordinates',
onlyOnTypes: [
SCThingType.Building,
SCThingType.PointOfInterest,
SCThingType.Room,
],
sortTypes: ['distance'],
},
{
fieldName: 'geo.point.coordinates',
onlyOnTypes: [
SCThingType.Building,
SCThingType.PointOfInterest,
SCThingType.Room,
],
sortTypes: ['distance'],
},
{
fieldName: 'inPlace.geo.point.coordinates',
onlyOnTypes: [
SCThingType.DateSeries,
SCThingType.Dish,
SCThingType.Floor,
SCThingType.Organization,
SCThingType.PointOfInterest,
SCThingType.Room,
SCThingType.Ticket,
],
sortTypes: ['distance'],
},
{
fieldName: 'offers',
onlyOnTypes: [
SCThingType.Dish,
],
sortTypes: ['price'],
},
],
},
};
@Injectable()
export class FakeBackendInterceptor implements HttpInterceptor {
sampleFetcher: SampleThings;
// http: HttpClient;
// tslint:disable-next-line:no-empty
constructor(http: HttpClient) {
this.sampleFetcher = new SampleThings(http);
// this.http = http;
}
// intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
// let data: SCThing[] = [];
// // fake responses for search requests for easier (backendless) development process
// if (request.url.endsWith('/search') && request.method === 'POST') {
// if (typeof request.body.filter !== 'undefined' && typeof request.body.filter.arguments !== 'undefined') {
// if (request.body.filter.arguments.field === 'uid') {
// // provide items with given uid for search requests requesting single items (detail view)
// data = getSampleThings(request.body.filter.arguments.value);
// return this.sampleFetcher.getSampleThings().pipe(map((sampleData: any) => {
// return new HttpResponse({status: 200, body: {data: [sampleData.instance]}});
// // return new HttpResponse({status: 200, body: {data: [sampleData.instance]}});
// }),
// // data = getSampleThings();
// );
// }
// } else {
// // if filter and arguments are not set, then provide all sample items (things)
// data = getSampleThings();
// // fake a response of the backend with previously defined data
// return of(new HttpResponse({status: 200, body: {data: data}}));
// }
// // fake a response of the backend with previously defined data
// // return of(new HttpResponse({status: 200, body: {data: data}}));
// return next.handle(request);
// } else {
// // for all other requests, forward the requests to actually requested URL (backend)
// return next.handle(request);
// }
// }
// }
// }
// intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
// // let data: SCThing[] = [];
// // fake responses for search requests for easier (backendless) development process
// if (request.url.endsWith('/search') && request.method === 'POST') {
// return this.sampleFetcher.getSampleThings().pipe(map((sampleData: any) => {
// return new HttpResponse({status: 200, body: {data: sampleData}});
// // return new HttpResponse({status: 200, body: {data: [sampleData.instance]}});
// }));
// // return of(new HttpResponse({status: 200, body: {data: data}}));
// } else {
// // for all other requests, forward the requests to actually requested URL (backend)
// return next.handle(request);
// }
// }
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
// let data: SCThing[] = [];
// fake responses for search requests for easier (backendless) development process
if (request.url.endsWith('/search') && request.method === 'POST') {
if (typeof request.body.filter !== 'undefined' && typeof request.body.filter.arguments !== 'undefined') {
if (request.body.filter.arguments.field === 'uid') {
return this.sampleFetcher.getSampleThing(request.body.filter.arguments.value).pipe(map((sampleData: any) => {
return new HttpResponse({status: 200, body: {data: sampleData}});
}));
if (request.method === 'POST') {
if (request.url.endsWith('/') && request.method === 'POST') {
// respond with expected (faked) index response
return of(new HttpResponse({status: 200, body: sampleIndexResponse}));
// respond with a search response with sample data
} else if (request.url.endsWith('/search')) {
if (typeof request.body.filter !== 'undefined' && typeof request.body.filter.arguments !== 'undefined') {
if (request.body.filter.arguments.field === 'uid') {
return this.sampleFetcher.getSampleThing(request.body.filter.arguments.value)
.pipe(map((sampleData: any) => {
return new HttpResponse({status: 200, body: {data: sampleData}});
}));
}
}
return this.sampleFetcher.getSampleThings().pipe(map((sampleData: any) => {
return new HttpResponse({status: 200, body: {data: sampleData}});
}));
}
return this.sampleFetcher.getSampleThings().pipe(map((sampleData: any) => {
return new HttpResponse({status: 200, body: {data: sampleData}});
// return new HttpResponse({status: 200, body: {data: [sampleData.instance]}});
}));
// return of(new HttpResponse({status: 200, body: {data: data}}));
} else {
// for all other requests, forward the requests to actually requested URL (backend)
return next.handle(request);
}
return next.handle(request);
}
}