Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
First cut of fabric:create UI for #329
  • Loading branch information
gashcrumb committed Jul 30, 2013
1 parent eacc9db commit afbab6f
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 5 deletions.
20 changes: 20 additions & 0 deletions hawtio-web/src/main/webapp/app/fabric/html/createFabric.html
@@ -0,0 +1,20 @@
<div ng-controller="Fabric.CreateFabricController">


<div class="row-fluid">

<div class="span5">
<div simple-form name='create_fabric' data='schema' entity='entity'></div>
</div>

<div class="span5">
<h2>No Fabric Detected!</h2>
<p>It appears that fabric has not yet been initialized. Please configure your fabric and click the "Create" button to continue</p>
<p class="centered"><button class="btn btn-success" hawtio-submit="create_fabric"><i class="icon-ok" ng-disabled="!forms.create_fabric.$valid"></i> Create Fabric</button></p>
</div>

</div>



</div>
11 changes: 7 additions & 4 deletions hawtio-web/src/main/webapp/app/fabric/html/layoutFabric.html
@@ -1,5 +1,8 @@
<ul class="nav nav-tabs" ng-controller="Fabric.NavBarController">
<li ng-class='{active : isActive("#/fabric/view")}'>
<li ng-hide="hasFabric" ng-class='{active : isActive("#/fabric/create")}'>
<a ng-href="#/fabric/create{{hash}}">Create Fabric</a>
</li>
<li ng-show="hasFabric" ng-class='{active : isActive("#/fabric/view")}'>
<a ng-href="#/fabric/view{{hash}}">Overview</a>
</li>
<!--
Expand All @@ -10,7 +13,7 @@
<a ng-href="#/fabric/containers{{hash}}">Containers</a>
</li>
-->
<li ng-class='{active : isActive("#/fabric/clusters")}' ng-disabled="!Fabric.getZooKeeperFacadeMBean(workspace)">
<li ng-show="hasFabric" ng-class='{active : isActive("#/fabric/clusters")}' ng-disabled="!Fabric.getZooKeeperFacadeMBean(workspace)">
<a ng-href="{{clusterLink()}}" title="View the web application, messaging and integration clusters in this fabric">Clusters</a>
</li>
<li ng-show="kibanaHref">
Expand All @@ -19,13 +22,13 @@
<li ng-show="hasMetrics">
<a ng-href="#/insight/all" title="View the metrics of the containers in this fabric">Metrics</a>
</li>
<li ng-class='{active : isActive("#/fabric/map")}'>
<li ng-show="hasFabric" ng-class='{active : isActive("#/fabric/map")}'>
<a ng-href="#/fabric/map{{hash}}" title="View the containers on a google map">Map</a>
</li>
<li ng-show="droolsHref">
<a ng-href="{{droolsHref}}" target="drools" title="View and manage the rules and workflows in this Fabric">Rules</a>
</li>
<li ng-show="canUpload" ng-class='{active : isActive("#/fabric/patching")}'>
<li ng-show="hasFabric" ng-show="canUpload" ng-class='{active : isActive("#/fabric/patching")}'>
<a ng-href="#/fabric/patching" title="Upload and apply patches to this fabric">Patching</a>
</li>
</ul>
Expand Down
42 changes: 42 additions & 0 deletions hawtio-web/src/main/webapp/app/fabric/js/createFabric.ts
@@ -0,0 +1,42 @@
module Fabric {

export function CreateFabricController($scope, jolokia, $location) {

Fabric.schemaConfigure();

$scope.schema = (<any>window).org_fusesource_fabric_api_CreateEnsembleOptions;

$scope.entity = {
zooKeeperServerPort: 2181,
globalResolver: 'localhostname',
resolver: 'localhostname',
agentEnabled: true,
autoImportEnabled: true,
minimumPort: 0,
maximumPort: 65535,
profiles: ['fabric', 'hawtio']
};

$scope.forms = {};

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

jolokia.execute(Fabric.clusterManagerMBean, 'createCluster(java.util.List, java.util.Map)', null, angular.toJson(json), {
method: 'post',
success: (response) => {
notification('success', "Created fabric!");
$location.url("/fabric/overview");
Core.$apply($scope);
},
error: (response) => {
notification('error', "Error creating fabric: " + response.error);
Core.$apply($scope);
}
});
}


console.log("window: ", (<any>window).org_fusesource_fabric_api_CreateEnsembleOptions);
}

}
3 changes: 2 additions & 1 deletion hawtio-web/src/main/webapp/app/fabric/js/fabricPlugin.ts
Expand Up @@ -7,6 +7,7 @@ module Fabric {

angular.module('fabric', ['bootstrap', 'ui.bootstrap', 'ui.bootstrap.dialog', 'ngResource', 'ngGrid', 'hawtio-forms', 'hawtioCore', 'ngDragDrop']).config(($routeProvider) => {
$routeProvider.
when('/fabric/create', {templateUrl: templatePath + 'createFabric.html'}).
when('/fabric/containers/createContainer', {templateUrl: templatePath + 'createContainer.html' , reloadOnSearch: false }).
when('/fabric/map', {templateUrl: templatePath + 'map.html'}).
when('/fabric/clusters/*page', {templateUrl: templatePath + 'clusters.html'}).
Expand All @@ -31,7 +32,7 @@ module Fabric {
viewRegistry['fabric'] = templatePath + 'layoutFabric.html';

try {
var id = jolokia.getAttribute('org.fusesource.fabric:type=Fabric', 'CurrentContainerName', {timeout: 1});
var id = jolokia.getAttribute(Fabric.managerMBean, 'CurrentContainerName', {timeout: 1});
if (id) {
pageTitle.push(id);
}
Expand Down
1 change: 1 addition & 0 deletions hawtio-web/src/main/webapp/app/fabric/js/helpers.ts
@@ -1,6 +1,7 @@
module Fabric {

export var managerMBean = "org.fusesource.fabric:type=Fabric";
export var clusterManagerMBean = "org.fusesource.fabric:type=ClusterServiceManager";

export function initScope($scope, workspace) {
$scope.hasFabricWiki = () => {
Expand Down
9 changes: 9 additions & 0 deletions hawtio-web/src/main/webapp/app/fabric/js/navbar.ts
Expand Up @@ -22,6 +22,15 @@ module Fabric {
Fabric.containerWebAppURL(jolokia, "drools-wb-distribution-wars", containerId, onDroolsUrl, onDroolsUrl);
$scope.hasMetrics = workspace.treeContainsDomainAndProperties('org.elasticsearch', {service: 'restjmx'});
$scope.canUpload = workspace.treeContainsDomainAndProperties('io.hawt.jmx', {type: 'UploadManager'});
var ensembleContainers = jolokia.getAttribute(Fabric.clusterManagerMBean, "EnsembleContainers");
if (!ensembleContainers || ensembleContainers.length == 0) {
$scope.hasFabric = false;
} else {
$scope.hasFabric = true;
}
if (!$scope.hasFabric) {
$location.url("/fabric/create");
}
}

function onKibanaUrl(response) {
Expand Down
23 changes: 23 additions & 0 deletions hawtio-web/src/main/webapp/app/fabric/js/schemaConfigure.ts
Expand Up @@ -14,6 +14,24 @@ module Fabric {
Core.pathSet(org_fusesource_fabric_api_CreateSshContainerOptions, ["properties", name, "required"], true);
});

var tmp = (<any>window).org_fusesource_fabric_api_CreateEnsembleOptions;

angular.forEach(["username", "password", "role"], (name) => {
Core.pathSet(tmp, ["properties", name, "type"], 'string');
Core.pathSet(tmp, ["properties", name, "required"], true);
});

var resolverEnum = ['localip', 'localhostname', 'publicip', 'publichostname', 'manualip'];

angular.forEach([org_fusesource_fabric_api_CreateChildContainerOptions, org_fusesource_fabric_api_CreateJCloudsContainerOptions, org_fusesource_fabric_api_CreateSshContainerOptions, tmp], (schema) => {
angular.forEach(['globalResolver', 'resolver'], (name) => {
Core.pathSet(tmp, ['properties', name, 'enum'], resolverEnum);
});
});

Core.pathSet(tmp, ['properties', 'password', 'password'], true);
delete tmp['properties']['users'];

// use tabs to reorder the fields
org_fusesource_fabric_api_CreateChildContainerOptions["tabs"] = {
'Default': ['name', '*']
Expand All @@ -25,5 +43,10 @@ module Fabric {
'Default': ['name', '*']
};

tmp['tabs'] = {
'Basic': ['username', 'password', 'role', 'zookeeperPassword', 'zooKeeperServerPort', 'globalResolver', 'resolver', 'manualIp'],
'Advanced': ['*']
};

}
}

0 comments on commit afbab6f

Please sign in to comment.