-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CHE-2059 Add ssh view for workspace in UD
- allow to view default ssh key for workspace - allow to remove this default key - allow to generate default key if not present Change-Id: Ifca18aed416f91846cf1adeb2a6e32389df196d3 Signed-off-by: Florent BENOIT <fbenoit@codenvy.com>
- Loading branch information
Showing
9 changed files
with
349 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
118 changes: 118 additions & 0 deletions
118
...rd/src/app/workspaces/workspace-details/workspace-ssh/workspace-details-ssh.controller.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
/* | ||
* Copyright (c) 2015-2016 Codenvy, S.A. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Codenvy, S.A. - initial API and implementation | ||
*/ | ||
import {CheWorkspace} from "../../../../components/api/che-workspace.factory"; | ||
import {CheNotification} from "../../../../components/notification/che-notification.factory"; | ||
import {CheSsh} from "../../../../components/api/che-ssh.factory"; | ||
'use strict'; | ||
|
||
/** | ||
* @ngdoc controller | ||
* @name workspace.details.controller:WorkspaceDetailsSSHCtrl | ||
* @description This class is handling the controller for details of workspace : section ssh | ||
* @author Florent Benoit | ||
*/ | ||
export class WorkspaceDetailsSshCtrl { | ||
|
||
/** | ||
* Workspace. | ||
*/ | ||
private cheWorkspace: CheWorkspace; | ||
|
||
/** | ||
* SSH. | ||
*/ | ||
private cheSsh: CheSsh; | ||
|
||
/** | ||
* Notification. | ||
*/ | ||
private cheNotification: CheNotification; | ||
|
||
/** | ||
* Material Design Dialog Service | ||
*/ | ||
private $mdDialog: ng.material.IDialogService; | ||
|
||
/** | ||
* Angular Log service. | ||
*/ | ||
private $log: ng.ILogService; | ||
|
||
/** | ||
* Angular Q service. | ||
*/ | ||
private $q: ng.IQService; | ||
|
||
private $timeout : ng.ITimeoutService; | ||
|
||
private privateKey : string; | ||
private publicKey : string; | ||
|
||
private namespace : string; | ||
private workspaceName : string; | ||
private workspaceKey : string; | ||
private workspace : any; | ||
private workspaceId: string; | ||
|
||
private sshKeyPair : any; | ||
|
||
|
||
/** | ||
* Default constructor that is using resource | ||
* @ngInject for Dependency injection | ||
*/ | ||
constructor($route : ng.route.IRouteService, cheSsh: CheSsh, cheWorkspace: CheWorkspace, cheNotification, $mdDialog : ng.material.IDialogService, $log : ng.ILogService, $q : ng.IQService, $timeout : ng.ITimeoutService) { | ||
this.cheWorkspace = cheWorkspace; | ||
this.cheSsh = cheSsh; | ||
this.cheNotification = cheNotification; | ||
this.$mdDialog = $mdDialog; | ||
this.$log = $log; | ||
this.$q = $q; | ||
|
||
this.namespace = $route.current.params.namespace; | ||
this.workspaceName = $route.current.params.workspaceName; | ||
this.workspaceKey = this.namespace + ":" + this.workspaceName; | ||
|
||
this.updateData(); | ||
|
||
} | ||
|
||
|
||
updateData() { | ||
this.workspace = this.cheWorkspace.getWorkspaceByName(this.namespace, this.workspaceName); | ||
this.workspaceId = this.workspace.id; | ||
|
||
// get ssh key | ||
this.cheSsh.fetchKey("workspace", this.workspaceId).finally(() => { | ||
this.sshKeyPair = this.cheSsh.getKey("workspace", this.workspaceId); | ||
|
||
}); | ||
} | ||
|
||
/** | ||
* Remove the default workspace keypair | ||
*/ | ||
removeDefaultKey() { | ||
this.cheSsh.removeKey("workspace", this.workspaceId).then( | ||
() => {this.$timeout( this.updateData(), 3000)} | ||
); | ||
} | ||
|
||
/** | ||
* Generate a new default workspace keypair | ||
*/ | ||
generateDefaultKey() { | ||
this.cheSsh.generateKey("workspace", this.workspaceId).then(() => {this.$timeout( this.updateData(), 3000)}); | ||
} | ||
|
||
|
||
|
||
} |
46 changes: 46 additions & 0 deletions
46
...ard/src/app/workspaces/workspace-details/workspace-ssh/workspace-details-ssh.directive.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright (c) 2015-2016 Codenvy, S.A. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Codenvy, S.A. - initial API and implementation | ||
*/ | ||
'use strict'; | ||
|
||
/** | ||
* @ngdoc directive | ||
* @name workspaces.details.directive:workspaceDetailsSSH | ||
* @restrict E | ||
* @element | ||
* | ||
* @description | ||
* <workspace-details-ssh></workspace-ssh-ssh>` for displaying workspace ssh entry. | ||
* | ||
* @usage | ||
* <workspace-details-ssh></workspace-details-ssh> | ||
* | ||
* @author Florent Benoit | ||
*/ | ||
export class WorkspaceDetailsSsh { | ||
|
||
|
||
restrict: string = 'E'; | ||
templateUrl: string = 'app/workspaces/workspace-details/workspace-ssh/workspace-details-ssh.html'; | ||
|
||
controller: string = 'WorkspaceDetailsSshCtrl'; | ||
controllerAs: string = 'workspaceDetailsSshCtrl'; | ||
bindToController: boolean = true; | ||
|
||
|
||
/** | ||
* Default constructor that is using resource | ||
* @ngInject for Dependency injection | ||
*/ | ||
constructor () { | ||
|
||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
dashboard/src/app/workspaces/workspace-details/workspace-ssh/workspace-details-ssh.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<!-- | ||
Copyright (c) 2015 Codenvy, S.A. | ||
All rights reserved. This program and the accompanying materials | ||
are made available under the terms of the Eclipse Public License v1.0 | ||
which accompanies this distribution, and is available at | ||
http://www.eclipse.org/legal/epl-v10.html | ||
Contributors: | ||
Codenvy, S.A. - initial API and implementation | ||
--> | ||
<md-content flex class="workspace-ssh-content"> | ||
|
||
<che-label-container che-label-name="Default key" che-label-description="Default SSH key is generated when workspace is created. It is possible to connect to any machine of the workspace by using this key."> | ||
|
||
<div layout="column" ng-if="workspaceDetailsSshCtrl.sshKeyPair"> | ||
<che-text-info che-label-name="Private key" che-text="workspaceDetailsSshCtrl.sshKeyPair.privateKey" | ||
che-copy-clipboard="true" | ||
class="workspace-ssh-content-private"></che-text-info> | ||
|
||
<che-text-info che-label-name="Public key" che-text="workspaceDetailsSshCtrl.sshKeyPair.publicKey" | ||
che-copy-clipboard="true" | ||
class=""></che-text-info> | ||
|
||
<che-button-danger che-button-title="Remove default SSH key" | ||
ng-click="workspaceDetailsSshCtrl.removeDefaultKey()"></che-button-danger> | ||
</div> | ||
|
||
|
||
<div layout="column" ng-if="!workspaceDetailsSshCtrl.sshKeyPair"> | ||
<che-button-primary che-button-title="Generate" | ||
ng-click="workspaceDetailsSshCtrl.generateDefaultKey()"></che-button-primary> | ||
<span class="workspace-ssh-content-notice">There is no default SSH key associated to this current workspace. A new key can be generated.</span> | ||
<span ng-if="workspaceDetailsSshCtrl.workspace.status === 'RUNNING'">Note: Workspace is currently in RUNNING state. It will require a restart of the workspace in order to be taken into account.</span> | ||
</div> | ||
</che-label-container> | ||
|
||
</md-content> | ||
|
26 changes: 26 additions & 0 deletions
26
dashboard/src/app/workspaces/workspace-details/workspace-ssh/workspace-details-ssh.styl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
.workspace-ssh-content | ||
margin 0 | ||
button | ||
margin 0 | ||
|
||
|
||
.workspace-ssh-content | ||
.che-text-info-mobile span, .che-text-info-desktop span | ||
border-width 0 | ||
padding-bottom 20px | ||
|
||
.che-text-info-mobile span label, .che-text-info-desktop span label | ||
max-width 500px | ||
word-wrap break-word | ||
font-family Fixed, monospace | ||
color $disabled-color | ||
|
||
.che-text-info .copy-clipboard | ||
margin-top 50px | ||
margin-left 20px | ||
|
||
.workspace-ssh-content-notice | ||
padding-top 20px | ||
|
||
.workspace-ssh-content .workspace-ssh-content-private .che-text-info-desktop span label | ||
white-space pre |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.