Skip to content

Commit

Permalink
Fix #418 and fix #486 and also disable selection/installing/uninstall…
Browse files Browse the repository at this point in the history
…ing if fabric is running
  • Loading branch information
gashcrumb committed Aug 19, 2013
1 parent 5e13e93 commit e43989d
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 71 deletions.
4 changes: 4 additions & 0 deletions hawtio-web/src/main/webapp/app/fabric/js/helpers.ts
Expand Up @@ -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);
Expand Down
6 changes: 1 addition & 5 deletions hawtio-web/src/main/webapp/app/fabric/js/navbar.ts
Expand Up @@ -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");
}
Expand Down
9 changes: 7 additions & 2 deletions hawtio-web/src/main/webapp/app/karaf/html/features.html
Expand Up @@ -5,10 +5,10 @@
<fieldset>
<div class="control-group inline-block">
<div class="btn-group">
<button ng-disabled="selectedFeatures.length == 0" class="btn" ng-click="install()"><i
<button ng-disabled="hasFabric || selectedFeatures.length == 0" class="btn" ng-click="install()"><i
class="icon-play-circle"></i> Start
</button>
<button ng-disabled="selectedFeatures.length == 0" class="btn" ng-click="uninstall()"><i
<button ng-disabled="hasFabric || selectedFeatures.length == 0" class="btn" ng-click="uninstall()"><i
class="icon-off"></i> Stop
</button>
</div>
Expand All @@ -18,6 +18,11 @@
<label for="repositories">Repositories: </label>
<select id="repositories" ng-model="repository" ng-options="v.id for v in repositories"></select>
</div>
&nbsp;
<div class="control-group inline-block">
<label for="installedOnly" title="Only show installed features">Installed only: </label>
<input type="checkbox" id="installedOnly" name="installedOnly" ng-model="installedOnly">
</div>
</fieldset>
</form>
</div>
Expand Down
146 changes: 87 additions & 59 deletions 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 = [];
Expand All @@ -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,
Expand All @@ -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: '<div class="ngCellText">{{row.getProperty(col.field)}}</div>',
width: 200
},
Expand All @@ -100,11 +120,19 @@ module Karaf {
cellTemplate: '<div class="ngCellText"><a href="#/osgi/feature/{{row.entity.Name}}/{{row.entity.Version}}">{{row.getProperty(col.field)}}</a></div>',
width: 200
},
{
field: 'RepositoryName',
displayName: 'Repository'
},
{
field: 'Installed',
displayName: 'Installed'
}
]
],
sortInfo: {
fields: ['Installed', 'RepositoryName'],
directions: ['asc', 'asc']
}
};

var featuresMBean = Karaf.getSelectionFeaturesMBean(workspace);
Expand Down
7 changes: 2 additions & 5 deletions hawtio-web/src/main/webapp/app/karaf/js/helpers.ts
Expand Up @@ -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);
});

Expand Down

0 comments on commit e43989d

Please sign in to comment.