Skip to content

Commit

Permalink
improve #322 so we store previous values of user/pwd/port so they are…
Browse files Browse the repository at this point in the history
… reused
  • Loading branch information
jstrachan committed May 3, 2013
1 parent e0b445d commit 73fe1ed
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions hawtio-web/src/main/webapp/app/jvm/js/connect.ts
@@ -1,14 +1,37 @@
module JVM {
export function ConnectController($scope, $location, workspace) {
export function ConnectController($scope, $location, localStorage, workspace) {

JVM.configureScope($scope, $location, workspace);

$scope.host = "localhost";
$scope.port = 8181;
$scope.path = "jolokia";
$scope.useProxy = true;
$scope.userName = null;
$scope.password = null;

// lets load the local storage configuration
var key = "jvmConnect";
var config = {};
var configJson = localStorage[key];
if (configJson) {
try {
config = JSON.parse(configJson);
} catch (e) {
// ignore
}
}
$scope.port = config["port"] || 8181;
$scope.userName = config["userName"];
$scope.password = config["password"];

// replicate changes to local storage
angular.forEach(["userName", "password", "port"], (name) => {
$scope.$watch(name, () => {
var value = $scope[name];
if (value) {
config[name] = value;
localStorage[key] = JSON.stringify(config);
}
});
});

$scope.gotoServer = () => {
var host = $scope.host || "localhost";
Expand Down

0 comments on commit 73fe1ed

Please sign in to comment.