Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

add sync status

Abhinavb99deb59d166
diff --git a/apps/photos/public/locales/en/translation.json b/apps/photos/public/locales/en/translation.json
index 22a28c3e26..4fd318ab04 100644
--- a/apps/photos/public/locales/en/translation.json
+++ b/apps/photos/public/locales/en/translation.json
@@ -594,5 +594,7 @@
"IMAGE": "Image",
"VIDEO": "Video",
"LIVE_PHOTO": "Live Photo",
- "CONVERT": "Convert"
+ "CONVERT": "Convert",
+ "STATUS": "Status",
+ "INDEXED_ITEMS": "Indexed Items"
}
diff --git a/apps/photos/src/components/Container.ts b/apps/photos/src/components/Container.ts
index f3c399db12..a6318f11a0 100644
--- a/apps/photos/src/components/Container.ts
+++ b/apps/photos/src/components/Container.ts
@@ -72,5 +72,4 @@ export const VerticalFlex = styled(HorizontalFlex)({
export const VerticallyCenteredFlex = styled(HorizontalFlex)({
alignItems: 'center',
- display: 'flex',
});
diff --git a/apps/photos/src/components/Sidebar/AdvancedSettings.tsx b/apps/photos/src/components/Sidebar/AdvancedSettings.tsx
index 323282dd31..0dbac52bd1 100644
--- a/apps/photos/src/components/Sidebar/AdvancedSettings.tsx
+++ b/apps/photos/src/components/Sidebar/AdvancedSettings.tsx
@@ -1,15 +1,17 @@
import ChevronRight from '@mui/icons-material/ChevronRight';
import ScienceIcon from '@mui/icons-material/Science';
-import { Box, DialogProps, Stack } from '@mui/material';
+import { Box, DialogProps, Stack, Typography } from '@mui/material';
import { EnteDrawer } from 'components/EnteDrawer';
import MLSearchSettings from 'components/MachineLearning/MLSearchSettings';
import MenuSectionTitle from 'components/Menu/MenuSectionTitle';
import Titlebar from 'components/Titlebar';
-import { useState } from 'react';
+import { useEffect, useState } from 'react';
import { t } from 'i18next';
import { EnteMenuItem } from 'components/Menu/EnteMenuItem';
import { MenuItemGroup } from 'components/Menu/MenuItemGroup';
+import { VerticallyCenteredFlex } from 'components/Container';
+import { ClipExtractionStatus, ClipService } from 'services/clipService';
export default function AdvancedSettings({ open, onClose, onRootClose }) {
const [mlSearchSettingsView, setMlSearchSettingsView] = useState(false);
@@ -30,6 +32,15 @@ export default function AdvancedSettings({ open, onClose, onRootClose }) {
}
};
+ const [indexingStatus, setIndexingStatus] = useState<ClipExtractionStatus>({
+ indexed: 0,
+ pending: 0,
+ });
+
+ useEffect(() => {
+ ClipService.setOnUpdateHandler(setIndexingStatus);
+ }, []);
+
return (
<EnteDrawer
transitionDuration={0}
@@ -60,6 +71,32 @@ export default function AdvancedSettings({ open, onClose, onRootClose }) {
/>
</MenuItemGroup>
</Box>
+
+ <Box>
+ <MenuSectionTitle title={t('STATUS')} />
+ <Stack py={'12px'} px={'12px'} spacing={'24px'}>
+ <VerticallyCenteredFlex
+ justifyContent="space-between"
+ alignItems={'center'}>
+ <Typography>
+ {t('INDEXED_ITEMS')}
+ </Typography>
+ <Typography>
+ {indexingStatus.indexed}
+ </Typography>
+ </VerticallyCenteredFlex>
+ <VerticallyCenteredFlex
+ justifyContent="space-between"
+ alignItems={'center'}>
+ <Typography>
+ {t('PENDING_ITEMS')}
+ </Typography>
+ <Typography>
+ {indexingStatus.pending}
+ </Typography>
+ </VerticallyCenteredFlex>
+ </Stack>
+ </Box>
</Stack>
</Box>
</Stack>
diff --git a/apps/photos/src/services/clipService.ts b/apps/photos/src/services/clipService.ts
index fa2e4de425..1af3fe48e1 100644
--- a/apps/photos/src/services/clipService.ts
+++ b/apps/photos/src/services/clipService.ts
@@ -14,15 +14,46 @@ import { getPersonalFiles } from 'utils/file';
const CLIP_EMBEDDING_LENGTH = 512;
+export interface ClipExtractionStatus {
+ pending: number;
+ indexed: number;
+}
+
class ClipServiceImpl {
private electronAPIs: ElectronAPIs;
private embeddingExtractionInProgress: AbortController = null;
private reRunNeeded = false;
+ private clipExtractionStatus: ClipExtractionStatus = {
+ pending: 0,
+ indexed: 0,
+ };
+ private onUpdateHandler: (status: ClipExtractionStatus) => void = null;
constructor() {
this.electronAPIs = globalThis['ElectronAPIs'];
}
+ setOnUpdateHandler = (handler: (status: ClipExtractionStatus) => void) => {
+ this.onUpdateHandler = handler;
+ handler(this.clipExtractionStatus);
+ };
+
+ private updateClipEmbeddingExtractionStatus = (
+ status: ClipExtractionStatus
+ ) => {
+ this.clipExtractionStatus = status;
+ if (this.onUpdateHandler) {
+ this.onUpdateHandler(status);
+ }
+ };
+
+ onSuccessStatusUpdater = () => {
+ this.updateClipEmbeddingExtractionStatus({
+ pending: this.clipExtractionStatus.pending - 1,
+ indexed: this.clipExtractionStatus.indexed + 1,
+ });
+ };
+
scheduleImageEmbeddingExtraction = async () => {
try {
if (this.embeddingExtractionInProgress) {
@@ -79,6 +110,10 @@ class ClipServiceImpl {
localFiles,
existingEmbeddings
);
+ this.updateClipEmbeddingExtractionStatus({
+ indexed: existingEmbeddings.length,
+ pending: pendingFiles.length,
+ });
if (pendingFiles.length === 0) {
addLogLine('no clip embedding extraction needed, all done');
return;
@@ -120,6 +155,7 @@ class ClipServiceImpl {
encryptedEmbeddingData.decryptionHeader,
model: Model.GGML_CLIP,
});
+ this.onSuccessStatusUpdater();
addLogLine(
`successfully put clip embedding to server for file: ${file.metadata.title} fileID: ${file.id}`
);