ocket8888 commented on a change in pull request #6005:
URL: https://github.com/apache/trafficcontrol/pull/6005#discussion_r669804036
##########
File path:
traffic_portal/app/src/common/modules/table/deliveryServiceServers/TableAssignDSServersController.js
##########
@@ -17,87 +17,54 @@
* under the License.
*/
-var TableAssignDSServersController = function(deliveryService, servers,
assignedServers, $scope, $uibModalInstance) {
-
- var selectedServers = [];
+/** @typedef {
import('../../../../common/modules/table/agGrid/CommonGridController').CGC }
CGC */
- var addAll = function() {
- markVisibleServers(true);
- };
-
- var removeAll = function() {
- markVisibleServers(false);
- };
+var TableAssignDSServersController = function(deliveryService, servers,
assignedServers, $scope, $uibModalInstance) {
- var markVisibleServers = function(selected) {
- var visibleServerIds = $('#dsServersUnassignedTable
tr.server-row').map(
- function() {
- return parseInt($(this).attr('id'));
- }).get();
- $scope.servers = _.map(servers, function(server) {
- if (visibleServerIds.includes(server.id)) {
- server['selected'] = selected;
- }
- return server;
- });
- updateSelectedCount();
- };
+ $scope.selectedServers = [];
- var updateSelectedCount = function() {
- selectedServers = _.filter($scope.servers, function(server) {
return server['selected'] == true; } );
- $('div.selected-count').html('<b>' + selectedServers.length + '
servers selected</b>');
- };
+ /** @type CGC.ColumnDefinition */
+ $scope.columns = [
+ {
+ headerName: "Host",
+ field: "hostName",
+ checkboxSelection: true,
+ headerCheckboxSelection: true,
+ },
+ {
+ headerName: "Cache Group",
+ field: "cachegroup",
+ },
+ {
+ headerName: "Profile",
+ field: "profile"
+ }
+ ];
$scope.deliveryService = deliveryService;
- $scope.servers = _.map(servers, function(server) {
- var isAssigned = _.find(assignedServers,
function(assignedServer) { return assignedServer.id == server.id });
+ $scope.servers = servers.map(server => {
+ let isAssigned = assignedServers.find(assignedServer =>
assignedServer.id === server.id);
if (isAssigned) {
server['selected'] = true;
}
return server;
});
- $scope.selectAll = function($event) {
- var checkbox = $event.target;
- if (checkbox.checked) {
- addAll();
- } else {
- removeAll();
- }
- };
-
- $scope.onChange = function() {
- updateSelectedCount();
- };
-
$scope.submit = function() {
- var selectedServerIds = _.pluck(selectedServers, 'id');
+ const selectedServerIds = this.selectedServers.map(s =>
s["id"]);
Review comment:
Since when does our build system allow fat-arrow functions? I had to try
it myself to believe it worked - that used to break in half.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]