webpack added file_versions.js

This commit is contained in:
Terry 2021-04-22 16:04:10 +02:00
parent 528a5fa3bf
commit 46f77a7c9e
2 changed files with 33 additions and 27 deletions

View File

@ -31,13 +31,19 @@
<!-- Version content --> <!-- Version content -->
<template> <template>
<!-- Version information --> <!-- Version information -->
<ListItemIcon :versions="versionsList" icon="icon-text" title="10 days ago" subtitle="< 1KB"> <ListItemIcon :versions="versionsList"
icon="icon-text"
title="10 days ago"
subtitle="< 1KB">
<Actions> <Actions>
<ActionButton icon="icon-edit" @click="alert('Edit')">{{version.timestamp}}Restore</ActionButton> <ActionButton icon="icon-edit" @click="alert('Edit')">
<ActionButton icon="icon-delete" @click="alert('Delete')">Download</ActionButton> {{ version.timestamp }}Restore
</ActionButton>
<ActionButton icon="icon-delete" @click="alert('Delete')">
Download
</ActionButton>
</Actions> </Actions>
</ListItemIcon> </ListItemIcon>
</template> </template>
</div> </div>
</template> </template>
@ -47,17 +53,18 @@
import Avatar from '@nextcloud/vue/dist/Components/Avatar' import Avatar from '@nextcloud/vue/dist/Components/Avatar'
import axios from '@nextcloud/axios' import axios from '@nextcloud/axios'
import { generateRemoteUrl} from "@nextcloud/router"; import { generateRemoteUrl } from '@nextcloud/router'
import { ListItemIcon } from '@nextcloud/vue' import { ListItemIcon } from '@nextcloud/vue'
import { getCurrentUser } from '@nextcloud/auth'
import { sendHeartbeat } from '../../../user_status/src/services/heartbeatService'
export default { export default {
name: 'VersionTab', name: 'VersionTab',
components: { components: {
Avatar,
ListItemIcon, ListItemIcon,
VersionEntry VersionEntry,
}, },
data() { data() {
@ -79,32 +86,31 @@ export default {
} }
}, },
methods: { methods: {
setFileInfo (fileInfo) { setFileInfo(fileInfo) {
this._fileInfo = fileInfo this._fileInfo = fileInfo
}, },
getFileInfo () { getFileInfo() {
return this._fileInfo return this._fileInfo
}, },
setCurrentUser (user) { setCurrentUser(user) {
this._currentUser = user this._currentUser = user
}, },
getCurrentUser () { getCurrentUser() {
return this._currentUser || OC.getCurrentUser().uid return this._currentUser || getCurrentUser().uid
}, },
setClient (client) { setClient(client) {
this._client = client this._client = client
}, },
/** /**
* Update current fileInfo and fetch new data * Update current fileInfo and fetch new data
* @param {Object} fileInfo the current file FileInfo * @param {Object} fileInfo the current file FileInfo
*/ */
async update (fileInfo) { async update(fileInfo) {
fileInfo = this.fileInfo fileInfo = this.fileInfo
name = this._fileInfo.get('name') name = this._fileInfo.get('name')
}, },
@ -116,19 +122,19 @@ export default {
/** /**
* Get the existing shares infos * Get the existing shares infos
*/ */
async getVersions () { async getVersions() {
try { try {
this.loading = true this.loading = true
// init params // init params
const shareUrl = generateRemoteUrl('dav') + this.getCurrentUser() + '/versions/' + this._fileInfo.get('id') const shareUrl = generateRemoteUrl('dav') + this.getCurrentUser() + '/versions/' + this._fileInfo.get('id')
const format = 'json' const format = 'json'
console.log('Shareurl:', shareUrl); console.log('Shareurl:', shareUrl)
// TODO: replace with proper getFUllpath implementation of our own FileInfo model // TODO: replace with proper getFUllpath implementation of our own FileInfo model
const path = (this.fileInfo.path + '/' + this.fileInfo.name).replace('//', '/') const path = (this.fileInfo.path + '/' + this.fileInfo.name).replace('//', '/')
console.log(path); console.log(path)
// fetch version // fetch version
const fetchVersion = await axios.get(shareUrl, { const fetchVersion = await axios.get(shareUrl, {
params: { params: {
format, format,
@ -139,7 +145,7 @@ export default {
this.loading = false this.loading = false
// process results // process results
this.versionList = fetchVersion.data this.versionList = fetchVersion.data
console.log(versionList); console.log(versionList)
this.version.fullPath = fullPath this.version.fullPath = fullPath
this.version.fileId = fileId this.version.fileId = fileId
this.version.name = name this.version.name = name
@ -155,9 +161,9 @@ export default {
console.error('Error loading the version list', error) console.error('Error loading the version list', error)
} }
}, },
mounted(){ mounted() {
this.getVersions(); this.getVersions()
} },
} },
} }
</script> </script>

View File

@ -26,8 +26,8 @@ const path = require('path')
module.exports = { module.exports = {
entry: { entry: {
// files_versions : path.join(__dirname, 'src', 'files_versions.js'), files_versions: path.join(__dirname, 'src', 'files_versions.js'),
files_versions_tab : path.join(__dirname, 'src', 'files_versions_tab.js'), files_versions_tab: path.join(__dirname, 'src', 'files_versions_tab.js'),
}, },
output: { output: {
path: path.resolve(__dirname, './js'), path: path.resolve(__dirname, './js'),