Skip to content

Commit

Permalink
Fix #461
Browse files Browse the repository at this point in the history
  • Loading branch information
gashcrumb committed Aug 12, 2013
1 parent 22d828e commit 70849eb
Show file tree
Hide file tree
Showing 5 changed files with 152 additions and 183 deletions.
21 changes: 0 additions & 21 deletions hawtio-web/pom.xml
Expand Up @@ -415,15 +415,6 @@
<org.fusesource.fabric.api.CreateEnsembleOptions>
${schema-outdir}/createEnsembleOptions.js
</org.fusesource.fabric.api.CreateEnsembleOptions>
<org.fusesource.fabric.api.CreateChildContainerOptions>
${schema-outdir}/createChildContainerOptions.js
</org.fusesource.fabric.api.CreateChildContainerOptions>
<org.fusesource.fabric.service.ssh.CreateSshContainerOptions>
${schema-outdir}/createSshContainerOptions.js
</org.fusesource.fabric.service.ssh.CreateSshContainerOptions>
<org.fusesource.fabric.service.jclouds.CreateJCloudsContainerOptions>
${schema-outdir}/createJcloudsContainerOptions.js
</org.fusesource.fabric.service.jclouds.CreateJCloudsContainerOptions>
<io.hawt.dozer.schema.Mappings>
${schema-outdir}/dozerMappings.js
</io.hawt.dozer.schema.Mappings>
Expand All @@ -439,18 +430,6 @@
</classes>
</configuration>
<dependencies>
<dependency>
<groupId>org.fusesource.fabric</groupId>
<artifactId>fabric-core-agent-ssh</artifactId>
<version>${fabric-version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.fusesource.fabric</groupId>
<artifactId>fabric-core-agent-jclouds</artifactId>
<version>${fabric-version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.fusesource.fabric</groupId>
<artifactId>fabric-core</artifactId>
Expand Down
31 changes: 9 additions & 22 deletions hawtio-web/src/main/webapp/app/fabric/html/createContainer.html
Expand Up @@ -5,35 +5,22 @@
<a class='btn' ng-href="#/fabric/view"><i class='icon-remove'></i> Cancel</a>
</div>
<div class="pull-right" ng-switch="activeTab">
<button ng-switch-when='org_fusesource_fabric_api_CreateChildContainerOptions' class='btn pull-right' ng-href="" hawtio-submit='create_child_container'
ng-disabled="!forms.create_child_container.$valid">
<i class="icon-ok"></i> Create Child Container</button>
<button ng-switch-when='org_fusesource_fabric_service_ssh_CreateSshContainerOptions' class='btn pull-right' ng-href="" hawtio-submit='create_ssh_container'
ng-disabled="!forms.create_ssh_container.$valid">
<i class="icon-ok"></i> Create SSH Container</button>
<button ng-switch-when='org_fusesource_fabric_service_jclouds_CreateJCloudsContainerOptions' class='btn pull-right' ng-href="" hawtio-submit='create_cloud_container'
ng-disabled="!forms.create_cloud_container.$valid">
<i class="icon-ok"></i> Create JCloud Container</button>
<button class='btn pull-right' hawtio-submit='create_container'
ng-disabled="!forms.create_container.$valid">
<i class="icon-ok"></i> Create Container</button>
</div>
</div>

<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_CreateChildContainerOptions'>
<div simple-form name='create_child_container' data='schema' entity='entity'></div>
</div>
<div class="tab-pane" title="SSH Container" value='org_fusesource_fabric_service_ssh_CreateSshContainerOptions'>
<div simple-form name='create_ssh_container' data='schema' entity='entity'></div>
</div>
<div class="tab-pane" title="Cloud Container" value='org_fusesource_fabric_service_jclouds_CreateJCloudsContainerOptions'>
<div simple-form name='create_cloud_container' data='schema' entity='entity'></div>
</div>
<div class="span6">
Method of container creation:
<select ng-model="selectedProvider" ng-options="key for (key, value) in providers"></select>
<div id="create-form">
<div simple-form name="create_container" data="schema" entity="entity"></div>
</div>
</div>

<div class="span5">
<div class="span6">
<p>2. Select the target version and add the required profiles to deploy</p>
<div fabric-version-selector='selectedVersion'></div>
<div fabric-profile-selector='selectedProfiles' version-id='selectedVersion.id'></div>
Expand Down
100 changes: 42 additions & 58 deletions hawtio-web/src/main/webapp/app/fabric/js/createContainer.ts
@@ -1,13 +1,50 @@
module Fabric {

export function CreateContainerController($scope, $window, $location, workspace, jolokia, localStorage) {
export function CreateContainerController($scope, $element, $compile, $location, workspace, jolokia, localStorage) {

$scope.versionsOp = 'versions()';

$scope.activeTab = 'org_fusesource_fabric_api_CreateChildContainerOptions';

$scope.providers = Fabric.registeredProviders(jolokia);
$scope.selectedProvider = $scope.providers[Object.extended($scope.providers).keys().first()];
$scope.schema = {};
$scope.entity = {};

$scope.entity = {
number: 1
};

$scope.$watch('selectedProvider', (newValue, oldValue) => {
if (newValue) {
console.log("Selected provider: ", $scope.selectedProvider);
Fabric.getSchema($scope.selectedProvider.id, $scope.selectedProvider.className, jolokia, (schema) => {
$scope.schema = schema;
Core.$apply($scope);
});
}

}, true);

$scope.$watch('schema', (newValue, oldValue) => {
if (newValue !== oldValue) {

$scope.entity['providerType'] = $scope.selectedProvider.id;
$location.search('tab', $scope.selectedProvider.id);

switch($scope.selectedProvider.id) {

case 'child':
$scope.entity['jmxUser'] = localStorage['fabric.userName'];
$scope.entity['jmxPassword'] = localStorage['fabric.password'];
break;

case 'ssh':
break;

case 'jcloud':
break;
}
}
}, true);

$scope.response = {};

$scope.versions = [];
Expand All @@ -28,21 +65,7 @@ module Fabric {
$scope.init = () => {

var tab = $location.search()['tab'];
if (tab) {
switch(tab) {
case 'child':
$scope.activeTab = 'org_fusesource_fabric_api_CreateChildContainerOptions';
break;
case 'ssh':
$scope.activeTab = 'org_fusesource_fabric_service_ssh_CreateSshContainerOptions';
break;
case 'cloud':
$scope.activeTab = 'org_fusesource_fabric_service_jclouds_CreateJCloudsContainerOptions';
break;
default:
$scope.activeTab = 'org_fusesource_fabric_api_CreateChildContainerOptions';
}
}
$scope.selectedProvider = $scope.providers[tab];

var parentId = $location.search()['parentId'];
if (parentId) {
Expand Down Expand Up @@ -99,43 +122,6 @@ module Fabric {
});


$scope.renderForm = () => {

$scope.schema = Object.extended($window[$scope.activeTab]).clone();
$scope.schema.description = '';

angular.forEach($scope.schema.properties, (value, key) => {
if (!value) {
delete $scope.schema.properties[key];
}
});

$scope.entity['number'] = 1;

switch($scope.activeTab) {

case 'org_fusesource_fabric_api_CreateChildContainerOptions':
$scope.entity['providerType'] = 'child';
$scope.entity['jmxUser'] = localStorage['fabric.userName'];
$scope.entity['jmxPassword'] = localStorage['fabric.password'];

$location.search('tab', 'child');

break;

case 'org_fusesource_fabric_service_ssh_CreateSshContainerOptions':
$scope.entity['providerType'] = 'ssh';
$location.search('tab', 'ssh');
break;

case 'org_fusesource_fabric_service_jclouds_CreateJCloudsContainerOptions':
$scope.entity['providerType'] = 'jclouds';
$location.search('tab', 'cloud');
break;
}
}


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

if (json.saveJmxCredentials) {
Expand Down Expand Up @@ -177,8 +163,6 @@ module Fabric {
$location.url('/fabric/view');
}

$scope.$watch('activeTab', $scope.renderForm);

}

}
23 changes: 23 additions & 0 deletions hawtio-web/src/main/webapp/app/fabric/js/helpers.ts
Expand Up @@ -337,4 +337,27 @@ module Fabric {
Core.connectToServer(localStorage, options);

}

export function registeredProviders(jolokia) {
var providers = jolokia.execute(Fabric.managerMBean, 'registeredProviders()');
var answer = {};
angular.forEach(providers, (value, key) => {
answer[key] = {
id: key,
className: value
};
});
return answer;
}

export function getSchema(id, className, jolokia, cb) {
jolokia.execute('io.hawt.jsonschema:type=SchemaLookup', 'getSchemaForClass(java.lang.String)', className, {
success: (value) => {
cb(Fabric.customizeSchema(id, angular.fromJson(value)));
}
});
}



}

0 comments on commit 70849eb

Please sign in to comment.