From 80c144568469a6924e106ead61221b2741d67b7f Mon Sep 17 00:00:00 2001 From: "Shah, Rima" Date: Mon, 18 Dec 2023 13:17:54 -0700 Subject: [PATCH 1/3] Fixed Compare Profiles Page Issue Fixed get profiles to return list of asscoaited parameters to a profile. --- traffic_ops/traffic_ops_golang/profile/profiles.go | 8 ++++---- .../app/src/common/service/utils/CollectionUtils.js | 2 ++ .../src/modules/private/profiles/compare/diff/index.js | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/traffic_ops/traffic_ops_golang/profile/profiles.go b/traffic_ops/traffic_ops_golang/profile/profiles.go index df706be8fb..ebae86a7c0 100644 --- a/traffic_ops/traffic_ops_golang/profile/profiles.go +++ b/traffic_ops/traffic_ops_golang/profile/profiles.go @@ -429,7 +429,7 @@ func Read(w http.ResponseWriter, r *http.Request) { profile := tc.ProfileV5{} var profileList []tc.ProfileV5 for rows.Next() { - if err = rows.Scan(&profile.Description, &profile.ID, &profile.LastUpdated, &profile.Name, &profile.RoutingDisabled, &profile.Type, &profile.CDNID, &profile.CDNName); err != nil { + if err = rows.StructScan(&profile); err != nil { api.HandleErr(w, r, tx.Tx, http.StatusInternalServerError, nil, fmt.Errorf("error getting profile(s): %w", err)) return } @@ -439,9 +439,9 @@ func Read(w http.ResponseWriter, r *http.Request) { profileInterfaces := []interface{}{} for _, p := range profileList { - // Attach Parameters if the 'param' parameter is sent - if _, ok := inf.Params["param"]; ok { - p.Parameters, err = ReadParameters(inf.Tx, inf.User, p.ID, inf.User.Can("PARAMETER-SECURE:READ")) + // Attach Parameters if the 'id' parameter is sent + if _, ok := inf.Params["id"]; ok { + p.Parameters, err = ReadParameters(inf.Tx, inf.User, p.ID, inf.User.Can("PARAMETER:SECURE-READ")) if err != nil { api.HandleErr(w, r, tx.Tx, http.StatusInternalServerError, nil, fmt.Errorf("profile read: error reading parameters for a profile: %w", err)) return diff --git a/traffic_portal/app/src/common/service/utils/CollectionUtils.js b/traffic_portal/app/src/common/service/utils/CollectionUtils.js index a92ff0954a..cf85706abe 100644 --- a/traffic_portal/app/src/common/service/utils/CollectionUtils.js +++ b/traffic_portal/app/src/common/service/utils/CollectionUtils.js @@ -78,6 +78,8 @@ class CollectionUtils { * @returns {T[]} */ uniqArray(array1, array2, key) { + array1 = array1 || []; + array2 = array2 || []; /** @type {Set} */ const keys = new Set(); /** @type {T[]} */ diff --git a/traffic_portal/app/src/modules/private/profiles/compare/diff/index.js b/traffic_portal/app/src/modules/private/profiles/compare/diff/index.js index 7b2187dc67..ebbd1d72dd 100644 --- a/traffic_portal/app/src/modules/private/profiles/compare/diff/index.js +++ b/traffic_portal/app/src/modules/private/profiles/compare/diff/index.js @@ -38,7 +38,7 @@ module.exports = angular.module('trafficPortal.private.profiles.diff', []) * @param {{params: {id: unknown}[]}} profile2 * @param {import("../../../../../common/service/utils/CollectionUtils")} collectionUtils */ - profilesParams: function(profile1, profile2, collectionUtils) { + profilesParams: function(profile1, profile2, collectionUtils) { return collectionUtils.uniqArray(profile1.params, profile2.params, 'id'); }, showAll: function() { From 198e9467ae643987f24481f06ce9791ecdc2455f Mon Sep 17 00:00:00 2001 From: Rima Shah Date: Mon, 18 Dec 2023 15:08:03 -0700 Subject: [PATCH 2/3] Updated changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7bd8157e96..d4d063cef7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -98,7 +98,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - [#7814](https://github.com/apache/trafficcontrol/issues/7814) All Go components: Updated the module path to [`github.com/apache/trafficcontrol/v8`](https://pkg.go.dev/github.com/apache/trafficcontrol/v8). Module https://pkg.go.dev/github.com/apache/trafficcontrol will not receive further updates. ### Fixed -- [#7879](https://github.com/comcast-cdn/trafficcontrol/pull/7879) *Traffic Ops, Traffic Portal*: Fixed broken capability links for delivery service and added required capability as a column in DS table. +- [#7885](https://github.com/apache/trafficcontrol/pull/7885) *Traffic Portal* Fixed the issue where Compare Profiles page was not being displayed. +- [#7879](https://github.com/apache/trafficcontrol/7879) *Traffic Ops, Traffic Portal*: Fixed broken capability links for delivery service and added required capability as a column in DS table. - [#7878](https://github.com/apache/trafficcontrol/pull/7878) *Traffic Ops, Traffic Portal*: Fixed the case where TO was failing to assign delivery services to a server, due to a bug in the way the list of preexisting delivery services was being returned. - [#7819](https://github.com/apache/trafficcontrol/pull/7819) *Traffic Ops*: API v5 routes should not use `privLevel` comparisons. - [#7802](https://github.com/apache/trafficcontrol/pull/7802) *Traffic Control Health Client*: Fixed ReadMe.md typos and duplicates. From 19e4b858d50937905c931bdef2f49c91db0ad9d6 Mon Sep 17 00:00:00 2001 From: Rima Shah Date: Tue, 19 Dec 2023 10:36:05 -0700 Subject: [PATCH 3/3] using a defined constant instead of hard coded value --- traffic_ops/traffic_ops_golang/profile/profiles.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/traffic_ops/traffic_ops_golang/profile/profiles.go b/traffic_ops/traffic_ops_golang/profile/profiles.go index ebae86a7c0..efaa0380b4 100644 --- a/traffic_ops/traffic_ops_golang/profile/profiles.go +++ b/traffic_ops/traffic_ops_golang/profile/profiles.go @@ -441,7 +441,7 @@ func Read(w http.ResponseWriter, r *http.Request) { for _, p := range profileList { // Attach Parameters if the 'id' parameter is sent if _, ok := inf.Params["id"]; ok { - p.Parameters, err = ReadParameters(inf.Tx, inf.User, p.ID, inf.User.Can("PARAMETER:SECURE-READ")) + p.Parameters, err = ReadParameters(inf.Tx, inf.User, p.ID, inf.User.Can(tc.PermParameterSecureRead)) if err != nil { api.HandleErr(w, r, tx.Tx, http.StatusInternalServerError, nil, fmt.Errorf("profile read: error reading parameters for a profile: %w", err)) return