This is an automated email from the ASF dual-hosted git repository.
shamrick pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
The following commit(s) were added to refs/heads/master by this push:
new eb9f531a43 Fix Traffic Portal affected server count in Profile change
confirmation dialogs (#6900)
eb9f531a43 is described below
commit eb9f531a43a9efae4f2f3d0c57fee948e9d029dd
Author: ocket8888 <[email protected]>
AuthorDate: Tue Jun 14 11:25:14 2022 -0600
Fix Traffic Portal affected server count in Profile change confirmation
dialogs (#6900)
---
.../TableParameterProfilesController.js | 71 ++++------
.../TableProfileParametersController.js | 157 +++++++--------------
.../TableProfilesParamsCompareController.js | 14 +-
3 files changed, 82 insertions(+), 160 deletions(-)
diff --git
a/traffic_portal/app/src/common/modules/table/parameterProfiles/TableParameterProfilesController.js
b/traffic_portal/app/src/common/modules/table/parameterProfiles/TableParameterProfilesController.js
index 06c5f8e18f..1ddfd63de8 100644
---
a/traffic_portal/app/src/common/modules/table/parameterProfiles/TableParameterProfilesController.js
+++
b/traffic_portal/app/src/common/modules/table/parameterProfiles/TableParameterProfilesController.js
@@ -17,7 +17,7 @@
* under the License.
*/
-const TableParameterProfilesController = function (parameter, profiles,
$controller, $scope, $state, $uibModal, $window, locationUtils,
deliveryServiceService, profileParameterService, serverService, profileService,
messageModel, fileUtils) {
+const TableParameterProfilesController = function (parameter, profiles,
$scope, $state, $uibModal, $window, locationUtils, deliveryServiceService,
profileParameterService, serverService, profileService, messageModel,
fileUtils) {
const deleteProfile = function (profile) {
profileService.deleteProfile(profile.id)
.then(function (result) {
@@ -215,54 +215,35 @@ const TableParameterProfilesController = function
(parameter, profiles, $control
},
];
- $scope.confirmRemoveProfile = function (profile, $event) {
+ $scope.confirmRemoveProfile = async function (profile, $event) {
if ($event) {
$event.stopPropagation();
}
+ const params = {
+ message: `The ${profile.name} profile is used by `,
+ title: "Remove Parameter from Profile?",
+ };
if (profile.type === 'DS_PROFILE') { // if this is a ds
profile, then it is used by delivery service(s) so we'll fetch the ds count...
- deliveryServiceService.getDeliveryServices({profile:
profile.id}).then(function (result) {
- const params = {
- title: 'Remove Parameter from Profile?',
- message: 'The ' + profile.name + '
profile is used by ' + result.length + ' delivery service(s). Are you sure you
want to remove the ' + parameter.name + ' parameter from this profile?'
- };
- const modalInstance = $uibModal.open({
- templateUrl:
'common/modules/dialog/confirm/dialog.confirm.tpl.html',
- controller: 'DialogConfirmController',
- size: 'md',
- resolve: {
- params: function () {
- return params;
- }
- }
- });
- modalInstance.result.then(function () {
- removeProfile(profile.id);
- }, function () {
- // do nothing
- });
- });
+ const result = await
deliveryServiceService.getDeliveryServices({profile: profile.id});
+ params.message += `${result.length} delivery
service(s).`;
} else { // otherwise the profile is used by servers so we'll
fetch the server count...
- serverService.getServers({profileId:
profile.id}).then(function (result) {
- const params = {
- title: 'Remove Parameter from Profile?',
- message: 'The ' + profile.name + '
profile is used by ' + result.length + ' server(s). Are you sure you want to
remove the ' + parameter.name + ' parameter from this profile?'
- };
- const modalInstance = $uibModal.open({
- templateUrl:
'common/modules/dialog/confirm/dialog.confirm.tpl.html',
- controller: 'DialogConfirmController',
- size: 'md',
- resolve: {
- params: function () {
- return params;
- }
- }
- });
- modalInstance.result.then(function () {
- removeProfile(profile.id);
- }, function () {
- // do nothing
- });
- });
+ const result = await
serverService.getServers({profileName: profile.name});
+ params.message += `${result.length} server(s).`;
+ }
+ const modalInstance = $uibModal.open({
+ templateUrl:
'common/modules/dialog/confirm/dialog.confirm.tpl.html',
+ controller: 'DialogConfirmController',
+ size: 'md',
+ resolve: {
+ params: () => params
+ }
+ });
+ try {
+ await modalInstance.result
+ await removeProfile(profile.id);
+ } catch {
+ // modalInstances will throw if the user cancels the
action.
+ // it's not an actual error, so we don't need to
actually handle it.
}
};
@@ -353,5 +334,5 @@ const TableParameterProfilesController = function
(parameter, profiles, $control
};
-TableParameterProfilesController.$inject = ['parameter', 'profiles',
'$controller', '$scope', '$state', '$uibModal', '$window', 'locationUtils',
'deliveryServiceService', 'profileParameterService', 'serverService',
'profileService', 'messageModel', 'fileUtils'];
+TableParameterProfilesController.$inject = ['parameter', 'profiles', '$scope',
'$state', '$uibModal', '$window', 'locationUtils', 'deliveryServiceService',
'profileParameterService', 'serverService', 'profileService', 'messageModel',
'fileUtils'];
module.exports = TableParameterProfilesController;
diff --git
a/traffic_portal/app/src/common/modules/table/profileParameters/TableProfileParametersController.js
b/traffic_portal/app/src/common/modules/table/profileParameters/TableProfileParametersController.js
index df8ec87ab9..b2498cbc46 100644
---
a/traffic_portal/app/src/common/modules/table/profileParameters/TableProfileParametersController.js
+++
b/traffic_portal/app/src/common/modules/table/profileParameters/TableProfileParametersController.js
@@ -56,127 +56,72 @@ var TableProfileParametersController = function(profile,
parameters, $controller
);
};
- $scope.confirmRemoveParam = function(parameter, $event) {
+ $scope.confirmRemoveParam = async function(parameter, $event) {
if ($event) {
$event.stopPropagation(); // this kills the click event
so it doesn't trigger anything else
}
+
+ const params = {
+ message: `The ${profile.name} profile is used by `,
+ title: "Remove Parameter from Profile?"
+ };
if (profile.type == 'DS_PROFILE') { // if this is a ds profile,
then it is used by delivery service(s) so we'll fetch the ds count...
- deliveryServiceService.getDeliveryServices({ profile:
profile.id }).
- then(function(result) {
- var params = {
- title: 'Remove Parameter from
Profile?',
- message: 'The ' + profile.name
+ ' profile is used by ' + result.length + ' delivery service(s). Are you sure
you want to remove the ' + parameter.name + ' parameter from this profile?'
- };
- var modalInstance = $uibModal.open({
- templateUrl:
'common/modules/dialog/confirm/dialog.confirm.tpl.html',
- controller:
'DialogConfirmController',
- size: 'md',
- resolve: {
- params: function () {
- return params;
- }
- }
- });
- modalInstance.result.then(function() {
- removeParameter(parameter.id);
- }, function () {
- // do nothing
- });
- });
+ const result = await
deliveryServiceService.getDeliveryServices({ profile: profile.id });
+ params.message += `${result.length} delivery
service(s). Are you sure you want to remove the ${parameter.name} parameter
from this profile?`
} else { // otherwise the profile is used by servers so we'll
fetch the server count...
- serverService.getServers({ profileId: profile.id }).
- then(function(result) {
- var params = {
- title: 'Remove Parameter from
Profile?',
- message: 'The ' + profile.name
+ ' profile is used by ' + result.length + ' server(s). Are you sure you want
to remove the ' + parameter.name + ' parameter from this profile?'
- };
- var modalInstance = $uibModal.open({
- templateUrl:
'common/modules/dialog/confirm/dialog.confirm.tpl.html',
- controller:
'DialogConfirmController',
- size: 'md',
- resolve: {
- params: function () {
- return params;
- }
- }
- });
- modalInstance.result.then(function() {
- removeParameter(parameter.id);
- }, function () {
- // do nothing
- });
- });
+ const result = await serverService.getServers({
profileName: profile.name });
+ params.message += `${result.length} server(s). Are you
sure you want to remove the ${parameter.name} parameter from this profile?`
+ }
+ const modalInstance = $uibModal.open({
+ templateUrl:
'common/modules/dialog/confirm/dialog.confirm.tpl.html',
+ controller: 'DialogConfirmController',
+ size: 'md',
+ resolve: {
+ params: () => params
+ }
+ });
+ try {
+ await modalInstance.result;
+ await removeParameter(parameter.id);
+ } catch {
+ // modalInstances will throw if the user cancels the
action.
+ // it's not an actual error, so we don't need to
actually handle it.
}
};
- $scope.selectParams = function() {
- var modalInstance = $uibModal.open({
+ $scope.selectParams = async function() {
+ const modalInstance = $uibModal.open({
templateUrl:
'common/modules/table/profileParameters/table.profileParamsUnassigned.tpl.html',
controller: 'TableProfileParamsUnassignedController',
size: 'lg',
resolve: {
- profile: function() {
- return profile;
- },
- allParams: function(parameterService) {
- return parameterService.getParameters();
- },
- assignedParams: function() {
- return parameters;
- }
- }
+ allParams: parameterService =>
parameterService.getParameters(),
+ assignedParams: () => parameters,
+ profile: () => profile
+ },
});
- modalInstance.result.then(function(selectedParamIds) {
- if (profile.type == 'DS_PROFILE') { // if this is a ds
profile, then it is used by delivery service(s) so we'll fetch the ds count...
- deliveryServiceService.getDeliveryServices({
profile: profile.id }).
- then(function(result) {
- var params = {
- title: 'Modify ' +
profile.name + ' parameters',
- message: 'The ' +
profile.name + ' profile is used by ' + result.length + ' delivery service(s).
Are you sure you want to modify the parameters?'
- };
- var modalInstance =
$uibModal.open({
- templateUrl:
'common/modules/dialog/confirm/dialog.confirm.tpl.html',
- controller:
'DialogConfirmController',
- size: 'md',
- resolve: {
- params:
function () {
- return
params;
- }
- }
- });
-
modalInstance.result.then(function() {
-
linkProfileParameters(selectedParamIds);
- }, function () {
- // do nothing
- });
- });
- } else { // otherwise the profile is used by servers so
we'll fetch the server count...
- serverService.getServers({ profileId:
profile.id }).
- then(function(result) {
- var params = {
- title: 'Modify ' +
profile.name + ' parameters',
- message: 'The ' +
profile.name + ' profile is used by ' + result.length + ' server(s). Are you
sure you want to modify the parameters?'
- };
- var modalInstance =
$uibModal.open({
- templateUrl:
'common/modules/dialog/confirm/dialog.confirm.tpl.html',
- controller:
'DialogConfirmController',
- size: 'md',
- resolve: {
- params:
function () {
- return
params;
- }
- }
- });
-
modalInstance.result.then(function() {
-
linkProfileParameters(selectedParamIds);
- }, function () {
- // do nothing
- });
- });
+ const selectedParamIds = await modalInstance.result;
+ const params = {
+ message: `The ${profile.name} profile is used by `,
+ title: `Modify ${profile.name} parameters`
+ }
+ if (profile.type == 'DS_PROFILE') { // if this is a ds profile,
then it is used by delivery service(s) so we'll fetch the ds count...
+ const result = await
deliveryServiceService.getDeliveryServices({ profile: profile.id });
+ params.message += `${result.length} delivery
service(s). Are you sure you want to modify the parameters?`;
+ } else { // otherwise the profile is used by servers so we'll
fetch the server count...
+ const result = await serverService.getServers({
profileName: profile.name });
+ params.message += `${result.length} server(s). Are you
sure you want to modify the parameters?`
+ }
+ const confirmModal = $uibModal.open({
+ templateUrl:
'common/modules/dialog/confirm/dialog.confirm.tpl.html',
+ controller: 'DialogConfirmController',
+ size: 'md',
+ resolve: {
+ params: () => params
}
- }, function () {
- // do nothing
});
+ await confirmModal.result;
+ await linkProfileParameters(selectedParamIds);
};
$scope.toggleVisibility = function(colName) {
diff --git
a/traffic_portal/app/src/common/modules/table/profilesParamsCompare/TableProfilesParamsCompareController.js
b/traffic_portal/app/src/common/modules/table/profilesParamsCompare/TableProfilesParamsCompareController.js
index 469b1bde01..4a93535385 100644
---
a/traffic_portal/app/src/common/modules/table/profilesParamsCompare/TableProfilesParamsCompareController.js
+++
b/traffic_portal/app/src/common/modules/table/profilesParamsCompare/TableProfilesParamsCompareController.js
@@ -22,17 +22,13 @@ var TableProfilesParamsCompareController =
function(profile1, profile2, profiles
let updateProfile1 = false,
updateProfile2 = false;
- let getProfileUsage = function(profile, profNum) {
+ async function getProfileUsage(profile, profNum) {
if (profile.type === 'DS_PROFILE') { // if this is a ds
profile, then it is used by delivery service(s) so we'll fetch the ds count...
- deliveryServiceService.getDeliveryServices({ profile:
profile.id }).
- then(function(result) {
- $scope['profile' + profNum + 'Usage'] =
result.length + ' delivery services';
- });
+ const result = await
deliveryServiceService.getDeliveryServices({ profile: profile.id });
+ $scope[`profile${profNum}Usage`] = `${result.length}
delivery services`;
} else { // otherwise the profile is used by servers so we'll
fetch the server count...
- serverService.getServers({ profileId: profile.id }).
- then(function(result) {
- $scope['profile' + profNum + 'Usage'] =
result.length + ' servers';
- });
+ const result = await serverService.getServers({
profileName: profile.name });
+ $scope[`profile${profNum}Usage`] = `${result.length}
servers`;
}
};