TagSpaces is an offline, open source, document manager with tagging support
Tsn409 read macos tags (#1159)
Stanimirfb1953fcb60e
diff --git a/app/components/dialogs/ProgressDialog.tsx b/app/components/dialogs/ProgressDialog.tsxnew file mode 100644index 000000000..2865f29e2--- /dev/null+++ b/app/components/dialogs/ProgressDialog.tsx@@ -0,0 +1,47 @@+/**+ * TagSpaces - universal file and folder organizer+ * Copyright (C) 2017-present TagSpaces UG (haftungsbeschraenkt)+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License (version 3) as+ * published by the Free Software Foundation.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ *+ */++import React from 'react';+import DialogContent from '@material-ui/core/DialogContent';+import DialogTitle from '@material-ui/core/DialogTitle';+import Dialog from '@material-ui/core/Dialog';+import { CircularProgress } from '@material-ui/core';++interface Props {+ open: boolean;+ onClose: () => void;+}++const ProgressDialog = (props: Props) => (+ <Dialog open={props.open} onClose={props.onClose}>+ <DialogTitle data-tid="progressDialogTitle">+ {/* {i18n.t('core:importDialogTitle')} */}+ </DialogTitle>+ <DialogContent+ style={{+ marginLeft: 'auto',+ marginRight: 'auto',+ flexGrow: 1+ }}+ >+ <CircularProgress size={24} />+ </DialogContent>+ </Dialog>+);++export default ProgressDialog;diff --git a/app/components/menus/DirectoryMenu.tsx b/app/components/menus/DirectoryMenu.tsxindex 3b1fcb231..3f0a31665 100644--- a/app/components/menus/DirectoryMenu.tsx+++ b/app/components/menus/DirectoryMenu.tsx@@ -28,6 +28,7 @@ import Divider from '@material-ui/core/Divider';// import ContentExtractionIcon from '@material-ui/icons/TrackChanges';import OpenFolderIcon from '@material-ui/icons/SubdirectoryArrowLeft';import AddExistingFileIcon from '@material-ui/icons/ExitToApp';+import ImportTagsIcon from '@material-ui/icons/FindInPage';import OpenFolderNativelyIcon from '@material-ui/icons/Launch';import AutoRenew from '@material-ui/icons/Autorenew';import DefaultPerspectiveIcon from '@material-ui/icons/GridOn';@@ -40,6 +41,7 @@ import RenameFolderIcon from '@material-ui/icons/FormatTextdirectionLToR';import DeleteForeverIcon from '@material-ui/icons/DeleteForever';import SettingsIcon from '@material-ui/icons/Settings';import { Progress } from 'aws-sdk/clients/s3';+import { Pro } from '../../pro';import ConfirmDialog from '../dialogs/ConfirmDialog';import CreateDirectoryDialog from '../dialogs/CreateDirectoryDialog';import RenameDirectoryDialog from '../dialogs/RenameDirectoryDialog';@@ -54,6 +56,8 @@ import PlatformIO from '-/services/platform-io';import { formatDateTime4Tag } from '-/utils/misc';import { actions as AppActions } from '-/reducers/app';import IOActions from '-/reducers/io-actions';+import { Tag } from '-/reducers/taglibrary';+import TaggingActions from '-/reducers/tagging-actions';interface Props {open: boolean;@@ -83,7 +87,13 @@ interface Props {) => void;isReadOnlyMode?: boolean;toggleUploadDialog: () => void;+ toggleProgressDialog: () => void;resetProgress: () => void;+ addTags: (+ paths: Array<string>,+ tags: Array<Tag>,+ updateIndex: boolean+ ) => void;}const DirectoryMenu = (props: Props) => {@@ -163,6 +173,45 @@ const DirectoryMenu = (props: Props) => {fileInput.click();}+ function importMacTags() {+ props.onClose();+ if (Pro && Pro.MacTagsImport && Pro.MacTagsImport.importTags) {+ props.toggleProgressDialog();++ const entryCallback = entry => {+ Pro.MacTagsImport.readMacOSTags(entry.path)+ .then(tags => {+ if (tags.length > 0) {+ props.addTags([entry.path], tags, true);+ }+ return tags;+ })+ .catch(err => {+ console.warn('Error creating tags: ' + err);+ });+ };+ Pro.MacTagsImport.importTags(props.directoryPath, entryCallback)+ .then(() => {+ // props.loadDirectoryContent(props.directoryPath); // TODO after first import tags is not imported without reloadDirContent+ props.toggleProgressDialog();+ console.log('Import tags succeeded ' + props.directoryPath);+ props.showNotification(+ 'Tags from ' + props.directoryPath + ' are imported successfully.',+ 'default',+ true+ );+ return true;+ })+ .catch(err => {+ console.warn('Error importing tags: ' + err);+ props.toggleProgressDialog();+ });+ } else {+ props.showNotification(i18n.t('core:proFeature'), 'default', true);+ return true;+ }+ }+function onFail(message) {console.log('Camera Failed: ' + message);}@@ -419,6 +468,14 @@ const DirectoryMenu = (props: Props) => {<ListItemText primary={i18n.t('core:addFiles')} /></MenuItem>)}+ {process.platform === 'darwin' && (+ <MenuItem data-tid="importMacTags" onClick={importMacTags}>+ <ListItemIcon>+ <ImportTagsIcon />+ </ListItemIcon>+ <ListItemText primary={i18n.t('core:importMacTags')} />+ </MenuItem>+ )}{AppConfig.isCordova && (<MenuItem data-tid="takePicture" onClick={cameraTakePicture}><ListItemIcon>@@ -506,9 +563,11 @@ function mapDispatchToProps(dispatch) {showNotification: AppActions.showNotification,onUploadProgress: AppActions.onUploadProgress,toggleUploadDialog: AppActions.toggleUploadDialog,+ toggleProgressDialog: AppActions.toggleProgressDialog,resetProgress: AppActions.resetProgress,extractContent: IOActions.extractContent,- uploadFilesAPI: IOActions.uploadFilesAPI+ uploadFilesAPI: IOActions.uploadFilesAPI,+ addTags: TaggingActions.addTags},dispatch);diff --git a/app/containers/MainPage.tsx b/app/containers/MainPage.tsxindex f4113a25b..71816a5da 100644--- a/app/containers/MainPage.tsx+++ b/app/containers/MainPage.tsx@@ -70,7 +70,8 @@ import {isUploadDialogOpened,isCreateFileDialogOpened,isSettingsDialogOpened,- isReadOnlyMode+ isReadOnlyMode,+ isProgressOpened} from '../reducers/app';import {actions as LocationIndexActions,@@ -88,6 +89,7 @@ import withDnDContext from '-/containers/withDnDContext';import { CustomDragLayer } from '-/components/CustomDragLayer';import IOActions from '-/reducers/io-actions';import FileUploadDialog from '-/components/dialogs/FileUploadDialog';+import ProgressDialog from '-/components/dialogs/ProgressDialog';const initialSplitSize = 44;const drawerWidth = 300;@@ -155,8 +157,10 @@ interface Props {isOnboardingDialogOpened: boolean;isSelectDirectoryDialogOpened: boolean;isUploadProgressDialogOpened: boolean;+ isProgressDialogOpened: boolean;toggleSelectDirectoryDialog: () => void;toggleUploadDialog: () => void;+ toggleProgressDialog: () => void;resetProgress: () => void;isEditTagDialogOpened: boolean;keyBindings: any;@@ -623,6 +627,7 @@ class MainPage extends Component<Props, State> {isCreateDirectoryOpened,isEditTagDialogOpened,isUploadProgressDialogOpened,+ isProgressDialogOpened,toggleOnboardingDialog,toggleSettingsDialog,toggleKeysDialog,@@ -633,6 +638,7 @@ class MainPage extends Component<Props, State> {toggleCreateFileDialog,toggleSelectDirectoryDialog,toggleUploadDialog,+ toggleProgressDialog,toggleEditTagDialog,setFirstRun,openURLExternally,@@ -703,6 +709,12 @@ class MainPage extends Component<Props, State> {onClose={toggleUploadDialog}/>)}+ {isProgressDialogOpened && (+ <ProgressDialog+ open={isProgressDialogOpened}+ onClose={toggleProgressDialog}+ />+ )}<CreateDirectoryDialogopen={isCreateDirectoryOpened}onClose={toggleCreateDirectoryDialog}@@ -920,6 +932,7 @@ function mapStateToProps(state) {isLicenseDialogOpened: isLicenseDialogOpened(state),isThirdPartyLibsDialogOpened: isThirdPartyLibsDialogOpened(state),isUploadProgressDialogOpened: isUploadDialogOpened(state),+ isProgressDialogOpened: isProgressOpened(state),isIndexing: isIndexing(state),isReadOnlyMode: isReadOnlyMode(state),isGeneratingThumbs: isGeneratingThumbs(state),@@ -948,6 +961,7 @@ function mapDispatchToProps(dispatch) {toggleCreateDirectoryDialog: AppActions.toggleCreateDirectoryDialog,toggleSelectDirectoryDialog: AppActions.toggleSelectDirectoryDialog,toggleUploadDialog: AppActions.toggleUploadDialog,+ toggleProgressDialog: AppActions.toggleProgressDialog,resetProgress: AppActions.resetProgress,toggleEditTagDialog: AppActions.toggleEditTagDialog,hideNotifications: AppActions.hideNotifications,diff --git a/app/locales/en/core.json b/app/locales/en/core.jsonindex 916d198ab..9c1f47b94 100644--- a/app/locales/en/core.json+++ b/app/locales/en/core.json@@ -467,5 +467,6 @@"importDialogTitle": "Import Files","stopAll": "Stop all","fileExist": "File with the same name already exist",+ "importMacTags": "Import macOS tags","-": "-"}diff --git a/app/reducers/app.ts b/app/reducers/app.tsindex 3a2eeb0e2..57b91cdcf 100644--- a/app/reducers/app.ts+++ b/app/reducers/app.ts@@ -84,6 +84,7 @@ export const types = {TOGGLE_CREATE_FILE_DIALOG: 'APP/TOGGLE_CREATE_FILE_DIALOG',TOGGLE_SELECT_DIRECTORY_DIALOG: 'APP/TOGGLE_SELECT_DIRECTORY_DIALOG',TOGGLE_UPLOAD_DIALOG: 'APP/TOGGLE_UPLOAD_DIALOG',+ TOGGLE_PROGRESS_DIALOG: 'APP/TOGGLE_PROGRESS_DIALOG',OPEN_LOCATIONMANAGER_PANEL: 'APP/OPEN_LOCATIONMANAGER_PANEL',OPEN_TAGLIBRARY_PANEL: 'APP/OPEN_TAGLIBRARY_PANEL',OPEN_SEARCH_PANEL: 'APP/OPEN_SEARCH_PANEL',@@ -309,6 +310,12 @@ export default (state: any = initialState, action: any) => {}return state;}+ case types.TOGGLE_PROGRESS_DIALOG: {+ return {+ ...state,+ progressDialogOpened: !state.progressDialogOpened+ };+ }case types.SET_SEARCH_RESULTS: {return {...state,@@ -679,6 +686,9 @@ export const actions = {toggleUploadDialog: () => ({type: types.TOGGLE_UPLOAD_DIALOG}),+ toggleProgressDialog: () => ({+ type: types.TOGGLE_PROGRESS_DIALOG+ }),openLocationManagerPanel: () => ({ type: types.OPEN_LOCATIONMANAGER_PANEL }),openTagLibraryPanel: () => ({ type: types.OPEN_TAGLIBRARY_PANEL }),openSearchPanel: () => ({ type: types.OPEN_SEARCH_PANEL }),@@ -1751,6 +1761,7 @@ export const isSelectDirectoryDialogOpened = (state: any) =>state.app.selectDirectoryDialogOpened;export const isUploadDialogOpened = (state: any) =>state.app.uploadDialogOpened;+export const isProgressOpened = (state: any) => state.app.progressDialogOpened;export const getOpenedFiles = (state: any) => state.app.openedFiles;export const getNotificationStatus = (state: any) =>state.app.notificationStatus;diff --git a/app/services/utils-io.ts b/app/services/utils-io.tsindex 601da2a74..afb16d816 100644--- a/app/services/utils-io.ts+++ b/app/services/utils-io.ts@@ -187,6 +187,7 @@ export function walkDirectory(recursive: false,skipMetaFolder: true,skipDotHiddenFolder: false,+ skipDotHiddenFiles: false,loadMetaDate: true,extractText: false,...options@@ -205,13 +206,23 @@ export function walkDirectory(}if (entry.isFile) {- if (fileCallback) {+ if (+ fileCallback &&+ (!mergedOptions.skipDotHiddenFiles ||+ !entry.name.startsWith('.'))+ ) {fileCallback(entry);}return entry;}- if (dirCallback) {+ if (+ dirCallback &&+ (!mergedOptions.skipDotHiddenFolder ||+ !entry.name.startsWith('.')) &&+ (!mergedOptions.skipMetaFolder ||+ entry.name !== AppConfig.metaFolder)+ ) {dirCallback(entry);}