diff --git a/src/app/workspaces/workspace-details/workspace-overview/workspace-details-overview.controller.ts b/src/app/workspaces/workspace-details/workspace-overview/workspace-details-overview.controller.ts index f571c2fe3..b14be07b8 100644 --- a/src/app/workspaces/workspace-details/workspace-overview/workspace-details-overview.controller.ts +++ b/src/app/workspaces/workspace-details/workspace-overview/workspace-details-overview.controller.ts @@ -18,7 +18,7 @@ import { WorkspaceDetailsService } from '../workspace-details.service'; import { CheKubernetesNamespace } from '../../../../components/api/che-kubernetes-namespace.factory'; import { CheDashboardConfigurationService } from '../../../../components/branding/che-dashboard-configuration.service'; import { TogglableFeature } from '../../../../components/branding/branding.constant'; -import { STORAGE_TYPE } from '../../../../components/api/storage-type'; +import { StorageType } from '../../../../components/api/storage-type'; const STARTING = WorkspaceStatus[WorkspaceStatus.STARTING]; const RUNNING = WorkspaceStatus[WorkspaceStatus.RUNNING]; @@ -55,6 +55,8 @@ export class WorkspaceDetailsOverviewController { */ infrastructureNamespace: string; enabledKubernetesNamespaceSelector: boolean = false; + storageTypeOptions: Array<{ name: string }>; + storageType: string; private $location: ng.ILocationService; private $mdDialog: ng.material.IDialogService; @@ -80,8 +82,6 @@ export class WorkspaceDetailsOverviewController { private isLoading: boolean; private isEphemeralMode: boolean; private attributes: che.IWorkspaceConfigAttributes; - private storageType: { label: any; id: number; description:string}; - private storageDescription: string; private attributesCopy: che.IWorkspaceConfigAttributes; private workspaceDeletePromise: ng.IPromise; @@ -138,6 +138,8 @@ export class WorkspaceDetailsOverviewController { this.enabledKubernetesNamespaceSelector = this.cheDashboardConfigurationService.enabledFeature(TogglableFeature.KUBERNETES_NAMESPACE_SELECTOR); + this.storageTypeOptions = StorageType.getAllowedTypes().map(type => ({ name: type })); + this.init(); } @@ -145,29 +147,20 @@ export class WorkspaceDetailsOverviewController { this.attributes = this.cheWorkspace.getWorkspaceDataManager().getAttributes(this.workspaceDetails); this.name = this.cheWorkspace.getWorkspaceDataManager().getName(this.workspaceDetails); this.isEphemeralMode = this.attributes && this.attributes.persistVolumes ? !JSON.parse(this.attributes.persistVolumes) : false; - this.storageType = this.getStorageType(); - this.storageDescription = this.storageType.description; this.attributesCopy = angular.copy(this.cheWorkspace.getWorkspaceDataManager().getAttributes(this.workspaceDetails)); - this.updateInfrastructureNamespace(); - } - - getStorageType() { - if (!this.attributes) { - return STORAGE_TYPE.EPHEMERAL; - } - if (this.attributes.persistVolumes as string === 'true') { - return STORAGE_TYPE.PERSISTENT; - } - if (this.attributes.persistVolumes as string === 'false') - if (this.attributes.asyncPersist as string === 'true') { - return STORAGE_TYPE.ASYNCHRONOUS; - } - else { - return STORAGE_TYPE.EPHEMERAL; + if (!this.attributes || this.attributes.persistVolumes === 'true') { + this.storageType = StorageType.PERSISTENT; + } else { + if (this.attributes.asyncPersist === 'true') { + this.storageType = StorageType.ASYNCHRONOUS; + } else { + this.storageType = StorageType.EPHEMERAL; } - } + } + this.updateInfrastructureNamespace(); + } /** * Returns namespace by its ID @@ -383,47 +376,66 @@ export class WorkspaceDetailsOverviewController { this.onChange(); } - getSupportedStorageTypes() { - return [STORAGE_TYPE.PERSISTENT, STORAGE_TYPE.EPHEMERAL, STORAGE_TYPE.ASYNCHRONOUS] + showStorageTypeDescription(): ng.IPromise { + const title = 'Storage Types'; + const content = StorageType.getAllDescriptions(); + return this.$mdDialog.show({ + clickOutsideToClose: true, + controller: ['$scope', ($scope) => { + $scope.hide = () => { + this.$mdDialog.hide(); + }; + $scope.cancel = () => { + this.$mdDialog.cancel(); + }; + }], + template: ` + +
+
${content}
+
+ + +
+
+
+ `, + }); } - updateStorageType() { - switch (this.storageType.id) { - case STORAGE_TYPE.PERSISTENT.id: { - this.storageDescription = STORAGE_TYPE.PERSISTENT.description; - if (!this.attributesCopy) { - this.attributes = undefined; + onStorageTypeChanged(type: StorageType): void { + switch (type) { + case StorageType.PERSISTENT: { + if (!this.attributesCopy) { + delete this.attributes; + } else { + if (this.attributesCopy.persistVolumes === 'true') { + this.attributes.persistVolumes = 'true'; + delete this.attributes.asyncPersist; } else { - if ((this.attributesCopy.persistVolumes as string) === 'true') { - (this.attributes.persistVolumes as string) = 'true'; - delete this.attributes.asyncPersist; - } else { - delete this.attributes.persistVolumes; - delete this.attributes.asyncPersist; - if (Object.keys(this.attributes).length === 0) { - this.attributes = undefined; - } + delete this.attributes.persistVolumes; + delete this.attributes.asyncPersist; + if (Object.keys(this.attributes).length === 0) { + delete this.attributes; } } - break; - } - case STORAGE_TYPE.EPHEMERAL.id: { - this.storageDescription = STORAGE_TYPE.EPHEMERAL.description; - this.attributes = this.attributes || {}; - this.attributes.persistVolumes = 'false'; - delete this.attributes.asyncPersist; - break; - } - case STORAGE_TYPE.ASYNCHRONOUS.id: { - this.storageDescription = STORAGE_TYPE.ASYNCHRONOUS.description; - this.attributes = this.attributes || {}; - this.attributes.persistVolumes = 'false'; - this.attributes.asyncPersist = 'true'; - break; - } - default: { - break; } + break; + } + case StorageType.EPHEMERAL: { + this.attributes = this.attributes || {}; + this.attributes.persistVolumes = 'false'; + delete this.attributes.asyncPersist; + break; + } + case StorageType.ASYNCHRONOUS: { + this.attributes = this.attributes || {}; + this.attributes.persistVolumes = 'false'; + this.attributes.asyncPersist = 'true'; + break; + } } this.cheWorkspace.getWorkspaceDataManager().setAttributes(this.workspaceDetails, this.attributes); this.onChange(); diff --git a/src/app/workspaces/workspace-details/workspace-overview/workspace-details-overview.html b/src/app/workspaces/workspace-details/workspace-overview/workspace-details-overview.html index a26b08314..2a9e4da81 100644 --- a/src/app/workspaces/workspace-details/workspace-overview/workspace-details-overview.html +++ b/src/app/workspaces/workspace-details/workspace-overview/workspace-details-overview.html @@ -58,15 +58,20 @@ - +
-
- +
+ + +
+ -
{{workspaceDetailsOverviewController.storageDescription}}
diff --git a/src/app/workspaces/workspace-details/workspace-overview/workspace-details-overview.styl b/src/app/workspaces/workspace-details/workspace-overview/workspace-details-overview.styl index c35bc76ed..f33aa527e 100644 --- a/src/app/workspaces/workspace-details/workspace-overview/workspace-details-overview.styl +++ b/src/app/workspaces/workspace-details/workspace-overview/workspace-details-overview.styl @@ -92,4 +92,12 @@ .che-label-container-content .workspace-overview-action-buttons margin-top 20px + .che-select-container + margin-top 10px + .md-select-value + span:first-child + margin-bottom 5px + + .learn-more-button + padding-top 10px diff --git a/src/components/api/storage-type.ts b/src/components/api/storage-type.ts index 42eff96dc..a46a675c9 100644 --- a/src/components/api/storage-type.ts +++ b/src/components/api/storage-type.ts @@ -11,12 +11,6 @@ */ 'use strict'; -export const STORAGE_TYPE = { - 'PERSISTENT': { id: 1, label: 'Persistent', description: 'Persistent Storage slow I/O but persistent.' }, - 'EPHEMERAL': { id: 2, label: 'Ephemeral', description: 'Ephemeral Storage allows for faster I/O but may have limited storage and is not persistent.' }, - 'ASYNCHRONOUS': { id: 3, label: 'Asynchronous', description: 'Experimental feature: Asynchronous storage is combination of Ephemeral and Persistent storage. Allows for faster I/O and keep your changes, will backup on stop and restore on start workspace.' } -} - export enum StorageType { 'ASYNCHRONOUS' = 'Asynchronous', 'EPHEMERAL' = 'Ephemeral', @@ -24,6 +18,11 @@ export enum StorageType { } export namespace StorageType { + // temporary func that returns allowed storage types + // should be removed in favour of an API method as soon as it is implemented + export function getAllowedTypes(): StorageType[] { + return [StorageType.EPHEMERAL, StorageType.PERSISTENT]; + } export function getTypeDescription(type: StorageType): string { switch (type) { case StorageType.ASYNCHRONOUS: diff --git a/src/components/widget/select/che-select.directive.ts b/src/components/widget/select/che-select.directive.ts index 4fd534570..436a5603b 100644 --- a/src/components/widget/select/che-select.directive.ts +++ b/src/components/widget/select/che-select.directive.ts @@ -40,34 +40,21 @@ export class CheSelect { placeHolder: '@chePlaceHolder', optionValues: '=cheOptionValues', myName: '=cheName', - myForm: '=cheForm' + myForm: '=cheForm', + onSelect: '&?cheOnSelect' }; } template($element: ng.IAugmentedJQuery, $attrs: ICheSelectAttributes): string { return `
- - - - - {{optionValue.name}} - - - -
-
- -
diff --git a/src/components/widget/select/che-select.styl b/src/components/widget/select/che-select.styl index 81e94e32f..e05307784 100644 --- a/src/components/widget/select/che-select.styl +++ b/src/components/widget/select/che-select.styl @@ -1,9 +1,11 @@ -.che-select .che-select-container - outline none +.che-select + min-width 200px + + .che-select-container + outline none .che-select .che-select-mobile, .che-select .che-select-desktop - width 100% .che-select .che-select-desktop .che-select-container position relative