diff --git a/backend/src/share/dto/myShare.dto.ts b/backend/src/share/dto/myShare.dto.ts index e548da54..b2163220 100644 --- a/backend/src/share/dto/myShare.dto.ts +++ b/backend/src/share/dto/myShare.dto.ts @@ -2,6 +2,7 @@ import { Expose, plainToClass, Type } from "class-transformer"; import { ShareDTO } from "./share.dto"; import { FileDTO } from "../../file/dto/file.dto"; import { OmitType } from "@nestjs/swagger"; +import { MyShareSecurityDTO } from "./myShareSecurity.dto"; export class MyShareDTO extends OmitType(ShareDTO, [ "files", @@ -21,6 +22,9 @@ export class MyShareDTO extends OmitType(ShareDTO, [ @Type(() => OmitType(FileDTO, ["share", "from"] as const)) files: Omit[]; + @Expose() + security?: MyShareSecurityDTO; + from(partial: Partial) { return plainToClass(MyShareDTO, partial, { excludeExtraneousValues: true }); } diff --git a/backend/src/share/dto/myShareSecurity.dto.ts b/backend/src/share/dto/myShareSecurity.dto.ts new file mode 100644 index 00000000..62d915b5 --- /dev/null +++ b/backend/src/share/dto/myShareSecurity.dto.ts @@ -0,0 +1,9 @@ +import { Expose } from "class-transformer"; + +export class MyShareSecurityDTO { + @Expose() + passwordProtected: boolean; + + @Expose() + maxViews: number; +} diff --git a/backend/src/share/share.service.ts b/backend/src/share/share.service.ts index 11e905e5..8cfcbff1 100644 --- a/backend/src/share/share.service.ts +++ b/backend/src/share/share.service.ts @@ -233,7 +233,7 @@ export class ShareService { orderBy: { expiration: "desc", }, - include: { recipients: true, files: true }, + include: { recipients: true, files: true, security: true }, }); return shares.map((share) => { @@ -241,6 +241,10 @@ export class ShareService { ...share, size: share.files.reduce((acc, file) => acc + parseInt(file.size), 0), recipients: share.recipients.map((recipients) => recipients.email), + security: { + maxViews: share.security?.maxViews, + passwordProtected: !!share.security?.password, + }, }; }); } diff --git a/frontend/src/i18n/translations/de-DE.ts b/frontend/src/i18n/translations/de-DE.ts index 111a85d7..ea55a5f4 100644 --- a/frontend/src/i18n/translations/de-DE.ts +++ b/frontend/src/i18n/translations/de-DE.ts @@ -124,6 +124,8 @@ export default { "account.shares.table.expiresAt": "Läuft ab am", "account.shares.table.createdAt": "Angelegt am", "account.shares.table.size": "Größe", + "account.shares.table.password-protected": "Passwortgeschützt", + "account.shares.table.visitor-count": "{count} von {max}", "account.shares.table.expiry-never": "nie", "account.shares.modal.share-informations": "Teile deine Information", "account.shares.modal.share-link": "Freigabe teilen", diff --git a/frontend/src/i18n/translations/en-US.ts b/frontend/src/i18n/translations/en-US.ts index ad61a690..04d66369 100644 --- a/frontend/src/i18n/translations/en-US.ts +++ b/frontend/src/i18n/translations/en-US.ts @@ -158,6 +158,8 @@ export default { "account.shares.table.expiresAt": "Expires on", "account.shares.table.createdAt": "Created on", "account.shares.table.size": "Size", + "account.shares.table.password-protected": "Password protected", + "account.shares.table.visitor-count": "{count} of {max}", "account.shares.table.expiry-never": "Never", "account.shares.modal.share-informations": "Share informations", diff --git a/frontend/src/pages/account/shares.tsx b/frontend/src/pages/account/shares.tsx index 8b64aaad..261f8a2e 100644 --- a/frontend/src/pages/account/shares.tsx +++ b/frontend/src/pages/account/shares.tsx @@ -15,7 +15,7 @@ import { useModals } from "@mantine/modals"; import moment from "moment"; import Link from "next/link"; import { useEffect, useState } from "react"; -import { TbEdit, TbInfoCircle, TbLink, TbTrash } from "react-icons/tb"; +import { TbEdit, TbInfoCircle, TbLink, TbLock, TbTrash } from "react-icons/tb"; import { FormattedMessage } from "react-intl"; import Meta from "../../components/Meta"; import showShareInformationsModal from "../../components/account/showShareInformationsModal"; @@ -85,13 +85,37 @@ const MyShares = () => { {shares.map((share) => ( - {share.id} - {share.name} - {share.views} - {moment(share.expiration).unix() === 0 - ? - : moment(share.expiration).format("LLL")} + + {share.id}{" "} + {share.security.passwordProtected && ( + + )} + + + {share.name} + + {share.security.maxViews ? ( + + ) : ( + share.views + )} + + + {moment(share.expiration).unix() === 0 ? ( + + ) : ( + moment(share.expiration).format("LLL") + )} diff --git a/frontend/src/types/share.type.ts b/frontend/src/types/share.type.ts index 10d5d6e8..abecf13a 100644 --- a/frontend/src/types/share.type.ts +++ b/frontend/src/types/share.type.ts @@ -34,9 +34,10 @@ export type ShareMetaData = { isZipReady: boolean; }; -export type MyShare = Share & { +export type MyShare = Omit & { views: number; createdAt: Date; + security: MyShareSecurity; }; export type MyReverseShare = { @@ -52,3 +53,8 @@ export type ShareSecurity = { maxViews?: number; password?: string; }; + +export type MyShareSecurity = { + passwordProtected: boolean; + maxViews: number; +};