ENTAXY-480 release version 1.8.3
This commit is contained in:
@ -0,0 +1,102 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* entaxy-management-plugin
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* ==========
|
||||
* 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.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
var Entaxy;
|
||||
(function (Entaxy) {
|
||||
Entaxy._module
|
||||
.run(AddHeaderTools);
|
||||
|
||||
function AddHeaderTools(HawtioExtension, $location, $http, $interval) {
|
||||
'ngInject';
|
||||
|
||||
let baseLocation = getBaseLocation();
|
||||
let path = '/system/health';
|
||||
let format = '?format=json';
|
||||
|
||||
HawtioExtension.add('context-selector', $scope => {
|
||||
let div = document.createElement('div');
|
||||
div.className = 'health-checks-status';
|
||||
div.appendChild(document.createTextNode('Health checks status:'));
|
||||
|
||||
return div;
|
||||
});
|
||||
|
||||
HawtioExtension.add('context-selector', $scope => {
|
||||
|
||||
let ref = document.createElement('a');
|
||||
ref.setAttribute('href', baseLocation + path);
|
||||
ref.setAttribute('target', '_blank');
|
||||
|
||||
let span = document.createElement('span');
|
||||
|
||||
changeSpanClassname();
|
||||
|
||||
ref.appendChild(span);
|
||||
|
||||
let updateStatus;
|
||||
|
||||
$scope.startUpdate = function() {
|
||||
if (angular.isDefined(updateStatus)) return;
|
||||
|
||||
updateStatus = $interval(changeSpanClassname, 15000);
|
||||
}
|
||||
|
||||
$scope.startUpdate();
|
||||
|
||||
$scope.stopUpdate = function() {
|
||||
if (angular.isDefined(updateStatus)) {
|
||||
$interval.cancel(updateStatus);
|
||||
updateStatus = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
$scope.$on('$destroy', function() {
|
||||
$scope.stopUpdate();
|
||||
});
|
||||
|
||||
function changeSpanClassname() {
|
||||
$http.get(baseLocation + path + format).then(
|
||||
(response) => {
|
||||
let status = response.data.overallResult;
|
||||
|
||||
if (status === 'OK') {
|
||||
span.className = 'health-checks pficon pficon-ok';
|
||||
} else if (status === 'WARN') {
|
||||
span.className = 'health-checks pficon pficon-warning-triangle-o';
|
||||
} else {
|
||||
span.className = 'health-checks pficon pficon-error-circle-o';
|
||||
}
|
||||
},
|
||||
(error) => {
|
||||
Entaxy.log.error('Unable to get health checks status');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return ref;
|
||||
});
|
||||
|
||||
function getBaseLocation() {
|
||||
let port = $location.port();
|
||||
return $location.protocol() + '://' + $location.host() + (port ? (':' + port) : '');
|
||||
}
|
||||
}
|
||||
AddHeaderTools.$inject = ['HawtioExtension', '$location', '$http', '$interval'];
|
||||
|
||||
})(Entaxy || (Entaxy = {}));
|
Reference in New Issue
Block a user