2017-06-28 10:45:41 +00:00
|
|
|
<template>
|
|
|
|
<div id="app">
|
|
|
|
<header>
|
2017-06-28 21:20:28 +00:00
|
|
|
<div>
|
2017-06-28 18:26:07 +00:00
|
|
|
<img src="./assets/logo.svg" alt="File Manager">
|
|
|
|
<search></search>
|
|
|
|
</div>
|
2017-06-28 21:20:28 +00:00
|
|
|
<div>
|
2017-06-29 10:34:47 +00:00
|
|
|
<rename-button v-show="showRenameButton()"></rename-button>
|
|
|
|
<move-button v-show="showDeleteButton()"></move-button>
|
|
|
|
<delete-button v-show="showDeleteButton()"></delete-button>
|
2017-06-29 08:11:46 +00:00
|
|
|
<switch-button v-show="req.kind !== 'editor'"></switch-button>
|
|
|
|
<download-button></download-button>
|
|
|
|
<upload-button v-show="showUpload()"></upload-button>
|
2017-06-28 18:26:07 +00:00
|
|
|
<info-button></info-button>
|
|
|
|
</div>
|
|
|
|
<!-- <div id="click-overlay"></div> -->
|
2017-06-28 10:45:41 +00:00
|
|
|
</header>
|
|
|
|
<nav id="sidebar">
|
2017-06-28 15:05:30 +00:00
|
|
|
<a class="action" :href="baseURL + '/'">
|
2017-06-28 10:45:41 +00:00
|
|
|
<i class="material-icons">folder</i>
|
|
|
|
<span>My Files</span>
|
|
|
|
</a>
|
|
|
|
<div class="action" id="logout" tabindex="0" role="button" aria-label="Log out">
|
|
|
|
<i class="material-icons" title="Logout">exit_to_app</i>
|
|
|
|
<span>Logout</span>
|
|
|
|
</div>
|
|
|
|
</nav>
|
|
|
|
<main>
|
2017-06-29 08:11:46 +00:00
|
|
|
<listing v-if="req.kind === 'listing'"></listing>
|
2017-06-28 10:45:41 +00:00
|
|
|
</main>
|
|
|
|
|
2017-06-29 08:11:46 +00:00
|
|
|
<preview v-if="req.kind === 'preview'"></preview>
|
2017-06-28 10:45:41 +00:00
|
|
|
|
|
|
|
<!-- TODO: show on listing and allowedit -->
|
|
|
|
<div class="floating">
|
|
|
|
<div tabindex="0" role="button" class="action" id="new">
|
|
|
|
<i class="material-icons" title="New file or directory">add</i>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- TODO ??? -->
|
|
|
|
<div id="multiple-selection" class="mobile-only">
|
|
|
|
<p>Multiple selection enabled</p>
|
|
|
|
<div tabindex="0" role="button" class="action" id="multiple-selection-cancel">
|
|
|
|
<i class="material-icons" title="Clear">clear</i>
|
|
|
|
</div>
|
|
|
|
</div>
|
2017-06-28 21:24:00 +00:00
|
|
|
|
2017-06-29 10:34:47 +00:00
|
|
|
<rename-prompt v-show="showRename" :class="{ active: showRename }"></rename-prompt>
|
|
|
|
<delete-prompt v-show="showDelete" :class="{ active: showDelete }"></delete-prompt>
|
2017-06-28 21:20:28 +00:00
|
|
|
<info-prompt v-show="showInfo" :class="{ active: showInfo }"></info-prompt>
|
|
|
|
<help v-show="showHelp" :class="{ active: showHelp }"></help>
|
|
|
|
|
2017-06-29 09:17:35 +00:00
|
|
|
<div v-show="showOverlay()" @click="resetPrompts" class="overlay" :class="{ active: showOverlay() }"></div>
|
2017-06-28 21:20:28 +00:00
|
|
|
|
|
|
|
<footer>Served with <a rel="noopener noreferrer" href="https://github.com/hacdias/caddy-filemanager">File Manager</a>.</footer>
|
2017-06-28 10:45:41 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import Search from './components/Search'
|
|
|
|
import Preview from './components/Preview'
|
2017-06-28 21:20:28 +00:00
|
|
|
import Help from './components/Help'
|
2017-06-28 10:45:41 +00:00
|
|
|
import Listing from './components/Listing'
|
2017-06-28 18:26:07 +00:00
|
|
|
import InfoButton from './components/InfoButton'
|
2017-06-28 21:20:28 +00:00
|
|
|
import InfoPrompt from './components/InfoPrompt'
|
2017-06-28 21:24:00 +00:00
|
|
|
import DeleteButton from './components/DeleteButton'
|
2017-06-29 10:34:47 +00:00
|
|
|
import DeletePrompt from './components/DeletePrompt'
|
2017-06-29 08:11:46 +00:00
|
|
|
import RenameButton from './components/RenameButton'
|
2017-06-29 10:34:47 +00:00
|
|
|
import RenamePrompt from './components/RenamePrompt'
|
2017-06-29 08:11:46 +00:00
|
|
|
import UploadButton from './components/UploadButton'
|
|
|
|
import DownloadButton from './components/DownloadButton'
|
|
|
|
import SwitchButton from './components/SwitchViewButton'
|
|
|
|
import MoveButton from './components/MoveButton'
|
2017-06-28 15:05:30 +00:00
|
|
|
import css from './css.js'
|
|
|
|
|
|
|
|
function updateColumnSizes () {
|
|
|
|
let columns = Math.floor(document.querySelector('main').offsetWidth / 300)
|
|
|
|
let items = css(['#listing.mosaic .item', '.mosaic#listing .item'])
|
|
|
|
|
|
|
|
items.style.width = `calc(${100 / columns}% - 1em)`
|
|
|
|
}
|
2017-06-28 10:45:41 +00:00
|
|
|
|
2017-06-29 09:17:35 +00:00
|
|
|
function resetPrompts () {
|
|
|
|
window.info.showHelp = false
|
|
|
|
window.info.showInfo = false
|
|
|
|
window.info.showDelete = false
|
|
|
|
window.info.showRename = false
|
|
|
|
window.info.showMove = false
|
|
|
|
}
|
|
|
|
|
2017-06-28 21:20:28 +00:00
|
|
|
window.addEventListener('keydown', (event) => {
|
|
|
|
// Esc!
|
|
|
|
if (event.keyCode === 27) {
|
2017-06-29 09:17:35 +00:00
|
|
|
resetPrompts()
|
2017-06-28 21:20:28 +00:00
|
|
|
|
|
|
|
// Unselect all files and folders.
|
|
|
|
if (window.info.req.kind === 'listing') {
|
|
|
|
let items = document.getElementsByClassName('item')
|
|
|
|
Array.from(items).forEach(link => {
|
|
|
|
link.setAttribute('aria-selected', false)
|
|
|
|
})
|
|
|
|
|
|
|
|
window.info.listing.selected.length = 0
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// Del!
|
|
|
|
if (event.keyCode === 46) {
|
|
|
|
window.info.showDelete = true
|
|
|
|
}
|
|
|
|
|
|
|
|
// F1!
|
|
|
|
if (event.keyCode === 112) {
|
|
|
|
event.preventDefault()
|
|
|
|
window.info.showHelp = true
|
|
|
|
}
|
|
|
|
|
|
|
|
// F2!
|
|
|
|
if (event.keyCode === 113) {
|
|
|
|
window.info.showRename = true
|
|
|
|
}
|
|
|
|
|
|
|
|
// CTRL + S
|
|
|
|
if (event.ctrlKey || event.metaKey) {
|
|
|
|
switch (String.fromCharCode(event.which).toLowerCase()) {
|
|
|
|
case 's':
|
|
|
|
event.preventDefault()
|
|
|
|
|
|
|
|
if (window.info.req.kind !== 'editor') {
|
|
|
|
window.location = '?download=true'
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: save file on editor!
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2017-06-28 10:45:41 +00:00
|
|
|
export default {
|
|
|
|
name: 'app',
|
2017-06-29 08:11:46 +00:00
|
|
|
components: {
|
|
|
|
Search,
|
|
|
|
Preview,
|
|
|
|
Listing,
|
|
|
|
InfoButton,
|
|
|
|
InfoPrompt,
|
|
|
|
Help,
|
|
|
|
DeleteButton,
|
2017-06-29 10:34:47 +00:00
|
|
|
DeletePrompt,
|
2017-06-29 08:11:46 +00:00
|
|
|
RenameButton,
|
2017-06-29 10:34:47 +00:00
|
|
|
RenamePrompt,
|
2017-06-29 08:11:46 +00:00
|
|
|
DownloadButton,
|
|
|
|
UploadButton,
|
|
|
|
SwitchButton,
|
|
|
|
MoveButton
|
|
|
|
},
|
2017-06-28 15:05:30 +00:00
|
|
|
mounted: function () {
|
|
|
|
updateColumnSizes()
|
|
|
|
window.addEventListener('resize', updateColumnSizes)
|
2017-06-29 08:11:46 +00:00
|
|
|
window.history.replaceState({
|
|
|
|
url: window.location.pathname,
|
|
|
|
name: document.title
|
|
|
|
}, document.title, window.location.pathname)
|
2017-06-28 10:45:41 +00:00
|
|
|
},
|
2017-06-28 15:05:30 +00:00
|
|
|
data: function () {
|
|
|
|
return window.info
|
2017-06-28 21:20:28 +00:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
showOverlay: function () {
|
2017-06-29 08:11:46 +00:00
|
|
|
return this.showInfo || this.showHelp || this.showDelete || this.showRename || this.showMove
|
|
|
|
},
|
|
|
|
showUpload: function () {
|
|
|
|
if (this.req.kind === 'editor') return false
|
|
|
|
return this.user.allowNew
|
2017-06-29 09:17:35 +00:00
|
|
|
},
|
2017-06-29 10:34:47 +00:00
|
|
|
showDeleteButton: function () {
|
|
|
|
if (this.req.kind === 'listing') {
|
|
|
|
if (this.listing.selected.length === 0) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.user.allowEdit
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.user.allowEdit
|
|
|
|
},
|
|
|
|
showRenameButton: function () {
|
|
|
|
if (this.req.kind === 'listing') {
|
|
|
|
if (this.listing.selected.length === 1) {
|
|
|
|
return this.user.allowEdit
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.user.allowEdit
|
|
|
|
},
|
2017-06-29 09:17:35 +00:00
|
|
|
resetPrompts: resetPrompts
|
2017-06-28 10:45:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
@import './css/styles.css';
|
|
|
|
</style>
|