-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e15c6f3
commit 59f2e9a
Showing
5 changed files
with
90 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import React, { useState } from 'react'; | ||
|
||
import { Modal } from '@renderer/components/UI'; | ||
import { EditorManager } from '@renderer/lib/data/EditorManager'; | ||
import { getPlatform } from '@renderer/lib/data/PlatformLoader'; | ||
import { Platform } from '@renderer/types/platform'; | ||
interface FilePropertiesModalProps { | ||
isOpen: boolean; | ||
onClose: () => void; | ||
manager: EditorManager; | ||
} | ||
|
||
export const FilePropertiesModal: React.FC<FilePropertiesModalProps> = ({ | ||
onClose, | ||
manager, | ||
...props | ||
}) => { | ||
const [fileSize, setFileSize] = useState<number>(0); | ||
const [fileLastModified, setFileLastModified] = useState<Date>(); | ||
const [fileBirthDate, setFileBirthDate] = useState<Date>(); | ||
const [platform, setPlatform] = useState<Platform | undefined>(undefined); | ||
// получение метаданных о файле | ||
const onAfterOpen = () => { | ||
window.electron.ipcRenderer.invoke('File:getMetadata', manager.data?.basename).then((stat) => { | ||
setFileBirthDate(stat['birthtime']); | ||
setFileLastModified(stat['mtime']); | ||
setFileSize(stat['size']); | ||
}); | ||
|
||
setPlatform(getPlatform(manager.data.elements.platform)); | ||
//setPlatform(getPlatform(manager.data.elements.platform)); | ||
}; | ||
// получить строку, предназначенную для чтения пользователем | ||
function dateFormat(date: Date | undefined): string { | ||
if (!date) { | ||
return ''; | ||
} | ||
return `${date.getDate()}.${ | ||
date.getMonth() + 1 | ||
}.${date.getFullYear()}, ${date.getHours()}:${date.getMinutes()}`; | ||
} | ||
return ( | ||
<Modal {...props} onRequestClose={onClose} onAfterOpen={onAfterOpen} title="Свойства"> | ||
<div> | ||
<b>Название:</b> {manager.data.name} | ||
<br /> | ||
<b>Платформа:</b> {platform?.name} | ||
<br /> | ||
<b>Путь к файлу:</b> {manager.data.basename} | ||
<br /> | ||
<b>Дата и время последнего изменения файла:</b> {dateFormat(fileLastModified)} | ||
<br /> | ||
<b>Дата и время создания файла:</b> {dateFormat(fileBirthDate)} | ||
<br /> | ||
<b>Размер файла:</b> {`${fileSize} байтов`} | ||
<br /> | ||
</div> | ||
</Modal> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters