Loading app/controllers/CreateIndexController.scala +6 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,12 @@ import scala.concurrent.ExecutionContext.Implicits.global class CreateIndexController extends BaseController { def indices = process { (request, client) => client.getIndices(ElasticServer(request.host, request.authentication)).map { response => Status(response.status)(response.body) } } def execute = process { (request, client) => client.createIndex(request.get("index"), request.getOpt("metadata").getOrElse(Json.obj()), ElasticServer(request.host, request.authentication)).map { response => Status(response.status)(response.body) Loading app/controllers/NavbarController.scala 0 → 100644 +14 −0 Original line number Diff line number Diff line package controllers import models.ElasticServer import scala.concurrent.ExecutionContext.Implicits.global class NavbarController extends BaseController { def index = process { (request, client) => client.clusterHealth(ElasticServer(request.host, request.authentication)).map { response => Status(response.status)(response.body) } } } app/models/createindex/Indices.scala 0 → 100644 +11 −0 Original line number Diff line number Diff line package models.createindex import play.api.libs.json.{JsArray, JsString, JsValue} object Indices { def apply(data: JsValue) = JsArray(data.as[JsArray].value.collect { case index => (index \ "index").as[JsString] }) } conf/routes +8 −2 Original line number Diff line number Diff line Loading @@ -8,7 +8,7 @@ GET / controllers.Application.index() # POST /main @controllers.Main.execute POST /apis/overview @controllers.ClusterOverviewController.execute POST /apis/close_indices @controllers.CloseIndexController.execute POST /apis/open_indices @controllers.OpenIndexController.execute POST /apis/force_merge @controllers.ForceMergeController.execute Loading @@ -27,13 +27,19 @@ POST /apis/get_cluster_mapping @controllers.GetClusterMappingContr POST /apis/get_aliases @controllers.GetAliasesController.execute POST /apis/update_aliases @controllers.UpdateAliasesController.execute POST /apis/get_index_metadata @controllers.GetIndexMetadataController.execute POST /apis/create_index @controllers.CreateIndexController.execute # Overview module POST /overview @controllers.ClusterOverviewController.execute # Navbar module POST /navbar @controllers.NavbarController.index # Analysis module POST /analysis/indices @controllers.AnalysisController.getIndices POST /analysis/analyzers @controllers.AnalysisController.getIndexAnalyzers POST /analysis/fields @controllers.AnalysisController.getIndexFields POST /analysis/analyze/analyzer @controllers.AnalysisController.analyzeByAnalyzer POST /analysis/analyze/field @controllers.AnalysisController.analyzeByField # Create index module POST /create_index/create @controllers.CreateIndexController.execute POST /create_index/indices @controllers.CreateIndexController.indices GET /apis/hosts @controllers.HostsController.index Loading public/app.js +142 −171 Original line number Diff line number Diff line Loading @@ -558,8 +558,9 @@ angular.module('cerebro').controller('AlertsController', ['$scope', ]); angular.module('cerebro').controller('AliasesController', ['$scope', 'AlertService', 'AceEditorService', 'DataService', function($scope, AlertService, AceEditorService, DataService) { 'AlertService', 'AceEditorService', 'DataService', 'RefreshService', function($scope, AlertService, AceEditorService, DataService, RefreshService) { $scope.editor = undefined; Loading @@ -571,18 +572,6 @@ angular.module('cerebro').controller('AliasesController', ['$scope', $scope.changes = []; $scope.$watch( function() { return DataService.getData(); }, function(data) { if (data && !$scope.indices) { $scope.indices = data.indices; } }, true ); $scope.$watch('paginator', function(filter, previous) { $scope.page = $scope.paginator.getPage(); }, true); Loading Loading @@ -638,10 +627,19 @@ angular.module('cerebro').controller('AliasesController', ['$scope', ); }; $scope.setup = function() { if (DataService.getData()) { $scope.indices = DataService.getData().indices; $scope.loadIndices = function() { DataService.getIndices( function(indices) { $scope.indices = indices; }, function(error) { AlertService.error('Error loading indices', error); } ); }; $scope.setup = function() { $scope.loadIndices(); $scope.loadAliases(); $scope.initEditor(); }; Loading Loading @@ -697,7 +695,6 @@ angular.module('cerebro').controller('AnalysisController', ['$scope', $scope.field_tokens = response; }; var error = function(error) { $scope.field_tokens = undefined; AlertService.error('Error analyzing text by field', error); }; DataService.analyzeByField(index, field, text, success, error); Loading Loading @@ -771,8 +768,9 @@ angular.module('cerebro').controller('ConnectController', [ }]); angular.module('cerebro').controller('CreateIndexController', ['$scope', 'AlertService', 'DataService', 'AceEditorService', function($scope, AlertService, DataService, AceEditorService) { 'AlertService', 'DataService', 'AceEditorService', 'RefreshService', function($scope, AlertService, DataService, AceEditorService, RefreshService) { $scope.editor = undefined; $scope.shards = ''; Loading @@ -784,22 +782,15 @@ angular.module('cerebro').controller('CreateIndexController', ['$scope', if (!$scope.editor) { $scope.editor = AceEditorService.init('index-settings'); } if (DataService.getData()) { $scope.indices = DataService.getData().indices; } }; $scope.$watch( function() { return DataService.getData(); DataService.getIndices( function(indices) { $scope.indices = indices; }, function(data) { if (data && !$scope.indices) { $scope.indices = data.indices; function(error) { AlertService.error('Error loading indices', error); } }, true ); }; $scope.loadIndexMetadata = function(index) { DataService.getIndexMetadata(index, Loading Loading @@ -828,7 +819,7 @@ angular.module('cerebro').controller('CreateIndexController', ['$scope', } DataService.createIndex($scope.name, data, function(response) { DataService.forceRefresh(); RefreshService.refresh(); AlertService.success('Index successfully created'); }, function(error) { Loading Loading @@ -863,8 +854,8 @@ angular.module('cerebro').controller('ModalController', ['$scope', ]); angular.module('cerebro').controller('NavbarController', ['$scope', '$http', 'PageService', 'DataService', function($scope, $http, PageService, DataService) { 'PageService', 'DataService', 'RefreshService', function($scope, $http, PageService, DataService, RefreshService) { $scope.status = undefined; $scope.cluster_name = undefined; Loading @@ -872,27 +863,35 @@ angular.module('cerebro').controller('NavbarController', ['$scope', '$http', $scope.$watch( function() { return DataService.getData(); return RefreshService.lastUpdate(); }, function() { DataService.getNavbarData( function(data) { if (data) { $scope.status = data.status; $scope.cluster_name = data.cluster_name; $scope.host = DataService.getHost(); } else { PageService.setup($scope.cluster_name, $scope.status); }, function(error) { $scope.status = undefined; $scope.cluster_name = undefined; $scope.host = undefined; PageService.setup(); } ); } ); }] ); } ]); angular.module('cerebro').controller('OverviewController', ['$scope', '$http', '$window', 'DataService', 'AlertService', 'ModalService', function($scope, $http, $window, DataService, AlertService, ModalService) { '$window', 'DataService', 'AlertService', 'ModalService', 'RefreshService', function($scope, $http, $window, DataService, AlertService, ModalService, RefreshService) { $scope.data = undefined; $scope.indices = undefined; $scope.nodes = undefined; Loading Loading @@ -926,17 +925,28 @@ angular.module('cerebro').controller('OverviewController', ['$scope', '$http', $scope.$watch( function() { return DataService.getData(); return RefreshService.lastUpdate(); }, function() { $scope.refresh(); }, true ); $scope.refresh = function() { DataService.getOverview( function(data) { if (data) { $scope.data = data; $scope.setIndices(data.indices); $scope.setNodes(data.nodes); $scope.unassigned_shards = data.unassigned_shards; $scope.closed_indices = data.closed_indices; $scope.special_indices = data.special_indices; $scope.shardAllocation = data.shard_allocation; } else { }, function(error) { AlertService.error('Error while loading data', error); $scope.data = undefined; $scope.indices = undefined; $scope.nodes = undefined; $scope.unassigned_shards = 0; Loading @@ -944,12 +954,12 @@ angular.module('cerebro').controller('OverviewController', ['$scope', '$http', $scope.special_indices = 0; $scope.shardAllocation = true; } } ); }; $scope.$watch('paginator', function() { if (DataService.getData()) { $scope.setIndices(DataService.getData().indices); if ($scope.data) { $scope.setIndices($scope.data.indices); } }, true); Loading @@ -959,8 +969,8 @@ angular.module('cerebro').controller('OverviewController', ['$scope', '$http', }; $scope.$watch('nodes_filter', function() { if (DataService.getData()) { $scope.setNodes(DataService.getData().nodes); if ($scope.data) { $scope.setNodes($scope.data.nodes); } }, true); Loading @@ -972,7 +982,7 @@ angular.module('cerebro').controller('OverviewController', ['$scope', '$http', }; var success = function(data) { DataService.forceRefresh(); RefreshService.refresh(); AlertService.success('Operation successfully executed', data); }; Loading Loading @@ -1378,10 +1388,9 @@ angular.module('cerebro').factory('AlertService', function() { return this; }); angular.module('cerebro').factory('DataService', function($rootScope, $timeout, $http, $location) { var data; // current data angular.module('cerebro').factory('DataService', ['$rootScope', '$timeout', '$http', '$location', 'RefreshService', function($rootScope, $timeout, $http, $location, RefreshService) { var host; Loading @@ -1398,60 +1407,33 @@ angular.module('cerebro').factory('DataService', var baseUrl = buildBaseUrl(); var successfulRefresh = function(success) { return function(response) { data = response; if (success) { success(response); } }; }; var failedRefresh = function(error) { return function(response) { data = undefined; if (error) { error(response); } }; }; var refresh = function(success, error) { if (host) { request( '/apis/overview', {}, successfulRefresh(success), failedRefresh(error) ); } else { $location.path('/connect'); } }; var autoRefresh = function() { refresh(); $timeout(autoRefresh, 3000); }; this.getData = function() { return data; }; this.forceRefresh = function() { refresh(); }; this.getHost = function() { return host; }; this.setHost = function(newHost, newUsername, newPassword, success, error) { data = undefined; host = newHost; username = newUsername; password = newPassword; refresh(success, error); RefreshService.refresh(); success(); }; // Navbar this.getNavbarData = function(success, error) { request('/navbar', {}, success, error); }; // Overview this.getOverview = function(success, error) { request('/overview', {}, success, error); }; // Create index this.getIndices = function(success, error) { request('/create_index/indices', {}, success, error); }; this.createIndex = function(index, metadata, success, error) { var data = {index: index, metadata: metadata}; request('/create_index/create', data, success, error); }; this.closeIndex = function(index, success, error) { Loading Loading @@ -1524,11 +1506,6 @@ angular.module('cerebro').factory('DataService', request('/apis/get_index_metadata', {index: index}, success, error); }; this.createIndex = function(index, metadata, success, error) { var data = {index: index, metadata: metadata}; request('/apis/create_index', data, success, error); }; this.getOpenIndices = function(success, error) { request('/analysis/indices', {}, success, error); }; Loading @@ -1552,6 +1529,7 @@ angular.module('cerebro').factory('DataService', }; var request = function(path, data, success, error) { if (host) { var defaultData = { host: host, username: username, Loading @@ -1563,6 +1541,7 @@ angular.module('cerebro').factory('DataService', data: angular.merge(data, defaultData) // adds host to data }; $http(config).success(success).error(error); } }; this.getHosts = function(success, error) { Loading @@ -1577,11 +1556,10 @@ angular.module('cerebro').factory('DataService', this.setHost($location.search().location); } autoRefresh(); return this; }); } ]); angular.module('cerebro').factory('ModalService', ['$sce', function($sce) { Loading Loading @@ -1635,17 +1613,10 @@ angular.module('cerebro').factory('PageService', ['DataService', '$rootScope', img.src = faviconUrl; } $rootScope.$watch( function() { return DataService.getData(); }, function(data) { if (data) { setPageTitle(data.cluster_name); setFavIconColor(data.status); } } ); this.setup = function(newName, newStatus) { setPageTitle(newName); setFavIconColor(newStatus); }; var setPageTitle = function(newClusterName) { if (clusterName !== newClusterName) { Loading Loading @@ -1701,7 +1672,7 @@ angular.module('cerebro').factory('RefreshService', var autoRefresh = function(instance) { instance.refresh(); $timeout(autoRefresh, 1000); $timeout(function() { autoRefresh(instance); }, 3000); }; autoRefresh(this); Loading @@ -1711,7 +1682,8 @@ angular.module('cerebro').factory('RefreshService', ); angular.module('cerebro').controller('StatsController', ['$scope', '$http', 'DataService', function($scope, $http, DataService) { 'DataService', 'RefreshService', function($scope, $http, DataService, RefreshService) { $scope.number_of_nodes = undefined; Loading @@ -1729,30 +1701,29 @@ angular.module('cerebro').controller('StatsController', ['$scope', '$http', $scope.size_in_bytes = undefined; $scope.cluster_name = undefined; $scope.$watch( function() { return DataService.getData(); }, function(data) { if (data) { $scope.number_of_nodes = data.number_of_nodes; $scope.indices = data.indices.length; $scope.active_primary_shards = data.active_primary_shards; $scope.active_shards = data.active_shards; $scope.relocating_shards = data.relocating_shards; $scope.initializing_shards = data.initializing_shards; $scope.unassigned_shards = data.unassigned_shards; $scope.docs_count = data.docs_count; $scope.size_in_bytes = data.size_in_bytes; $scope.cluster_name = data.cluster_name; $scope.total_shards = $scope.active_shards + $scope.relocating_shards + $scope.initializing_shards + $scope.unassigned_shards; } } ); // $scope.$watch( // function() { // return RefreshService.lastUpdate(); // }, // function(data) { // if (data) { // $scope.number_of_nodes = data.number_of_nodes; // $scope.indices = data.indices.length; // $scope.active_primary_shards = data.active_primary_shards; // $scope.active_shards = data.active_shards; // $scope.relocating_shards = data.relocating_shards; // $scope.initializing_shards = data.initializing_shards; // $scope.unassigned_shards = data.unassigned_shards; // $scope.docs_count = data.docs_count; // $scope.size_in_bytes = data.size_in_bytes; // $scope.cluster_name = data.cluster_name; // // $scope.total_shards = $scope.active_shards + // $scope.relocating_shards + // $scope.initializing_shards + // $scope.unassigned_shards; // } // } // ); }]); Loading
app/controllers/CreateIndexController.scala +6 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,12 @@ import scala.concurrent.ExecutionContext.Implicits.global class CreateIndexController extends BaseController { def indices = process { (request, client) => client.getIndices(ElasticServer(request.host, request.authentication)).map { response => Status(response.status)(response.body) } } def execute = process { (request, client) => client.createIndex(request.get("index"), request.getOpt("metadata").getOrElse(Json.obj()), ElasticServer(request.host, request.authentication)).map { response => Status(response.status)(response.body) Loading
app/controllers/NavbarController.scala 0 → 100644 +14 −0 Original line number Diff line number Diff line package controllers import models.ElasticServer import scala.concurrent.ExecutionContext.Implicits.global class NavbarController extends BaseController { def index = process { (request, client) => client.clusterHealth(ElasticServer(request.host, request.authentication)).map { response => Status(response.status)(response.body) } } }
app/models/createindex/Indices.scala 0 → 100644 +11 −0 Original line number Diff line number Diff line package models.createindex import play.api.libs.json.{JsArray, JsString, JsValue} object Indices { def apply(data: JsValue) = JsArray(data.as[JsArray].value.collect { case index => (index \ "index").as[JsString] }) }
conf/routes +8 −2 Original line number Diff line number Diff line Loading @@ -8,7 +8,7 @@ GET / controllers.Application.index() # POST /main @controllers.Main.execute POST /apis/overview @controllers.ClusterOverviewController.execute POST /apis/close_indices @controllers.CloseIndexController.execute POST /apis/open_indices @controllers.OpenIndexController.execute POST /apis/force_merge @controllers.ForceMergeController.execute Loading @@ -27,13 +27,19 @@ POST /apis/get_cluster_mapping @controllers.GetClusterMappingContr POST /apis/get_aliases @controllers.GetAliasesController.execute POST /apis/update_aliases @controllers.UpdateAliasesController.execute POST /apis/get_index_metadata @controllers.GetIndexMetadataController.execute POST /apis/create_index @controllers.CreateIndexController.execute # Overview module POST /overview @controllers.ClusterOverviewController.execute # Navbar module POST /navbar @controllers.NavbarController.index # Analysis module POST /analysis/indices @controllers.AnalysisController.getIndices POST /analysis/analyzers @controllers.AnalysisController.getIndexAnalyzers POST /analysis/fields @controllers.AnalysisController.getIndexFields POST /analysis/analyze/analyzer @controllers.AnalysisController.analyzeByAnalyzer POST /analysis/analyze/field @controllers.AnalysisController.analyzeByField # Create index module POST /create_index/create @controllers.CreateIndexController.execute POST /create_index/indices @controllers.CreateIndexController.indices GET /apis/hosts @controllers.HostsController.index Loading
public/app.js +142 −171 Original line number Diff line number Diff line Loading @@ -558,8 +558,9 @@ angular.module('cerebro').controller('AlertsController', ['$scope', ]); angular.module('cerebro').controller('AliasesController', ['$scope', 'AlertService', 'AceEditorService', 'DataService', function($scope, AlertService, AceEditorService, DataService) { 'AlertService', 'AceEditorService', 'DataService', 'RefreshService', function($scope, AlertService, AceEditorService, DataService, RefreshService) { $scope.editor = undefined; Loading @@ -571,18 +572,6 @@ angular.module('cerebro').controller('AliasesController', ['$scope', $scope.changes = []; $scope.$watch( function() { return DataService.getData(); }, function(data) { if (data && !$scope.indices) { $scope.indices = data.indices; } }, true ); $scope.$watch('paginator', function(filter, previous) { $scope.page = $scope.paginator.getPage(); }, true); Loading Loading @@ -638,10 +627,19 @@ angular.module('cerebro').controller('AliasesController', ['$scope', ); }; $scope.setup = function() { if (DataService.getData()) { $scope.indices = DataService.getData().indices; $scope.loadIndices = function() { DataService.getIndices( function(indices) { $scope.indices = indices; }, function(error) { AlertService.error('Error loading indices', error); } ); }; $scope.setup = function() { $scope.loadIndices(); $scope.loadAliases(); $scope.initEditor(); }; Loading Loading @@ -697,7 +695,6 @@ angular.module('cerebro').controller('AnalysisController', ['$scope', $scope.field_tokens = response; }; var error = function(error) { $scope.field_tokens = undefined; AlertService.error('Error analyzing text by field', error); }; DataService.analyzeByField(index, field, text, success, error); Loading Loading @@ -771,8 +768,9 @@ angular.module('cerebro').controller('ConnectController', [ }]); angular.module('cerebro').controller('CreateIndexController', ['$scope', 'AlertService', 'DataService', 'AceEditorService', function($scope, AlertService, DataService, AceEditorService) { 'AlertService', 'DataService', 'AceEditorService', 'RefreshService', function($scope, AlertService, DataService, AceEditorService, RefreshService) { $scope.editor = undefined; $scope.shards = ''; Loading @@ -784,22 +782,15 @@ angular.module('cerebro').controller('CreateIndexController', ['$scope', if (!$scope.editor) { $scope.editor = AceEditorService.init('index-settings'); } if (DataService.getData()) { $scope.indices = DataService.getData().indices; } }; $scope.$watch( function() { return DataService.getData(); DataService.getIndices( function(indices) { $scope.indices = indices; }, function(data) { if (data && !$scope.indices) { $scope.indices = data.indices; function(error) { AlertService.error('Error loading indices', error); } }, true ); }; $scope.loadIndexMetadata = function(index) { DataService.getIndexMetadata(index, Loading Loading @@ -828,7 +819,7 @@ angular.module('cerebro').controller('CreateIndexController', ['$scope', } DataService.createIndex($scope.name, data, function(response) { DataService.forceRefresh(); RefreshService.refresh(); AlertService.success('Index successfully created'); }, function(error) { Loading Loading @@ -863,8 +854,8 @@ angular.module('cerebro').controller('ModalController', ['$scope', ]); angular.module('cerebro').controller('NavbarController', ['$scope', '$http', 'PageService', 'DataService', function($scope, $http, PageService, DataService) { 'PageService', 'DataService', 'RefreshService', function($scope, $http, PageService, DataService, RefreshService) { $scope.status = undefined; $scope.cluster_name = undefined; Loading @@ -872,27 +863,35 @@ angular.module('cerebro').controller('NavbarController', ['$scope', '$http', $scope.$watch( function() { return DataService.getData(); return RefreshService.lastUpdate(); }, function() { DataService.getNavbarData( function(data) { if (data) { $scope.status = data.status; $scope.cluster_name = data.cluster_name; $scope.host = DataService.getHost(); } else { PageService.setup($scope.cluster_name, $scope.status); }, function(error) { $scope.status = undefined; $scope.cluster_name = undefined; $scope.host = undefined; PageService.setup(); } ); } ); }] ); } ]); angular.module('cerebro').controller('OverviewController', ['$scope', '$http', '$window', 'DataService', 'AlertService', 'ModalService', function($scope, $http, $window, DataService, AlertService, ModalService) { '$window', 'DataService', 'AlertService', 'ModalService', 'RefreshService', function($scope, $http, $window, DataService, AlertService, ModalService, RefreshService) { $scope.data = undefined; $scope.indices = undefined; $scope.nodes = undefined; Loading Loading @@ -926,17 +925,28 @@ angular.module('cerebro').controller('OverviewController', ['$scope', '$http', $scope.$watch( function() { return DataService.getData(); return RefreshService.lastUpdate(); }, function() { $scope.refresh(); }, true ); $scope.refresh = function() { DataService.getOverview( function(data) { if (data) { $scope.data = data; $scope.setIndices(data.indices); $scope.setNodes(data.nodes); $scope.unassigned_shards = data.unassigned_shards; $scope.closed_indices = data.closed_indices; $scope.special_indices = data.special_indices; $scope.shardAllocation = data.shard_allocation; } else { }, function(error) { AlertService.error('Error while loading data', error); $scope.data = undefined; $scope.indices = undefined; $scope.nodes = undefined; $scope.unassigned_shards = 0; Loading @@ -944,12 +954,12 @@ angular.module('cerebro').controller('OverviewController', ['$scope', '$http', $scope.special_indices = 0; $scope.shardAllocation = true; } } ); }; $scope.$watch('paginator', function() { if (DataService.getData()) { $scope.setIndices(DataService.getData().indices); if ($scope.data) { $scope.setIndices($scope.data.indices); } }, true); Loading @@ -959,8 +969,8 @@ angular.module('cerebro').controller('OverviewController', ['$scope', '$http', }; $scope.$watch('nodes_filter', function() { if (DataService.getData()) { $scope.setNodes(DataService.getData().nodes); if ($scope.data) { $scope.setNodes($scope.data.nodes); } }, true); Loading @@ -972,7 +982,7 @@ angular.module('cerebro').controller('OverviewController', ['$scope', '$http', }; var success = function(data) { DataService.forceRefresh(); RefreshService.refresh(); AlertService.success('Operation successfully executed', data); }; Loading Loading @@ -1378,10 +1388,9 @@ angular.module('cerebro').factory('AlertService', function() { return this; }); angular.module('cerebro').factory('DataService', function($rootScope, $timeout, $http, $location) { var data; // current data angular.module('cerebro').factory('DataService', ['$rootScope', '$timeout', '$http', '$location', 'RefreshService', function($rootScope, $timeout, $http, $location, RefreshService) { var host; Loading @@ -1398,60 +1407,33 @@ angular.module('cerebro').factory('DataService', var baseUrl = buildBaseUrl(); var successfulRefresh = function(success) { return function(response) { data = response; if (success) { success(response); } }; }; var failedRefresh = function(error) { return function(response) { data = undefined; if (error) { error(response); } }; }; var refresh = function(success, error) { if (host) { request( '/apis/overview', {}, successfulRefresh(success), failedRefresh(error) ); } else { $location.path('/connect'); } }; var autoRefresh = function() { refresh(); $timeout(autoRefresh, 3000); }; this.getData = function() { return data; }; this.forceRefresh = function() { refresh(); }; this.getHost = function() { return host; }; this.setHost = function(newHost, newUsername, newPassword, success, error) { data = undefined; host = newHost; username = newUsername; password = newPassword; refresh(success, error); RefreshService.refresh(); success(); }; // Navbar this.getNavbarData = function(success, error) { request('/navbar', {}, success, error); }; // Overview this.getOverview = function(success, error) { request('/overview', {}, success, error); }; // Create index this.getIndices = function(success, error) { request('/create_index/indices', {}, success, error); }; this.createIndex = function(index, metadata, success, error) { var data = {index: index, metadata: metadata}; request('/create_index/create', data, success, error); }; this.closeIndex = function(index, success, error) { Loading Loading @@ -1524,11 +1506,6 @@ angular.module('cerebro').factory('DataService', request('/apis/get_index_metadata', {index: index}, success, error); }; this.createIndex = function(index, metadata, success, error) { var data = {index: index, metadata: metadata}; request('/apis/create_index', data, success, error); }; this.getOpenIndices = function(success, error) { request('/analysis/indices', {}, success, error); }; Loading @@ -1552,6 +1529,7 @@ angular.module('cerebro').factory('DataService', }; var request = function(path, data, success, error) { if (host) { var defaultData = { host: host, username: username, Loading @@ -1563,6 +1541,7 @@ angular.module('cerebro').factory('DataService', data: angular.merge(data, defaultData) // adds host to data }; $http(config).success(success).error(error); } }; this.getHosts = function(success, error) { Loading @@ -1577,11 +1556,10 @@ angular.module('cerebro').factory('DataService', this.setHost($location.search().location); } autoRefresh(); return this; }); } ]); angular.module('cerebro').factory('ModalService', ['$sce', function($sce) { Loading Loading @@ -1635,17 +1613,10 @@ angular.module('cerebro').factory('PageService', ['DataService', '$rootScope', img.src = faviconUrl; } $rootScope.$watch( function() { return DataService.getData(); }, function(data) { if (data) { setPageTitle(data.cluster_name); setFavIconColor(data.status); } } ); this.setup = function(newName, newStatus) { setPageTitle(newName); setFavIconColor(newStatus); }; var setPageTitle = function(newClusterName) { if (clusterName !== newClusterName) { Loading Loading @@ -1701,7 +1672,7 @@ angular.module('cerebro').factory('RefreshService', var autoRefresh = function(instance) { instance.refresh(); $timeout(autoRefresh, 1000); $timeout(function() { autoRefresh(instance); }, 3000); }; autoRefresh(this); Loading @@ -1711,7 +1682,8 @@ angular.module('cerebro').factory('RefreshService', ); angular.module('cerebro').controller('StatsController', ['$scope', '$http', 'DataService', function($scope, $http, DataService) { 'DataService', 'RefreshService', function($scope, $http, DataService, RefreshService) { $scope.number_of_nodes = undefined; Loading @@ -1729,30 +1701,29 @@ angular.module('cerebro').controller('StatsController', ['$scope', '$http', $scope.size_in_bytes = undefined; $scope.cluster_name = undefined; $scope.$watch( function() { return DataService.getData(); }, function(data) { if (data) { $scope.number_of_nodes = data.number_of_nodes; $scope.indices = data.indices.length; $scope.active_primary_shards = data.active_primary_shards; $scope.active_shards = data.active_shards; $scope.relocating_shards = data.relocating_shards; $scope.initializing_shards = data.initializing_shards; $scope.unassigned_shards = data.unassigned_shards; $scope.docs_count = data.docs_count; $scope.size_in_bytes = data.size_in_bytes; $scope.cluster_name = data.cluster_name; $scope.total_shards = $scope.active_shards + $scope.relocating_shards + $scope.initializing_shards + $scope.unassigned_shards; } } ); // $scope.$watch( // function() { // return RefreshService.lastUpdate(); // }, // function(data) { // if (data) { // $scope.number_of_nodes = data.number_of_nodes; // $scope.indices = data.indices.length; // $scope.active_primary_shards = data.active_primary_shards; // $scope.active_shards = data.active_shards; // $scope.relocating_shards = data.relocating_shards; // $scope.initializing_shards = data.initializing_shards; // $scope.unassigned_shards = data.unassigned_shards; // $scope.docs_count = data.docs_count; // $scope.size_in_bytes = data.size_in_bytes; // $scope.cluster_name = data.cluster_name; // // $scope.total_shards = $scope.active_shards + // $scope.relocating_shards + // $scope.initializing_shards + // $scope.unassigned_shards; // } // } // ); }]);