Skip to content

Commit

Permalink
feat: add modified column
Browse files Browse the repository at this point in the history
Signed-off-by: John Molakvoæ <[email protected]>
  • Loading branch information
skjnldsv committed Jun 22, 2023
1 parent c20648c commit 9b94781
Show file tree
Hide file tree
Showing 11 changed files with 73 additions and 13 deletions.
25 changes: 25 additions & 0 deletions apps/files/src/components/FileEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,13 @@
<span>{{ size }}</span>
</td>

<!-- Mtime -->
<td v-if="isMtimeAvailable"
class="files-list__row-mtime"
@click="openDetailsIfAvailable">
<span>{{ mtime }}</span>
</td>

<!-- View columns -->
<td v-for="column in columns"
:key="column.id"
Expand Down Expand Up @@ -165,6 +172,7 @@ import { hashCode } from '../utils/hashUtils.ts'
import { isCachedPreview } from '../services/PreviewService.ts'
import { useActionsMenuStore } from '../store/actionsmenu.ts'
import { useFilesStore } from '../store/files.ts'
import type moment from 'moment'
import { useKeyboardStore } from '../store/keyboard.ts'
import { useSelectionStore } from '../store/selection.ts'
import { useUserConfigStore } from '../store/userconfig.ts'
Expand Down Expand Up @@ -200,6 +208,10 @@ export default Vue.extend({
type: Boolean,
default: false,
},
isMtimeAvailable: {
type: Boolean,
default: false,
},
isSizeAvailable: {
type: Boolean,
default: false,
Expand Down Expand Up @@ -300,6 +312,19 @@ export default Vue.extend({
return minOpacity + (1 - minOpacity) * Math.pow((this.source.size / maxOpacitySize), 2)
},
mtime() {
if (this.source.mtime) {
return moment(this.source.mtime).fromNow()
}
return this.t('files_trashbin', 'A long time ago')
},
mtimeTitle() {
if (this.source.mtime) {
return moment(this.source.mtime).format('LLL')
}
return ''
},
linkTo() {
if (this.enabledDefaultActions.length > 0) {
const action = this.enabledDefaultActions[0]
Expand Down
8 changes: 8 additions & 0 deletions apps/files/src/components/FilesListFooter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
<span>{{ totalSize }}</span>
</td>

<!-- Mtime -->
<td v-if="isMtimeAvailable"
class="files-list__column files-list__row-mtime" />

<!-- Custom views columns -->
<th v-for="column in columns"
:key="column.id"
Expand All @@ -67,6 +71,10 @@ export default Vue.extend({
},

props: {
isMtimeAvailable: {
type: Boolean,
default: false,
},
isSizeAvailable: {
type: Boolean,
default: false,
Expand Down
11 changes: 11 additions & 0 deletions apps/files/src/components/FilesListHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@
<FilesListHeaderButton :name="t('files', 'Size')" mode="size" />
</th>

<!-- Mtime -->
<th v-if="isMtimeAvailable"
:class="{'files-list__column--sortable': isMtimeAvailable}"
class="files-list__column files-list__row-mtime">
<FilesListHeaderButton :name="t('files', 'Modified')" mode="mtime" />
</th>

<!-- Custom views columns -->
<th v-for="column in columns"
:key="column.id"
Expand Down Expand Up @@ -91,6 +98,10 @@ export default Vue.extend({
],
props: {
isMtimeAvailable: {
type: Boolean,
default: false,
},
isSizeAvailable: {
type: Boolean,
default: false,
Expand Down
15 changes: 15 additions & 0 deletions apps/files/src/components/FilesListVirtual.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<!-- File row -->
<FileEntry :active="active"
:index="index"
:is-mtime-available="isMtimeAvailable"
:is-size-available="isSizeAvailable"
:files-list-width="filesListWidth"
:nodes="nodes"
Expand All @@ -50,13 +51,15 @@

<!-- Thead-->
<FilesListHeader :files-list-width="filesListWidth"
:is-mtime-available="isMtimeAvailable"
:is-size-available="isSizeAvailable"
:nodes="nodes" />
</template>

<template #after>
<!-- Tfoot-->
<FilesListFooter :files-list-width="filesListWidth"
:is-mtime-available="isMtimeAvailable"
:is-size-available="isSizeAvailable"
:nodes="nodes"
:summary="summary" />
Expand Down Expand Up @@ -121,6 +124,13 @@ export default Vue.extend({
summary() {
return translate('files', '{summaryFile} and {summaryFolder}', this)
},
isMtimeAvailable() {
// Hide mtime column on narrow screens
if (this.filesListWidth < 768) {
return false
}
return this.nodes.some(node => node.mtime !== undefined)
},
isSizeAvailable() {
// Hide size column on narrow screens
if (this.filesListWidth < 768) {
Expand Down Expand Up @@ -355,6 +365,7 @@ export default Vue.extend({
}
}
.files-list__row-mtime,
.files-list__row-size {
// Right align text
justify-content: flex-end;
Expand All @@ -371,6 +382,10 @@ export default Vue.extend({
}
}
.files-list__row-mtime {
width: calc(var(--row-height) * 2);
}
.files-list__row-column-custom {
width: calc(var(--row-height) * 2);
}
Expand Down
2 changes: 1 addition & 1 deletion apps/files/src/store/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
/* eslint-disable */
import type { Folder, Node } from '@nextcloud/files'
import type { FilesStore, RootsStore, RootOptions, Service, FilesState } from '../types.ts'
import type { FilesStore, RootsStore, RootOptions, Service, FilesState } from '../types'

import { defineStore } from 'pinia'
import { subscribe } from '@nextcloud/event-bus'
Expand Down
2 changes: 1 addition & 1 deletion apps/files/src/store/paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
*/
/* eslint-disable */
import type { PathOptions, ServicesState } from '../types.ts'
import type { PathOptions, ServicesState } from '../types'

import { defineStore } from 'pinia'
import { subscribe } from '@nextcloud/event-bus'
Expand Down
2 changes: 1 addition & 1 deletion apps/files/src/store/userconfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { generateUrl } from '@nextcloud/router'
import { defineStore } from 'pinia'
import Vue from 'vue'
import axios from '@nextcloud/axios'
import type { UserConfig, UserConfigStore } from '../types.ts'
import type { UserConfig, UserConfigStore } from '../types'
import { emit, subscribe } from '@nextcloud/event-bus'

const userConfig = loadState('files', 'config', {
Expand Down
2 changes: 1 addition & 1 deletion apps/files/src/views/Navigation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import FolderSvg from '@mdi/svg/svg/folder.svg'
import ShareSvg from '@mdi/svg/svg/share-variant.svg'
import { createTestingPinia } from '@pinia/testing'

import NavigationService from '../services/Navigation.ts'
import NavigationService from '../services/Navigation'
import NavigationView from './Navigation.vue'
import router from '../router/router.js'
import { useViewConfigStore } from '../store/viewConfig'
Expand Down
12 changes: 6 additions & 6 deletions apps/files/src/views/favorites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
import type NavigationService from '../services/Navigation.ts'
import type { Navigation } from '../services/Navigation.ts'
import type { Navigation } from '../services/Navigation'
import type NavigationService from '../services/Navigation'
import { getLanguage, translate as t } from '@nextcloud/l10n'
import StarSvg from '@mdi/svg/svg/star.svg?raw'
import FolderSvg from '@mdi/svg/svg/folder.svg?raw'
import StarSvg from '@mdi/svg/svg/star.svg?raw'

import { getContents } from '../services/Favorites.ts'
import { loadState } from '@nextcloud/initial-state'
import { basename } from 'path'
import { getContents } from '../services/Favorites'
import { hashCode } from '../utils/hashUtils'
import { subscribe } from '@nextcloud/event-bus'
import { loadState } from '@nextcloud/initial-state'
import { Node, FileType } from '@nextcloud/files'
import { subscribe } from '@nextcloud/event-bus'
import logger from '../logger'

const generateFolderView = function(folder: string, index = 0): Navigation {
Expand Down
4 changes: 2 additions & 2 deletions apps/files_trashbin/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
import type NavigationService from '../../files/src/services/Navigation.ts'
import type { Navigation } from '../../files/src/services/Navigation.ts'
import type NavigationService from '../../files/src/services/Navigation'
import type { Navigation } from '../../files/src/services/Navigation'

import { translate as t, translate } from '@nextcloud/l10n'
import DeleteSvg from '@mdi/svg/svg/delete.svg?raw'
Expand Down
3 changes: 2 additions & 1 deletion apps/files_trashbin/src/services/trashbin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ const resultToNode = function(node: FileStat): File | Folder {
const nodeData = {
id: node.props?.fileid as number || 0,
source: generateRemoteUrl('dav' + rootPath + node.filename),
mtime: new Date(node.lastmod),
// do not show the mtime column
// mtime: new Date(node.lastmod),
mime: node.mime as string,
size: node.props?.size as number || 0,
permissions,
Expand Down

0 comments on commit 9b94781

Please sign in to comment.