Skip to content
Snippets Groups Projects
Commit 3c7a71da authored by Alexander Lovett's avatar Alexander Lovett
Browse files

Merge branch 'develop' into 'master'

V2.0.12

See merge request alexander.lovett/looking-glass!3
parents f5d99bb7 15891e6d
Branches
No related tags found
No related merge requests found
Showing
with 595 additions and 465 deletions
......@@ -107,3 +107,5 @@ fabric.properties
.idea/**/markdown-navigator/
# End of https://www.gitignore.io/api/intellij
node_modules
dist
# 2.0.12
* [LGR-73](https://jira.software.geant.org/browse/LGR-73) - Use inventory provider for router info
# 2.0.11
* [LGR-70](https://jira.software.geant.org/browse/LGR-70) - UI Separated from JAR
* [LGR-69](https://jira.software.geant.org/browse/LGR-69) - Integrate Jenkins pipeline
......
{
"name": "looking-glass",
"version": "2.0.11",
"version": "2.0.12",
"scripts": {
"ng": "ng",
"start": "ng serve",
......
......@@ -5,18 +5,14 @@ import { HomeComponent } from './interfaces/components/home/home.component';
import { ErrorComponent } from './interfaces/components/error/error.component';
import { AdminComponent } from './interfaces/components/admin/admin.component';
import { NetworkRouterResolver } from './interfaces/resolvers/network-router-resolver';
import { UserResolver } from './interfaces/resolvers/user-resolver';
import { CommandResolver } from './interfaces/resolvers/command-resolver';
import { HomeResolverService } from './interfaces/resolvers/home-resolver.service';
const routes: Routes = [
{
path: '',
component: HomeComponent,
resolve: {
networkRouters: NetworkRouterResolver,
user: UserResolver,
commandGroups: CommandResolver
aggregated: HomeResolverService
}
},
{
......@@ -46,9 +42,7 @@ const routes: Routes = [
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule],
providers: [
NetworkRouterResolver,
UserResolver,
CommandResolver
HomeResolverService
]
})
export class AppRoutingModule { }
......@@ -3,5 +3,11 @@ import { NetworkRouter } from './network-router';
export interface NetworkRouterService {
getRouters(): Observable<NetworkRouter>;
getRouters(restriction: NetworkRouterService.AccessRestriction): Observable<NetworkRouter>;
}
export namespace NetworkRouterService {
export enum AccessRestriction {
All = "all",
Public = "public"
}
}
......@@ -13,26 +13,29 @@ export class HttpNetworkRouterService implements NetworkRouterService{
constructor(private httpClient: HttpClient) { }
getRouters(): Observable<NetworkRouter> {
return this.httpClient.get<HttpNetworkRouterService.Router[]>('rest/routers/all')
getRouters(restriction: NetworkRouterService.AccessRestriction): Observable<NetworkRouter> {
return this.httpClient.get<HttpNetworkRouterService.Router[]>(`rest/routers/${restriction}`)
.mergeMap(routers => from(routers))
.map(router => new NetworkRouter(
router.name,
router["equipment name"],
new Coordinates(
router.coordinates.longitude,
router.coordinates.latitude),
router.popCountryCode,
router.abbreviatedName
router.pop.longitude.toString(),
router.pop.latitude.toString()),
router.pop["country code"],
router.pop.abbreviation
));
}
}
namespace HttpNetworkRouterService {
export interface Router {
popCountryCode: string;
coordinates: Coordinates;
name: string;
popCity: string;
abbreviatedName: string;
["equipment name"]: string;
pop: Pop;
}
export interface Pop {
abbreviation: string;
["country code"]: string;
latitude: Number;
longitude: Number;
}
export interface Coordinates {
latitude: string;
......
......@@ -79,9 +79,9 @@ describe('HomeComponent', () => {
.compileComponents()
.then(() => {
route.data = of(data);
data.commandGroups = commands;
data.networkRouters = routers;
data.aggregated = {};
data.aggregated.commandGroups = commands;
data.aggregated.networkRouters = routers;
fixture = TestBed.createComponent(HomeComponent);
component = fixture.componentInstance;
......@@ -130,7 +130,7 @@ describe('HomeComponent', () => {
describe('logged in user', () => {
beforeEach(() => {
data.user = {
data.aggregated.user = {
"givenName": "Alexander"
}
})
......
......@@ -223,6 +223,8 @@ export class HomeComponent implements OnInit, AfterViewInit {
var context: HomeComponent = this;
this.route.data
.map(data => data.aggregated)
.do(data => console.log(data))
.do(data => context.user = data.user)
.do(data => populateCommands(context, data.commandGroups))
.subscribe(data => {
......
import { CommandGroupView } from "../views/command-group-view";
import { Resolve } from "@angular/router";
import { Observable } from "rxjs";
import { Injectable, Inject } from "@angular/core";
import { CommandViewService } from "../views/command-view.service";
@Injectable()
export class CommandResolver implements Resolve<CommandGroupView[]>{
constructor(@Inject('commandViewService') private commandStore: CommandViewService) { }
resolve(): Observable<CommandGroupView[]> {
return this.commandStore.getCommandViews()
.toArray();
}
}
import { Injectable, Inject } from '@angular/core';
import { Resolve, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
import { User } from 'src/app/domain/user';
import { NetworkRouterView } from '../views/network-router-view';
import { CommandGroupView } from '../views/command-group-view';
import { Observable, zip } from 'rxjs';
import { UserService } from 'src/app/domain/user.service';
import { NetworkRouterViewService } from '../views/network-router-view.service';
import { CommandViewService } from '../views/command-view.service';
import 'rxjs/add/operator/do';
@Injectable({
providedIn: 'root'
})
export class HomeResolverService implements Resolve<{user: User, networkRouters: NetworkRouterView[], commandGroups: CommandGroupView[]}>{
constructor(
@Inject('userService') private userService: UserService,
@Inject('networkRouterViewService') private routerStore: NetworkRouterViewService,
@Inject('commandViewService') private commandStore: CommandViewService) { }
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<{ user: User; networkRouters: NetworkRouterView[]; commandGroups: CommandGroupView[]; }> {
return this.userService.getUser()
.flatMap(user => zip(
this.routerStore.getRouterViews(user ? NetworkRouterViewService.AccessRestriction.All : NetworkRouterViewService.AccessRestriction.Public).toArray(),
this.commandStore.getCommandViews().toArray(),
function(networkRouters: NetworkRouterView[], commandGroups: CommandGroupView[]) {
return {
user: user,
networkRouters: networkRouters,
commandGroups: commandGroups
}
}
)
)
}
}
import { Resolve, ActivatedRouteSnapshot } from "@angular/router";
import { Injectable, Inject } from "@angular/core";
import { NetworkRouterViewService } from "../views/network-router-view.service";
import { NetworkRouterView } from "../views/network-router-view";
import { Observable } from "rxjs";
@Injectable()
export class NetworkRouterResolver implements Resolve<NetworkRouterView[]> {
constructor(@Inject('networkRouterViewService') private routerStore: NetworkRouterViewService) {}
resolve(): Observable<NetworkRouterView[]> {
return this.routerStore.getRouterViews()
.toArray();
}
}
import { Resolve, ActivatedRouteSnapshot, RouterStateSnapshot } from "@angular/router";
import { User } from "src/app/domain/user";
import { Observable } from "rxjs";
import { Injectable, Inject } from "@angular/core";
import { UserService } from "src/app/domain/user.service";
@Injectable()
export class UserResolver implements Resolve<User>{
constructor(@Inject('userService') private userService: UserService) { }
resolve(): Observable<User> {
return this.userService.getUser();
}
}
import { Injectable, Inject } from '@angular/core';
import { NetworkRouterViewService } from '../network-router-view.service';
import { Observable, from } from 'rxjs';
import { share } from 'rxjs/operators'
import { Inject, Injectable } from '@angular/core';
import { from, Observable } from 'rxjs';
import { NetworkRouterView } from '../network-router-view';
import { NetworkRouterViewService } from '../network-router-view.service';
@Injectable({
providedIn: 'root'
})
export class NetworkRouterViewCacheService implements NetworkRouterViewService{
private cache$: NetworkRouterView[] = [];
private cache$: Map<NetworkRouterViewService.AccessRestriction, NetworkRouterView[]> = new Map();
constructor(@Inject('masterNetworkRouterViewService') private networkRouterViewService: NetworkRouterViewService) { }
getRouterViews(): Observable<NetworkRouterView> {
if(this.cache$.length < 1) {
var cache = this.cache$;
getRouterViews(restriction: NetworkRouterViewService.AccessRestriction): Observable<NetworkRouterView> {
if(!this.cache$.get(restriction)) {
let routers: NetworkRouterView[] = [];
this.cache$.set(restriction, routers);
return this.networkRouterViewService
.getRouterViews()
.do(router => cache.push(router));
.getRouterViews(restriction)
.do(router => routers.push(router));
}
return from(this.cache$);
return from(this.cache$.get(restriction));
}
}
......@@ -3,6 +3,7 @@ import { NetworkRouterService } from 'src/app/domain/network-router.service';
import { Observable } from 'rxjs';
import { NetworkRouterView } from '../network-router-view';
import { NetworkRouterViewService } from '../network-router-view.service';
import { User } from 'src/app/domain/user';
@Injectable({
providedIn: 'root'
......@@ -11,9 +12,12 @@ export class InfrastructureBackedNetworkRouterViewService implements NetworkRout
constructor(@Inject('networkRouterService') private routerStore: NetworkRouterService) { }
public getRouterViews(): Observable<NetworkRouterView> {
public getRouterViews(restriction: NetworkRouterViewService.AccessRestriction): Observable<NetworkRouterView> {
return this.routerStore
.getRouters()
.getRouters(
restriction === NetworkRouterViewService.AccessRestriction.All ?
NetworkRouterService.AccessRestriction.All :
NetworkRouterService.AccessRestriction.Public)
.map(
router => new NetworkRouterView(
router.getId(),
......
import { Observable } from "rxjs";
import { NetworkRouterView } from "./network-router-view";
import { User } from "src/app/domain/user";
export interface NetworkRouterViewService {
getRouterViews(): Observable<NetworkRouterView>;
getRouterViews(restriction: NetworkRouterViewService.AccessRestriction): Observable<NetworkRouterView>;
}
export namespace NetworkRouterViewService {
export enum AccessRestriction {
All = "all",
Public = "public"
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment