Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat(files): add systemtags view
Signed-off-by: John Molakvoæ (skjnldsv) <[email protected]>
  • Loading branch information
skjnldsv committed Sep 18, 2023
commit 2845319187c6ae118338575798a3413b4613ecb6
4 changes: 2 additions & 2 deletions apps/dav/lib/SystemTag/SystemTagsInUseCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ public function getChildren(): array {
$tag = new SystemTag((string)$tagData['id'], $tagData['name'], (bool)$tagData['visibility'], (bool)$tagData['editable']);
// read only, so we can submit the isAdmin parameter as false generally
$node = new SystemTagNode($tag, $user, false, $this->systemTagManager);
$node->setNumberOfFiles($tagData['number_files']);
$node->setReferenceFileId($tagData['ref_file_id']);
$node->setNumberOfFiles((int) $tagData['number_files']);
$node->setReferenceFileId((int) $tagData['ref_file_id']);
$children[] = $node;
}
return $children;
Expand Down
7 changes: 7 additions & 0 deletions apps/files/src/components/FileEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ import AccountGroupIcon from 'vue-material-design-icons/AccountGroup.vue'
import FileIcon from 'vue-material-design-icons/File.vue'
import FolderIcon from 'vue-material-design-icons/Folder.vue'
import KeyIcon from 'vue-material-design-icons/Key.vue'
import TagIcon from 'vue-material-design-icons/Tag.vue'
import LinkIcon from 'vue-material-design-icons/Link.vue'
import NetworkIcon from 'vue-material-design-icons/Network.vue'
import AccountPlusIcon from 'vue-material-design-icons/AccountPlus.vue'
Expand Down Expand Up @@ -237,6 +238,7 @@ export default Vue.extend({
NcLoadingIcon,
NcTextField,
NetworkIcon,
TagIcon,
},

props: {
Expand Down Expand Up @@ -381,6 +383,11 @@ export default Vue.extend({
return KeyIcon
}

// System tags
if (this.source?.attributes?.['is-tag']) {
return TagIcon
}

// Link and mail shared folders
const shareTypes = Object.values(this.source?.attributes?.['share-types'] || {}).flat() as number[]
if (shareTypes.some(type => type === ShareType.SHARE_TYPE_LINK || type === ShareType.SHARE_TYPE_EMAIL)) {
Expand Down
29 changes: 1 addition & 28 deletions apps/files/src/services/Favorites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { getCurrentUser } from '@nextcloud/auth'

import { getClient, rootPath } from './WebdavClient'
import { getDavNameSpaces, getDavProperties, getDefaultPropfind } from './DavProperties'
import { resultToNode } from './Files'

const client = getClient()

Expand All @@ -47,34 +48,6 @@ interface ResponseProps extends DAVResultResponseProps {
size: number,
}

const resultToNode = function(node: FileStat): File | Folder {
const props = node.props as ResponseProps
const permissions = davParsePermissions(props?.permissions)
const owner = getCurrentUser()?.uid as string

const nodeData = {
id: props?.fileid as number || 0,
source: generateRemoteUrl('dav' + rootPath + node.filename),
mtime: new Date(node.lastmod),
mime: node.mime as string,
size: props?.size as number || 0,
permissions,
owner,
root: rootPath,
attributes: {
...node,
...props,
hasPreview: props?.['has-preview'],
},
}

delete nodeData.attributes.props

return node.type === 'file'
? new File(nodeData)
: new Folder(nodeData)
}

export const getContents = async (path = '/'): Promise<ContentsWithRoot> => {
const propfindPayload = getDefaultPropfind()

Expand Down
2 changes: 1 addition & 1 deletion apps/files/src/services/Files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ interface ResponseProps extends DAVResultResponseProps {
size: number,
}

const resultToNode = function(node: FileStat): File | Folder {
export const resultToNode = function(node: FileStat): File | Folder {
const props = node.props as ResponseProps
const permissions = davParsePermissions(props?.permissions)
const owner = getCurrentUser()?.uid as string
Expand Down
29 changes: 1 addition & 28 deletions apps/files/src/services/Recent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { getCurrentUser } from '@nextcloud/auth'

import { getClient, rootPath } from './WebdavClient'
import { getDavNameSpaces, getDavProperties } from './DavProperties'
import { resultToNode } from './Files'

const client = getClient(generateRemoteUrl('dav'))

Expand Down Expand Up @@ -94,34 +95,6 @@ interface ResponseProps extends DAVResultResponseProps {
size: number,
}

const resultToNode = function(node: FileStat): File | Folder {
const props = node.props as ResponseProps
const permissions = davParsePermissions(props?.permissions)
const owner = getCurrentUser()?.uid as string

const nodeData = {
id: props?.fileid as number || 0,
source: generateRemoteUrl('dav' + node.filename),
mtime: new Date(node.lastmod),
mime: node.mime as string,
size: props?.size as number || 0,
permissions,
owner,
root: rootPath,
attributes: {
...node,
...props,
hasPreview: props?.['has-preview'],
},
}

delete nodeData.attributes.props

return node.type === 'file'
? new File(nodeData)
: new Folder(nodeData)
}

export const getContents = async (path = '/'): Promise<ContentsWithRoot> => {
const contentsResponse = await client.getDirectoryContents(path, {
details: true,
Expand Down
12 changes: 11 additions & 1 deletion apps/files/src/views/FilesList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -328,12 +328,21 @@ export default Vue.extend({
},
},

mounted() {
this.fetchContent()
},

methods: {
async fetchContent() {
this.loading = true
const dir = this.dir
const currentView = this.currentView

if (!currentView) {
logger.debug('The current view doesn\'t exists or is not ready.', { currentView })
return
}

// If we have a cancellable promise ongoing, cancel it
if (typeof this.promise?.cancel === 'function') {
this.promise.cancel()
Expand Down Expand Up @@ -373,7 +382,8 @@ export default Vue.extend({
this.pathsStore.addPath({ service: currentView.id, fileid: node.fileid, path: join(dir, node.basename) })
})
} catch (error) {
logger.error('Error while fetching content', { error })
throw error
// logger.error('Error while fetching content', { error })
} finally {
this.loading = false
}
Expand Down
2 changes: 1 addition & 1 deletion apps/systemtags/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function boot(IBootContext $context): void {
LoadAdditionalScriptsEvent::class,
function () {
\OCP\Util::addScript('core', 'systemtags');
\OCP\Util::addScript(self::APP_ID, 'systemtags');
\OCP\Util::addInitScript(self::APP_ID, 'init');
}
);

Expand Down
131 changes: 0 additions & 131 deletions apps/systemtags/src/app.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,25 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
import './actions/inlineSystemTagsAction.js'

import './app.js'
import './systemtagsfilelist.js'
import './css/systemtagsfilelist.scss'
import './actions/inlineSystemTagsAction.ts'
import { translate as t } from '@nextcloud/l10n'
import { Column, Node, View, getNavigation } from '@nextcloud/files'
import TagMultipleSvg from '@mdi/svg/svg/tag-multiple.svg?raw'

window.OCA.SystemTags = OCA.SystemTags
import { getContents } from './services/systemtags.js'

const Navigation = getNavigation()
Navigation.register(new View({
id: 'systemtags',
name: t('systemtags', 'Tags'),
caption: t('systemtags', 'List of tags and their associated files and folders.'),

emptyTitle: t('systemtags', 'No tags found'),
emptyCaption: t('systemtags', 'Tags you have created will show up here.'),

icon: TagMultipleSvg,
order: 25,

getContents,
}))
8 changes: 3 additions & 5 deletions apps/systemtags/src/services/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,17 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
import type { FileStat, ResponseDataDetailed } from 'webdav'
import type { ServerTag, Tag, TagWithId } from '../types.js'

import axios from '@nextcloud/axios'
import { generateUrl } from '@nextcloud/router'
import { translate as t } from '@nextcloud/l10n'

import { davClient } from './davClient.js'
import { formatTag, parseIdFromLocation, parseTags } from '../utils.js'
import { formatTag, parseIdFromLocation, parseTags } from '../utils'
import { logger } from '../logger.js'

import type { FileStat, ResponseDataDetailed } from 'webdav'

import type { ServerTag, Tag, TagWithId } from '../types.js'

const fetchTagsBody = `<?xml version="1.0"?>
<d:propfind xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns">
<d:prop>
Expand Down
Loading