Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
frontend: kubernetes resource remove redirect
  • Loading branch information
wilhelmguo committed Mar 7, 2019
commit c03712d3bd25c0c983cf97ee79bebe4a68251982
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export class KubernetesNamespacedResource implements OnInit, OnDestroy {
resourceType: string;
kubeResource: KubeResourcesName;

namespaces: string[];
namespace: string;
namespaces = Array<string>();
namespace = '';

constructor(public kubernetesClient: KubernetesClient,
public route: ActivatedRoute,
Expand All @@ -40,18 +40,13 @@ export class KubernetesNamespacedResource implements OnInit, OnDestroy {

ngOnInit() {
this.initShow();
const cluster = this.route.snapshot.params['cluster'];
this.clusterService.getNames().subscribe(
response => {
const data = response.data;
this.clusters = data.map(item => item.name);
if (data && data.length > 0 && !cluster) {
this.router.navigateByUrl(`admin/kubernetes/${this.resourceType}/${data[0].name}`);
return;
}
if (cluster) {
this.jumpToHref(cluster);
}
this.cluster = data[0].name;
this.jumpToHref(this.cluster);

},
error => this.messageHandlerService.handleError(error)
);
Expand Down Expand Up @@ -191,17 +186,15 @@ export class KubernetesNamespacedResource implements OnInit, OnDestroy {
}
}

jumpToHref(cluster) {
jumpToHref(cluster: string) {
this.cluster = cluster;
this.router.navigateByUrl(`admin/kubernetes/${this.resourceType}/${cluster}`);
this.kubernetesClient.getNames(cluster, KubeResourceNamespace).subscribe(
this.kubernetesClient.getNames(this.cluster, KubeResourceNamespace).subscribe(
resp => {
this.namespace = '';
this.namespaces = Array<string>();
const namespaces: Array<any> = resp.data;
namespaces.map(ns => {
resp.data.map(ns => {
this.namespaces.push(ns.name);
});
this.namespace = this.namespaces && this.namespaces.length > 0 ? this.namespaces[0] : 'default';
this.retrieveResource();
},
error => this.messageHandlerService.handleError(error)
Expand Down
5 changes: 4 additions & 1 deletion src/frontend/src/assets/i18n/zh-Hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -614,8 +614,10 @@
"ENTER_CONTAINER": "进入容器",
"LOG": "查看日志"
},
"NAMESPACE_ALL": "全部",
"LABEL": {
"NAMESPACE": "命名空间:"
"NAMESPACE": "命名空间:",
"CLUSTER": "当前集群:"
},
"TITLE": {
"DETAIL": "详情"
Expand All @@ -629,6 +631,7 @@
"CREATE": "创建 Pod",
"LIST": {
"NAME": "名称",
"NAMESPACE": "命名空间",
"LABEL": "标签",
"IMAGES": "镜像",
"STATUS": "状态",
Expand Down