Skip to content

Commit

Permalink
Update and save the agent properties file
Browse files Browse the repository at this point in the history
  • Loading branch information
gashcrumb committed Jun 7, 2013
1 parent cf757e3 commit b2bea23
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 3 deletions.
11 changes: 9 additions & 2 deletions hawtio-web/src/main/webapp/app/fabric/html/editFeatures.html
Expand Up @@ -2,8 +2,15 @@

<div class="row-fluid">
<div class="span12">
<h2 style="display: inline;">/ <a ng-href="#/fabric/view?cv={{versionId}}&sp={{profileId}}">{{versionId}}</a> /
<a ng-href="#/fabric/profile/{{versionId}}/{{profileId}}">{{profileId}}</a> / Features</h2>
<div class="pull-left">
<h2 style="display: inline;">/ <a ng-href="#/fabric/view?cv={{versionId}}&sp={{profileId}}">{{versionId}}</a> /
<a ng-href="#/fabric/profile/{{versionId}}/{{profileId}}">{{profileId}}</a> / Features</h2>
</div>
<div class="pull-right">
<a class="btn" ng-disabled="deletingFeatures.length == 0 && addingFeatures.length == 0" href="" ng-click="save()"><i class="icon-save"></i> Save Changes</a>
<a class="btn" ng-href="#/fabric/profile/{{versionId}}/{{profileId}}">Done</a>
</div>

</div>
</div>

Expand Down
40 changes: 39 additions & 1 deletion hawtio-web/src/main/webapp/app/fabric/js/editFeatures.ts
Expand Up @@ -84,7 +84,6 @@ module Fabric {

$scope.$watch('selectedRepoJson', (newValue, oldValue) => {
if (newValue !== oldValue) {
console.log("selectedRepoJson: ", $scope.selectedRepoJson);
$scope.selectedRepoName = $scope.selectedRepoJson.name;
$scope.selectedRepoRepos = $scope.selectedRepoJson.repository;
$scope.selectedRepoFeatures = $scope.selectedRepoJson.feature;
Expand Down Expand Up @@ -183,6 +182,45 @@ module Fabric {
};


$scope.save = () => {
jolokia.request({
type: 'exec', mbean: managerMBean,
operation: 'getConfigurationFile(java.lang.String, java.lang.String, java.lang.String)',
arguments: [$scope.versionId, $scope.profileId, 'org.fusesource.fabric.agent.properties']
}, onSuccess($scope.doSave));
};


$scope.doSave = (response) => {
var configFile = response.value.decodeBase64();
var lines = configFile.lines();

if ($scope.deletingFeatures.length > 0) {
$scope.deletingFeatures.each((feature) => {
lines.remove((line) => {
return line.startsWith("feature." + feature.id);
});
});
}

if ($scope.addingFeatures.length > 0) {
$scope.addingFeatures.each((feature) => {
lines.add("feature." + feature.id + " = " + feature.id);
});
}

configFile = lines.join('\n');

saveConfigFile(jolokia, $scope.versionId, $scope.profileId, 'org.fusesource.fabric.agent.properties', configFile.encodeBase64(), () => {
notification('success', "Updated feature definitions...");
$scope.$apply();
}, (response) => {
notification('error', "Failed to save feature definitions due to " + response.error);
$scope.$apply();
});
};


Core.register(jolokia, $scope, [{
type: 'exec', mbean: managerMBean, operation: $scope.getProfileFeaturesOp,
arguments: [$scope.versionId, $scope.profileId]
Expand Down

0 comments on commit b2bea23

Please sign in to comment.