mirror of https://github.com/portainer/portainer
feat(k8s): remove cluster status panel (#5570)
parent
f0a88b7367
commit
46ffca92fd
|
@ -1,21 +0,0 @@
|
|||
import _ from 'lodash-es';
|
||||
import { KubernetesComponentStatus } from './models';
|
||||
|
||||
export class KubernetesComponentStatusConverter {
|
||||
/**
|
||||
* Convert API data to KubernetesComponentStatus model
|
||||
*/
|
||||
static apiToModel(data) {
|
||||
const res = new KubernetesComponentStatus();
|
||||
res.ComponentName = data.metadata.name;
|
||||
|
||||
const healthyCondition = _.find(data.conditions, { type: 'Healthy' });
|
||||
if (healthyCondition && healthyCondition.status === 'True') {
|
||||
res.Healthy = true;
|
||||
} else if (healthyCondition && healthyCondition.status === 'False') {
|
||||
res.ErrorMessage = healthyCondition.message;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
/**
|
||||
* KubernetesComponentStatus Model
|
||||
*/
|
||||
const _KubernetesComponentStatus = Object.freeze({
|
||||
ComponentName: '',
|
||||
Healthy: false,
|
||||
ErrorMessage: '',
|
||||
});
|
||||
|
||||
export class KubernetesComponentStatus {
|
||||
constructor() {
|
||||
Object.assign(this, JSON.parse(JSON.stringify(_KubernetesComponentStatus)));
|
||||
}
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
angular.module('portainer.kubernetes').factory('KubernetesComponentStatus', [
|
||||
'$resource',
|
||||
'API_ENDPOINT_ENDPOINTS',
|
||||
'EndpointProvider',
|
||||
function KubernetesComponentStatusFactory($resource, API_ENDPOINT_ENDPOINTS, EndpointProvider) {
|
||||
'use strict';
|
||||
return function () {
|
||||
const url = API_ENDPOINT_ENDPOINTS + '/:endpointId/kubernetes/api/v1' + '/componentstatuses/:id';
|
||||
return $resource(
|
||||
url,
|
||||
{
|
||||
endpointId: EndpointProvider.endpointID,
|
||||
},
|
||||
{
|
||||
get: {
|
||||
method: 'GET',
|
||||
ignoreLoadingBar: true,
|
||||
},
|
||||
}
|
||||
);
|
||||
};
|
||||
},
|
||||
]);
|
|
@ -1,34 +0,0 @@
|
|||
import angular from 'angular';
|
||||
import PortainerError from 'Portainer/error';
|
||||
import _ from 'lodash-es';
|
||||
import { KubernetesComponentStatusConverter } from './converter';
|
||||
|
||||
class KubernetesComponentStatusService {
|
||||
/* @ngInject */
|
||||
constructor($async, KubernetesComponentStatus) {
|
||||
this.$async = $async;
|
||||
this.KubernetesComponentStatus = KubernetesComponentStatus;
|
||||
|
||||
this.getAsync = this.getAsync.bind(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* GET
|
||||
*/
|
||||
async getAsync() {
|
||||
try {
|
||||
const data = await this.KubernetesComponentStatus().get().$promise;
|
||||
const res = _.map(data.items, (item) => KubernetesComponentStatusConverter.apiToModel(item));
|
||||
return res;
|
||||
} catch (err) {
|
||||
throw new PortainerError('Unable to retrieve cluster status', err);
|
||||
}
|
||||
}
|
||||
|
||||
get() {
|
||||
return this.$async(this.getAsync);
|
||||
}
|
||||
}
|
||||
|
||||
export default KubernetesComponentStatusService;
|
||||
angular.module('portainer.kubernetes').service('KubernetesComponentStatusService', KubernetesComponentStatusService);
|
|
@ -25,34 +25,6 @@
|
|||
</form>
|
||||
<!-- !resource-reservation -->
|
||||
|
||||
<!-- cluster-status -->
|
||||
<div class="col-sm-12 form-section-title">
|
||||
Cluster status
|
||||
</div>
|
||||
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr class="text-muted">
|
||||
<td style="border-top: none; width: 25%;">Component</td>
|
||||
<td style="border-top: none; width: 25%;">Status</td>
|
||||
<td style="border-top: none; width: 50%;" ng-if="ctrl.hasUnhealthyComponentStatus">Error</td>
|
||||
</tr>
|
||||
<tr ng-repeat="cs in ctrl.componentStatuses">
|
||||
<td style="width: 25%;">
|
||||
{{ cs.ComponentName }}
|
||||
</td>
|
||||
<td style="width: 25%;">
|
||||
<span ng-if="cs.Healthy"><i class="fa fa-check green-icon" aria-hidden="true" style="margin-right: 2px;"></i> healthy</span>
|
||||
<span ng-if="!cs.Healthy"><i class="fa fa-exclamation-circle orange-icon" aria-hidden="true" style="margin-right: 2px;"></i> unhealthy</span>
|
||||
</td>
|
||||
<td ng-if="ctrl.hasUnhealthyComponentStatus" style="width: 50%;">
|
||||
{{ cs.ErrorMessage !== '' ? cs.ErrorMessage : '-' }}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<!-- !cluster-status -->
|
||||
|
||||
<!-- leader-status -->
|
||||
<div ng-if="ctrl.systemEndpoints.length > 0">
|
||||
<div class="col-sm-12 form-section-title">
|
||||
|
|
|
@ -15,7 +15,6 @@ class KubernetesClusterController {
|
|||
KubernetesNodeService,
|
||||
KubernetesMetricsService,
|
||||
KubernetesApplicationService,
|
||||
KubernetesComponentStatusService,
|
||||
KubernetesEndpointService
|
||||
) {
|
||||
this.$async = $async;
|
||||
|
@ -26,32 +25,16 @@ class KubernetesClusterController {
|
|||
this.KubernetesNodeService = KubernetesNodeService;
|
||||
this.KubernetesMetricsService = KubernetesMetricsService;
|
||||
this.KubernetesApplicationService = KubernetesApplicationService;
|
||||
this.KubernetesComponentStatusService = KubernetesComponentStatusService;
|
||||
this.KubernetesEndpointService = KubernetesEndpointService;
|
||||
|
||||
this.onInit = this.onInit.bind(this);
|
||||
this.getNodes = this.getNodes.bind(this);
|
||||
this.getNodesAsync = this.getNodesAsync.bind(this);
|
||||
this.getApplicationsAsync = this.getApplicationsAsync.bind(this);
|
||||
this.getComponentStatus = this.getComponentStatus.bind(this);
|
||||
this.getComponentStatusAsync = this.getComponentStatusAsync.bind(this);
|
||||
this.getEndpointsAsync = this.getEndpointsAsync.bind(this);
|
||||
this.hasResourceUsageAccess = this.hasResourceUsageAccess.bind(this);
|
||||
}
|
||||
|
||||
async getComponentStatusAsync() {
|
||||
try {
|
||||
this.componentStatuses = await this.KubernetesComponentStatusService.get();
|
||||
this.hasUnhealthyComponentStatus = _.find(this.componentStatuses, { Healthy: false }) ? true : false;
|
||||
} catch (err) {
|
||||
this.Notifications.error('Failure', err, 'Unable to retrieve cluster component statuses');
|
||||
}
|
||||
}
|
||||
|
||||
getComponentStatus() {
|
||||
return this.$async(this.getComponentStatusAsync);
|
||||
}
|
||||
|
||||
async getEndpointsAsync() {
|
||||
try {
|
||||
const endpoints = await this.KubernetesEndpointService.get();
|
||||
|
@ -152,14 +135,12 @@ class KubernetesClusterController {
|
|||
this.state = {
|
||||
applicationsLoading: true,
|
||||
viewReady: false,
|
||||
hasUnhealthyComponentStatus: false,
|
||||
useServerMetrics,
|
||||
};
|
||||
|
||||
await this.getNodes();
|
||||
if (this.isAdmin) {
|
||||
await this.getEndpoints();
|
||||
await this.getComponentStatus();
|
||||
await this.getApplications();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue