Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
22 changes: 22 additions & 0 deletions src/app/backend/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ type TypeMeta struct {

// Scalable represents whether or not an object is scalable.
Scalable bool `json:"scalable,omitempty"`

// Restartable represents wheter or not an object is restartable.
Restartable bool `json:"restartable,omitempty"`
}

// ListMeta describes list of objects, i.e. holds information about pagination options set for the list.
Expand All @@ -104,6 +107,7 @@ func NewTypeMeta(kind ResourceKind) TypeMeta {
return TypeMeta{
Kind: kind,
Scalable: kind.Scalable(),
Restartable: kind.Restartable(),
}
}

Expand Down Expand Up @@ -164,6 +168,24 @@ func (k ResourceKind) Scalable() bool {
return false
}

// Restartable method return whether ResourceKind is restartable.
func (k ResourceKind) Restartable() bool {
restartable := []ResourceKind{
ResourceKindDeployment,
ResourceKindReplicaSet,
ResourceKindReplicationController,
ResourceKindStatefulSet,
}

for _, kind := range restartable {
if k == kind {
return true
}
}

return false
}

// ClientType represents type of client that is used to perform generic operations on resources.
// Different resources belong to different client, i.e. Deployments belongs to extension client
// and StatefulSets to apps client.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,18 @@ export class MenuComponent implements ActionColumn {
return this.typeMeta.scalable;
}

isRestartEnabled(): boolean {
return this.typeMeta.restartable;
}

onScale(): void {
this.verber_.showScaleDialog(this.typeMeta.kind, this.typeMeta, this.objectMeta);
}

onRestart(): void {
this.verber_.showRestartDialog(this.typeMeta.kind, this.typeMeta, this.objectMeta);
}

isPinEnabled(): boolean {
return pinnableResources.includes(this.typeMeta.kind);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@
id="edit"
(click)="onEdit()"
i18n>Edit</button>
<button mat-menu-item
id="restart"
*ngIf="isRestartEnabled()"
(click)="onRestart()"
i18n>Restart</button>
<button mat-menu-item
id="delete"
(click)="onDelete()"
Expand Down
19 changes: 19 additions & 0 deletions src/app/frontend/common/services/global/verber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,25 @@ export class VerberService {
.subscribe(_ => this.onScale.emit(true), this.handleErrorResponse_.bind(this));
}

showRestartDialog(displayName: string, typeMeta: TypeMeta, objectMeta: ObjectMeta): void {
const dialogConfig = this.getDialogConfig_(displayName, typeMeta, objectMeta);
this.dialog_
//.open(RestartResourceDialog, dialogConfig)
.open(ScaleResourceDialog, dialogConfig)
.afterClosed()
.pipe(filter(result => Number.isInteger(result)))
.pipe(
switchMap(result => {
const url = `api/v1/scale/${typeMeta.kind}${objectMeta.namespace ? `/${objectMeta.namespace}` : ''}/${
objectMeta.name
}/`;

return this.http_.put(url, result, {params: {scaleBy: result}});
})
)
.subscribe(_ => this.onScale.emit(true), this.handleErrorResponse_.bind(this));
}

showTriggerDialog(displayName: string, typeMeta: TypeMeta, objectMeta: ObjectMeta): void {
const dialogConfig = this.getDialogConfig_(displayName, typeMeta, objectMeta);
this.dialog_
Expand Down
1 change: 1 addition & 0 deletions src/app/frontend/typings/root.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export enum SupportedResources {
export interface TypeMeta {
kind: string;
scalable?: boolean;
restartable?: boolean;
}

export interface ListMeta {
Expand Down