From 14859ef5a8be3aa93c374dc38f3890e275c2f9f6 Mon Sep 17 00:00:00 2001 From: carddev81 Date: Tue, 7 Jan 2025 13:39:53 -0600 Subject: [PATCH 1/5] fix: move course title before platform provider within Grid view and remove bullet point when no start/end date --- frontend/src/Components/CatalogCourseCard.tsx | 15 +++--- .../src/Components/EnrolledCourseCard.tsx | 51 +++++++++++-------- 2 files changed, 37 insertions(+), 29 deletions(-) diff --git a/frontend/src/Components/CatalogCourseCard.tsx b/frontend/src/Components/CatalogCourseCard.tsx index 29f38451..1cfafa79 100644 --- a/frontend/src/Components/CatalogCourseCard.tsx +++ b/frontend/src/Components/CatalogCourseCard.tsx @@ -63,10 +63,9 @@ export default function CatalogCourseCard({ }) : ''; const finalDateStr = - ' • ' + - courseStartDtStr + - (courseStartDt || courseEndDt ? ' - ' : '') + - courseEndDtStr; + courseStartDt || courseEndDt + ? ' • ' + courseStartDtStr + ' - ' + courseEndDtStr + : ''; if (view == ViewType.List) { return (
{/* this should be the school or course that offers the course */} -

- {course.provider_name} - {finalDateStr} -

{course.course_name}

+

+ {course.provider_name} + {finalDateStr} +

{course.description}

diff --git a/frontend/src/Components/EnrolledCourseCard.tsx b/frontend/src/Components/EnrolledCourseCard.tsx index 4b25c5f5..9c86513a 100644 --- a/frontend/src/Components/EnrolledCourseCard.tsx +++ b/frontend/src/Components/EnrolledCourseCard.tsx @@ -20,23 +20,28 @@ export default function EnrolledCourseCard({ const url = course.external_url; let status: CourseStatus | null = null; if (course.course_progress == 100) status = CourseStatus.Completed; - const courseStartDt = course.start_dt ? new Date(course.start_dt) : course.start_dt; + const courseStartDt = course.start_dt + ? new Date(course.start_dt) + : course.start_dt; const courseEndDt = course.end_dt ? new Date(course.end_dt) : course.end_dt; - const courseStartDtStr = courseStartDt ? courseStartDt.toLocaleDateString('en-US', - { - year: 'numeric', - month: '2-digit', - day: 'numeric' - }) - : "" - const courseEndDtStr = courseEndDt ? courseEndDt.toLocaleDateString('en-US', - { - year: 'numeric', - month: '2-digit', - day: 'numeric' - }) - : ""; - const finalDateStr = " • " + courseStartDtStr + (courseStartDt || courseEndDt ? " - " : "") + courseEndDtStr + const courseStartDtStr = courseStartDt + ? courseStartDt.toLocaleDateString('en-US', { + year: 'numeric', + month: '2-digit', + day: 'numeric' + }) + : ''; + const courseEndDtStr = courseEndDt + ? courseEndDt.toLocaleDateString('en-US', { + year: 'numeric', + month: '2-digit', + day: 'numeric' + }) + : ''; + const finalDateStr = + courseStartDt || courseEndDt + ? ' • ' + courseStartDtStr + ' - ' + courseEndDtStr + : ''; if (view == ViewType.List) { return (

{course.course_name}

|

-

{course.provider_platform_name}{finalDateStr}

+

+ {course.provider_platform_name} + {finalDateStr} +

{status === CourseStatus.Completed ? (
@@ -86,13 +94,14 @@ export default function EnrolledCourseCard({ )}
-

- {course.provider_platform_name}{finalDateStr} -

-

+

{course.alt_name && course.alt_name + ' - '} {course.course_name}

+

+ {course.provider_platform_name} + {finalDateStr} +

{status == CourseStatus.Completed ? (
From 9b33dba1ccd22ebe0f9a06d6f74ddebb00689c0c Mon Sep 17 00:00:00 2001 From: carddev81 Date: Tue, 7 Jan 2025 13:43:46 -0600 Subject: [PATCH 2/5] fix: add cursor-pointer CSS style onto interactive elements per #617 --- frontend/src/Components/ProviderCard.tsx | 45 ++++++++++++++---------- frontend/src/Pages/AdminManagement.tsx | 6 ++-- frontend/src/Pages/StudentManagement.tsx | 6 ++-- 3 files changed, 33 insertions(+), 24 deletions(-) diff --git a/frontend/src/Components/ProviderCard.tsx b/frontend/src/Components/ProviderCard.tsx index fa242c88..7741ec9e 100644 --- a/frontend/src/Components/ProviderCard.tsx +++ b/frontend/src/Components/ProviderCard.tsx @@ -30,7 +30,7 @@ export default function ProviderCard({ openEditProvider: (prov: ProviderPlatform) => void; oidcClient: (prov: ProviderPlatform) => void; showAuthorizationInfo: (prov: ProviderPlatform) => void; - refreshToken: (prov: ProviderPlatform) => void; + refreshToken: (prov: ProviderPlatform) => void; archiveProvider: (prov: ProviderPlatform) => void; }) { const navigate = useNavigate(); @@ -38,7 +38,8 @@ export default function ProviderCard({ {provider.name} - {provider.oidc_id !== 0 || provider.type === ProviderPlatformType.BRIGHTSPACE ? ( + {provider.oidc_id !== 0 || + provider.type === ProviderPlatformType.BRIGHTSPACE ? ( ) : (
@@ -59,27 +60,31 @@ export default function ProviderCard({ {provider.state !== ProviderPlatformState.ARCHIVED ? ( <> - {provider.oidc_id !== 0 || provider.type === ProviderPlatformType.BRIGHTSPACE ? ( + {provider.oidc_id !== 0 || + provider.type === ProviderPlatformType.BRIGHTSPACE ? ( <> - {provider.type === ProviderPlatformType.BRIGHTSPACE ? ( + {provider.type === + ProviderPlatformType.BRIGHTSPACE ? ( - refreshToken(provider) - } - /> - ) : ( - showAuthorizationInfo(provider) - } - />) - } + tooltipClassName="cursor-pointer" + dataTip={'Refresh Token'} + icon={ArrowPathIcon} + onClick={() => refreshToken(provider)} + /> + ) : ( + + showAuthorizationInfo(provider) + } + /> + )} {provider.type !== ProviderPlatformType.KOLIBRI && ( @@ -92,17 +97,20 @@ export default function ProviderCard({ ) : ( oidcClient(provider)} /> )} openEditProvider(provider)} /> archiveProvider(provider)} @@ -110,6 +118,7 @@ export default function ProviderCard({ ) : ( archiveProvider(provider)} diff --git a/frontend/src/Pages/AdminManagement.tsx b/frontend/src/Pages/AdminManagement.tsx index d6135555..a6bdec1b 100644 --- a/frontend/src/Pages/AdminManagement.tsx +++ b/frontend/src/Pages/AdminManagement.tsx @@ -235,7 +235,7 @@ export default function AdminManagement() {
{ setTargetUser(user); editUserModal.current?.showModal(); @@ -246,7 +246,7 @@ export default function AdminManagement() { dataTip={ 'Reset Password' } - tooltipClassName="tooltip-left" + tooltipClassName="tooltip-left cursor-pointer" onClick={() => { setTargetUser(user); resetUserPasswordModal.current?.showModal(); @@ -259,7 +259,7 @@ export default function AdminManagement() { dataTip={getUserIconData[ 'data-tip' ](user)} - tooltipClassName="tooltip-left" + tooltipClassName="tooltip-left cursor-pointer" onClick={getUserIconData.onClick( user )} diff --git a/frontend/src/Pages/StudentManagement.tsx b/frontend/src/Pages/StudentManagement.tsx index 4a2def58..74080e17 100644 --- a/frontend/src/Pages/StudentManagement.tsx +++ b/frontend/src/Pages/StudentManagement.tsx @@ -216,7 +216,7 @@ export default function StudentManagement() {
{ setTargetUser(user); @@ -228,7 +228,7 @@ export default function StudentManagement() { dataTip={ 'Reset Password' } - tooltipClassName="tooltip-left" + tooltipClassName="tooltip-left cursor-pointer" icon={ ArrowPathRoundedSquareIcon } @@ -242,7 +242,7 @@ export default function StudentManagement() { dataTip={ 'Delete Student' } - tooltipClassName="tooltip-left" + tooltipClassName="tooltip-left cursor-pointer" icon={TrashIcon} onClick={() => { setTargetUser(user); From f2952cf736d3e013f4f77295e08a27a3416168e2 Mon Sep 17 00:00:00 2001 From: carddev81 Date: Tue, 7 Jan 2025 13:47:32 -0600 Subject: [PATCH 3/5] fix: add featuring libraries to resident view when library is featured per #592 and display featured content to other admins per #629 --- backend/src/handlers/libraries_handler.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/backend/src/handlers/libraries_handler.go b/backend/src/handlers/libraries_handler.go index d07af7bd..3190caf7 100644 --- a/backend/src/handlers/libraries_handler.go +++ b/backend/src/handlers/libraries_handler.go @@ -28,12 +28,13 @@ func (srv *Server) handleIndexLibraries(w http.ResponseWriter, r *http.Request, showHidden := "visible" if !userIsAdmin(r) && r.URL.Query().Get("visibility") == "hidden" { return newUnauthorizedServiceError() - } - if userIsAdmin(r) { + } else if !userIsAdmin(r) && r.URL.Query().Get("visibility") == "featured" { + showHidden = "featured" + } else if userIsAdmin(r) { showHidden = r.URL.Query().Get("visibility") } claims := r.Context().Value(ClaimsKey).(*Claims) - total, libraries, err := srv.Db.GetAllLibraries(page, perPage, claims.UserID, claims.FacilityID, showHidden, orderBy, search, days) + total, libraries, err := srv.Db.GetAllLibraries(page, perPage, days, claims.UserID, claims.FacilityID, showHidden, orderBy, search, claims.isAdmin()) if err != nil { return newDatabaseServiceError(err) } From 79523f9202de4272b46c0a286e9e44c6243ac3d4 Mon Sep 17 00:00:00 2001 From: carddev81 Date: Tue, 7 Jan 2025 13:49:12 -0600 Subject: [PATCH 4/5] fix: modify query to allow resident to favorite featured libraries --- backend/src/database/libraries.go | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/backend/src/database/libraries.go b/backend/src/database/libraries.go index ac4dec55..b814b115 100644 --- a/backend/src/database/libraries.go +++ b/backend/src/database/libraries.go @@ -2,6 +2,7 @@ package database import ( "UnlockEdv2/src/models" + "fmt" "strings" log "github.com/sirupsen/logrus" @@ -12,20 +13,29 @@ type LibraryResponse struct { IsFavorited bool `json:"is_favorited"` } -func (db *DB) GetAllLibraries(page, perPage int, userId, facilityId uint, visibility, orderBy, search string, days int) (int64, []LibraryResponse, error) { - var total int64 +func (db *DB) GetAllLibraries(page, perPage, days int, userId, facilityId uint, visibility, orderBy, search string, isAdmin bool) (int64, []LibraryResponse, error) { + var ( + total int64 + criteria string + id uint + ) libraries := make([]LibraryResponse, 0, perPage) - - tx := db.Model(&models.Library{}).Preload("OpenContentProvider").Select(` + //added the below to display featuring flags for all admins per facility + selectIsFavoriteOrIsFeatured := ` libraries.*, EXISTS ( SELECT 1 FROM open_content_favorites f WHERE f.content_id = libraries.id AND f.open_content_provider_id = libraries.open_content_provider_id - AND f.user_id = ? - ) AS is_favorited`, userId) + AND %s) AS is_favorited` + if isAdmin { + criteria, id = "f.facility_id = ?", facilityId + } else { + criteria, id = "f.user_id = ?", userId + } + tx := db.Model(&models.Library{}).Preload("OpenContentProvider").Select(fmt.Sprintf(selectIsFavoriteOrIsFeatured, criteria), id) visibility = strings.ToLower(visibility) isFeatured := false From c8e435a8ae48c422a3d220288b6bb2f9a8e9650a Mon Sep 17 00:00:00 2001 From: carddev81 Date: Tue, 7 Jan 2025 13:52:20 -0600 Subject: [PATCH 5/5] fix: modify query to allow resident to favorite featured libraries and modified libaries query to display featured libraries to other admins at the same facility --- backend/src/database/videos.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/backend/src/database/videos.go b/backend/src/database/videos.go index 8dbfa858..298ad9f8 100644 --- a/backend/src/database/videos.go +++ b/backend/src/database/videos.go @@ -27,18 +27,22 @@ func (db *DB) FavoriteOpenContent(contentID int, ocpID uint, userID uint, facili UserID: userID, FacilityID: facilityID, } - //use Unscoped method to ignore soft deletions + //added user id to query below to isolate favorite by user when facility id is passed in tx := db.Where("content_id = ? AND open_content_provider_id = ?", contentID, ocpID) if facilityID != nil { tx = tx.Where("facility_id = ?", facilityID) + } else { + tx = tx.Where("user_id = ?", userID) } if tx.First(&models.OpenContentFavorite{}).RowsAffected > 0 { - delTx := db.Where("content_id = ? AND user_id = ? AND open_content_provider_id = ?", contentID, userID, ocpID) + delTx := db.Where("content_id = ? AND open_content_provider_id = ?", contentID, ocpID) if facilityID != nil { delTx = delTx.Where("facility_id = ?", facilityID) + } else { + delTx = delTx.Where("user_id = ?", userID) } if err := delTx.Delete(&fav).Error; err != nil { - return false, newDeleteDBError(err, "video_favorites") + return false, newDeleteDBError(err, "open_content_favorites") } return false, nil } else {