Skip to content
This repository has been archived by the owner on Mar 31, 2024. It is now read-only.

Commit

Permalink
Merge pull request elastic#65 from spalger/betterServerUrlJuggle
Browse files Browse the repository at this point in the history
juggle the serverUrl between angular and non-angular worlds better
  • Loading branch information
bleskes committed Oct 27, 2015
2 parents bb1d5a1 + 0e994c0 commit 582b75d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
5 changes: 0 additions & 5 deletions public/src/controllers/SenseController.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,4 @@ require('ui/modules')
this.serverUrl = server;
});
});

// sync ui changes back to the es module
$scope.$watch('sense.serverUrl', (serverUrl) => {
es.setBaseUrl(serverUrl);
});
});
3 changes: 2 additions & 1 deletion public/src/directives/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
aria-label="Server Name"
class="form-control"
ng-focus="navbar.updateServerUrlHistory()"
ng-blur="navbar.commitServerUrlFormModel()"

sense-uib-typeahead="url for url in navbar.serverUrlHistory"
ng-model="sense.serverUrl"
ng-model="navbar.serverUrlFormModel"
typeahead-append-to-body="true"
typeahead-focus-first="false"

Expand Down
11 changes: 10 additions & 1 deletion public/src/directives/senseNavbar.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const history = require('../history');
const es = require('../es');

require('ui/modules')
.get('app/sense')
Expand All @@ -7,13 +8,21 @@ require('ui/modules')
restrict: 'A',
template: require('./navbar.html'),
controllerAs: 'navbar',
controller: function SenseNavbarController($element) {
controller: function SenseNavbarController($scope, $element) {
this.serverUrlHistory = [];
this.updateServerUrlHistory = function () {
this.serverUrlHistory = history.getHistoricalServers();
};

this.updateServerUrlHistory();

this.commitServerUrlFormModel = () => {
es.setBaseUrl(this.serverUrlFormModel);
};

$scope.$watch('sense.serverUrl', (serverUrl) => {
this.serverUrlFormModel = serverUrl;
});
}
};
});

0 comments on commit 582b75d

Please sign in to comment.