diff --git a/dashboard/src/assets/branding/product.json b/dashboard/src/assets/branding/product.json index c252fc3033c..ab480700ae9 100644 --- a/dashboard/src/assets/branding/product.json +++ b/dashboard/src/assets/branding/product.json @@ -6,6 +6,7 @@ "favicon": "favicon.ico", "loader": "loader.svg", "ideResources": "/_app/", + "websocketContext": "/wsmaster/websocket", "helpPath": "https://www.eclipse.org/che/", "helpTitle": "Community", "supportEmail": "wish@codenvy.com", diff --git a/dashboard/src/components/api/che-workspace.factory.ts b/dashboard/src/components/api/che-workspace.factory.ts index 49db46bca08..1eb48a3cb68 100644 --- a/dashboard/src/components/api/che-workspace.factory.ts +++ b/dashboard/src/components/api/che-workspace.factory.ts @@ -17,6 +17,7 @@ import {DockerImageEnvironmentManager} from './environment/docker-image-environm import {CheEnvironmentRegistry} from './environment/che-environment-registry.factory'; import {CheJsonRpcMasterApi} from './json-rpc/che-json-rpc-master-api'; import {CheJsonRpcApi} from './json-rpc/che-json-rpc-api.factory'; +import {CheBranding} from '../branding/che-branding.factory'; interface ICHELicenseResource extends ng.resource.IResourceClass { create: any; @@ -63,7 +64,7 @@ export class CheWorkspace { */ constructor($resource: ng.resource.IResourceService, $http: ng.IHttpService, $q: ng.IQService, cheJsonRpcApi: CheJsonRpcApi, $websocket: ng.websocket.IWebSocketProvider, $location: ng.ILocationService, proxySettings : string, userDashboardConfig: any, - lodash: any, cheEnvironmentRegistry: CheEnvironmentRegistry, $log: ng.ILogService) { + lodash: any, cheEnvironmentRegistry: CheEnvironmentRegistry, $log: ng.ILogService, cheBranding: CheBranding) { this.workspaceStatuses = ['RUNNING', 'STOPPED', 'PAUSED', 'STARTING', 'STOPPING', 'ERROR']; // keep resource @@ -92,8 +93,6 @@ export class CheWorkspace { // list of subscribed to websocket workspace Ids this.subscribedWorkspacesIds = []; this.statusDefers = {}; - this.jsonRpcApiLocation = this.formJsonRpcApiLocation($location, proxySettings, userDashboardConfig.developmentMode); - this.cheJsonRpcMasterApi = cheJsonRpcApi.getJsonRpcMasterApi(this.jsonRpcApiLocation); // remote call this.remoteWorkspaceAPI = >this.$resource('/api/workspace', {}, { @@ -117,6 +116,14 @@ export class CheWorkspace { cheEnvironmentRegistry.addEnvironmentManager('dockerimage', new DockerImageEnvironmentManager($log)); this.fetchWorkspaceSettings(); + + const CONTEXT_FETCHER_ID = 'websocketContextFetcher'; + const callback = () => { + this.jsonRpcApiLocation = this.formJsonRpcApiLocation($location, proxySettings, userDashboardConfig.developmentMode) + cheBranding.getWebsocketContext(); + this.cheJsonRpcMasterApi = cheJsonRpcApi.getJsonRpcMasterApi(this.jsonRpcApiLocation); + cheBranding.unregisterCallback(CONTEXT_FETCHER_ID); + }; + cheBranding.registerCallback(CONTEXT_FETCHER_ID, callback.bind(this)); } /** diff --git a/dashboard/src/components/api/json-rpc/che-json-rpc-master-api.ts b/dashboard/src/components/api/json-rpc/che-json-rpc-master-api.ts index 939f780a55f..002bd919ace 100644 --- a/dashboard/src/components/api/json-rpc/che-json-rpc-master-api.ts +++ b/dashboard/src/components/api/json-rpc/che-json-rpc-master-api.ts @@ -16,8 +16,6 @@ enum MasterChannels { ENVIRONMENT_OUTPUT, ENVIRONMENT_STATUS, WS_AGENT_OUTPUT, WORKSPACE_STATUS } -const websocketMasterApi: string = '/wsmaster/websocket'; - /** * Client API for workspace master interactions. * @@ -66,7 +64,7 @@ export class CheJsonRpcMasterApi { * @returns {IPromise>} */ connect(entrypoint: string): ng.IPromise { - return this.cheJsonRpcApi.connect(entrypoint + websocketMasterApi).then(() => { + return this.cheJsonRpcApi.connect(entrypoint).then(() => { return this.fetchClientId(); }); } diff --git a/dashboard/src/components/branding/che-branding.factory.ts b/dashboard/src/components/branding/che-branding.factory.ts index 9fca8465216..4531cb1dd52 100644 --- a/dashboard/src/components/branding/che-branding.factory.ts +++ b/dashboard/src/components/branding/che-branding.factory.ts @@ -19,6 +19,7 @@ interface IBranding { favicon?: string; loader?: string; ideResources?: string; + websocketContext?: string; helpPath?: string; helpTitle?: string; supportEmail?: string; @@ -35,12 +36,12 @@ interface IBranding { priorityStacks?: Array; defaultStack?: string; creationLink?: string; - } + }; footer?: { content?: string; links?: Array<{title: string, location: string}>; email?: {title: string, address: string, subject: string}; - } + }; } const ASSET_PREFIX = 'assets/branding/'; @@ -59,6 +60,7 @@ const DEFAULT_DOCS_WORKSPACE = '/docs/getting-started/intro/index.html'; const DEFAULT_WORKSPACE_PRIORITY_STACKS = ['Java', 'Java-MySQL', 'Blank']; const DEFAULT_WORKSPACE_DEFAULT_STACK = 'java-mysql'; const DEFAULT_WORKSPACE_CREATION_LINK = '#/create-workspace'; +const DEFAULT_WEBSOCKET_CONTEXT = '/api/websocket'; /** * This class is handling the branding data in Che. @@ -113,6 +115,7 @@ export class CheBranding { favicon: this.getProductFavicon(), loaderURL: this.getLoaderUrl(), ideResourcesPath: this.getIdeResourcesPath(), + websocketContext: this.getWebsocketContext(), helpPath: this.getProductHelpPath(), helpTitle: this.getProductHelpTitle(), footer: this.getFooter(), @@ -198,6 +201,15 @@ export class CheBranding { return this.brandingData.ideResources ? this.brandingData.ideResources : DEFAULT_IDE_RESOURCES_PATH; } + /** + * Gets ide resources path. + * @returns {string} + */ + getWebsocketContext(): string { + debugger; + return this.brandingData.websocketContext ? this.brandingData.websocketContext : DEFAULT_WEBSOCKET_CONTEXT; + } + /** * Gets product help path. * @returns {string} @@ -211,7 +223,7 @@ export class CheBranding { * @returns {string} */ getProductHelpTitle(): string { - return this.brandingData.helpTitle ? this.brandingData.helpTitle : null + return this.brandingData.helpTitle ? this.brandingData.helpTitle : null; } /**