Skip to content

Commit

Permalink
Support MemoLanes archive export (Part 1) (#104)
Browse files Browse the repository at this point in the history
Co-authored-by: Zed(Zijun) Chen <[email protected]>
  • Loading branch information
newhzh and CaviarChen authored Nov 4, 2024
1 parent 9a1ce1d commit d4f26d3
Show file tree
Hide file tree
Showing 9 changed files with 1,226 additions and 522 deletions.
2 changes: 2 additions & 0 deletions frontend/src/I18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ i18n
"snapshot-list-source-sync": "Sync",
"snapshot-list-source-upload": "Upload",
"snapshot-list-download": "Download",
"snapshot-list-export-mldx": "Export MemoLanes Archive",
"snapshot-list-view": "View",
"snapshot-list-note-edit": "Edit Note",
"snapshot-list-note-edit-err-tolong":
Expand Down Expand Up @@ -154,6 +155,7 @@ i18n
"snapshot-list-source-sync": "同步",
"snapshot-list-source-upload": "上传",
"snapshot-list-download": "下载",
"snapshot-list-export-mldx": "导出迹忆归档",
"snapshot-list-view": "查看",
"snapshot-list-note-edit": "编辑备注",
"snapshot-list-note-edit-err-tolong": "备注过长,请修改",
Expand Down
14 changes: 14 additions & 0 deletions frontend/src/time-machine/Api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,4 +341,18 @@ export default class Api {
}
return result;
}

public static async getMemoleanesArchiveDownloadToken(): Promise<
Result<string>
> {
const result = await this.requestApi(
"memolanes_archive/download_token",
"get",
true
);
if (result.ok) {
result.ok = result.ok.token;
}
return result;
}
}
45 changes: 33 additions & 12 deletions frontend/src/time-machine/DashboardSnapshot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ const SnapshotListPanel: React.FC<{
<FileDownloadIcon />
</Button>
</Whisper>

<Whisper
placement="bottom"
controlId="control-id-hover"
Expand Down Expand Up @@ -448,18 +449,38 @@ function DashboardSnapshot() {
header={
<Stack justifyContent="space-between">
<span>{t("snapshot-list-title")}</span>
<IconButton
icon={<PlusIcon />}
onClick={() => {
setUploadDialogState({
uploadDate: null,
uploadNote: null,
uploadState: "empty",
});
}}
>
{t("snapshot-list-upload")}
</IconButton>
<Stack justifyContent="flex-end">
<IconButton
icon={<PlusIcon />}
onClick={() => {
setUploadDialogState({
uploadDate: null,
uploadNote: null,
uploadState: "empty",
});
}}
>
{t("snapshot-list-upload")}
</IconButton>
{/* TODO: This feature is not ready. */}
{/* <IconButton
style={{ marginLeft: "10px" }}
icon={<FileDownloadIcon />}
onClick={async () => {
const token = await Api.getMemoleanesArchiveDownloadToken();
if (token.ok) {
window.open(
Api.backendUrl + "misc/download?token=" + token.ok,
"_blank"
);
} else {
//TODO: error handling
}
}}
>
{t("snapshot-list-export-mldx")}
</IconButton> */}
</Stack>
</Stack>
}
>
Expand Down
Loading

0 comments on commit d4f26d3

Please sign in to comment.