Remove Permissions and add Date formatting in File listing
Removed 'Permissions' column from the file listing in index.html to declutter the view. Instead of showing permissions, we now format the 'Modified' field with a human-friendly date format, to improve readability. This involves changes in 'list.js', where the field 'Permissions' is now replaced with a formatted 'Modified' date. Additionally, a 'formatDate' function is added in 'files.js' to handle the new date formatting logic.
This commit is contained in:
parent
00a7c6e684
commit
d7abbd21fd
|
@ -59,7 +59,6 @@
|
||||||
<tr class="sticky top-0 bg-red-500">
|
<tr class="sticky top-0 bg-red-500">
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
<th>Size</th>
|
<th>Size</th>
|
||||||
<th>Permissions</th>
|
|
||||||
<th>Modified</th>
|
<th>Modified</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
@ -71,7 +70,6 @@
|
||||||
<tr data-el="action">
|
<tr data-el="action">
|
||||||
<td data-el="name"></td>
|
<td data-el="name"></td>
|
||||||
<td data-el="size"></td>
|
<td data-el="size"></td>
|
||||||
<td data-el="permission"></td>
|
|
||||||
<td data-el="modified"></td>
|
<td data-el="modified"></td>
|
||||||
</tr>
|
</tr>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -90,4 +90,20 @@ export const formatDirectoryItemCount = (directoryItemCount) => {
|
||||||
|
|
||||||
export const openFile = async (path) => {
|
export const openFile = async (path) => {
|
||||||
return await tauriInvoke('open_file', { path });
|
return await tauriInvoke('open_file', { path });
|
||||||
|
}
|
||||||
|
|
||||||
|
export const formatDate = (timestamp) => {
|
||||||
|
const now = (new Date).getTime();
|
||||||
|
const date = new Date(parseInt(`${timestamp}000`))
|
||||||
|
const then = (date).getTime();
|
||||||
|
const diff = now - then;
|
||||||
|
const diffInDays = Math.floor(diff/(1000 * 60 * 60 * 24));
|
||||||
|
|
||||||
|
if (diffInDays <= 0) {
|
||||||
|
return `${date.getHours()}:${date.getMinutes()}`;
|
||||||
|
} else if (diffInDays <= 365) {
|
||||||
|
return `${date.toLocaleString('default', { month: 'short' })} ${date.getDate()}`
|
||||||
|
}
|
||||||
|
|
||||||
|
return `${date.toLocaleString('default', { month: 'short' })} ${date.getDate()} ${date.getFullYear()}`;
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
import {getTemplate} from "../../libs/template.js";
|
import {getTemplate} from "../../libs/template.js";
|
||||||
import {formatBytes, formatDirectoryItemCount, getEntries, openFile} from "../files.js";
|
import {formatBytes, formatDate, formatDirectoryItemCount, getEntries, openFile} from "../files.js";
|
||||||
import {getCurrentDir, navigate} from "../../libs/navigation.js";
|
import {getCurrentDir, navigate} from "../../libs/navigation.js";
|
||||||
import {getOneElementOrThrow} from "../../libs/element.js";
|
import {getOneElementOrThrow} from "../../libs/element.js";
|
||||||
import {sep} from "../../libs/path.js";
|
import {sep} from "../../libs/path.js";
|
||||||
|
@ -42,8 +42,7 @@ export const renderListFiles = () => {
|
||||||
if (entry.is_directory) prefix = sep;
|
if (entry.is_directory) prefix = sep;
|
||||||
return `${prefix}${value}`;
|
return `${prefix}${value}`;
|
||||||
});
|
});
|
||||||
applyValue(entry, itemTemplate, 'permission')
|
applyValue(entry, itemTemplate, 'modified', (value) => formatDate(value))
|
||||||
applyValue(entry, itemTemplate, 'modified')
|
|
||||||
applyValue(
|
applyValue(
|
||||||
entry,
|
entry,
|
||||||
itemTemplate,
|
itemTemplate,
|
||||||
|
|
Loading…
Reference in New Issue