Commit b9400eee by Steve Oakey Committed by Johannes Edmeier

Adds Flyway Support

Adds an application view that displays a table of Flyway migrations as retrieved from the /flyway Actuator endpoint. The module is conditional on this endpoint being available. Fixes gh-206
parent 90405067
/*
* Copyright 2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';
module.exports = function ($scope, $http, application) {
'ngInject';
$scope.migrations = [];
$scope.successStates = ['BASELINE', 'MISSING_SUCCESS', 'SUCCESS', 'OUT_OF_ORDER', 'FUTURE_SUCCESS'];
$scope.warningStates = ['PENDING', 'ABOVE_TARGET', 'PREINIT', 'BELOW_BASELINE', 'IGNORED'];
$scope.failedStates = ['MISSING_FAILED', 'FAILED', 'FUTURE_FAILED'];
$scope.searchFilter;
$scope.refresh = function () {
$http.get('/api/applications/' + application.id + '/flyway').then(function (response) {
$scope.migrations = response.data;
});
};
$scope.refresh();
$scope.inArray = function(migrationStatus, statusArray) {
return statusArray.indexOf(migrationStatus) !== -1;
};
};
/*
* Copyright 2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';
var angular = require('angular');
var module = angular.module('sba-applications-flyway', ['sba-applications']);
global.sbaModules.push(module.name);
module.controller('flywayCtrl', require('./controllers/flywayCtrl.js'));
module.config(function ($stateProvider) {
$stateProvider.state('applications.flyway', {
url: '/flyway',
templateUrl: 'applications-flyway/views/flyway.html',
controller: 'flywayCtrl'
});
});
module.run(function (ApplicationViews, $http, $sce) {
ApplicationViews.register({
order: 100,
title: $sce.trustAsHtml('<i class="fa fa-database fa-fw"></i>Flyway'),
state: 'applications.flyway',
show: function (application) {
if (!application.managementUrl || !application.statusInfo.status || application.statusInfo.status === 'OFFLINE') {
return false;
}
return $http.head('api/applications/' + application.id + '/flyway').then(function () {
return true;
}).catch(function () {
return false;
});
}
});
});
<div class="input-append">
<input placeholder="Filter" class="input-xxlarge" type="search" ng-model="searchFilter" />
<button class="btn" title="reload list" ng-click="refresh()"><i class="fa fa-repeat"></i></button>
</div>
<sba-info-panel title="Flyway Migrations" raw="api/applications/{{ application.id }}/flyway">
<table class="table">
<thead>
<th>Type</th>
<th>Checksum</th>
<th>Version</th>
<th>Description</th>
<th>Script</th>
<th>State</th>
<th>Installed</th>
<th>Execution Time</th>
</thead>
<tbody>
<tr ng-repeat="migration in migrations | filter:searchFilter">
<td ng-bind="migration.type"></td>
<td ng-bind="migration.checksum"></td>
<td ng-bind="migration.version"></td>
<td ng-bind="migration.description"></td>
<td ng-bind="migration.script"></td>
<td><span class="label" ng-class="{
'label-success': inArray(migration.state, successStates),
'label-warning': inArray(migration.state, warningStates),
'label-danger': inArray(migration.state, failedStates)}" ng-bind="migration.state"></span></td>
<td ng-bind="migration.installedOn | date:'dd.MM.yyyy HH:mm:ss.sss'"></td>
<td ng-bind="migration.executionTime + 'ms'"></td>
</tr>
</tbody>
</table>
</sba-info-panel>
...@@ -49,7 +49,7 @@ public class ApplicationRouteLocator implements RefreshableRouteLocator { ...@@ -49,7 +49,7 @@ public class ApplicationRouteLocator implements RefreshableRouteLocator {
private String prefix; private String prefix;
private String servletPath; private String servletPath;
private String[] proxyEndpoints = { "env", "metrics", "trace", "dump", "jolokia", "info", private String[] proxyEndpoints = { "env", "metrics", "trace", "dump", "jolokia", "info",
"configprops", "trace", "activiti", "logfile", "refresh" }; "configprops", "trace", "activiti", "logfile", "refresh", "flyway" };
public ApplicationRouteLocator(String servletPath, ApplicationRegistry registry, public ApplicationRouteLocator(String servletPath, ApplicationRegistry registry,
String prefix) { String prefix) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment