diff --git a/hawtio-web/src/main/webapp/app/fabric/js/helpers.ts b/hawtio-web/src/main/webapp/app/fabric/js/helpers.ts index 0808dab6a4..c452abcbc3 100644 --- a/hawtio-web/src/main/webapp/app/fabric/js/helpers.ts +++ b/hawtio-web/src/main/webapp/app/fabric/js/helpers.ts @@ -3,6 +3,10 @@ module Fabric { export var managerMBean = "org.fusesource.fabric:type=Fabric"; export var clusterManagerMBean = "org.fusesource.fabric:type=ClusterServiceManager"; + export function hasFabric(workspace) { + return workspace.treeContainsDomainAndProperties(Fabric.jmxDomain, {type: "Fabric"}); + } + export function initScope($scope, workspace) { $scope.hasFabricWiki = () => { return Git.isGitMBeanFabric(workspace); diff --git a/hawtio-web/src/main/webapp/app/fabric/js/navbar.ts b/hawtio-web/src/main/webapp/app/fabric/js/navbar.ts index 47bc543f8d..de69b262bf 100644 --- a/hawtio-web/src/main/webapp/app/fabric/js/navbar.ts +++ b/hawtio-web/src/main/webapp/app/fabric/js/navbar.ts @@ -17,11 +17,7 @@ module Fabric { $scope.hasMetrics = workspace.treeContainsDomainAndProperties('org.elasticsearch', {service: 'restjmx'}); $scope.canUpload = workspace.treeContainsDomainAndProperties('io.hawt.jmx', {type: 'UploadManager'}); var ensembleContainers = jolokia.getAttribute(Fabric.clusterManagerMBean, "EnsembleContainers", {method: "GET"}); - if (workspace.treeContainsDomainAndProperties(Fabric.jmxDomain, {type: "Fabric"})) { - $scope.hasFabric = true; - } else { - $scope.hasFabric = false; - } + $scope.hasFabric = Fabric.hasFabric(workspace); if (!$scope.hasFabric) { $location.url("/fabric/create"); } diff --git a/hawtio-web/src/main/webapp/app/karaf/html/features.html b/hawtio-web/src/main/webapp/app/karaf/html/features.html index ed940e95ab..0dcaebfca1 100644 --- a/hawtio-web/src/main/webapp/app/karaf/html/features.html +++ b/hawtio-web/src/main/webapp/app/karaf/html/features.html @@ -5,10 +5,10 @@
- -
@@ -18,6 +18,11 @@
+   +
+ + +
diff --git a/hawtio-web/src/main/webapp/app/karaf/js/features.ts b/hawtio-web/src/main/webapp/app/karaf/js/features.ts index 2db8709fd0..d12e1a952e 100644 --- a/hawtio-web/src/main/webapp/app/karaf/js/features.ts +++ b/hawtio-web/src/main/webapp/app/karaf/js/features.ts @@ -1,13 +1,21 @@ module Karaf { - export function FeaturesController($scope, $location, workspace, jolokia) { + export function FeaturesController($scope, $location, workspace, jolokia, $parse) { $scope.feature = empty(); + $scope.installedOnly = true; + $scope.hasFabric = Fabric.hasFabric(workspace); var key = $location.search()['repo']; if (key) { $scope.repository = { id: key }; } + /* + var installed = $location.search()['installedOnly']; + if (installed) { + $parse(installed)($scope); + } + */ // caches last jolokia result $scope.result = []; @@ -20,64 +28,73 @@ module Karaf { $scope.selectedFeatures = []; - /* - var SearchProvider = function (scope, location) { - var self = this; - self.scope = scope; - self.location = location; - - self.callback = function (newValue, oldValue) { - if (angular.isUndefined(oldValue) && angular.isUndefined(newValue)) { - // if for some reason we do not have a values - return - } - - // if we have an old value to quick compare against - if (angular.isDefined(oldValue)) { - if (newValue === oldValue) { - return; - } - if (newValue.id === oldValue.id) { - return; - } - } - self.scope.features = featuresOfRepo(self.scope.repository.id, self.scope.features); - self.scope.feature = setSelect(self.scope.repository, self.scope.repositories); - - var q = location.search(); - q['repo'] = self.scope.repository.id; - location.search(q); - self.evalFilter(); - }; - - self.scope.$watch('repository', self.callback); - - self.init = function (childScope, grid) { - self.grid = grid; - self.childScope = childScope; - grid.searchProvider = self; - }; - - self.evalFilter = function () { - var byRepo = self.grid.sortedData; - if (angular.isDefined(self.scope.repository)) { - if (self.scope.repository.id !== "") { - byRepo = self.grid.sortedData.findAll(function (item) { - return item.Repository === self.scope.repository.id - }); - } - } - self.grid.filteredData = byRepo; - self.grid.rowFactory.filteredDataChanged(); - }; - - } - - var searchProvider = new SearchProvider($scope, $location); - */ + var SearchProvider = function (scope, location) { + var self = this; + self.scope = scope; + self.location = location; + + self.callback = function (newValue, oldValue) { + if (angular.isUndefined(oldValue) && angular.isUndefined(newValue)) { + // if for some reason we do not have a values + return + } + + // if we have an old value to quick compare against + if (angular.isDefined(oldValue)) { + if (newValue === oldValue) { + return; + } + if (newValue.id === oldValue.id) { + return; + } + } + self.scope.features = featuresOfRepo(self.scope.repository.id, self.scope.features); + self.scope.feature = setSelect(self.scope.repository, self.scope.repositories); + + var q = location.search(); + q['repo'] = self.scope.repository.id; + location.search(q); + self.evalFilter(); + }; + + self.scope.$watch('repository', self.callback); + + self.scope.$watch('installedOnly', (newValue, oldValue) => { + if (newValue !== oldValue) { + self.evalFilter(); + } + }); + + self.init = function (childScope, grid) { + self.grid = grid; + self.childScope = childScope; + grid.searchProvider = self; + }; + + self.evalFilter = function () { + var byRepo = self.grid.rowCache; + if (angular.isDefined(self.scope.repository)) { + if (self.scope.repository.id !== "") { + byRepo = self.grid.rowCache.findAll((item) => { + return item.entity.RepositoryName === self.scope.repository.id; + }); + } + } + if (self.scope.installedOnly) { + byRepo = byRepo.findAll((item) => { + return item.entity.Installed; + }); + } + self.grid.filteredRows = byRepo; + self.grid.rowFactory.filteredRowsChanged(); + }; + + } + + var searchProvider = new SearchProvider($scope, $location); $scope.featureOptions = { - //plugins: [searchProvider], + plugins: [searchProvider], data: 'features', showFilter: false, showColumnMenu: false, @@ -86,11 +103,14 @@ module Karaf { }, selectedItems: $scope.selectedFeatures, rowHeight: 32, + enableRowSelection: !$scope.hasFabric, selectWithCheckboxOnly: true, + keepLastSelected: true, + showSelectionCheckbox: !$scope.hasFabric, columnDefs: [ { field: 'Name', - displayName: 'Name', + displayName: 'Feature Name', cellTemplate: '
{{row.getProperty(col.field)}}
', width: 200 }, @@ -100,11 +120,19 @@ module Karaf { cellTemplate: '', width: 200 }, + { + field: 'RepositoryName', + displayName: 'Repository' + }, { field: 'Installed', displayName: 'Installed' } - ] + ], + sortInfo: { + fields: ['Installed', 'RepositoryName'], + directions: ['asc', 'asc'] + } }; var featuresMBean = Karaf.getSelectionFeaturesMBean(workspace); diff --git a/hawtio-web/src/main/webapp/app/karaf/js/helpers.ts b/hawtio-web/src/main/webapp/app/karaf/js/helpers.ts index 1261bbd561..cdb559966d 100644 --- a/hawtio-web/src/main/webapp/app/karaf/js/helpers.ts +++ b/hawtio-web/src/main/webapp/app/karaf/js/helpers.ts @@ -82,11 +82,8 @@ module Karaf { angular.forEach(feature, (entry) => { var f = Object.extended(fullFeatures[entry['Name']][entry['Version']]).clone(); f["Id"] = entry["Name"] + "/" + entry["Version"]; - /* - f["Name"] = entry["Name"]; - f["Version"] = entry["Version"]; - f["Installed"] = entry["Installed"]; - f["Repository"] = repo["Name"];*/ + f["RepositoryName"] = repo["Name"]; + f["RepositoryURI"] = repo["Uri"]; features.push(f); });