State {{ currentPartition }} \n' +
+ 'Current Status: {{statusInfo}} Source
The query has been updated but not saved. Your changes will not take effect until you hit the "Update" button
State {{ currentPartition }} \n' +
'{{ state | json }}\n' +
' Events
Instructions Make sure you use the Google Chrome browser. Open a debugger (Ctrl +Shift +J on Windows). Check the debugger console for errors (occurred while running the projection definition on while loading state and events). Click the ‘Run’ button above. Watch for errors in the debugger console Check the debugging status on XXXXXXXXX. Execution will stop on ‘debugger’ statement immediately before invoking your event handler. Any log output and emitted events will appear in the log viewer.
');
}]);
@@ -126,7 +126,7 @@ try {
}
module.run(['$templateCache', function($templateCache) {
$templateCache.put('query.tpl.html',
- '{{status}} State \n' +
+ '{{status}} {{stateReason}} State \n' +
'{{state | json}}\n' +
' ');
}]);
diff --git a/src/js/modules/projections/views/projections.item.debug.tpl.html b/src/js/modules/projections/views/projections.item.debug.tpl.html
index ac765713..82b26229 100644
--- a/src/js/modules/projections/views/projections.item.debug.tpl.html
+++ b/src/js/modules/projections/views/projections.item.debug.tpl.html
@@ -14,7 +14,7 @@ Projection Debug
Update
-
Back
+
Back
diff --git a/src/js/modules/projections/views/query.tpl.html b/src/js/modules/projections/views/query.tpl.html
index 221c4ca1..86c1f9b3 100644
--- a/src/js/modules/projections/views/query.tpl.html
+++ b/src/js/modules/projections/views/query.tpl.html
@@ -15,8 +15,9 @@
Query
- {{status}}
+ {{status}}
+
{{stateReason}}
diff --git a/src/js/modules/security/controllers/SignInCtrl.js b/src/js/modules/security/controllers/SignInCtrl.js
index 75b0248b..56f8c9db 100644
--- a/src/js/modules/security/controllers/SignInCtrl.js
+++ b/src/js/modules/security/controllers/SignInCtrl.js
@@ -29,16 +29,23 @@ define(['./_module'], function (app) {
$rootScope.esVersion = $rootScope.esVersion == '0.0.0.0' ? 'development build' : $rootScope.esVersion;
$rootScope.projectionsAllowed = info.projectionsMode != 'None';
$rootScope.projectionsMode = info.projectionsMode;
- scavengeNotificationService.start();
- authService.setCredentials($scope.log.username, $scope.log.password, $scope.log.server);
- infoService.getOptions().then(function onGetOptions(response){
- var options = response.data;
- for (var index in options) {
- if(options[index].name == "ClusterSize" && options[index].value > 1){
- $rootScope.singleNode = false;
- }
- }
- redirectAfterLoggingIn();
+
+ authService.getUserGroups($scope.log.username).then(function(groups) {
+ authService.setCredentials($scope.log.username, $scope.log.password, $scope.log.server, groups);
+ if($rootScope.isAdmin) {
+ scavengeNotificationService.start();
+ infoService.getOptions().then(function onGetOptions(response){
+ var options = response.data;
+ for (var index in options) {
+ if(options[index].name == "ClusterSize" && options[index].value > 1){
+ $rootScope.singleNode = false;
+ }
+ }
+ redirectAfterLoggingIn();
+ });
+ } else {
+ redirectAfterLoggingIn();
+ }
});
})
.error(function () {
diff --git a/src/js/modules/streams/controllers/StreamsListCtrl.js b/src/js/modules/streams/controllers/StreamsListCtrl.js
index 98d7d84f..ad020ee9 100644
--- a/src/js/modules/streams/controllers/StreamsListCtrl.js
+++ b/src/js/modules/streams/controllers/StreamsListCtrl.js
@@ -3,8 +3,8 @@ define(['./_module'], function (app) {
'use strict';
return app.controller('StreamsListCtrl', [
- '$scope', '$state', 'StreamsService',
- function ($scope, $state, streamsService) {
+ '$rootScope', '$scope', '$state', 'StreamsService', 'MessageService',
+ function ($rootScope, $scope, $state, streamsService, msg) {
function filter (entries) {
var filtered = {}, i = 0, length = entries.length, item, result = [];
@@ -23,26 +23,32 @@ define(['./_module'], function (app) {
return result;
}
- $scope.search = '$all';
-
$scope.gotoStream = function ($event) {
$event.preventDefault();
$event.stopPropagation();
- // todo: do check if stream exists
-
- $state.go('^.item.events', { streamId: $scope.search });
+ streamsService.checkStreamExists($scope.search).then(function(exists) {
+ if(exists) {
+ $state.go('^.item.events', { streamId: $scope.search });
+ } else {
+ msg.warn('Could not open stream ' + $scope.search +'. This usually means the stream does not exist or you do not have permission to view it');
+ }
+ });
};
- streamsService.recentlyChangedStreams()
- .success(function (data) {
- $scope.changedStreams = filter(data.entries);
- });
-
- streamsService.recentlyCreatedStreams()
- .success(function (data) {
- $scope.createdStreams = filter(data.entries);
- });
+ if($rootScope.isAdmin !== false) {
+ $scope.search = '$all';
+
+ streamsService.recentlyChangedStreams()
+ .success(function (data) {
+ $scope.changedStreams = filter(data.entries);
+ });
+
+ streamsService.recentlyCreatedStreams()
+ .success(function (data) {
+ $scope.createdStreams = filter(data.entries);
+ });
+ }
}
]);
});
diff --git a/src/js/modules/streams/services/StreamsService.js b/src/js/modules/streams/services/StreamsService.js
index a7623b89..af58b6e3 100644
--- a/src/js/modules/streams/services/StreamsService.js
+++ b/src/js/modules/streams/services/StreamsService.js
@@ -75,6 +75,16 @@ define(['./_module'], function(app) {
};
return $http.get(url, header);
+ },
+ checkStreamExists: function(streamId) {
+ var deferred = $q.defer();
+ var url = urlBuilder.build(urls.streams.events, streamId);
+ $http.get(url).success(function() {
+ deferred.resolve(true);
+ }).error(function() {
+ deferred.resolve(false);
+ });
+ return deferred.promise;
}
};
}
diff --git a/src/js/modules/streams/templates/templates.js b/src/js/modules/streams/templates/templates.js
index 34a0ca74..0c430990 100644
--- a/src/js/modules/streams/templates/templates.js
+++ b/src/js/modules/streams/templates/templates.js
@@ -54,7 +54,7 @@ try {
}
module.run(['$templateCache', function($templateCache) {
$templateCache.put('streams.item.tpl.html',
- '
');
+ '
');
}]);
})();
@@ -66,7 +66,7 @@ try {
}
module.run(['$templateCache', function($templateCache) {
$templateCache.put('streams.list.tpl.html',
- '
');
+ '
You must be an admin to view recently created streams ');
}]);
})();
diff --git a/src/js/modules/streams/views/streams.item.tpl.html b/src/js/modules/streams/views/streams.item.tpl.html
index f5682584..4fcec399 100644
--- a/src/js/modules/streams/views/streams.item.tpl.html
+++ b/src/js/modules/streams/views/streams.item.tpl.html
@@ -5,7 +5,7 @@
Event Stream '{{ streamId }}'
{{ isPolling == true ? 'Pause' : 'Resume' }}
- Edit ACL
+ Edit ACL
Back
diff --git a/src/js/modules/streams/views/streams.list.tpl.html b/src/js/modules/streams/views/streams.list.tpl.html
index 7c0e85e5..d4cba5d3 100644
--- a/src/js/modules/streams/views/streams.list.tpl.html
+++ b/src/js/modules/streams/views/streams.list.tpl.html
@@ -5,12 +5,12 @@ Stream Browser
-
+
@@ -56,3 +56,4 @@ Stream Browser
+
You must be an admin to view recently created streams
diff --git a/src/js/run.js b/src/js/run.js
index 8fcfb3ec..a170ca0f 100644
--- a/src/js/run.js
+++ b/src/js/run.js
@@ -30,15 +30,17 @@ define(['es-ui'], function (app) {
$rootScope.esVersion = $rootScope.esVersion == '0.0.0.0' ? 'development build' : $rootScope.esVersion;
$rootScope.projectionsAllowed = info.projectionsMode != 'None';
$rootScope.projectionsMode = info.projectionsMode;
- scavengeNotificationService.start();
- infoService.getOptions().then(function onGetOptions(response){
- var options = response.data;
- for (var index in options) {
- if(options[index].name == "ClusterSize" && options[index].value > 1){
- $rootScope.singleNode = false;
+ if($rootScope.isAdmin) {
+ scavengeNotificationService.start();
+ infoService.getOptions().then(function onGetOptions(response){
+ var options = response.data;
+ for (var index in options) {
+ if(options[index].name == "ClusterSize" && options[index].value > 1){
+ $rootScope.singleNode = false;
+ }
}
- }
- });
+ });
+ }
});
}, function () {
$rootScope.previousUrl = $location.$$path;
diff --git a/src/js/services/AuthService.js b/src/js/services/AuthService.js
index 9bfc244c..990e3338 100644
--- a/src/js/services/AuthService.js
+++ b/src/js/services/AuthService.js
@@ -12,7 +12,8 @@ define(['./_module'], function (app) {
'$rootScope',
'$location',
'urls',
- function (Base64, $q, $cookieStore, $http, $rootScope, $location, urls) {
+ 'UrlBuilder',
+ function (Base64, $q, $cookieStore, $http, $rootScope, $location, urls, urlBuilder) {
// initialize to whatever is in the cookie, if anything
// i know, hoising, but i don't like jshint warnings
var currentUrl = $location.host() + ':' + $location.port();
@@ -25,6 +26,14 @@ define(['./_module'], function (app) {
return escreds.servers[server].credentials;
}
+ function getGroupsFromCookie(server){
+ var escreds = $cookieStore.get('es-creds');
+ if(!escreds || !escreds.servers[server]){
+ return null;
+ }
+ return escreds.servers[server].groups;
+ }
+
function clearCredentials(server){
document.execCommand('ClearAuthenticationCache');
$http.defaults.headers.common.Authorization = 'Basic ';
@@ -35,7 +44,7 @@ define(['./_module'], function (app) {
}
}
- function addCredentialsToCookie(server, username, password){
+ function addCredentialsToCookie(server, username, password, groups){
var escreds = $cookieStore.get('es-creds');
if(!escreds){
escreds = {
@@ -43,7 +52,8 @@ define(['./_module'], function (app) {
}
}
escreds.servers[server] = {
- credentials : Base64.encode(username + ':' + password)
+ credentials : Base64.encode(username + ':' + password),
+ groups : groups
}
$cookieStore.put('es-creds', escreds);
}
@@ -52,6 +62,14 @@ define(['./_module'], function (app) {
$rootScope.baseUrl = url;
}
+ function setUserAdmin(groups) {
+ $rootScope.isAdmin = false;
+ if(groups && groups.length > 0)
+ {
+ $rootScope.isAdmin = groups.indexOf('$admins') > -1;
+ }
+ }
+
var escreds = getCredentialsFromCookie(currentUrl);
if(escreds) {
setBaseUrl(currentUrl);
@@ -72,14 +90,16 @@ define(['./_module'], function (app) {
return {
- setCredentials: function (username, password, server) {
+ setCredentials: function (username, password, server, groups) {
var credentials = Base64.encode(username + ':' + password);
+
$http.defaults.headers.common.Authorization = 'Basic ' + credentials;
server = prepareUrl(server);
setBaseUrl(server);
+ setUserAdmin(groups);
- addCredentialsToCookie(server, username, password);
+ addCredentialsToCookie(server, username, password, groups);
},
clearCredentials: function () {
clearCredentials($rootScope.baseUrl);
@@ -92,6 +112,8 @@ define(['./_module'], function (app) {
} else {
this.validate(credentials, server)
.success(function() {
+ var groups = getGroupsFromCookie(server);
+ setUserAdmin(groups);
deferred.resolve();
})
.error(function (){
@@ -136,6 +158,14 @@ define(['./_module'], function (app) {
Authorization: 'Basic ' + credentials
}
});
+ },
+ getUserGroups: function(username) {
+ var deferred = $q.defer();
+ $http.get(urlBuilder.build(urls.users.get, username)).success(function(userInfo) {
+ var groups = userInfo.data.groups;
+ deferred.resolve(groups);
+ });
+ return deferred.promise;
}
};
}
diff --git a/src/js/templates/templates.js b/src/js/templates/templates.js
index 0a9030d6..5fa30d59 100644
--- a/src/js/templates/templates.js
+++ b/src/js/templates/templates.js
@@ -18,7 +18,7 @@ try {
}
module.run(['$templateCache', function($templateCache) {
$templateCache.put('index.tpl.html',
- '
');
+ '
');
}]);
})();
});
\ No newline at end of file
diff --git a/src/scss/_module-siteheader.scss b/src/scss/_module-siteheader.scss
index 134da736..325fc4e4 100644
--- a/src/scss/_module-siteheader.scss
+++ b/src/scss/_module-siteheader.scss
@@ -51,6 +51,11 @@
background: $green-dark;
color: $white-off;
}
+ &.disabled {
+ color:$green-dark;
+ pointer-events:none;
+ cursor:default;
+ }
}
}
@@ -59,7 +64,7 @@
a {
background: $green-dark;
color: $white;
- &:focus, &:hover {
+ &:focus, &:hover, &.disabled {
background: $green-dark;
color: $white;
}
diff --git a/src/views/index.tpl.html b/src/views/index.tpl.html
index 04bb59cb..84acddc8 100644
--- a/src/views/index.tpl.html
+++ b/src/views/index.tpl.html
@@ -15,20 +15,20 @@
Stream Browser
-
- Projections
+
+ Projections
-
- Query
+
+ Query
-
- Competing Consumers
+
+ Competing Consumers
-
- Admin
+
+ Admin
-
- Users
+
+ Users
Log Out