diff --git a/backend/src/database/open_content.go b/backend/src/database/open_content.go index 86bb277b..f73fb0e6 100644 --- a/backend/src/database/open_content.go +++ b/backend/src/database/open_content.go @@ -193,12 +193,14 @@ func (db *DB) GetTopUserOpenContent(id int) ([]models.OpenContentItem, error) { Table("open_content_activities oca"). Joins("LEFT JOIN videos v ON v.id = oca.content_id AND v.open_content_provider_id = oca.open_content_provider_id AND v.visibility_status = TRUE"). Where("oca.user_id = ?", id). - Group("v.title, v.url, v.thumbnail_url, v.open_content_provider_id, v.id"), + Group("v.title, v.url, v.thumbnail_url, v.open_content_provider_id, v.id"). + Having("count(v.id) > 0"), db.Select("l.name, l.path as url, l.image_url as thumbnail_url, l.open_content_provider_id, l.id as content_id, 'library' as type, count(l.id) as visits"). Table("open_content_activities oca"). Joins("LEFT JOIN libraries l on l.id = oca.content_id AND l.open_content_provider_id = oca.open_content_provider_id AND l.visibility_status = TRUE"). Where("oca.user_id = ?", id). - Group("l.name, l.path, l.image_url, l.open_content_provider_id, l.id"), + Group("l.name, l.path, l.image_url, l.open_content_provider_id, l.id"). + Having("count(l.id) > 0"), ).Find(&content).Error; err != nil { return nil, newGetRecordsDBError(err, "open_content_items") } diff --git a/backend/src/handlers/open_content_activity_handler.go b/backend/src/handlers/open_content_activity_handler.go index 3c053810..6bfc95a2 100644 --- a/backend/src/handlers/open_content_activity_handler.go +++ b/backend/src/handlers/open_content_activity_handler.go @@ -10,7 +10,7 @@ func (srv *Server) registerOpenContentActivityRoutes() []routeDef { axx := models.Feature(models.OpenContentAccess) return []routeDef{ {"GET /api/open-content/activity", srv.handleGetTopFacilityOpenContent, false, axx}, - {"PUT /api/open-content/activity/{id}", srv.handleGetTopUserOpenContent, false, axx}, + {"GET /api/open-content/activity/{id}", srv.handleGetTopUserOpenContent, false, axx}, } } diff --git a/backend/src/handlers/server.go b/backend/src/handlers/server.go index a6076de9..9ee573cf 100644 --- a/backend/src/handlers/server.go +++ b/backend/src/handlers/server.go @@ -79,7 +79,6 @@ func (srv *Server) RegisterRoutes() { srv.registerOryRoutes, srv.registerFacilitiesRoutes, srv.registerOpenContentRoutes, - srv.registerOpenContentActivityRoutes, srv.registerLibraryRoutes, srv.registerProgramsRoutes, srv.registerSectionsRoutes, @@ -88,6 +87,7 @@ func (srv *Server) RegisterRoutes() { srv.registerAttendanceRoutes, srv.registerVideoRoutes, srv.registerFeatureFlagRoutes, + srv.registerOpenContentActivityRoutes, } { srv.register(route) } diff --git a/frontend/src/Components/LibraryCard.tsx b/frontend/src/Components/LibraryCard.tsx index 77037ab8..f0ee3b6c 100644 --- a/frontend/src/Components/LibraryCard.tsx +++ b/frontend/src/Components/LibraryCard.tsx @@ -79,7 +79,7 @@ export default function LibraryCard({
{`${library.name}
@@ -89,7 +89,7 @@ export default function LibraryCard({
void toggleFavorite(e)}> diff --git a/frontend/src/Components/LibraryLayout.tsx b/frontend/src/Components/LibraryLayout.tsx index c4c21fce..9967eeb5 100644 --- a/frontend/src/Components/LibraryLayout.tsx +++ b/frontend/src/Components/LibraryLayout.tsx @@ -77,7 +77,7 @@ export default function LibaryLayout({ }, [filterLibrariesAdmin, filterLibraries, searchTerm]); return ( -
+
)}
-
+
{libraries?.data.map((library) => ( {/* admin view */} -
  • - - - Dashboard - -
  • -
  • - - - Students - -
  • -
  • - - - Admins - -
  • + {hasFeature( + user, + FeatureAccess.OpenContentAccess + ) && user.feature_access.length === 1 ? ( +
  • + + + Dashboard + +
  • + ) : ( +
  • + + + Dashboard + +
  • + )} {hasFeature( user, FeatureAccess.OpenContentAccess @@ -105,12 +105,6 @@ export default function Navbar({ )} -
  • - - - Resources - -
  • {hasFeature( user, FeatureAccess.ProviderAccess @@ -147,6 +141,24 @@ export default function Navbar({ )} +
  • + + + Students + +
  • +
  • + + + Admins + +
  • +
  • + + + Resources + +
  • ) : ( <> - {/* student view */} -
  • - - - Dashboard - -
  • + {hasFeature( + user, + FeatureAccess.OpenContentAccess + ) && user.feature_access.length === 1 ? ( +
  • + + + Dashboard + +
  • + ) : ( +
  • + + + Dashboard + +
  • + )} {hasFeature( user, FeatureAccess.ProviderAccess diff --git a/frontend/src/Components/VideoContent.tsx b/frontend/src/Components/VideoContent.tsx index 7a13351c..ace9a493 100644 --- a/frontend/src/Components/VideoContent.tsx +++ b/frontend/src/Components/VideoContent.tsx @@ -53,56 +53,51 @@ export default function VideoContent() { }; return ( -
    -
    -

    Videos

    -
    -
    - - -
    -
    -
    - {videoData.map((video) => ( - - ))} -
    - {!isLoading && !error && meta && ( -
    - -
    - )} - {error && ( - - Failed to load videos. - - )} - {!isLoading && !error && videoData.length === 0 && ( - No results - )} +
    +
    + +
    +
    + {videoData.map((video) => ( + + ))} +
    + {!isLoading && !error && meta && ( +
    + +
    + )} + {error && ( + + Failed to load videos. + + )} + {!isLoading && !error && videoData.length === 0 && ( + No results + )}
    ); } diff --git a/frontend/src/Components/cards/OpenContentCard.tsx b/frontend/src/Components/cards/OpenContentCard.tsx index 3a28bd05..e59c3ffe 100644 --- a/frontend/src/Components/cards/OpenContentCard.tsx +++ b/frontend/src/Components/cards/OpenContentCard.tsx @@ -8,13 +8,14 @@ export default function OpenContentCardRow({ }) { const navigate = useNavigate(); function redirectToViewer() { - if ('url' in content) { - if (content.type === 'video') { - navigate(`/viewer/videos/${content.content_id}`); - } else if (content.type === 'library') { - navigate(`/viewer/libraries/${content.content_id}`); - } - } + const isFavorite = !('url' in content); + const type = isFavorite ? content.content_type : content.type; + const basePath = + type === 'video' + ? `/viewer/videos/${content.content_id}` + : `/viewer/libraries/${content.content_id}`; + + navigate(basePath); } return ( diff --git a/frontend/src/Pages/Favorites.tsx b/frontend/src/Pages/Favorites.tsx index 88c5cc6a..6782f7c2 100644 --- a/frontend/src/Pages/Favorites.tsx +++ b/frontend/src/Pages/Favorites.tsx @@ -30,8 +30,7 @@ export default function FavoritesPage() { }; return ( -
    - My Favorites +
    {favorites.map((favorite) => ( No favorites found.

    )} {!isLoading && !error && meta && ( -
    +
    {/* main section */} @@ -37,6 +49,19 @@ export default function OpenContentLevelDashboard() { /> ); })} + {topUserContent.length < 5 && ( +
    + +

    Explore open content offered

    +
    + )}

    Popular Open Content

    diff --git a/frontend/src/Pages/VideoManagement.tsx b/frontend/src/Pages/VideoManagement.tsx index 238718fd..a0e3cafe 100644 --- a/frontend/src/Pages/VideoManagement.tsx +++ b/frontend/src/Pages/VideoManagement.tsx @@ -100,10 +100,9 @@ export default function VideoManagement() { return (
    -
    -

    Video Management

    +
    -
    +