diff --git a/src/app/kubernetes/model/helpers.ts b/src/app/kubernetes/model/helpers.ts index 994b3ff..0afe6e9 100644 --- a/src/app/kubernetes/model/helpers.ts +++ b/src/app/kubernetes/model/helpers.ts @@ -20,8 +20,9 @@ export var resourceKindToCollectionName = { }; export var resourceKindToOpenShiftConsoleCollectionName = { - "DeploymentConfig": "dc", "BuildConfig": "pipelines", + "DeploymentConfig": "dc", + "ReplicationController": "rc", }; /** diff --git a/src/app/kubernetes/model/kubernetesresource.model.ts b/src/app/kubernetes/model/kubernetesresource.model.ts index 32912cf..f0a07bd 100644 --- a/src/app/kubernetes/model/kubernetesresource.model.ts +++ b/src/app/kubernetes/model/kubernetesresource.model.ts @@ -52,10 +52,17 @@ export class KubernetesResource implements BaseEntity { this.labels = metadata.labels || new Map(); this.annotations = metadata.annotations || new Map(); this.version = this.labels["version"] || ""; - this.icon = this.annotations['fabric8.io/iconUrl'] || this.defaultIconUrl(); + + // for Replicas we need to also look in the spec.template.metadata.annotations + let spec = resource.spec || {}; + let template = spec.template || {}; + let templateMetadata = template.metadata || {}; + let templateAnnotations = templateMetadata.annotations || new Map(); + + this.icon = this.annotations['fabric8.io/iconUrl'] || templateAnnotations['fabric8.io/iconUrl'] || this.defaultIconUrl(); // TODO any other annotations we should look for? - this.description = this.annotations['description'] || ''; + this.description = this.annotations['description'] || templateAnnotations['description'] || ''; this.openShiftConsoleUrl = openShiftBrowseResourceUrl(this, currentOAuthConfig()); } diff --git a/src/app/kubernetes/service/devnamespace.scope.ts b/src/app/kubernetes/service/devnamespace.scope.ts index dc4a92e..3e5a2b2 100644 --- a/src/app/kubernetes/service/devnamespace.scope.ts +++ b/src/app/kubernetes/service/devnamespace.scope.ts @@ -16,6 +16,12 @@ export class DevNamespaceScope extends NamespaceScope { } protected getNamespace(params) { - return params['space'] || params['namespace'] || this.defaultNamespace(); + return params['space'] || this.getRouteParams('space') || + params['namespace'] || this.getRouteParams('namespace'); + } + + + currentNamespace(): any { + return this.findParamsFor(this.router.routerState.snapshot.root, "space") || super.currentNamespace(); } } diff --git a/src/app/kubernetes/service/namespace.scope.ts b/src/app/kubernetes/service/namespace.scope.ts index 9bdcee6..669f770 100644 --- a/src/app/kubernetes/service/namespace.scope.ts +++ b/src/app/kubernetes/service/namespace.scope.ts @@ -1,49 +1,58 @@ -import { Injectable } from '@angular/core'; -import { ActivatedRoute, Router, NavigationEnd } from "@angular/router"; -import { Observable } from 'rxjs'; -import { merge } from 'lodash'; +import {Injectable} from "@angular/core"; +import {ActivatedRoute, Router, NavigationEnd} from "@angular/router"; +import {Observable} from "rxjs"; @Injectable() export class NamespaceScope { public namespace: Observable; - constructor(private activatedRoute: ActivatedRoute, private router: Router) { + constructor(protected activatedRoute: ActivatedRoute, protected router: Router) { this.namespace = this.router.events .filter(event => event instanceof NavigationEnd) .map(() => this.activatedRoute) - .map(route => { - while (route.firstChild) route = route.firstChild; - return route; - }) + .map( + route => { + while (route.firstChild) route = route.firstChild; + return route; + }) .filter(route => route.outlet === 'primary') - .mergeMap(route => route.params).map(params => this.getNamespace(params)).distinctUntilChanged(); + .mergeMap(route => route.params).map(params => this.getNamespace(params)).filter(n => n).distinctUntilChanged(); } protected getNamespace(params) { - return this.getRouteParams()['namespace'] || this.defaultNamespace(); + return params['namespace'] || this.getRouteParams('namespace'); } - defaultNamespace(): string { - // TODO use some other mechanism to return the default? - return 'default'; - } - - private getRouteParams(): any { + protected getRouteParams(key): any { if ( this.router && this.router.routerState && this.router.routerState.snapshot && this.router.routerState.snapshot.root ) { - let firstChild = this.router.routerState.snapshot.root.firstChild; - let res = {}; - while (firstChild) { - res = merge(res, firstChild.params); - firstChild = firstChild.firstChild; + return this.findParamsFor(this.router.routerState.snapshot.root, key); + } + return null; + } + + protected findParamsFor(route, key): any { + let children = route.children; + for (let child of children) { + let params = child.params; + if (params) { + let answer = params[key]; + if (!answer) { + answer = this.findParamsFor(child, key); + } + if (answer) { + return answer; + } } - return res; } return null; } + currentNamespace() { + return this.findParamsFor(this.router.routerState.snapshot.root, "namespace"); + } } diff --git a/src/app/kubernetes/service/namespaced.resource.service.ts b/src/app/kubernetes/service/namespaced.resource.service.ts index ead36d3..40983dc 100644 --- a/src/app/kubernetes/service/namespaced.resource.service.ts +++ b/src/app/kubernetes/service/namespaced.resource.service.ts @@ -21,7 +21,7 @@ export abstract class NamespacedResourceService

{{e.environment.name}}

- + {{e.environment.name}}

diff --git a/src/app/kubernetes/ui/replicaset/view-wrapper/view-wrapper.replicaset.component.ts b/src/app/kubernetes/ui/replicaset/view-wrapper/view-wrapper.replicaset.component.ts index 6e94cf0..088994d 100644 --- a/src/app/kubernetes/ui/replicaset/view-wrapper/view-wrapper.replicaset.component.ts +++ b/src/app/kubernetes/ui/replicaset/view-wrapper/view-wrapper.replicaset.component.ts @@ -1,9 +1,9 @@ import {Component, OnInit} from "@angular/core"; import {Observable} from "rxjs/Observable"; import {ReplicaSet} from "../../../model/replicaset.model"; -import {ReplicaSetStore} from "../../../store/replicaset.store"; import {AbstractViewWrapperComponent} from "../../../support/abstract-viewwrapper-component"; import {ActivatedRoute} from "@angular/router"; +import {CompositeReplicaSetStore} from "../../../store/compositedreplicaset.store"; @Component({ selector: 'fabric8-replicaset-view-wrapper', @@ -13,7 +13,7 @@ import {ActivatedRoute} from "@angular/router"; export class ReplicaSetViewWrapperComponent extends AbstractViewWrapperComponent implements OnInit { replicaset: Observable; - constructor(private store: ReplicaSetStore, route: ActivatedRoute) { + constructor(private store: CompositeReplicaSetStore, route: ActivatedRoute) { super(route); }