Skip to content

Commit

Permalink
Little more work on #37 and kick off re-usable version selector
Browse files Browse the repository at this point in the history
  • Loading branch information
gashcrumb committed Jun 26, 2013
1 parent fa46521 commit 81d48b1
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 15 deletions.
Expand Up @@ -25,7 +25,7 @@
<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">
<li 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
9 changes: 6 additions & 3 deletions hawtio-web/src/main/webapp/app/fabric/html/patching.html
@@ -1,11 +1,14 @@
<div ng-controller="Fabric.PatchingController">

<div class="row-fluid">


<div class="span5">
<div class="span4">
<p>1) Upload 1 or more patch files to apply to this fabric</p>
<div hawtio-file-upload="files" target="patches"></div>
</div>
<div class="span4">
<p>2) Select what version to derive the new patched version from</p>
<div fabric-version-selector="targetVersion"></div>
</div>
</div>


Expand Down
@@ -0,0 +1 @@
<select ng-model="selectedVersion" ng-options="v.id for v in versions"></select>
28 changes: 18 additions & 10 deletions hawtio-web/src/main/webapp/app/fabric/js/fabricPlugin.ts
@@ -1,21 +1,29 @@
module Fabric {

export var jmxDomain = 'org.fusesource.fabric';

export var templatePath = 'app/fabric/html/';


angular.module('fabric', ['bootstrap', 'ui.bootstrap', 'ui.bootstrap.dialog', 'ngResource', 'ngGrid', 'hawtio-forms', 'hawtioCore', 'ngDragDrop']).config(($routeProvider) => {
$routeProvider.
when('/fabric/containers/createContainer', {templateUrl: 'app/fabric/html/createContainer.html' , reloadOnSearch: false }).
when('/fabric/map', {templateUrl: 'app/fabric/html/map.html'}).
when('/fabric/clusters/*page', {templateUrl: 'app/fabric/html/clusters.html'}).
when('/fabric/container/:containerId', {templateUrl: 'app/fabric/html/container.html'}).
when('/fabric/profile/:versionId/:profileId', {templateUrl: 'app/fabric/html/profile.html'}).
when('/fabric/profile/:versionId/:profileId/editFeatures', {templateUrl: 'app/fabric/html/editFeatures.html'}).
when('/fabric/profile/:versionId/:profileId/:fname', {templateUrl: 'app/fabric/html/pid.html'}).
when('/fabric/view', { templateUrl: 'app/fabric/html/fabricView.html', reloadOnSearch: false }).
when('/fabric/patching', { templateUrl: 'app/fabric/html/patching.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'}).
when('/fabric/container/:containerId', {templateUrl: templatePath + 'container.html'}).
when('/fabric/profile/:versionId/:profileId', {templateUrl: templatePath + 'profile.html'}).
when('/fabric/profile/:versionId/:profileId/editFeatures', {templateUrl: templatePath + 'editFeatures.html'}).
when('/fabric/profile/:versionId/:profileId/:fname', {templateUrl: templatePath + 'pid.html'}).
when('/fabric/view', { templateUrl: templatePath + 'fabricView.html', reloadOnSearch: false }).
when('/fabric/patching', { templateUrl: templatePath + 'patching.html' });
}).
directive('fabricVersionSelector', function() {
return new Fabric.VersionSelector();
}).

run(($location: ng.ILocationService, workspace: Workspace, jolokia, viewRegistry, pageTitle) => {

viewRegistry['fabric'] = "app/fabric/html/layoutFabric.html";
viewRegistry['fabric'] = templatePath + 'layoutFabric.html';

try {
var id = jolokia.getAttribute('org.fusesource.fabric:type=Fabric', 'CurrentContainerName', {timeout: 1});
Expand Down
5 changes: 5 additions & 0 deletions hawtio-web/src/main/webapp/app/fabric/js/patching.ts
Expand Up @@ -2,6 +2,11 @@ module Fabric {
export function PatchingController($scope, jolokia) {

$scope.files = [];
$scope.targetVersion = null;

$scope.$watch('targetVersion', (newValue, oldValue) => {
console.log("targetVersion: ", $scope.targetVersion);
});

}
}
@@ -0,0 +1,55 @@
module Fabric {

export class VersionSelector {

public restrict = 'A';
public replace = true;
public templateUrl = Fabric.templatePath + "versionSelector.html";


public scope = {
selectedVersion: '=fabricVersionSelector'
};


public controller = ($scope, $element, $attrs, jolokia) => {
$scope.versions = [];
$scope.responseJson = '';


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

}
}, true);


$scope.render = (response) => {
var responseJson = angular.toJson(response.value);
if ($scope.responseJson !== responseJson) {
$scope.responseJson = responseJson;
$scope.versions = response.value;
//$scope.$apply();
}
}


Core.register(jolokia, $scope, {
type: 'exec',
mbean: managerMBean,
operation: 'versions(java.util.List)',
arguments: [['id', 'defaultVersion']]
}, onSuccess($scope.render));


};

}

}
2 changes: 1 addition & 1 deletion hawtio-web/src/main/webapp/app/ui/js/fileUpload.ts
Expand Up @@ -31,7 +31,7 @@ module UI {
if ($scope.responseJson !== responseJson) {
$scope.responseJson = responseJson;
$scope.files = response.value;
$scope.$apply();
Core.$applyNowOrLater($scope);
}
}

Expand Down

0 comments on commit 81d48b1

Please sign in to comment.