Skip to content

Commit

Permalink
More work on #32, can create new config files in a profile
Browse files Browse the repository at this point in the history
  • Loading branch information
gashcrumb committed May 10, 2013
1 parent fbcda54 commit 10d0f6a
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 87 deletions.
85 changes: 0 additions & 85 deletions hawtio-web/src/main/webapp/app/fabric/html/profile-details.html

This file was deleted.

104 changes: 103 additions & 1 deletion hawtio-web/src/main/webapp/app/fabric/html/profile.html
Expand Up @@ -18,7 +18,109 @@ <h2 style="display: inline;">Version: <a ng-href="#/fabric/profiles?pv={{version
</div>

<div class="row-fluid">
<div ng-include src="'app/fabric/html/profile-details.html'"></div>

<div class="span2">
<ul class="unstyled">
<li>
<strong>Abstract:</strong> {{row.abstractProfile}}
</li>
<li>
<strong>Locked:</strong> {{row.locked}}
</li>
</ul>
<dl ng-show="row.parentIds.length > 0">
<dt>Parents:</dt>
<dd>
<ul class="unstyled">
<li ng-repeat="profile in row.parentIds">
<a href="#/fabric/profile/{{versionId}}/{{profile}}{{hash}}">{{profile}}</a>
</li>
</ul>
</dd>
</dl>
<dl ng-show="row.childIds.length > 0">
<dt>Children:</dt>
<dd>
<ul class="unstyled">
<li ng-repeat="profile in row.childIds">
<a href="#/fabric/profile/{{versionId}}/{{profile}}{{hash}}">{{profile}}</a>
</li>
</ul>
</dd>
</dl>
</div>
<div class="span4">
<dl>
<dt>Features ({{row.features.length}}):</dt>
<dd>
<ul class="unstyled">
<li ng-repeat="feature in row.features">
{{feature}}
</li>
</ul>
</dd>
</dl>
<dl>
<dt>Fuse Application Bundles ({{row.fabs.length}}):</dt>
<dd>
<ul class="unstyled">
<li ng-repeat="fab in row.fabs">
{{fab}}
</li>
</ul>
</dd>
</dl>
<dl>
<dt>Bundles ({{row.bundles.length}}):</dt>
<dd>
<ul class="unstyled">
<li ng-repeat="bundle in row.bundles">
{{bundle}}
</li>
</ul>
</dd>
</dl>
</div>
<div class="span4">
<dl>
<dt>Feature Repositories ({{row.repositories.length}}):</dt>
<dd>
<ul class="unstyled">
<li ng-repeat="repository in row.repositories">
{{repository}}
</li>
</ul>
</dd>
</dl>
<dl>
<dt>Configuration Files ({{row.configurations.length}}):</dt>
<dd>
<ul class="unstyled">
<li ng-repeat="configuration in row.configurations">
<a href="#/fabric/profile/{{versionId}}/{{profileId}}/{{configuration}}">{{configuration}}</a>
</li>
</ul>
<button class="btn" ng-click="newFileDialog = true"><i class="icon-file-alt"></i> New</button>
</dd>
</dl>
</div>
</div>

<div modal="newFileDialog">
<form name="newFile" class="form-horizontal no-bottom-margin" ng-submit="doCreateFile()">
<div class="modal-header"><h4>Create new configuration file...</h4></div>
<div class="modal-body">
<label style="display: inline">File Name: </label>
<input name="id" class="input-xlarge" type="text" ng-model="newFileName" required ng-pattern="/^[.a-zA-Z0-9_-]*$/">
<span class="help-block" ng-show="newFile.id.$error.required">Please enter a file name</span>
<span class="help-block" ng-show="newFile.id.$error.pattern">File name can only contain letters, numbers, '-', '_' and '.'</span>
</div>
<div class="modal-footer">
<input class="btn btn-success" ng-disabled="!newFile.$valid" type="submit" value="Create">
<input class="btn btn-primary" ng-click="newFileDialog = false" value="Cancel">
</div>
</form>
</div>

</div>

4 changes: 4 additions & 0 deletions hawtio-web/src/main/webapp/app/fabric/js/helpers.ts
Expand Up @@ -14,6 +14,10 @@ module Fabric {
}
}

export function newConfigFile(jolokia, version, profile, pid, success, error) {
doAction('setConfigurationFile(java.lang.String, java.lang.String, java.lang.String, [B)', jolokia, [version, profile, pid, []], success, error);
}

export function saveConfigFile(jolokia, version, profile, pid, data, success, error) {
doAction('setConfigurationFile(java.lang.String, java.lang.String, java.lang.String, [B)', jolokia, [version, profile, pid, data], success, error);
}
Expand Down
15 changes: 14 additions & 1 deletion hawtio-web/src/main/webapp/app/fabric/js/profile.ts
@@ -1,8 +1,11 @@
module Fabric {

export function ProfileController($scope, workspace:Workspace, $routeParams, jolokia) {
export function ProfileController($scope, $routeParams, jolokia, $location) {
$scope.versionId = $routeParams.versionId;
$scope.profileId = $routeParams.profileId;

$scope.newFileDialog = false;
$scope.newFileName = '';

if (angular.isDefined($scope.versionId) && angular.isDefined($scope.profileId)) {

Expand All @@ -13,6 +16,16 @@ module Fabric {
}, onSuccess(render));

}

$scope.doCreateFile = () => {
$scope.newFileDialog = false;
newConfigFile(jolokia, $scope.versionId, $scope.profileId, $scope.newFileName, () => {
notification('success', 'Created new configuration file ' + $scope.newFileName);
$location.path("/fabric/profile/" + $scope.versionId + "/" + $scope.profileId + "/" + $scope.newFileName);
}, (response) => {
notification('error', 'Failed to create ' + $scope.newFileName + ' due to ' + response.error);
})
}

function render(response) {
if (!Object.equal($scope.row, response.value)) {
Expand Down

0 comments on commit 10d0f6a

Please sign in to comment.