Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CODENVY-931: add snapshot creating state to workspace status #2747

Merged
merged 1 commit into from
Oct 11, 2016
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export class WorkspaceStatusIndicator {
'<div class="spinner"><div class="rect1"></div><div class="rect2"></div><div class="rect3"></div></div>' +
'</span>' +
'<span ng-switch-when="ERROR" class="fa fa-circle workspace-status-error"></span>' +
'<span ng-switch-when="SNAPSHOT_CREATING" class="fa fa-circle workspace-status-snapshot"></span>' +
'<span ng-switch-default class="fa ' + (emptyCircleOnStopped ? 'fa-circle-o' : 'fa-circle') + ' workspace-status-default"></span>' +
'</span>';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
.workspace-status-running
color #46af00 !important

.workspace-status-snapshot
color $warning-color !important

.workspace-status-spinner
display inline-block
line-height inherit
Expand Down
12 changes: 11 additions & 1 deletion dashboard/src/components/api/che-workspace.factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export class CheWorkspace {
* @ngInject for Dependency injection
*/
constructor ($resource, $q, cheWebsocket, lodash, cheEnvironmentRegistry, $log) {
this.workspaceStatuses = ['RUNNING', 'STOPPED', 'PAUSED', 'STARTING', 'STOPPING', 'ERROR', 'SNAPSHOT_CREATING'];

// keep resource
this.$resource = $resource;
this.$q = $q;
Expand Down Expand Up @@ -475,7 +477,15 @@ export class CheWorkspace {
this.websocketBusByWorkspaceId.set(workspaceId, bus);

bus.subscribe('workspace:' + workspaceId, (message) => {
this.getWorkspaceById(workspaceId).status = message.eventType;

//Filter workspace events, which really indicate the status change:
if (this.workspaceStatuses.indexOf(message.eventType) >= 0) {
this.getWorkspaceById(workspaceId).status = message.eventType;
} else if (message.eventType === 'SNAPSHOT_CREATED') {
//Snapshot can be created for RUNNING workspace only. As far as snapshot creation is only the events, not the state,
//we introduced SNAPSHOT_CREATING status to be handled by UI, though it is fake one, and end of it is indicated by SNAPSHOT_CREATED.
this.getWorkspaceById(workspaceId).status = 'RUNNING';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

status is RUNNING ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, workspace snapshot can be created for running workspace only, so it's really running. But we artificially introduce - SNAPSHOT_CREATING - to display it as status, though real status is still RUNNING. And we get back to it on SNAPSHOT_CREATED event

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok I see thx

}

if (!this.statusDefers[workspaceId] || !this.statusDefers[workspaceId][message.eventType]) {
return;
Expand Down