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

Workspace loader #8838

Merged
merged 29 commits into from
Mar 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
c046c23
#8556 separate workspace loader
evidolob Feb 7, 2018
3bdda26
#8556 split webpack config into prod and dev
evidolob Feb 7, 2018
beab08d
#8556 add copyright headers
evidolob Feb 7, 2018
ae4413e
#8556 fix dev config
evidolob Feb 8, 2018
f8e4555
#8556 create war packaging, add loader war to the main assembly, use …
evidolob Feb 8, 2018
85bc171
#8556 use plain css instead less, remove unused webpack plugins
evidolob Feb 8, 2018
6fef1d9
#8556 add missing types, use 'requare' function from webpack instead …
evidolob Feb 8, 2018
623ad30
UI for workspace-loader (#8714)
Feb 12, 2018
315e528
Fix name of workspace-loader directory
Feb 12, 2018
70c640c
Fix name of workspace-loader directory
Feb 12, 2018
448bbe4
Cleanup
Feb 12, 2018
a259456
Workspace loader application usage in dashboard
ashumilova Feb 13, 2018
3fe4e8e
Fix license years
Feb 20, 2018
0d4565a
Remove .tsx
Feb 20, 2018
b639037
Remove unused dependency
Feb 20, 2018
a5faf98
Cleanup
Feb 20, 2018
2cf0f54
Cleanup
Feb 20, 2018
0b3d8f4
Fixup
Feb 20, 2018
f177c10
Remove package-lock.json
Feb 21, 2018
48dec0f
Build workspace loader in docker
Feb 21, 2018
478c8f5
Better cleaning
Feb 21, 2018
cd73ec6
Add check for unused locals, parameters, fallthrough cases
Feb 22, 2018
38b0262
Add unit tests
Feb 26, 2018
3c9456b
Fixup
Feb 27, 2018
d0b418d
Fixup
Feb 27, 2018
66694bb
Use jest instead karma+jasmine
Feb 28, 2018
40c76d8
Remove comments from tsconfig
Feb 28, 2018
5f92e85
Run tests when building
Mar 2, 2018
cddb76f
Original query params must be transfered to IDE
Mar 2, 2018
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ maven-eclipse.xml
*.iws
.idea/

.vscode/

# Compiled source #
###################
!*.com/
Expand Down
5 changes: 5 additions & 0 deletions assembly/assembly-main/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
<artifactId>assembly-ide-war</artifactId>
<type>war</type>
</dependency>
<dependency>
<groupId>org.eclipse.che</groupId>
<artifactId>assembly-workspace-loader-war</artifactId>
<type>war</type>
</dependency>
<dependency>
<groupId>org.eclipse.che</groupId>
<artifactId>assembly-wsagent-server</artifactId>
Expand Down
9 changes: 9 additions & 0 deletions assembly/assembly-main/src/assembly/assembly.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@
<include>org.eclipse.che.dashboard:che-dashboard-war</include>
</includes>
</dependencySet>
<dependencySet>
<useProjectArtifact>false</useProjectArtifact>
<unpack>false</unpack>
<outputDirectory>tomcat/webapps</outputDirectory>
<outputFileNameMapping>workspace-loader.war</outputFileNameMapping>
<includes>
<include>org.eclipse.che:assembly-workspace-loader-war</include>
</includes>
</dependencySet>
<dependencySet>
<useProjectArtifact>false</useProjectArtifact>
<unpack>false</unpack>
Expand Down
72 changes: 72 additions & 0 deletions assembly/assembly-workspace-loader-war/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright (c) 2018-2018 Red Hat, Inc.
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:
Red Hat, Inc. - initial API and implementation

-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>che-assembly-parent</artifactId>
<groupId>org.eclipse.che</groupId>
<version>6.2.0-SNAPSHOT</version>
</parent>
<artifactId>assembly-workspace-loader-war</artifactId>
<packaging>war</packaging>
<name>Che Workspace Loader :: War Packaging</name>
<description>Packages Che Workspace Loader application as a Java web app</description>
<inceptionYear>2018</inceptionYear>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.che.workspace.loader</groupId>
<artifactId>che-workspace-loader</artifactId>
<type>zip</type>
<scope>runtime</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<overlays>
<overlay>
<groupId>org.eclipse.che.workspace.loader</groupId>
<artifactId>che-workspace-loader</artifactId>
<type>zip</type>
</overlay>
</overlays>
<packagingExcludes>/webapp/</packagingExcludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>analyze</id>
<configuration>
<ignoredUnusedDeclaredDependencies>
<!-- dependency is required just to overlay it's content -->
<dep>org.eclipse.che.workspace.loader:che-workspace-loader</dep>
</ignoredUnusedDeclaredDependencies>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright (c) 2018-2018 Red Hat, Inc.
* 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:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che;

import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
* Defines a controller that is serving the index.html page of a workspace loader.
*
* @author Florent Benoit
*/
public class WSLoaderController extends HttpServlet {

/** Use the default dispatcher to serve the resource. */
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

RequestDispatcher dispatcher = request.getRequestDispatcher("/loader/index.html");
dispatcher.forward(request, response);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright (c) 2018-2018 Red Hat, Inc.
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:
Red Hat, Inc. - initial API and implementation

-->
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0"
metadata-complete="true">
<absolute-ordering></absolute-ordering>

<servlet>
<servlet-name>WSLoader</servlet-name>
<servlet-class>org.eclipse.che.WSLoaderController</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>WSLoader</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>/loader/*</url-pattern>
</servlet-mapping>

</web-app>
1 change: 1 addition & 0 deletions assembly/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<module>assembly-wsagent-server</module>
<module>assembly-ide-war</module>
<module>assembly-wsmaster-war</module>
<module>assembly-workspace-loader-war</module>
<module>assembly-main</module>
</modules>
</project>
4 changes: 3 additions & 1 deletion dashboard/gulp/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var serverOptions = {

var options = minimist(process.argv.slice(2), serverOptions);

var patterns = ['/api', '/ext', '/ws', '/datasource', '/java-ca', '/im', '/che', '/admin'];
var patterns = ['/api', '/ext', '/ws', '/datasource', '/java-ca', '/im', '/che', '/admin', '/workspace-loader'];

var proxies = [];

Expand All @@ -36,6 +36,8 @@ patterns.forEach(function(pattern) {
proxyOptions.route = '/admin';
} else if (pattern === '/ext') {
proxyOptions.route = '/ext';
} else if (pattern === '/workspace-loader') {
proxyOptions.route = '/workspace-loader';
} else {
proxyOptions.route = '/api';
}
Expand Down
4 changes: 2 additions & 2 deletions dashboard/src/app/ide/ide.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,11 @@ class IdeSvc {
let inDevMode = this.userDashboardConfig.developmentMode;
let randVal = Math.floor((Math.random() * 1000000) + 1);
let appendUrl = '?uid=' + randVal;

let workspace = this.cheWorkspace.getWorkspaceById(workspaceId);
this.openedWorkspace = workspace;

let ideUrlLink = workspace.links.ide;
let workspaceLoaderUrl = this.cheWorkspace.getWorkspaceLoaderUrl(workspace.namespace, workspace.config.name);
let ideUrlLink = workspaceLoaderUrl || workspace.links.ide;

if (this.ideAction != null) {
appendUrl = appendUrl + '&action=' + this.ideAction;
Expand Down
2 changes: 1 addition & 1 deletion dashboard/src/components/api/che-organizations.factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ export class CheOrganization implements che.api.ICheOrganization {
return this.cheResourcesDistribution.fetchAvailableOrganizationResources(organization.id).then(() => {
let resource = this.cheResourcesDistribution.getOrganizationAvailableResourceByType(organization.id, this.resourceLimits.RAM);
if (resource.amount === -1) {
return 'RAM is not limited'
return 'RAM is not limited';
}

return resource ? 'Available RAM: ' + (resource.amount / 1024) + 'GB' : null;
Expand Down
1 change: 1 addition & 0 deletions dashboard/src/components/api/test/che-http-backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export class CheHttpBackend {
this.$httpBackend.when('GET', '/api/').respond(200, {rootResources: []});

this.$httpBackend.when('GET', '/api/keycloak/settings').respond(404);
this.$httpBackend.when('GET', '/workspace-loader/').respond(404);

// add the remote call
let workspaceReturn = [];
Expand Down
20 changes: 20 additions & 0 deletions dashboard/src/components/api/workspace/che-workspace.factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export class CheWorkspace {
private statusDefers: Object;
private workspaceSettings: any;
private jsonRpcApiLocation: string;
private workspaceLoaderUrl: string;
/**
* Map with instance of Observable by workspaceId.
*/
Expand Down Expand Up @@ -164,6 +165,8 @@ export class CheWorkspace {
cheBranding.unregisterCallback(CONTEXT_FETCHER_ID);
};
cheBranding.registerCallback(CONTEXT_FETCHER_ID, callback.bind(this));

this.checkWorkspaceLoader(userDashboardConfig.developmentMode, proxySettings);
}

/**
Expand Down Expand Up @@ -648,6 +651,10 @@ export class CheWorkspace {
return '/ide/' + namespace + '/' + workspaceName;
}

getWorkspaceLoaderUrl(namespace: string, workspaceName: string): string {
return this.workspaceLoaderUrl ? this.workspaceLoaderUrl + namespace + '/' + workspaceName : null;
}

/**
* Creates deferred object which will be resolved
* when workspace change it's status to given
Expand Down Expand Up @@ -797,4 +804,17 @@ export class CheWorkspace {
}
return wsUrl;
}

private checkWorkspaceLoader(devmode: boolean, proxySettings: string): void {
let url = '/workspace-loader/';

let promise = this.$http.get(url);
promise.then((response: {data: any}) => {
this.workspaceLoaderUrl = devmode ? proxySettings + url : url;
}, (error: any) => {
if (error.status !== 304) {
this.workspaceLoaderUrl = null;
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@

script.onerror = script.onabort = function() {
console.error("Cannot load " + script.src);
Loader.startLoading();
};

document.head.appendChild(script);
Expand Down Expand Up @@ -135,10 +136,14 @@
* Show loader and load compilation-mapping.txt file to determine which IDE JavaScript file will be loaded
*/
this.startLoading = function() {
setTimeout(function() {
setTimeout(() => {
document.getElementById("ide-loader").style.opacity = 1;
}, 1);

setTimeout(() => {
window.parent.postMessage("show-ide", "*");
}, 250);

var msg = "Cannot load compilation mappings";

try {
Expand Down Expand Up @@ -362,9 +367,8 @@
};
};

setTimeout(function() {
setTimeout(() => {
Loader.loadKeycloakSettings();
window.parent.postMessage("show-ide", "*");
}, 1);

</script>
Expand Down
13 changes: 13 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<module>ide/che-ide-full</module>
<module>ide/che-ide-gwt-app</module>
<module>dashboard</module>
<module>workspace-loader</module>
<module>assembly</module>
<module>selenium</module>
</modules>
Expand Down Expand Up @@ -89,6 +90,12 @@
<artifactId>assembly-main</artifactId>
<version>${che.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.che</groupId>
<artifactId>assembly-workspace-loader-war</artifactId>
<version>${che.version}</version>
<type>war</type>
</dependency>
<dependency>
<groupId>org.eclipse.che</groupId>
<artifactId>assembly-wsagent-server</artifactId>
Expand Down Expand Up @@ -1876,6 +1883,12 @@
<artifactId>che-selenium-test</artifactId>
<version>${che.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.che.workspace.loader</groupId>
<artifactId>che-workspace-loader</artifactId>
<version>${che.version}</version>
<type>zip</type>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-commons-test</artifactId>
Expand Down
5 changes: 5 additions & 0 deletions workspace-loader/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Dockerfile
node_modules
target
dist
package-lock.json
3 changes: 3 additions & 0 deletions workspace-loader/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
dist/
package-lock.json
24 changes: 24 additions & 0 deletions workspace-loader/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright (c) 2018-2018 Red Hat, Inc
# 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

# This is a Dockerfile allowing to build workspace loader by using a docker container.
# Build step: $ docker build -t eclipse-che-workspace-loader .
# It builds an archive file that can be used by doing later
# $ docker run --rm eclipse-che-workspace-loader | tar -C target/ -zxf -
FROM node:6.11.2

COPY package.json /workspace-loader/
RUN cd /workspace-loader && npm install

COPY . /workspace-loader/

RUN cd /workspace-loader && \
npm run build && \
npm run test && \
cd target && \
tar zcf /tmp/workspace-loader.tar.gz dist

CMD zcat /tmp/workspace-loader.tar.gz
Loading