Renaming of prompts

pull/144/head
Henrique Dias 2017-07-03 17:15:47 +01:00
parent 3785423d74
commit e0f3687b26
No known key found for this signature in database
GPG Key ID: 936F5EB68D786730
11 changed files with 133 additions and 84 deletions

View File

@ -21,51 +21,16 @@
</div> </div>
</header> </header>
<nav> <sidebar></sidebar>
<router-link class="action" to="/files/">
<i class="material-icons">folder</i>
<span>My Files</span>
</router-link>
<div v-if="user.allowNew">
<button @click="$store.commit('showNewDir', true)" aria-label="New directory" title="New directory" class="action">
<i class="material-icons">create_new_folder</i>
<span>New folder</span>
</button>
<button @click="$store.commit('showNewFile', true)" aria-label="New file" title="New file" class="action">
<i class="material-icons">note_add</i>
<span>New file</span>
</button>
</div>
<div v-for="plugin in plugins">
<button v-for="action in plugin.sidebar" @click="action.click" :aria-label="action.name" :title="action.name" class="action">
<i class="material-icons">{{ action.icon }}</i>
<span>{{ action.name }}</span>
</button>
</div>
<button @click="logout" class="action" id="logout" aria-label="Log out">
<i class="material-icons" title="Logout">exit_to_app</i>
<span>Logout</span>
</button>
</nav>
<main> <main>
<div v-if="loading">Loading...</div>
<editor v-if="isEditor"></editor> <editor v-if="isEditor"></editor>
<listing v-if="isListing"></listing> <listing v-if="isListing"></listing>
<preview v-if="isPreview"></preview> <preview v-if="isPreview"></preview>
</main> </main>
<download-prompt v-if="showDownload" :class="{ active: showDownload }"></download-prompt> <prompts></prompts>
<new-file-prompt v-if="showNewFile" :class="{ active: showNewFile }"></new-file-prompt>
<new-dir-prompt v-if="showNewDir" :class="{ active: showNewDir }"></new-dir-prompt>
<rename-prompt v-if="showRename" :class="{ active: showRename }"></rename-prompt>
<delete-prompt v-if="showDelete" :class="{ active: showDelete }"></delete-prompt>
<info-prompt v-if="showInfo" :class="{ active: showInfo }"></info-prompt>
<move-prompt v-if="showMove" :class="{ active: showMove }"></move-prompt>
<help v-show="showHelp" :class="{ active: showHelp }"></help>
<div v-show="showOverlay" @click="resetPrompts" class="overlay" :class="{ active: showOverlay }"></div>
<footer>Served with <a rel="noopener noreferrer" href="https://github.com/hacdias/caddy-filemanager">File Manager</a>.</footer> <footer>Served with <a rel="noopener noreferrer" href="https://github.com/hacdias/caddy-filemanager">File Manager</a>.</footer>
</div> </div>
@ -73,26 +38,19 @@
<script> <script>
import Search from './Search' import Search from './Search'
import Help from './Help'
import Preview from './Preview' import Preview from './Preview'
import Listing from './Listing' import Listing from './Listing'
import Editor from './Editor' import Editor from './Editor'
import Sidebar from './Sidebar'
import Prompts from './prompts/Prompts'
import InfoButton from './buttons/InfoButton' import InfoButton from './buttons/InfoButton'
import InfoPrompt from './prompts/InfoPrompt'
import DeleteButton from './buttons/DeleteButton' import DeleteButton from './buttons/DeleteButton'
import DeletePrompt from './prompts/DeletePrompt'
import RenameButton from './buttons/RenameButton' import RenameButton from './buttons/RenameButton'
import RenamePrompt from './prompts/RenamePrompt'
import UploadButton from './buttons/UploadButton' import UploadButton from './buttons/UploadButton'
import DownloadButton from './buttons/DownloadButton' import DownloadButton from './buttons/DownloadButton'
import DownloadPrompt from './prompts/DownloadPrompt'
import SwitchButton from './buttons/SwitchViewButton' import SwitchButton from './buttons/SwitchViewButton'
import MoveButton from './buttons/MoveButton' import MoveButton from './buttons/MoveButton'
import MovePrompt from './prompts/MovePrompt'
import NewFilePrompt from './prompts/NewFilePrompt'
import NewDirPrompt from './prompts/NewDirPrompt'
import css from '@/utils/css' import css from '@/utils/css'
import auth from '@/utils/auth'
import api from '@/utils/api' import api from '@/utils/api'
import {mapGetters, mapState} from 'vuex' import {mapGetters, mapState} from 'vuex'
@ -112,41 +70,26 @@ export default {
Preview, Preview,
Listing, Listing,
Editor, Editor,
Sidebar,
InfoButton, InfoButton,
InfoPrompt,
Help,
DeleteButton, DeleteButton,
DeletePrompt,
RenameButton, RenameButton,
RenamePrompt,
DownloadButton, DownloadButton,
DownloadPrompt,
UploadButton, UploadButton,
SwitchButton, SwitchButton,
MoveButton, MoveButton,
MovePrompt, Prompts
NewFilePrompt,
NewDirPrompt
}, },
computed: { computed: {
...mapGetters([ ...mapGetters([
'selectedCount', 'selectedCount'
'showOverlay'
]), ]),
...mapState([ ...mapState([
'req', 'req',
'user', 'user',
'reload', 'reload',
'baseURL', 'baseURL',
'multiple', 'multiple'
'showInfo',
'showHelp',
'showDelete',
'showRename',
'showMove',
'showNewFile',
'showNewDir',
'showDownload'
]), ]),
isListing () { isListing () {
return this.req.kind === 'listing' && !this.loading return this.req.kind === 'listing' && !this.loading
@ -160,8 +103,8 @@ export default {
}, },
data: function () { data: function () {
return { return {
plugins: [], loading: true,
loading: true error: ''
} }
}, },
created () { created () {
@ -178,10 +121,6 @@ export default {
updateColumnSizes() updateColumnSizes()
window.addEventListener('resize', updateColumnSizes) window.addEventListener('resize', updateColumnSizes)
if (window.plugins !== undefined || window.plugins !== null) {
this.plugins = window.plugins
}
window.addEventListener('keydown', (event) => { window.addEventListener('keydown', (event) => {
// Esc! // Esc!
if (event.keyCode === 27) { if (event.keyCode === 27) {
@ -300,11 +239,7 @@ export default {
} }
return false return false
}, }
resetPrompts: function () {
this.$store.commit('resetPrompts')
},
logout: auth.logout
} }
} }
</script> </script>

View File

@ -0,0 +1,55 @@
<template>
<nav>
<router-link class="action" to="/files/">
<i class="material-icons">folder</i>
<span>My Files</span>
</router-link>
<div v-if="user.allowNew">
<button @click="$store.commit('showNewDir', true)" aria-label="New directory" title="New directory" class="action">
<i class="material-icons">create_new_folder</i>
<span>New folder</span>
</button>
<button @click="$store.commit('showNewFile', true)" aria-label="New file" title="New file" class="action">
<i class="material-icons">note_add</i>
<span>New file</span>
</button>
</div>
<div v-for="plugin in plugins">
<button v-for="action in plugin.sidebar" @click="action.click" :aria-label="action.name" :title="action.name" class="action">
<i class="material-icons">{{ action.icon }}</i>
<span>{{ action.name }}</span>
</button>
</div>
<button @click="logout" class="action" id="logout" aria-label="Log out">
<i class="material-icons" title="Logout">exit_to_app</i>
<span>Logout</span>
</button>
</nav>
</template>
<script>
import {mapState} from 'vuex'
import auth from '@/utils/auth'
export default {
name: 'sidebar',
data: () => {
return {
plugins: []
}
},
computed: mapState(['user']),
mounted () {
if (window.plugins !== undefined || window.plugins !== null) {
this.plugins = window.plugins
}
},
methods: {
logout: auth.logout
}
}
</script>

View File

@ -16,7 +16,7 @@ import api from '@/utils/api'
import url from '@/utils/url' import url from '@/utils/url'
export default { export default {
name: 'delete-prompt', name: 'delete',
computed: { computed: {
...mapGetters(['selectedCount']), ...mapGetters(['selectedCount']),
...mapState(['req', 'selected']) ...mapState(['req', 'selected'])

View File

@ -14,7 +14,7 @@
import {mapGetters, mapState} from 'vuex' import {mapGetters, mapState} from 'vuex'
export default { export default {
name: 'download-prompt', name: 'download',
computed: { computed: {
...mapState(['selected', 'req']), ...mapState(['selected', 'req']),
...mapGetters(['selectedCount']) ...mapGetters(['selectedCount'])

View File

@ -33,7 +33,7 @@ import moment from 'moment'
import api from '@/utils/api' import api from '@/utils/api'
export default { export default {
name: 'info-prompt', name: 'info',
computed: { computed: {
...mapState(['req', 'selected']), ...mapState(['req', 'selected']),
...mapGetters(['selectedCount']) ...mapGetters(['selectedCount'])

View File

@ -22,7 +22,7 @@ import url from '@/utils/url'
import api from '@/utils/api' import api from '@/utils/api'
export default { export default {
name: 'move-prompt', name: 'move',
data: function () { data: function () {
return { return {
items: [], items: [],

View File

@ -15,7 +15,7 @@ import url from '@/utils/url'
import api from '@/utils/api' import api from '@/utils/api'
export default { export default {
name: 'new-dir-prompt', name: 'new-dir',
data: function () { data: function () {
return { return {
name: '' name: ''

View File

@ -15,7 +15,7 @@ import url from '@/utils/url'
import api from '@/utils/api' import api from '@/utils/api'
export default { export default {
name: 'new-file-prompt', name: 'new-file',
data: function () { data: function () {
return { return {
name: '' name: ''

View File

@ -0,0 +1,59 @@
<template>
<div>
<help v-show="showHelp" :class="{ active: showHelp }"></help>
<download v-if="showDownload" :class="{ active: showDownload }"></download>
<new-file v-if="showNewFile" :class="{ active: showNewFile }"></new-file>
<new-dir v-if="showNewDir" :class="{ active: showNewDir }"></new-dir>
<rename v-if="showRename" :class="{ active: showRename }"></rename>
<delete v-if="showDelete" :class="{ active: showDelete }"></delete>
<info v-if="showInfo" :class="{ active: showInfo }"></info>
<move v-if="showMove" :class="{ active: showMove }"></move>
<div v-show="showOverlay" @click="resetPrompts" class="overlay" :class="{ active: showOverlay }"></div>
</div>
</template>
<script>
import Help from './Help'
import Info from './Info'
import Delete from './Delete'
import Rename from './Rename'
import Download from './Download'
import Move from './Move'
import NewFile from './NewFile'
import NewDir from './NewDir'
import {mapGetters, mapState} from 'vuex'
export default {
name: 'prompts',
components: {
Info,
Delete,
Rename,
Download,
Move,
NewFile,
NewDir,
Help
},
computed: {
...mapGetters([
'showOverlay'
]),
...mapState([
'showInfo',
'showHelp',
'showDelete',
'showRename',
'showMove',
'showNewFile',
'showNewDir',
'showDownload'
])
},
methods: {
resetPrompts () {
this.$store.commit('resetPrompts')
}
}
}
</script>

View File

@ -16,7 +16,7 @@ import url from '@/utils/url'
import api from '@/utils/api' import api from '@/utils/api'
export default { export default {
name: 'rename-prompt', name: 'rename',
data: function () { data: function () {
return { return {
name: '' name: ''