Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Can now select container version/profiles and also added a button to …
…the profile detail page
  • Loading branch information
gashcrumb committed May 31, 2013
1 parent 4c61f8e commit 8cdc1de
Show file tree
Hide file tree
Showing 4 changed files with 145 additions and 8 deletions.
50 changes: 48 additions & 2 deletions hawtio-web/src/main/webapp/app/fabric/html/createContainer.html
Expand Up @@ -13,6 +13,7 @@

<div class="row-fluid">
<div class="span5">
<p>1. Select the container creation method and fill in the relevant details</p>
<div class="tabbable hawtio-form-tabs" ng-model=activeTab>
<div class="tab-pane" title="Child Container" value='org_fusesource_fabric_api_CreateContainerChildOptions'>
<div simple-form name='create-child-container' data='schema' entity='entity'></div>
Expand All @@ -28,12 +29,57 @@
</div>
</div>
</div>
<div class="span4">
<select ng-model="selectedVersion" ng-options="version.id for version in versions"></select>

<div class="span5">
<p>2. Select the target version and add the required profiles to deploy</p>
<form class="form-horizontal no-bottom-margin">
<fieldset>
<div class="control-group">
<label class="control-label">Version: </label>
<div class="controls">
<select ng-model="selectedVersion" ng-options="version.id for version in versions"></select>
</div>
</div>
<div class="control-group">
<label class="control-label">Profiles: </label>
<div class="controls">
<p>
<input class="search-query" type="text" placeholder="Filter..." ng-model="profileIdFilter">
</p>
<p>
<label class="checkbox" ng-repeat="profile in profiles" ng-show="profile.id.has(profileIdFilter)">
<input type="checkbox" ng-model="profile.selected"> {{profile.id}}
</label>
</p>
</div>
</fieldset>

</form>
</div>

</div>


<div modal="showAddProfileDialog">
<form name="addProfile" class="form-horizontal no-bottom-margin" ng-submit="addProfile()">
<div class="modal-header"><h4>Add profiles to container: {{row.id}}</h4></div>
<div class="modal-body">
<div class="control-group">

<label>Select one or more profiles to add to this container: </label>
<div class="controls">


</div>
</div>
<div class="modal-footer">
<input class="btn btn-success" type="submit" value="Add">
<input class="btn btn-primary" ng-click="showAddProfileDialog = false" value="Cancel">
</div>
</form>
</div>




</div>
1 change: 1 addition & 0 deletions hawtio-web/src/main/webapp/app/fabric/html/profile.html
Expand Up @@ -14,6 +14,7 @@ <h2 style="display: inline;">/ <a ng-href="#/fabric/view?cv={{versionId}}&sp={{r
</a>
</div>
<div class="pull-right">
<a class="btn" ng-href="#/fabric/containers/createContainer?versionId={{versionId}}&profileIds={{profileId}}"><i class="icon-truck"></i> Create Container</a>
<a ng-href="#/wiki/branch/{{versionId}}/view/{{row.id}}" class="btn" ng-show="hasFabricWiki()"
title="View, edit or create configuration files in this profile"><i class="icon-edit"></i> Configuration</a>
</div>
Expand Down
100 changes: 95 additions & 5 deletions hawtio-web/src/main/webapp/app/fabric/js/createContainer.ts
Expand Up @@ -9,12 +9,19 @@ module Fabric {

$scope.schema = {};
$scope.entity = {};
$scope.response = {};

$scope.versions = [];
$scope.selectedVersion = {};
$scope.profiles = [];

$scope.selectedVersion = undefined;

$scope.selectedProfiles = [];
$scope.selectedProfileIds = '';
$scope.selectedVersionId = '';
$scope.profileIdFilter = '';

$scope.response = {};
$scope.showAddProfileDialog = false;

$scope.init = () => {

Expand Down Expand Up @@ -45,34 +52,109 @@ module Fabric {
$scope.selectedVersionId = versionId;
}

var profileIds = $location.search()['profileIds'];
if (profileIds) {
$scope.selectedProfileIds = profileIds;
}

}

$scope.init();


$scope.$on('$routeUpdate', $scope.init);

$scope.$watch('selectedVersion', (oldValue, newValue) => {
$scope.$watch('versions', (newValue, oldValue) => {

if (newValue !== oldValue) {
if (!$scope.selectedVersion) {
if ($scope.selectedVersionId && $scope.selectedVersionId !== '') {
$scope.selectedVersion = $scope.versions.find((v) => { return v.id === $scope.selectedVersionId });
} else {
$scope.selectedVersion = $scope.versions.find((v) => {return v.defaultVersion });
}
console.log("$scope.selectedVersion: ", $scope.selectedVersion);
}
}

});


$scope.$watch('selectedVersion', (newValue, oldValue) => {
if (oldValue !== newValue) {
$scope.selectedVersionId = $scope.selectedVersion.id;
$scope.profiles = $scope.selectedVersion.profiles.map((p) => { return { id: p }; });
$location.search('versionId', $scope.selectedVersionId);
}
}, true);


$scope.$watch('profiles', (newValue, oldValue) => {

if (oldValue !== newValue) {
var sp = $scope.selectedProfileIds.split(',');
newValue.each((profile) => {

if(!angular.isDefined(profile.selected)) {

var selected = false;

if (oldValue) {
var p = oldValue.find((p) => { return p.id === profile.id });
if (p) {
selected = p.selected;
}
}

if (!selected && sp.length > 0) {
selected = sp.any(profile.id);
}

profile.selected = selected;
}
});
}
});


$scope.$watch('profiles', (newValue, oldValue) => {
if (newValue !== oldValue) {
$scope.selectedProfiles = $scope.profiles.filter((p) => { return p.selected });
}
}, true);


$scope.$watch('selectedProfiles', (newValue, oldValue) => {
if (oldValue !== newValue) {
$scope.selectedProfileIds = $scope.selectedProfiles.map((p) => { return p.id; }).join(',');
}
}, true);


$scope.$watch('selectedProfileIds', (newValue, oldValue) => {
$location.search('profileIds', $scope.selectedProfileIds);
});


$scope.render = (response) => {
if (!Object.equal($scope.response, response.value)) {
$scope.response = response.value;
$scope.versions = Object.clone($scope.response);
if (Object.equal($scope.selectedVersion, {})) {

if (!Object.equal($scope.selectedVersion, {})) {
console.log("versions: ", $scope.versions);
if ($scope.selectedVersionId !== '') {
$scope.selectedVersion = $scope.versions.find((v) => { return v.defaultVersion === true; });
} else {
$scope.selectedVersion = $scope.versions.find((v) => { return v.id === $scope.selectedVersionId; });
}
}

$scope.$apply();
}
}


$scope.renderForm = () => {

$scope.schema = Object.extended($window[$scope.activeTab]).clone();
Expand Down Expand Up @@ -127,13 +209,19 @@ module Fabric {
}
}


$scope.onSubmit = (json, form) => {

if ($scope.entity.saveJmxCredentials) {
localStorage['fabric.userName'] = $scope.entity.jmxUser;
localStorage['fabric.password'] = $scope.entity.jmxPassword;
}

json['version'] = $scope.selectedVersion.id;
if ($scope.selectedProfiles.length > 0) {
json['profiles'] = $scope.selectedProfiles.map((p) => { return p.id; });
}

jolokia.request({
type: 'exec', mbean: managerMBean,
operation: 'createContainers(java.util.Map)',
Expand All @@ -148,14 +236,16 @@ module Fabric {
if (!error) {
notification('success', "Successfully created containers");
}
$scope.$apply();
},
error: (response) => {
notification('error', "Error creating containers: " + response.error);
$scope.$apply();
}
});

notification('info', "Requesting that new container(s) be created");
$location.path('/fabric/view');
$location.url('/fabric/view');
}

$scope.$watch('activeTab', $scope.renderForm);
Expand Down
2 changes: 1 addition & 1 deletion hawtio-web/src/main/webapp/app/fabric/js/fabricView.ts
Expand Up @@ -703,7 +703,7 @@ module Fabric {


$scope.createChildContainer = (container) => {
$location.url('/fabric/containers/createContainer').search({ tab: 'child', 'parentId': container.id });
$location.url('/fabric/containers/createContainer').search({ 'tab': 'child', 'parentId': container.id });
};


Expand Down

0 comments on commit 8cdc1de

Please sign in to comment.