Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes 10334,BZ1217694 - Working indicator in products repository list #5268

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -22,6 +22,7 @@ angular.module('Bastion.products').controller('ProductRepositoriesController',
'enabled': true,
'full_result': true
});
repositoriesNutupane.masterOnly = true;

function getParams() {
return {
Expand All @@ -35,7 +36,7 @@ angular.module('Bastion.products').controller('ProductRepositoriesController',

function success(response) {
angular.forEach(response.task.input.target_ids, function (row) {
$scope.repositoriesTable.removeRow(row);
$scope.detailsTable.removeRow(row);
});
$scope.removingTasks.push(response.task.id);
}
Expand All @@ -49,8 +50,8 @@ angular.module('Bastion.products').controller('ProductRepositoriesController',
$scope.errorMessages = [];

$scope.checksums = [{name: translate('Default'), id: null}, {id: 'sha256', name: 'sha256'}, {id: 'sha1', name: 'sha1'}];
$scope.repositoriesTable = repositoriesNutupane.table;
$scope.repositoriesTable.removeRow = repositoriesNutupane.removeRow;
$scope.detailsTable = repositoriesNutupane.table;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to add:

repositoriesNutupane.masterOnly = true;

otherwise it throws javascript errors

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't met any errors even without this line. Could you please check it again with the latest commit if you still see any errors?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you get this error when performing a search

$scope.detailsTable.removeRow = repositoriesNutupane.removeRow;
repositoriesNutupane.query();

$scope.syncSelectedRepositories = function () {
Expand Down
@@ -1,36 +1,31 @@
<span page-title ng-model="product">{{ 'Repositories for Product:' | translate }} {{ product.name }}</span>

<section class="details details-full">
<div bst-alert="success" ng-show="removingTasks.length > 0" close="close($index)" ng-repeat="task in removingTasks">
<div>
<p translate>Removal of selected repositories initiated successfully. </p>
<div>
<a href="/foreman_tasks/tasks/{{task}}" translate>Click here to check the status of the task.</a>
<section ng-hide="panel.loading">
<div data-extend-template="layouts/details-nutupane.html">
<div data-block="header"> {{ 'Repositories' | translate }} </div>
<div data-block="messages">
<div bst-alert="success" ng-show="removingTasks.length > 0" close="close($index)" ng-repeat="task in removingTasks">
<div>
<p translate>Removal of selected repositories initiated successfully. </p>
<div><a href="/foreman_tasks/tasks/{{task}}" translate>Click here to check the status of the task.</a></div>
</div>
</div>
<div bst-alerts success-messages="successMessages" error-messages="errorMessages"></div>
<div bst-alert="danger" ng-show="warningMessages">
<strong translate>There were errors while removing the following Repositories:</strong>
<ol>
<li data-ng-repeat="message in warningMessages">
{{ message }}
</li>
</ol>
<a ui-sref="products.details.tasks.details({taskId: warningTaskId})" translate>Click here to see the task for the successful removals.</a>
</div>
</div>
</div>
<div bst-alerts success-messages="successMessages" error-messages="errorMessages"></div>
<div bst-alert="danger" ng-show="warningMessages">
<strong translate>There were errors while removing the following Repositories:</strong>
<ol>
<li data-ng-repeat="message in warningMessages">
{{ message }}
</li>
</ol>
<a ui-sref="products.details.tasks.details({taskId: warningTaskId})" translate>Click here to see the task for the successful removals.</a>
</div>
<h4 translate>Repositories</h4>

<input type="text"
class="form-control filter-input"
placeholder="{{ 'Filter' | translate }}"
ng-model="repositorySearch"/>

<span class="pull-right">

<div data-block="actions">
<div bst-modal="removeSelectedRepositories()">
<div data-block="modal-header" translate>Remove {{ repositoriesTable.numSelected }} Repositories?</div>
<div data-block="modal-body" translate>Are you sure you want to remove the {{ repositoriesTable.numSelected }} repositories selected?</div>
<div data-block="modal-header" translate>Remove {{ detailsTable.numSelected }} Repositories?</div>
<div data-block="modal-body" translate>Are you sure you want to remove the {{ detailsTable.numSelected }} repositories selected?</div>
</div>

<span ng-switch="getRepositoriesNonDeletableReason(product)" bst-feature-flag="custom_products">
Expand All @@ -51,7 +46,7 @@ <h4 translate>Repositories</h4>
<button class="btn btn-default"
ng-click="openModal()"
ng-show="canRemoveRepositories(product)"
ng-disabled="removingRepositories || repositoriesTable.numSelected == 0">
ng-disabled="removingRepositories || detailsTable.numSelected == 0">
<span ng-show="removingRepositories">
<i class="fa fa-spinner inline-icon fa-spin"></i>
<span>{{ "Removing Repositories" | translate }}</span>
Expand All @@ -63,98 +58,99 @@ <h4 translate>Repositories</h4>

</button>

<button class="btn btn-default"
ng-click="syncSelectedRepositories()"
ng-hide="denied('sync_products', product)"
ng-disabled="syncInProgress || repositoriesTable.numSelected == 0">
<i class="fa fa-spinner fa-spin" ng-show="syncInProgress"></i>
<span ng-show="syncInProgress" translate>Syncing...</span>
<i ng-hide="syncInProgress" class="fa fa-refresh"></i>
<span ng-hide="syncInProgress" translate>Sync Now</span>
</button>
<button class="btn btn-primary"
bst-feature-flag="custom_products"
ng-hide="denied('edit_products', product)"
ng-disabled="product.readonly"
ui-sref="products.details.repositories.new({productId: product.id})">
<span translate>Create Repository</span>
</button>
</span>
<button class="btn btn-default"
ng-click="syncSelectedRepositories()"
ng-hide="denied('sync_products', product)"
ng-disabled="syncInProgress || detailsTable.numSelected == 0">
<i class="fa fa-spinner fa-spin" ng-show="syncInProgress"></i>
<span ng-show="syncInProgress" translate>Syncing...</span>
<i ng-hide="syncInProgress" class="fa fa-refresh"></i>
<span ng-hide="syncInProgress" translate>Sync Now</span>
</button>
<button class="btn btn-primary"
bst-feature-flag="custom_products"
ng-hide="denied('edit_products', product)"
ng-disabled="product.readonly"
ui-sref="products.details.repositories.new({productId: product.id})">
<span translate>Create Repository</span>
</button>
</div>

<table bst-table="repositoriesTable"
class="table table-striped"
ng-class="{'table-mask': repositoriesTable.working}"
ng-show="repositoriesTable.rows.length > 0">
<thead>
<tr bst-table-head row-select>
<th bst-table-column="name" translate>Name</th>
<th bst-table-column="type" translate>Type</th>
<th bst-table-column="sync-status" translate>Sync Status</th>
<th bst-table-column="content" translate>Content</th>
</tr>
</thead>
<span data-block="no-rows-message" translate>
You currently don't have any Repositories included in this Product, you can add Repositories using the button on the right.
</span>

<tbody>
<tr bst-table-row
row-select="repository"
ng-repeat="repository in repositoriesTable.rows | filter:repositorySearch">
<td bst-table-cell>
<a ng-href="/products/{{ product.id }}/repositories/{{ repository.id }}">{{ repository.name }}</a>
</td>
<td bst-table-cell>{{ repository.content_type }}</td>
<td bst-table-cell>
<span ng-show="repository.url">
<span ng-show="repository.last_sync == null" translate>
Not Synced
</span>
<span ng-hide="repository.last_sync == null">
<a href="/foreman_tasks/tasks/{{repository.last_sync.id}}">{{ repository.last_sync.result | capitalize}}</a>
<span translate>{{ repository.last_sync_words }} ago</span>
</span>
</span>
<span ng-hide="repository.url" translate>N/A</span>
</td>
<td bst-table-cell>
<span ng-show="repository.content_type == 'puppet'">
<a translate ui-sref="products.details.repositories.manage-content.puppet-modules({productId: product.id, repositoryId: repository.id})">
{{ repository.content_counts.puppet_module || 0 }} Puppet Modules
</a>
</span>
<div data-block="table">
<table bst-table="detailsTable"
class="table table-striped"
ng-show="detailsTable.rows.length > 0 && !detailsTable.working">
<thead>
<tr bst-table-head row-select>
<th bst-table-column="name" translate>Name</th>
<th bst-table-column="type" translate>Type</th>
<th bst-table-column="sync-status" translate>Sync Status</th>
<th bst-table-column="content" translate>Content</th>
</tr>
</thead>

<span ng-show="repository.content_type == 'yum'">
<div>
<a translate ui-sref="products.details.repositories.manage-content.packages({productId: product.id, repositoryId: repository.id})">
{{ repository.content_counts.rpm || 0 }} Packages
</a>
</div>
<tbody>
<tr bst-table-row
row-select="repository"
ng-repeat="repository in detailsTable.rows | filter:repositorySearch">
<td bst-table-cell>
<a ng-href="/products/{{ product.id }}/repositories/{{ repository.id }}">{{ repository.name }}</a>
</td>
<td bst-table-cell>{{ repository.content_type }}</td>
<td bst-table-cell>
<span ng-show="repository.url">
<span ng-show="repository.last_sync == null" translate>
Not Synced
</span>
<span ng-hide="repository.last_sync == null">
<a href="/foreman_tasks/tasks/{{repository.last_sync.id}}">{{ repository.last_sync.result | capitalize}}</a>
<span translate>{{ repository.last_sync_words }} ago</span>
</span>
</span>
<span ng-hide="repository.url" translate>N/A</span>
</td>
<td bst-table-cell>
<span ng-show="repository.content_type == 'puppet'">
<a translate ui-sref="products.details.repositories.manage-content.puppet-modules({productId: product.id, repositoryId: repository.id})">
{{ repository.content_counts.puppet_module || 0 }} Puppet Modules
</a>
</span>

<div>
<a ui-sref="errata.index({repositoryId: repository.id})" translate>
{{ repository.content_counts.erratum || 0 }} Errata
</a>
</div>
</span>
<span ng-show="repository.content_type == 'yum'">
<div>
<a translate ui-sref="products.details.repositories.manage-content.packages({productId: product.id, repositoryId: repository.id})">
{{ repository.content_counts.rpm || 0 }} Packages
</a>
</div>

<span ng-show="repository.content_type == 'docker'">
<div>
<span translate>
{{ repository.content_counts.docker_image || 0 }} Docker Images
<div>
<a ui-sref="errata.index({repositoryId: repository.id})" translate>
{{ repository.content_counts.erratum || 0 }} Errata
</a>
</div>
</span>
</div>
<div>
<span translate>
{{ repository.content_counts.docker_tag || 0 }} Docker Tags

<span ng-show="repository.content_type == 'docker'">
<div>
<span translate>
{{ repository.content_counts.docker_image || 0 }} Docker Images
</span>
</div>
<div>
<span translate>
{{ repository.content_counts.docker_tag || 0 }} Docker Tags
</span>
</div>
</span>
</div>
</span>
</td>
</tr>
</tbody>
</table>
</section>
</td>
</tr>
</tbody>
</table>
</div>
</div>

<p bst-alert="info" ng-show="repositoriesTable.rows.length === 0 && !repositoriesTable.working">
<span translate>
You currently don't have any Repositories included in this Product, you can add Repositories using the button on the right.
</span>
</p>
</section>
Expand Up @@ -143,7 +143,7 @@ angular.module('Bastion.repositories').controller('RepositoryDetailsInfoControll
$scope.errorMessages = response.data.errors;
};

$scope.repositoriesTable.removeRow(repository.id);
$scope.detailsTable.removeRow(repository.id);
repository.$delete(success, error);
};

Expand All @@ -155,7 +155,7 @@ angular.module('Bastion.repositories').controller('RepositoryDetailsInfoControll
};

updateRepositoriesTable = function () {
$scope.repositoriesTable.replaceRow($scope.repository);
$scope.detailsTable.replaceRow($scope.repository);
};
}]
);
Expand Up @@ -16,7 +16,7 @@ angular.module('Bastion.repositories').controller('NewRepositoryController',
function ($scope, Repository, GPGKey, FormUtils, translate) {

function success(response) {
$scope.repositoriesTable.rows.push(response);
$scope.detailsTable.rows.push(response);
$scope.successMessages.push(translate('Repository %s successfully created.').replace('%s', $scope.repository.name));
$scope.transitionTo('products.details.repositories.index', {productId: $scope.$stateParams.productId});
}
Expand Down
Expand Up @@ -56,7 +56,7 @@ describe('Controller: ProductRepositoriesController', function() {
}));

it("sets up the repositories nutupane table", function() {
expect($scope.repositoriesTable).toBe(expectedTable);
expect($scope.detailsTable).toBe(expectedTable);
});

it("provides a way to remove all of the selected repositories in the table", function() {
Expand Down