Skip to content

Commit

Permalink
Add updated column to series and event tables
Browse files Browse the repository at this point in the history
  • Loading branch information
owi92 committed Jan 27, 2025
1 parent 53908b1 commit 1e32aed
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 12 deletions.
1 change: 1 addition & 0 deletions backend/src/api/model/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ impl AuthorizedEvent {
title: series.title.clone(),
synced_data: None,
created: None,
updated: None,
metadata: None,
read_roles: None,
write_roles: None,
Expand Down
25 changes: 22 additions & 3 deletions backend/src/api/model/series.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,15 @@ use super::{
block::{BlockValue, NewSeriesBlock, VideoListLayout, VideoListOrder},
playlist::VideoListEntry,
realm::{NewRealm, RealmSpecifier, RemoveMountedSeriesOutcome, UpdatedRealmName},
shared::{load_writable_for_user, AssetMapping, Connection, LoadableAsset, PageInfo, SeriesSortColumn, SortOrder},
shared::{
load_writable_for_user,
AssetMapping,
Connection,
LoadableAsset,
PageInfo,
SeriesSortColumn,
SortOrder,
},
};


Expand All @@ -34,6 +42,7 @@ pub(crate) struct Series {
pub(crate) synced_data: Option<SyncedSeriesData>,
pub(crate) title: String,
pub(crate) created: Option<DateTime<Utc>>,
pub(crate) updated: Option<DateTime<Utc>>,
pub(crate) metadata: Option<ExtraMetadata>,
pub(crate) read_roles: Option<Vec<String>>,
pub(crate) write_roles: Option<Vec<String>>,
Expand All @@ -49,16 +58,22 @@ impl_from_db!(
select: {
series.{
id, opencast_id, state,
title, description, created,
metadata, read_roles, write_roles,
title, description,
metadata, created,
read_roles, write_roles,
},
updated: "case \
when ${table:series}.updated = '-infinity' then null \
else ${table:series}.updated \
end",
},
|row| {
Series {
key: row.id(),
opencast_id: row.opencast_id(),
title: row.title(),
created: row.created(),
updated: row.updated(),
metadata: row.metadata(),
read_roles: row.read_roles(),
write_roles: row.write_roles(),
Expand Down Expand Up @@ -308,6 +323,10 @@ impl Series {
&self.created
}

fn updated(&self) -> &Option<DateTime<Utc>> {
&self.updated
}

fn metadata(&self) -> &Option<ExtraMetadata> {
&self.metadata
}
Expand Down
1 change: 1 addition & 0 deletions frontend/src/i18n/locales/de.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ manage:
descending: absteigend
title: Titel
created: Erstellt
updated: Aktualisiert
no-entries-found: Keine Einträge gefunden.
missing-date: Unbekannt

Expand Down
1 change: 1 addition & 0 deletions frontend/src/i18n/locales/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ manage:
descending: descending
title: Title
created: Created
updated: Updated
no-entries-found: No entries found.
missing-date: Unknown

Expand Down
10 changes: 8 additions & 2 deletions frontend/src/routes/manage/Series/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { loadQuery } from "../../../relay";
import { NotAuthorized } from "../../../ui/error";
import {
ColumnProps,
CreatedColumn,
createQueryParamsParser,
DateColumn,
descriptionStyle,
ManageAssets,
TableRow,
Expand Down Expand Up @@ -79,6 +79,7 @@ const query = graphql`
id
title
created
updated
syncedData { description }
entries {
__typename
Expand Down Expand Up @@ -106,10 +107,15 @@ export const seriesColumns: ColumnProps[] = [
{i18n.t("manage.my-series.no-of-videos", { count: series.entries.length })}
</td>,
},
{
key: "UPDATED",
label: "manage.asset-table.columns.updated",
column: series => "updated" in series && <DateColumn date={series.updated ?? undefined} />,
},
{
key: "CREATED",
label: "manage.asset-table.columns.created",
column: series => <CreatedColumn created={series.created ?? undefined} />,
column: series => <DateColumn date={series.created ?? undefined} />,
},
];

Expand Down
10 changes: 8 additions & 2 deletions frontend/src/routes/manage/Video/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import { relativeDate } from "../../../ui/time";
import CONFIG from "../../../config";
import {
ColumnProps,
CreatedColumn,
createQueryParamsParser,
DateColumn,
descriptionStyle,
ManageAssets,
TableRow,
Expand Down Expand Up @@ -110,10 +110,16 @@ export type Event = Events[number];

// Todo: add series column
export const videoColumns: ColumnProps[] = [
{
key: "UPDATED",
label: "manage.asset-table.columns.updated",
column: event => (event.syncedData && "updated" in event.syncedData)
&& <DateColumn date={event.syncedData.updated} />,
},
{
key: "CREATED",
label: "manage.asset-table.columns.created",
column: event => <CreatedColumn created={event.created ?? undefined} />,
column: event => <DateColumn date={event.created ?? undefined} />,
},
];

Expand Down
10 changes: 5 additions & 5 deletions frontend/src/routes/manage/shared.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -246,19 +246,19 @@ export const descriptionStyle = {
} as const;

// Used for both `EventRow` and `SeriesRow`.
export const CreatedColumn: React.FC<{ created?: string }> = ({ created }) => {
export const DateColumn: React.FC<{ date?: string }> = ({ date }) => {
const { t, i18n } = useTranslation();
const isDark = useColorScheme().scheme === "dark";
const createdDate = created && new Date(created);
const parsedDate = date && new Date(date);
const greyColor = { color: isDark ? COLORS.neutral60 : COLORS.neutral50 };

return <td css={{ fontSize: 14 }}>
{createdDate
{parsedDate
? <>
{createdDate.toLocaleDateString(i18n.language)}
{parsedDate.toLocaleDateString(i18n.language)}
<br />
<span css={greyColor}>
{createdDate.toLocaleTimeString(i18n.language)}
{parsedDate.toLocaleTimeString(i18n.language)}
</span>
</>
: <i css={greyColor}>
Expand Down
1 change: 1 addition & 0 deletions frontend/src/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,7 @@ type Series implements Node {
opencastId: String!
title: String!
created: DateTime
updated: DateTime
metadata: ExtraMetadata
syncedData: SyncedSeriesData
acl: [AclItem!]
Expand Down

0 comments on commit 1e32aed

Please sign in to comment.