Merge pull request #5448 from ryanpetrello/remove-computed-group-and-host-fields

remove computed inventory fields from Host and Group

Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
softwarefactory-project-zuul[bot]
2020-01-15 19:53:30 +00:00
committed by GitHub
26 changed files with 177 additions and 545 deletions

View File

@@ -598,6 +598,11 @@ table, tbody {
}
.List-staticColumnLayout--groups {
display: grid;
grid-template-columns: @at-space @at-space-5x auto;
}
.List-staticColumnLayout--hostNestedGroups {
display: grid;
grid-template-columns: @at-space @at-space-5x @at-space-5x auto;
}

View File

@@ -39,7 +39,7 @@ export default
label: i18n._("Hosts")
},
{
url: "/#/hosts?host_search=has_active_failures:true",
url: "/#/hosts?host_search=last_job_host_summary__failed:true",
number: scope.data.hosts.failed,
label: i18n._("Failed Hosts"),
isFailureCount: true

View File

@@ -5,11 +5,9 @@
*************************************************/
export default
['$scope', '$rootScope', '$state', '$stateParams', 'HostsRelatedGroupsList', 'InventoryUpdate',
'CancelSourceUpdate', 'rbacUiControlService', 'GetBasePath',
'GetHostsStatusMsg', 'Dataset', 'Find', 'QuerySet', 'inventoryData', 'host', 'GroupsService',
'CancelSourceUpdate', 'rbacUiControlService', 'GetBasePath', 'Dataset', 'Find', 'QuerySet', 'inventoryData', 'host', 'GroupsService',
function($scope, $rootScope, $state, $stateParams, HostsRelatedGroupsList, InventoryUpdate,
CancelSourceUpdate, rbacUiControlService, GetBasePath,
GetHostsStatusMsg, Dataset, Find, qs, inventoryData, host, GroupsService){
CancelSourceUpdate, rbacUiControlService, GetBasePath, Dataset, Find, qs, inventoryData, host, GroupsService){
let list = HostsRelatedGroupsList;
@@ -29,27 +27,6 @@
$scope[`${list.iterator}_dataset`] = Dataset.data;
$scope[list.name] = $scope[`${list.iterator}_dataset`].results;
$scope.$watchCollection(list.name, function(){
_.forEach($scope[list.name], buildStatusIndicators);
});
}
function buildStatusIndicators(group){
if (group === undefined || group === null) {
group = {};
}
let hosts_status;
hosts_status = GetHostsStatusMsg({
active_failures: group.hosts_with_active_failures,
total_hosts: group.total_hosts,
inventory_id: $scope.inventory_id,
group_id: group.id
});
_.assign(group,
{hosts_status_tip: hosts_status.tooltip},
{hosts_status_class: hosts_status.class});
}
$scope.editGroup = function(id){

View File

@@ -1,33 +0,0 @@
export default
['i18n', function(i18n) {
return function(params) {
var active_failures = params.active_failures,
total_hosts = params.total_hosts,
tip, failures, html_class;
// Return values for use on host status indicator
if (active_failures > 0) {
tip = total_hosts + ((total_hosts === 1) ? ' host' : ' hosts') + '. ' + active_failures + i18n._(' with failed jobs.');
html_class = 'error';
failures = true;
} else {
failures = false;
if (total_hosts === 0) {
// no hosts
tip = i18n._("Contains 0 hosts.");
html_class = 'none';
} else {
// many hosts with 0 failures
tip = total_hosts + ((total_hosts === 1) ? ' host' : ' hosts') + '. ' + i18n._('No job failures');
html_class = 'success';
}
}
return {
tooltip: tip,
failures: failures,
'class': html_class
};
};
}];

View File

@@ -18,22 +18,6 @@
basePath: 'api/v2/inventories/{{$stateParams.inventory_id}}/groups/',
layoutClass: 'List-staticColumnLayout--groups',
actionHolderClass: 'List-actionHolder List-actionHolder--rootGroups',
staticColumns: [
{
field: 'failed_hosts',
content: {
label: '',
nosort: true,
mode: 'all',
iconOnly: true,
awToolTip: "{{ group.hosts_status_tip }}",
dataPlacement: "top",
icon: "{{ 'fa icon-job-' + group.hosts_status_class }}",
columnClass: 'status-column'
}
}
],
fields: {
name: {
label: i18n._('Groups'),

View File

@@ -5,13 +5,11 @@
*************************************************/
export default
['$scope', '$state', '$stateParams', 'listDefinition', 'InventoryUpdate',
'GroupsService', 'CancelSourceUpdate',
'GetHostsStatusMsg', 'Dataset', 'inventoryData', 'canAdd',
'InventoryHostsStrings', '$transitions',
'GroupsService', 'CancelSourceUpdate', 'Dataset', 'inventoryData', 'canAdd',
'InventoryHostsStrings', '$transitions', 'GetBasePath', 'Rest',
function($scope, $state, $stateParams, listDefinition, InventoryUpdate,
GroupsService, CancelSourceUpdate,
GetHostsStatusMsg, Dataset, inventoryData, canAdd,
InventoryHostsStrings, $transitions){
GroupsService, CancelSourceUpdate, Dataset, inventoryData, canAdd,
InventoryHostsStrings, $transitions, GetBasePath, Rest){
let list = listDefinition;
@@ -70,18 +68,6 @@
group.isSelected = true;
}
});
let hosts_status;
hosts_status = GetHostsStatusMsg({
active_failures: group.hosts_with_active_failures,
total_hosts: group.total_hosts,
inventory_id: $scope.inventory_id,
group_id: group.id
});
_.assign(group,
{hosts_status_tip: hosts_status.tooltip},
{hosts_status_class: hosts_status.class});
}
$scope.createGroup = function(){
@@ -102,35 +88,51 @@
$state.go('inventories.edit.groups.edit.nested_groups', {group_id: id});
};
$scope.deleteGroup = function(group){
$scope.toDelete = {};
$scope.strings.deleteModal = {};
angular.extend($scope.toDelete, group);
if($scope.toDelete.total_groups === 0 && $scope.toDelete.total_hosts === 0) {
// This group doesn't have any child groups or hosts - the user is just trying to delete
// the group
$scope.deleteOption = "delete";
}
else {
$scope.strings.deleteModal.group = InventoryHostsStrings.get('deletegroup.GROUP', $scope.toDelete.total_groups);
$scope.strings.deleteModal.host = InventoryHostsStrings.get('deletegroup.HOST', $scope.toDelete.total_hosts);
const promises = [];
Rest.setUrl(group.related.hosts);
promises.push(Rest.get());
Rest.setUrl(group.related.children);
promises.push(Rest.get());
Promise.all(promises)
.then(([hostResponse, groupResponse]) => {
$scope.toDelete = {};
$scope.strings.deleteModal = {};
$scope.toDelete.hostCount = _.get(hostResponse, ['data', 'count'], 0);
$scope.toDelete.groupCount = _.get(groupResponse, ['data', 'count'], 0);
angular.extend($scope.toDelete, group);
if($scope.toDelete.groupCount === 0 && $scope.toDelete.hostCount === 0) {
// This group doesn't have any child groups or hosts - the user is just trying to delete
// the group
$scope.deleteOption = "delete";
}
else {
$scope.strings.deleteModal.group = InventoryHostsStrings.get('deletegroup.GROUP', $scope.toDelete.groupCount);
$scope.strings.deleteModal.host = InventoryHostsStrings.get('deletegroup.HOST', $scope.toDelete.hostCount);
if($scope.toDelete.groupCount === 0 || $scope.toDelete.groupCount === 0) {
if($scope.toDelete.groupCount === 0) {
$scope.strings.deleteModal.deleteGroupsHosts = InventoryHostsStrings.get('deletegroup.DELETE_HOST', $scope.toDelete.hostCount);
$scope.strings.deleteModal.promoteGroupsHosts = InventoryHostsStrings.get('deletegroup.PROMOTE_HOST', $scope.toDelete.hostCount);
}
else if($scope.toDelete.hostCount === 0) {
$scope.strings.deleteModal.deleteGroupsHosts = InventoryHostsStrings.get('deletegroup.DELETE_GROUP', $scope.toDelete.groupCount);
$scope.strings.deleteModal.promoteGroupsHosts = InventoryHostsStrings.get('deletegroup.PROMOTE_GROUP', $scope.toDelete.groupCount);
}
}
else {
$scope.strings.deleteModal.deleteGroupsHosts = InventoryHostsStrings.get('deletegroup.DELETE_GROUPS_AND_HOSTS', {groups: $scope.toDelete.groupCount, hosts: $scope.toDelete.hostCount});
$scope.strings.deleteModal.promoteGroupsHosts = InventoryHostsStrings.get('deletegroup.PROMOTE_GROUPS_AND_HOSTS', {groups: $scope.toDelete.groupCount, hosts: $scope.toDelete.hostCount});
}
}
$('#group-delete-modal').modal('show');
});
if($scope.toDelete.total_groups === 0 || $scope.toDelete.total_hosts === 0) {
if($scope.toDelete.total_groups === 0) {
$scope.strings.deleteModal.deleteGroupsHosts = InventoryHostsStrings.get('deletegroup.DELETE_HOST', $scope.toDelete.total_hosts);
$scope.strings.deleteModal.promoteGroupsHosts = InventoryHostsStrings.get('deletegroup.PROMOTE_HOST', $scope.toDelete.total_hosts);
}
else if($scope.toDelete.total_hosts === 0) {
$scope.strings.deleteModal.deleteGroupsHosts = InventoryHostsStrings.get('deletegroup.DELETE_GROUP', $scope.toDelete.total_groups);
$scope.strings.deleteModal.promoteGroupsHosts = InventoryHostsStrings.get('deletegroup.PROMOTE_GROUP', $scope.toDelete.total_groups);
}
}
else {
$scope.strings.deleteModal.deleteGroupsHosts = InventoryHostsStrings.get('deletegroup.DELETE_GROUPS_AND_HOSTS', {groups: $scope.toDelete.total_groups, hosts: $scope.toDelete.total_hosts});
$scope.strings.deleteModal.promoteGroupsHosts = InventoryHostsStrings.get('deletegroup.PROMOTE_GROUPS_AND_HOSTS', {groups: $scope.toDelete.total_groups, hosts: $scope.toDelete.total_hosts});
}
}
$('#group-delete-modal').modal('show');
};
$scope.confirmDelete = function(){
let reloadListStateParams = null;

View File

@@ -18,12 +18,10 @@
</div>
</div>
<div class="Modal-body">
<div ng-show="toDelete.total_groups > 0 || toDelete.total_hosts > 0">
<div ng-show="toDelete.groupCount > 0 || toDelete.hostCount > 0">
<div>
<p class="Prompt-bodyQuery">Deleting group <em>{{ toDelete.name }}</em>.
<span ng-show="toDelete.total_groups > 0 && toDelete.total_hosts > 0"> <translate>This group contains</translate> {{ toDelete.total_groups }} {{:: strings.deleteModal.group }} <translate>and</translate> {{ toDelete.total_hosts }} {{:: strings.deleteModal.host }}. </span>
<span ng-show="toDelete.total_groups == 0 && toDelete.total_hosts > 0"> <translate>This group contains</translate> {{ toDelete.total_hosts }} {{:: strings.deleteModal.host }}. </span>
<span ng-show="toDelete.total_groups > 0 && toDelete.total_hosts == 0"> <translate>This group contains</translate> {{ toDelete.total_groups }} {{:: strings.deleteModal.group }}. </span>
<span> <translate>This group contains at least one group or host</translate>.</span>
<translate>Delete or promote the group's children?</translate></p>
<div style="margin: 15px auto;">
@@ -43,13 +41,13 @@
</div>
</div>
<div ng-show="toDelete.total_groups == 0 && toDelete.total_hosts == 0">
<div ng-show="toDelete.groupCount == 0 && toDelete.hostCount == 0">
<div class="Prompt-bodyQuery" translate>Are you sure you want to permanently delete the group below from the inventory?</div>
<div class="Prompt-bodyTarget">{{ toDelete.name }}</div>
</div>
<div class="Modal-footer">
<a href="#" data-target="#group-delete-modal" data-dismiss="modal" id="prompt_cancel_btn_groups_list" class="btn Modal-defaultButton Modal-footerButton" translate>CANCEL</a>
<a href="" ng-class="promptActionBtnClass" ng-click="confirmDelete()" id="prompt_action_btn_groups_list" ng-disabled="!deleteOption && (toDelete.total_groups > 0 || toDelete.total_hosts > 0)" class="btn Modal-footerButton Modal-errorButton" translate>DELETE</a>
<a href="" ng-class="promptActionBtnClass" ng-click="confirmDelete()" id="prompt_action_btn_groups_list" ng-disabled="!deleteOption && (toDelete.groupCount > 0 || toDelete.hostCount > 0)" class="btn Modal-footerButton Modal-errorButton" translate>DELETE</a>
</div>
</div>
</div>

View File

@@ -9,7 +9,6 @@ import groupAdd from './add/main';
import groupEdit from './edit/main';
import groupFormDefinition from './groups.form';
import groupListDefinition from './groups.list';
import GetHostsStatusMsg from './factories/get-hosts-status-msg.factory';
import nestedGroups from './related/nested-groups/main';
import nestedHosts from './related/nested-hosts/main';
@@ -22,5 +21,4 @@ export default
nestedHosts.name
])
.factory('GroupForm', groupFormDefinition)
.factory('GroupList', groupListDefinition)
.factory('GetHostsStatusMsg', GetHostsStatusMsg);
.factory('GroupList', groupListDefinition);

View File

@@ -6,11 +6,11 @@
export default
['$scope', '$rootScope', '$state', '$stateParams', 'NestedGroupListDefinition', 'InventoryUpdate',
'GroupsService', 'CancelSourceUpdate', 'rbacUiControlService', 'GetBasePath',
'GetHostsStatusMsg', 'Dataset', 'Find', 'QuerySet', 'inventoryData', 'canAdd', 'groupData', 'ProcessErrors',
'Dataset', 'Find', 'QuerySet', 'inventoryData', 'canAdd', 'groupData', 'ProcessErrors',
'$transitions',
function($scope, $rootScope, $state, $stateParams, NestedGroupListDefinition, InventoryUpdate,
GroupsService, CancelSourceUpdate, rbacUiControlService, GetBasePath,
GetHostsStatusMsg, Dataset, Find, qs, inventoryData, canAdd, groupData, ProcessErrors,
Dataset, Find, qs, inventoryData, canAdd, groupData, ProcessErrors,
$transitions){
let list = NestedGroupListDefinition;
@@ -35,10 +35,6 @@
$scope.inventory_id = $stateParams.inventory_id;
$scope.$watchCollection(list.name, function(){
_.forEach($scope[list.name], processRow);
});
$scope.$on('selectedOrDeselected', function(e, value) {
let item = value.value;
@@ -57,30 +53,6 @@
}
function processRow(group){
if (group === undefined || group === null) {
group = {};
}
angular.forEach($scope.groupsSelected, function(selectedGroup){
if(selectedGroup.id === group.id) {
group.isSelected = true;
}
});
let hosts_status;
hosts_status = GetHostsStatusMsg({
active_failures: group.hosts_with_active_failures,
total_hosts: group.total_hosts,
inventory_id: $scope.inventory_id,
group_id: group.id
});
_.assign(group,
{hosts_status_tip: hosts_status.tooltip},
{hosts_status_class: hosts_status.class});
}
$scope.disassociateGroup = function(group){
$scope.toDisassociate = {};
angular.extend($scope.toDisassociate, group);

View File

@@ -17,22 +17,6 @@
trackBy: 'nested_group.id',
basePath: 'api/v2/groups/{{$stateParams.group_id}}/children/',
layoutClass: 'List-staticColumnLayout--groups',
staticColumns: [
{
field: 'failed_hosts',
content: {
label: '',
nosort: true,
mode: 'all',
iconOnly: true,
awToolTip: "{{ nested_group.hosts_status_tip }}",
dataPlacement: "top",
icon: "{{ 'fa icon-job-' + nested_group.hosts_status_class }}",
columnClass: 'status-column'
}
}
],
fields: {
name: {
label: i18n._('Groups'),

View File

@@ -6,10 +6,10 @@
export default
['$scope', '$rootScope', '$state', '$stateParams', 'HostNestedGroupListDefinition', 'InventoryUpdate',
'GroupsService', 'CancelSourceUpdate', 'rbacUiControlService', 'GetBasePath',
'GetHostsStatusMsg', 'Dataset', 'Find', 'QuerySet', 'inventoryData', 'canAdd', 'ProcessErrors', 'host',
'Dataset', 'Find', 'QuerySet', 'inventoryData', 'canAdd', 'ProcessErrors', 'host',
function($scope, $rootScope, $state, $stateParams, HostNestedGroupListDefinition, InventoryUpdate,
GroupsService, CancelSourceUpdate, rbacUiControlService, GetBasePath,
GetHostsStatusMsg, Dataset, Find, qs, inventoryData, canAdd, ProcessErrors, host){
Dataset, Find, qs, inventoryData, canAdd, ProcessErrors, host){
let list = HostNestedGroupListDefinition;
@@ -26,10 +26,6 @@
$scope[`${list.iterator}_dataset`] = Dataset.data;
$scope[list.name] = $scope[`${list.iterator}_dataset`].results;
$scope.$watchCollection(list.name, function(){
_.forEach($scope[list.name], buildStatusIndicators);
});
$scope.$on('selectedOrDeselected', function(e, value) {
let item = value.value;
@@ -48,24 +44,6 @@
}
function buildStatusIndicators(group){
if (group === undefined || group === null) {
group = {};
}
let hosts_status;
hosts_status = GetHostsStatusMsg({
active_failures: group.hosts_with_active_failures,
total_hosts: group.total_hosts,
inventory_id: $scope.inventory_id,
group_id: group.id
});
_.assign(group,
{hosts_status_tip: hosts_status.tooltip},
{hosts_status_class: hosts_status.class});
}
$scope.associateGroup = function() {
$state.go('.associate');
};

View File

@@ -16,7 +16,7 @@
multiSelect: true,
trackBy: 'nested_group.id',
basePath: 'api/v2/hosts/{{$stateParams.host_id}}/all_groups/',
layoutClass: 'List-staticColumnLayout--groups',
layoutClass: 'List-staticColumnLayout--hostNestedGroups',
staticColumns: [
{
field: 'failed_hosts',

View File

@@ -18,57 +18,6 @@
</div>
</div>
<div class="Modal-body">
<div ng-show="toDelete.total_groups > 0 || toDelete.total_hosts > 0">
<div>
<p class="Prompt-bodyQuery"><translate>Deleting group</translate> <em>{{ toDelete.name }}</em>.
<span ng-show="toDelete.total_groups > 0 && toDelete.total_hosts > 0"> <translate>This group contains</translate> {{ toDelete.total_groups }} <translate>groups and</translate> {{ toDelete.total_hosts }} <translate>hosts</translate>. </span>
<span ng-show="toDelete.total_groups == 0 && toDelete.total_hosts > 0"> <translate>This group contains</translate> {{ toDelete.total_hosts }} <translate>hosts</translate>. </span>
<span ng-show="toDelete.total_groups > 0 && toDelete.total_hosts == 0"> <translate>This group contains</translate> {{ toDelete.total_groups }} <translate>groups</translate>. </span>
<translate>Delete or promote the group's children?</translate></p>
<div style="margin: 15px auto;">
<div class="radio" ng-show="toDelete.total_groups > 0 && toDelete.total_hosts > 0">
<label>
<input type="radio" ng-model="deleteOption" value="promote"> <translate>Promote groups and hosts</translate>
</label>
</div>
<div class="radio" ng-show="toDelete.total_groups > 0 && toDelete.total_hosts > 0">
<label>
<input type="radio" ng-model="deleteOption" value="delete"> <translate>Delete groups and hosts</translate>
</label>
</div>
<div class="radio" ng-show="toDelete.total_groups > 0 && toDelete.total_hosts == 0">
<label>
<input type="radio" ng-model="deleteOption" value="promote"> <translate>Promote groups</translate>
</label>
</div>
<div class="radio" ng-show="toDelete.total_groups > 0 && toDelete.total_hosts == 0">
<label>
<input type="radio" ng-model="deleteOption" value="delete"> <translate>Delete groups</translate>
</label>
</div>
<div class="radio" ng-show="toDelete.total_groups == 0 && toDelete.total_hosts > 0">
<label>
<input type="radio" ng-model="deleteOption" value="promote"> <translate>Promote hosts</translate>
</label>
</div>
<div class="radio" ng-show="toDelete.total_groups == 0 && toDelete.total_hosts > 0">
<label>
<input type="radio" ng-model="deleteOption" value="delete"> <translate>Delete hosts</translate>
</label>
</div>
</div>
</div>
</div>
<div ng-show="toDelete.total_groups == 0 && toDelete.total_hosts == 0">
<div class="Prompt-bodyQuery" translate>Are you sure you want to permanently delete the inventory source below from the inventory?</div>
<div class="Prompt-bodyTarget">{{ toDelete.name }}</div>
</div>
<div class="Modal-footer">
<a href="#" data-target="#group-delete-modal" data-dismiss="modal" id="prompt_cancel_btn_groups_list" class="btn Modal-defaultButton Modal-footerButton" translate>CANCEL</a>
<a href="" ng-class="promptActionBtnClass" ng-click="confirmDelete()" id="prompt_action_btn_groups_list" class="btn Modal-footerButton Modal-errorButton" translate>DELETE</a>