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

Serve web console from same port as API by default and allow configuring console's context root #1458

Merged
merged 2 commits into from
Mar 26, 2015
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
18 changes: 18 additions & 0 deletions assets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,24 @@ Architecture

The OpenShift v3 management console is based on AngularJS and [Hawt.io](https://github.com/hawtio/hawtio-core)

#### Navigation

The v3 console supports a custom context root. When running as part of the `openshift start` command the console's context root is injected into the `<base>` tag of the index.html file. In order to support custom context roots, all console URLs must be relative, so they should not contain a leading "/" character.

For example if you want to specify a URL directly in an HTML template to go to the project overview it would look like

```
<a href="project/foo/overview">
```

and would actually resolve to be `/contextroot/project/foo/overview` by the browser. Similarly, if you want to use JavaScript to change the current page location, you should use the $location service from angular like

```
$location.url("project/foo/overview")
```

Finally, if you want to reference the root of the web console use the path `./`

#### Custom directives and filters

The v3 console relies heavily on custom directives and filters, some of which are intended to be utilties and used throughout the console source. The list below is NOT a complete list of all of our directives and filters.
Expand Down
6 changes: 3 additions & 3 deletions assets/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/">
<a class="navbar-brand" href="./">
<img src="images/logo-origin-thin.svg" alt="OpenShift Origin">
</a>
</div>
Expand All @@ -56,7 +56,7 @@
<li class="divider"></li>
-->
<li>
<a href="/logout">Log out</a>
<a href="logout">Log out</a>
</li>
</ul>
</li>
Expand Down Expand Up @@ -99,7 +99,7 @@
<script src="bower_components/patternfly/components/bootstrap-select/bootstrap-select.js"></script>
<script src="bower_components/js-logger/src/logger.js"></script>
<script src="bower_components/hawtio-core/hawtio-core.js"></script>
<script src="bower_components/lodash/dist/lodash.compat.js"></script>
<script src="bower_components/lodash/lodash.js"></script>
<script src="bower_components/hawtio-core-navigation/dist/hawtio-core-navigation.js"></script>
<script src="bower_components/hawtio-extension-service/dist/hawtio-extension-service.js"></script>
<script src="bower_components/sifter/sifter.js"></script>
Expand Down
4 changes: 2 additions & 2 deletions assets/app/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ angular
if (injector) {
var routeParams = injector.get("$routeParams");
if (routeParams.project) {
return "/project/" + encodeURIComponent(routeParams.project) + "/" + path;
return "project/" + encodeURIComponent(routeParams.project) + "/" + path;
}
}
return "/project/:project/" + path;
return "project/:project/" + path;
}
};

Expand Down
4 changes: 2 additions & 2 deletions assets/app/scripts/controllers/newfromtemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ angular.module('openshiftConsole')
.controller('NewFromTemplateController', function ($scope, $http, $routeParams, DataService, $q, $location, TaskList, $parse) {

function errorPage(message) {
var redirect = URI('/error').query({
var redirect = URI('error').query({
"error_description": message
}).toString();
$location.url(redirect);
Expand Down Expand Up @@ -133,7 +133,7 @@ angular.module('openshiftConsole')
);
return d.promise;
});
$location.path("/project/" + $scope.projectName + "/overview");
$location.path("project/" + $scope.projectName + "/overview");
},
function(result) { // failure
$scope.alerts = [
Expand Down
2 changes: 1 addition & 1 deletion assets/app/scripts/controllers/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ angular.module('openshiftConsole')
var message = e.status == 403 ?
("The project " + $scope.projectName + " does not exist or you are not authorized to view it.") :
("The project " + $scope.projectName + " does not exist.")
var redirect = URI('/error').query({
var redirect = URI('error').query({
"error_description": message,
"error" : e.status == 403 ? 'access_denied' : 'not_found'
}).toString();
Expand Down
4 changes: 2 additions & 2 deletions assets/app/scripts/controllers/util/logout.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ angular.module('openshiftConsole')
// Make sure the logout completed
if (AuthService.isLoggedIn()) {
$log.debug("LogoutController, logout failed, still logged in");
$scope.logoutMessage = 'You could not be logged out. Return to the <a href="/">console</a>.';
$scope.logoutMessage = 'You could not be logged out. Return to the <a href="./">console</a>.';
} else {
if (AUTH_CFG.logout_uri) {
$log.debug("LogoutController, logout completed, redirecting to AUTH_CFG.logout_uri", AUTH_CFG.logout_uri);
Expand All @@ -37,6 +37,6 @@ angular.module('openshiftConsole')
} else {
// TODO: redirect to configurable logout destination
$log.debug("LogoutController, not logged in, logout complete");
$scope.logoutMessage = 'You are logged out. Return to the <a href="/">console</a>.';
$scope.logoutMessage = 'You are logged out. Return to the <a href="./">console</a>.';
}
});
12 changes: 6 additions & 6 deletions assets/app/scripts/controllers/util/oauth.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ angular.module('openshiftConsole')
// Typically, this means we accessed /oauth directly, rather than via an auth redirect
if (!token) {
authLogger.log("OAuthController, no token or error, redirecting to /");
$location.url('/');
$location.url('./');
return;
}

Expand All @@ -35,24 +35,24 @@ angular.module('openshiftConsole')
AuthService.setUser(user, token);

// Redirect to original destination (or default to '/')
var destination = then || '/';
var destination = then || './';
if (URI(destination).is('absolute')) {
if (debug) { Logger.log("OAuthController, invalid absolute redirect", destination); }
destination = '/';
authLogger.log("OAuthController, invalid absolute redirect", destination);
destination = './';
}
authLogger.log("OAuthController, redirecting", destination);
$location.url(destination);
})
.catch(function(rejection) {
// Handle an API error response fetching the user
var redirect = URI('/error').query({error: 'user_fetch_failed'}).toString();
var redirect = URI('error').query({error: 'user_fetch_failed'}).toString();
authLogger.error("OAuthController, error fetching user", rejection, "redirecting", redirect);
$location.url(redirect);
});

})
.catch(function(rejection) {
var redirect = URI('/error').query({
var redirect = URI('error').query({
error: rejection.error || "",
error_description: rejection.error_description || "",
error_uri: rejection.error_uri || "",
Expand Down
2 changes: 1 addition & 1 deletion assets/app/scripts/directives/catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ angular.module('openshiftConsole')
// Must trigger off of the modal's hidden event to guarantee modal has finished closing before switching screens
$(".modal", elem).on('hidden.bs.modal', function () {
scope.$apply(function() {
var createURI = URI.expand("/project/{project}/create/fromtemplate{?q*}", {
var createURI = URI.expand("project/{project}/create/fromtemplate{?q*}", {
project: scope.project,
q: {
name: scope.template.metadata.name,
Expand Down
2 changes: 1 addition & 1 deletion assets/app/views/_project-nav.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</div>
<div class="col-md-4 active-filters">
</div>
<div class="col-md-2" style="margin-top: 30px;"><a href="/project/{{projectName}}/catalog" class="btn btn-lg btn-primary">Create <i class="fa fa-plus" /></a></div>
<div class="col-md-2" style="margin-top: 30px;"><a href="project/{{projectName}}/catalog" class="btn btn-lg btn-primary">Create <i class="fa fa-plus" /></a></div>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion assets/app/views/images.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ <h1>Images</h1>
<div style="margin-bottom: 10px;" ng-repeat="image in images">
<h3>{{image.dockerImageReference | imageName}} <span class="small">({{image.metadata.name}})</span></h3>
<div>Created: <relative-timestamp timestamp="image.metadata.creationTimestamp"></relative-timestamp></div>
<div ng-if="build = (image | buildForImage : builds)">Created from: Build {{build.metadata.labels.buildconfig}} (<a href="/project/{{projectName}}/browse/builds" class="small" title="{{build.metadata.name}}">{{build.metadata.name.substr(0, 10)}}</a>)
<div ng-if="build = (image | buildForImage : builds)">Created from: Build {{build.metadata.labels.buildconfig}} (<a href="project/{{projectName}}/browse/builds" class="small" title="{{build.metadata.name}}">{{build.metadata.name.substr(0, 10)}}</a>)
</div>
</div>
</project-page>
Expand Down
2 changes: 1 addition & 1 deletion assets/app/views/projects.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="container">
<h1>Projects</h1>
<div class="tile tile-project tile-click" style="margin-bottom: 10px;" ng-repeat="project in projects">
<h2 class="project"><a class="tile-target" href="/project/{{project.metadata.name}}">{{project.displayName || project.metadata.name}}</a></h2>
<h2 class="project"><a class="tile-target" href="project/{{project.metadata.name}}">{{project.displayName || project.metadata.name}}</a></h2>
<div class="muted" style="margin-top: -5px;" ng-if="project | annotation : 'description'">{{project | annotation : 'description'}}</div>
</div>
<div ng-if="emptyMessage && (projects | hashSize) == 0">{{emptyMessage}}</div>
Expand Down
6 changes: 3 additions & 3 deletions assets/bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
"uri.js": "1.14.1",
"moment": "2.8.4",
"patternfly": "1.1.2",
"hawtio-core": "2.0.8",
"hawtio-core-navigation": "2.0.15",
"hawtio-core": "2.0.11",
"hawtio-core-navigation": "2.0.33",
"hawtio-extension-service": "2.0.0",
"lodash": "2.4.1",
"lodash": "3.2.0",
"jquery": "2.1.3",
"sifter": "0.3.4",
"microplugin": "0.0.3",
Expand Down
2 changes: 1 addition & 1 deletion assets/test/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module.exports = function(config) {
"bower_components/js-logger/src/logger.js",
//"bower_components/webcomponentsjs/webcomponents.js",
"bower_components/hawtio-core/hawtio-core.js",
"bower_components/lodash/dist/lodash.compat.js",
"bower_components/lodash/lodash.js",
"bower_components/hawtio-core-navigation/dist/hawtio-core-navigation.js",
"bower_components/hawtio-extension-service/dist/hawtio-extension-service.js",
'app/scripts/**/*.js',
Expand Down
2 changes: 0 additions & 2 deletions hack/test-extended.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ TIME_MIN=$((60 * $TIME_SEC))

# TODO: Randomize these ports
export OS_MASTER_PORT=$(go run ${OS_ROOT}/test/util/random_port/generate.go)
export OS_ASSETS_PORT=$(go run ${OS_ROOT}/test/util/random_port/generate.go)
export OS_DNS_PORT=$(go run ${OS_ROOT}/test/util/random_port/generate.go)
export ETCD_PORT=$(go run ${OS_ROOT}/test/util/random_port/generate.go)

DEFAULT_SERVER_IP=$(ifconfig | grep -Ev "(127.0.0.1|172.17.42.1)" | grep "inet " | head -n 1 | awk '{print $2}')

export OS_MASTER_ADDR=${DEFAULT_SERVER_IP}:${OS_MASTER_PORT}
export OS_ASSETS_ADDR=${DEFAULT_SERVER_IP}:${OS_ASSETS_PORT}
export OS_DNS_ADDR=${DEFAULT_SERVER_IP}:${OS_DNS_PORT}
export KUBERNETES_MASTER="https://${OS_MASTER_ADDR}"

Expand Down
Loading