diff --git a/src/app/frontend/common/components/actionbar/detailactions/component.ts b/src/app/frontend/common/components/actionbar/detailactions/component.ts index 7c642c088c5bea709194221ab7ab09eb81ef9246..2cb2130cbb220c1431bc7927ece1d309dfb0a480 100644 --- a/src/app/frontend/common/components/actionbar/detailactions/component.ts +++ b/src/app/frontend/common/components/actionbar/detailactions/component.ts @@ -14,6 +14,7 @@ import {Component, Input} from '@angular/core'; import {ObjectMeta, TypeMeta} from '@api/backendapi'; +import {ResourceMeta} from '../../../services/global/actionbar'; @Component({ selector: 'kd-actionbar-detail-actions', diff --git a/src/app/frontend/common/components/list/column/menu/component.ts b/src/app/frontend/common/components/list/column/menu/component.ts index 59fb0865ab49b88ff52c33b0d10e085172b20046..6922898e8cff61b022ec720755b3505bee8a8f0a 100644 --- a/src/app/frontend/common/components/list/column/menu/component.ts +++ b/src/app/frontend/common/components/list/column/menu/component.ts @@ -17,7 +17,21 @@ import {ObjectMeta, TypeMeta} from '@api/backendapi'; import {ActionColumn} from '@api/frontendapi'; import {StateService} from '@uirouter/core'; import {Subscription} from 'rxjs/Subscription'; + +import {logsState} from '../../../../../logs/state'; +import {LogsStateParams} from '../../../../params/params'; +import {KdStateService} from '../../../../services/global/state'; import {VerberService} from '../../../../services/global/verber'; +import {Resource} from '../../../../services/resource/endpoint'; + +const loggableResources: string[] = [ + Resource.daemonSet, Resource.job, Resource.pod, Resource.replicaSet, + Resource.replicationController, Resource.statefulSet +]; + +const scalableResources: string[] = [ + Resource.deployment, Resource.replicaSet, Resource.replicationController, Resource.statefulSet +]; @Component({ selector: 'kd-resource-context-menu', @@ -27,10 +41,13 @@ export class MenuComponent implements ActionColumn, OnDestroy { @Input() objectMeta: ObjectMeta; @Input() typeMeta: TypeMeta; + private onScaleSubscription_: Subscription; private onEditSubscription_: Subscription; private onDeleteSubscription_: Subscription; - constructor(private readonly verber_: VerberService, private readonly state_: StateService) {} + constructor( + private readonly verber_: VerberService, private readonly state_: StateService, + private readonly kdState_: KdStateService) {} setObjectMeta(objectMeta: ObjectMeta): void { this.objectMeta = objectMeta; @@ -41,10 +58,32 @@ export class MenuComponent implements ActionColumn, OnDestroy { } ngOnDestroy(): void { + if (this.onScaleSubscription_) this.onScaleSubscription_.unsubscribe(); if (this.onEditSubscription_) this.onEditSubscription_.unsubscribe(); if (this.onDeleteSubscription_) this.onDeleteSubscription_.unsubscribe(); } + showOption(optionName: string): boolean { + return (optionName === 'logs' && loggableResources.includes(this.typeMeta.kind)) || + (optionName === 'scale' && scalableResources.includes(this.typeMeta.kind)) || + (optionName === 'exec' && this.typeMeta.kind === Resource.pod); + } + + getLogsHref(): string { + return this.state_.href( + logsState.name, + new LogsStateParams(this.objectMeta.namespace, this.objectMeta.name, this.typeMeta.kind)); + } + + getExecHref(): string { + return this.kdState_.href('shell', this.objectMeta.name, this.objectMeta.namespace); + } + + onScale() { + this.onScaleSubscription_ = this.verber_.onScale.subscribe(this.onSuccess_.bind(this)); + this.verber_.showScaleDialog(this.typeMeta.kind, this.typeMeta, this.objectMeta); + } + onEdit(): void { this.onEditSubscription_ = this.verber_.onEdit.subscribe(this.onSuccess_.bind(this)); this.verber_.showEditDialog(this.typeMeta.kind, this.typeMeta, this.objectMeta); diff --git a/src/app/frontend/common/components/list/column/menu/template.html b/src/app/frontend/common/components/list/column/menu/template.html index d6fbb7e7d22ce89d253df029dd7c8c37e025f6d9..13e9b2bbe80511ed38b68beea4d2c87efff89f83 100644 --- a/src/app/frontend/common/components/list/column/menu/template.html +++ b/src/app/frontend/common/components/list/column/menu/template.html @@ -15,6 +15,15 @@ limitations under the License. --> + Logs + Exec +