Skip to content

Commit

Permalink
Allow to proper set webscoket context
Browse files Browse the repository at this point in the history
Signed-off-by: Anna Shumilova <ashumilo@redhat.com>
  • Loading branch information
ashumilova committed Aug 18, 2017
1 parent 96acc83 commit 05668ea
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
1 change: 1 addition & 0 deletions dashboard/src/assets/branding/product.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
13 changes: 10 additions & 3 deletions dashboard/src/components/api/che-workspace.factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> extends ng.resource.IResourceClass<T> {
create: any;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 = <ICHELicenseResource<any>>this.$resource('/api/workspace', {}, {
Expand All @@ -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));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -66,7 +64,7 @@ export class CheJsonRpcMasterApi {
* @returns {IPromise<IHttpPromiseCallbackArg<any>>}
*/
connect(entrypoint: string): ng.IPromise<any> {
return this.cheJsonRpcApi.connect(entrypoint + websocketMasterApi).then(() => {
return this.cheJsonRpcApi.connect(entrypoint).then(() => {
return this.fetchClientId();
});
}
Expand Down
18 changes: 15 additions & 3 deletions dashboard/src/components/branding/che-branding.factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ interface IBranding {
favicon?: string;
loader?: string;
ideResources?: string;
websocketContext?: string;
helpPath?: string;
helpTitle?: string;
supportEmail?: string;
Expand All @@ -35,12 +36,12 @@ interface IBranding {
priorityStacks?: Array<string>;
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/';
Expand All @@ -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.
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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}
Expand All @@ -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;
}

/**
Expand Down

0 comments on commit 05668ea

Please sign in to comment.