feat(k8s): display namespace status and terminating namespaces (#5551)

refactor(k8s): use function instead of filter
pull/5550/head
Anthony Lapenna 3 years ago committed by GitHub
parent e4fe4f9a43
commit 8d157c2c33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -92,6 +92,13 @@
<i class="fa fa-sort-alpha-up" aria-hidden="true" ng-if="$ctrl.state.orderBy === 'Namespace.Name' && $ctrl.state.reverseOrder"></i> <i class="fa fa-sort-alpha-up" aria-hidden="true" ng-if="$ctrl.state.orderBy === 'Namespace.Name' && $ctrl.state.reverseOrder"></i>
</a> </a>
</th> </th>
<th>
<a ng-click="$ctrl.changeOrderBy('Namespace.Status')">
Status
<i class="fa fa-sort-alpha-down" aria-hidden="true" ng-if="$ctrl.state.orderBy === 'Namespace.Status' && !$ctrl.state.reverseOrder"></i>
<i class="fa fa-sort-alpha-up" aria-hidden="true" ng-if="$ctrl.state.orderBy === 'Namespace.Status' && $ctrl.state.reverseOrder"></i>
</a>
</th>
<th> <th>
<a ng-click="$ctrl.changeOrderBy('Quota')"> <a ng-click="$ctrl.changeOrderBy('Quota')">
Quota Quota
@ -124,6 +131,9 @@
<a ui-sref="kubernetes.resourcePools.resourcePool({ id: item.Namespace.Name })">{{ item.Namespace.Name }}</a> <a ui-sref="kubernetes.resourcePools.resourcePool({ id: item.Namespace.Name })">{{ item.Namespace.Name }}</a>
<span style="margin-left: 5px;" class="label label-info image-tag" ng-if="$ctrl.isSystemNamespace(item)">system</span> <span style="margin-left: 5px;" class="label label-info image-tag" ng-if="$ctrl.isSystemNamespace(item)">system</span>
</td> </td>
<td>
<span class="label label-{{ $ctrl.namespaceStatusColor(item.Namespace.Status) }}">{{ item.Namespace.Status }}</span>
</td>
<td> <i class="fa {{ item.Quota ? 'fa-toggle-on' : 'fa-toggle-off' }}" aria-hidden="true" style="margin-right: 2px;"></i> {{ item.Quota ? 'Yes' : 'No' }} </td> <td> <i class="fa {{ item.Quota ? 'fa-toggle-on' : 'fa-toggle-off' }}" aria-hidden="true" style="margin-right: 2px;"></i> {{ item.Quota ? 'Yes' : 'No' }} </td>
<td>{{ item.Namespace.CreationDate | getisodate }} {{ item.Namespace.ResourcePoolOwner ? 'by ' + item.Namespace.ResourcePoolOwner : '' }}</td> <td>{{ item.Namespace.CreationDate | getisodate }} {{ item.Namespace.ResourcePoolOwner ? 'by ' + item.Namespace.ResourcePoolOwner : '' }}</td>
<td ng-if="$ctrl.isAdmin"> <td ng-if="$ctrl.isAdmin">

@ -38,6 +38,17 @@ angular.module('portainer.docker').controller('KubernetesResourcePoolsDatatableC
return !ctrl.isSystemNamespace(item) || (ctrl.settings.showSystem && ctrl.isAdmin); return !ctrl.isSystemNamespace(item) || (ctrl.settings.showSystem && ctrl.isAdmin);
}; };
this.namespaceStatusColor = function(status) {
switch (status.toLowerCase()) {
case 'active':
return 'success';
case 'terminating':
return 'danger';
default:
return 'primary';
}
};
/** /**
* Do not allow system namespaces to be selected * Do not allow system namespaces to be selected
*/ */

@ -41,14 +41,11 @@ class KubernetesNamespaceService {
const data = await this.KubernetesNamespaces().get().$promise; const data = await this.KubernetesNamespaces().get().$promise;
const promises = _.map(data.items, (item) => this.KubernetesNamespaces().status({ id: item.metadata.name }).$promise); const promises = _.map(data.items, (item) => this.KubernetesNamespaces().status({ id: item.metadata.name }).$promise);
const namespaces = await $allSettled(promises); const namespaces = await $allSettled(promises);
const visibleNamespaces = _.map(namespaces.fulfilled, (item) => { const allNamespaces = _.map(namespaces.fulfilled, (item) => {
if (item.status.phase !== 'Terminating') { return KubernetesNamespaceConverter.apiToNamespace(item);
return KubernetesNamespaceConverter.apiToNamespace(item);
}
}); });
const res = _.without(visibleNamespaces, undefined); updateNamespaces(allNamespaces);
updateNamespaces(res); return allNamespaces;
return res;
} catch (err) { } catch (err) {
throw new PortainerError('Unable to retrieve namespaces', err); throw new PortainerError('Unable to retrieve namespaces', err);
} }

Loading…
Cancel
Save