Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix #458 and consolidate where we're opening a new window and connect…
…ing to containers
  • Loading branch information
gashcrumb committed Aug 6, 2013
1 parent 5b85862 commit 89be82e
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 417 deletions.
86 changes: 86 additions & 0 deletions hawtio-web/src/main/webapp/app/core/js/helpers.ts
Expand Up @@ -855,4 +855,90 @@ module Core {
authInfo = btoa(authInfo);
return "Basic " + authInfo;
}

export class ConnectToServerOptions {
public host:string;
public port:number;
public path:string;
public useProxy:boolean = true;
public jolokiaUrl:string;
public userName:string;
public password:string;
}

export function connectToServer(localSturage, options:ConnectToServerOptions) {
var url = options.jolokiaUrl;

var userDetails = {
username: null,
password: null
};

if (options.userName) {
//full += "&_user=" + $scope.userName;
userDetails.username = options.userName;
}
if (options.password) {
//full += "&_pwd=" + $scope.password;
userDetails.password = options.password;
}

localStorage[url] = angular.toJson(userDetails);

if (url) {

if (options.useProxy) {
// lets remove the http stuff
var idx = url.indexOf("://");
if (idx > 0) {
url = url.substring(idx + 3);
}
// lets replace the : with a /
url = url.replace(":", "/");
url = Core.trimLeading(url, "/");
url = Core.trimTrailing(url, "/");
url = "/hawtio/proxy/" + url;
} else {
if (url.indexOf("://") < 0) {
url = "http://" + url;
}
}
console.log("going to server: " + url + " as user " + options.userName);

var full = "?url=" + encodeURIComponent(url);

full += "#/logs";
window.open(full);
} else {

var host = options.host || "localhost";
var port = options.port;
var path = Core.trimLeading(options.path || "jolokia", "/");
path = Core.trimTrailing(path, "/");

if (port > 0) {
host += ":" + port;
}
var url = host + "/" + path;

if (options.useProxy) {
url = "/hawtio/proxy/" + url;
} else {
if (url.indexOf("://") < 0) {
url = "http://" + url;
}
}
console.log("going to server: " + url + " as user " + options.userName);

var full = "?url=" + encodeURIComponent(url);

// default the osgi view
full += "#/osgi/bundle-list";
console.log("Full URL is: " + full);
window.open(full);
}

}


}
35 changes: 0 additions & 35 deletions hawtio-web/src/main/webapp/app/fabric/html/containers.html

This file was deleted.

4 changes: 2 additions & 2 deletions hawtio-web/src/main/webapp/app/fabric/js/container.ts
@@ -1,6 +1,6 @@
module Fabric {

export function ContainerController($scope, workspace:Workspace, $routeParams, jolokia, $location) {
export function ContainerController($scope, localStorage, $routeParams, jolokia, $location) {
$scope.containerId = $routeParams.containerId;

$scope.selectedProfiles = [];
Expand Down Expand Up @@ -33,7 +33,7 @@ module Fabric {
localStorage['fabric.userName'] = $scope.userName;
localStorage['fabric.password'] = $scope.password;
}
Fabric.connect($scope.row, $scope.userName, $scope.password, true);
Fabric.connect(localStorage, $scope.row, $scope.userName, $scope.password, true);
$scope.connectToContainerDialog = false;
};

Expand Down

0 comments on commit 89be82e

Please sign in to comment.