Popup on copy link.

Former-commit-id: e483df4402733b102d11b10436ff74aad11dfa7c [formerly 6d761c2ee838a9766f755b6c54cdc2ca388b5934] [formerly 1365e9e067af021ad0c680bae3af963dc4a90b28 [formerly 889871ec0a1fac26dee1b3152d0f87e2a7af2c65]]
Former-commit-id: ba443a90fded4501c0a6872eb293c14b2923c627 [formerly d21c6b9ab41869d2b10aa99853bc5b6931b63d96]
Former-commit-id: 7c19b231861797c62dc35c1e8a28f4ceeb8761c7
This commit is contained in:
Henrique Dias 2017-08-24 14:13:29 +01:00
parent 610d55c26f
commit d838856711
29 changed files with 129 additions and 116 deletions

View File

@ -134,7 +134,7 @@ export default {
}) })
.catch(error => { .catch(error => {
buttons.done(button) buttons.done(button)
this.$store.commit('showError', error) this.$showError(error)
this.$store.commit('setSchedule', '') this.$store.commit('setSchedule', '')
}) })
} }

View File

@ -210,17 +210,13 @@ export default {
if (this.$store.state.clipboard.key === 'x') { if (this.$store.state.clipboard.key === 'x') {
api.move(items).then(() => { api.move(items).then(() => {
this.$store.commit('setReload', true) this.$store.commit('setReload', true)
}).catch(error => { }).catch(this.$showError)
this.$store.commit('showError', error)
})
return return
} }
api.copy(items).then(() => { api.copy(items).then(() => {
this.$store.commit('setReload', true) this.$store.commit('setReload', true)
}).catch(error => { }).catch(this.$showError)
this.$store.commit('showError', error)
})
}, },
resizeEvent () { resizeEvent () {
// Update the columns size based on the window width. // Update the columns size based on the window width.
@ -348,7 +344,7 @@ export default {
}) })
.catch(error => { .catch(error => {
finish() finish()
this.$store.commit('showError', error) this.$showError(error)
}) })
return false return false

View File

@ -109,9 +109,7 @@ export default {
.then(() => { .then(() => {
this.$store.commit('setReload', true) this.$store.commit('setReload', true)
}) })
.catch(error => { .catch(this.$showError)
this.$store.commit('showError', error)
})
}, },
click: function (event) { click: function (event) {
if (this.selectedCount !== 0) event.preventDefault() if (this.selectedCount !== 0) event.preventDefault()

View File

@ -56,7 +56,7 @@ export default {
}) })
.catch(error => { .catch(error => {
buttons.done('copy') buttons.done('copy')
this.$store.commit('showError', error) this.$showError(error)
}) })
} }
} }

View File

@ -43,7 +43,7 @@ export default {
}) })
.catch(error => { .catch(error => {
buttons.done('delete') buttons.done('delete')
this.$store.commit('showError', error) this.$showError(error)
}) })
return return
@ -70,7 +70,7 @@ export default {
.catch(error => { .catch(error => {
buttons.done('delete') buttons.done('delete')
this.$store.commit('setReload', true) this.$store.commit('setReload', true)
this.$store.commit('showError', error) this.$showError(error)
}) })
} }
} }

View File

@ -1,31 +0,0 @@
<template>
<div class="prompt error">
<i class="material-icons">error_outline</i>
<h3>{{ $t('prompts.error') }}</h3>
<pre>{{ $store.state.showMessage }}</pre>
<div>
<button @click="close"
autofocus
:aria-label="$t('buttons.close')"
:title="$t('buttons.close')">{{ $t('buttons.close') }}</button>
<button @click="reportIssue"
class="cancel"
:aria-label="$t('buttons.reportIssue')"
:title="$t('buttons.reportIssue')">{{ $t('buttons.reportIssue') }}</button>
</div>
</div>
</template>
<script>
export default {
name: 'error',
methods: {
reportIssue () {
window.open('https://github.com/hacdias/filemanager/issues/new')
},
close () {
this.$store.commit('closeHovers')
}
}
}
</script>

View File

@ -53,7 +53,7 @@ export default {
// so we fetch the data from the previous directory. // so we fetch the data from the previous directory.
api.fetch(url.removeLastDir(this.$route.path)) api.fetch(url.removeLastDir(this.$route.path))
.then(this.fillOptions) .then(this.fillOptions)
.catch(this.showError) .catch(this.$showError)
}, },
methods: { methods: {
fillOptions (req) { fillOptions (req) {
@ -96,7 +96,7 @@ export default {
api.fetch(uri) api.fetch(uri)
.then(this.fillOptions) .then(this.fillOptions)
.catch(this.showError) .catch(this.$showError)
}, },
touchstart (event) { touchstart (event) {
let url = event.currentTarget.dataset.url let url = event.currentTarget.dataset.url

View File

@ -111,7 +111,7 @@ export default {
api.checksum(link, hash) api.checksum(link, hash)
.then((hash) => { event.target.innerHTML = hash }) .then((hash) => { event.target.innerHTML = hash })
.catch(error => { this.$store.commit('showError', error) }) .catch(this.$showError)
} }
} }
} }

View File

@ -56,7 +56,7 @@ export default {
}) })
.catch(error => { .catch(error => {
buttons.done('move') buttons.done('move')
this.$store.commit('showError', error) this.$showError(error)
}) })
event.preventDefault() event.preventDefault()

View File

@ -37,9 +37,7 @@ export default {
.then((url) => { .then((url) => {
this.$router.push({ path: url }) this.$router.push({ path: url })
}) })
.catch(error => { .catch(this.$showError)
this.$store.commit('showError', error)
})
}, },
new (url, type) { new (url, type) {
url = removePrefix(url) url = removePrefix(url)

View File

@ -43,7 +43,7 @@ export default {
api.post(uri) api.post(uri)
.then(() => { this.$router.push({ path: uri }) }) .then(() => { this.$router.push({ path: uri }) })
.catch(error => { this.$store.commit('showError', error) }) .catch(this.$showError)
// Close the prompt // Close the prompt
this.$store.commit('closeHovers') this.$store.commit('closeHovers')

View File

@ -44,7 +44,7 @@ export default {
// Create the new file. // Create the new file.
api.post(uri) api.post(uri)
.then(() => { this.$router.push({ path: uri }) }) .then(() => { this.$router.push({ path: uri }) })
.catch(error => { this.$store.commit('showError', error) }) .catch(this.$showError)
// Close the prompt. // Close the prompt.
this.$store.commit('closeHovers') this.$store.commit('closeHovers')

View File

@ -9,8 +9,6 @@
<info v-else-if="showInfo"></info> <info v-else-if="showInfo"></info>
<move v-else-if="showMove"></move> <move v-else-if="showMove"></move>
<copy v-else-if="showCopy"></copy> <copy v-else-if="showCopy"></copy>
<error v-else-if="showError"></error>
<success v-else-if="showSuccess"></success>
<replace v-else-if="showReplace"></replace> <replace v-else-if="showReplace"></replace>
<schedule v-else-if="show === 'schedule'"></schedule> <schedule v-else-if="show === 'schedule'"></schedule>
<new-archetype v-else-if="show === 'new-archetype'"></new-archetype> <new-archetype v-else-if="show === 'new-archetype'"></new-archetype>
@ -27,8 +25,6 @@ import Rename from './Rename'
import Download from './Download' import Download from './Download'
import Move from './Move' import Move from './Move'
import Copy from './Copy' import Copy from './Copy'
import Error from './Error'
import Success from './Success'
import NewFile from './NewFile' import NewFile from './NewFile'
import NewDir from './NewDir' import NewDir from './NewDir'
import NewArchetype from './NewArchetype' import NewArchetype from './NewArchetype'
@ -47,9 +43,7 @@ export default {
NewArchetype, NewArchetype,
Schedule, Schedule,
Rename, Rename,
Error,
Download, Download,
Success,
Move, Move,
Copy, Copy,
Share, Share,
@ -70,8 +64,6 @@ export default {
}, },
computed: { computed: {
...mapState(['show', 'plugins']), ...mapState(['show', 'plugins']),
showError: function () { return this.show === 'error' },
showSuccess: function () { return this.show === 'success' },
showInfo: function () { return this.show === 'info' }, showInfo: function () { return this.show === 'info' },
showHelp: function () { return this.show === 'help' }, showHelp: function () { return this.show === 'help' },
showDelete: function () { return this.show === 'delete' }, showDelete: function () { return this.show === 'delete' },

View File

@ -68,7 +68,7 @@ export default {
} }
this.$store.commit('setReload', true) this.$store.commit('setReload', true)
}).catch(error => { }).catch(error => {
this.$store.commit('showError', error) this.$showError(error)
}) })
this.$store.commit('closeHovers') this.$store.commit('closeHovers')

View File

@ -18,7 +18,7 @@
:aria-label="$t('buttons.delete')" :aria-label="$t('buttons.delete')"
:title="$t('buttons.delete')"><i class="material-icons">delete</i></button> :title="$t('buttons.delete')"><i class="material-icons">delete</i></button>
<button class="action copy" <button class="action copy-clipboard"
:data-clipboard-text="buildLink(link.hash)" :data-clipboard-text="buildLink(link.hash)"
:aria-label="$t('buttons.copyToClipboard')" :aria-label="$t('buttons.copyToClipboard')"
:title="$t('buttons.copyToClipboard')"><i class="material-icons">content_paste</i></button> :title="$t('buttons.copyToClipboard')"><i class="material-icons">content_paste</i></button>
@ -54,7 +54,7 @@
</template> </template>
<script> <script>
import { mapState, mapMutations } from 'vuex' import { mapState } from 'vuex'
import { getShare, deleteShare, share } from '@/utils/api' import { getShare, deleteShare, share } from '@/utils/api'
import moment from 'moment' import moment from 'moment'
import Clipboard from 'clipboard' import Clipboard from 'clipboard'
@ -101,20 +101,25 @@ export default {
}) })
.catch(error => { .catch(error => {
if (error === 404) return if (error === 404) return
this.showError(error) this.$showError(error)
}) })
}, },
mounted () { mounted () {
this.clip = new Clipboard('.copy') this.clip = new Clipboard('.copy-clipboard')
this.clip.on('success', (e) => {
this.$showSuccess(this.$t('success.linkCopied'))
})
},
beforeDestroy () {
this.clip.destroy()
}, },
methods: { methods: {
...mapMutations([ 'showError' ]),
submit: function (event) { submit: function (event) {
if (!this.time) return if (!this.time) return
share(this.url, this.time, this.unit) share(this.url, this.time, this.unit)
.then(result => { this.links.push(result); this.sort() }) .then(result => { this.links.push(result); this.sort() })
.catch(error => { this.showError(error) }) .catch(this.$showError)
}, },
getPermalink (event) { getPermalink (event) {
share(this.url) share(this.url)
@ -123,7 +128,7 @@ export default {
this.sort() this.sort()
this.hasPermanent = true this.hasPermanent = true
}) })
.catch(error => { this.showError(error) }) .catch(this.$showError)
}, },
deleteLink (event, link) { deleteLink (event, link) {
event.preventDefault() event.preventDefault()
@ -132,7 +137,7 @@ export default {
if (!link.expires) this.hasPermanent = false if (!link.expires) this.hasPermanent = false
this.links = this.links.filter(item => item.hash !== link.hash) this.links = this.links.filter(item => item.hash !== link.hash)
}) })
.catch(error => { this.showError(error) }) .catch(this.$showError)
}, },
humanTime (time) { humanTime (time) {
return moment(time).fromNow() return moment(time).fromNow()

View File

@ -1,23 +0,0 @@
<template>
<div class="prompt success">
<i class="material-icons">done</i>
<h3>{{ $store.state.showMessage }}</h3>
<div>
<button @click="close"
:aria-label="$t('buttons.ok')"
:title="$t('buttons.ok')"
autofocus>{{ $t('buttons.ok') }}</button>
</div>
</div>
</template>
<script>
export default {
name: 'success',
methods: {
close () {
this.$store.commit('closeHovers')
}
}
}
</script>

View File

@ -2,7 +2,6 @@ body {
font-family: 'Roboto', sans-serif; font-family: 'Roboto', sans-serif;
padding-top: 4em; padding-top: 4em;
background-color: #f8f8f8; background-color: #f8f8f8;
user-select: none;
color: #212121; color: #212121;
} }

View File

@ -206,3 +206,24 @@
margin-right: .5em; margin-right: .5em;
border: 1px solid #dadada; border: 1px solid #dadada;
} }
.prompt#share .action.copy-clipboard::after {
content: 'Copied!';
position: absolute;
left: -25%;
width: 150%;
font-size: .6em;
text-align: center;
background: #44a6f5;
color: #fff;
padding: .5em .2em;
border-radius: .4em;
top: -2em;
transition: .1s ease opacity;
opacity: 0;
}
.prompt#share .action.copy-clipboard.active::after {
opacity: 1;
}

View File

@ -1,4 +1,5 @@
@import "~normalize.css/normalize.css"; @import "~normalize.css/normalize.css";
@import "~noty/lib/noty.css";
@import "./fonts.css"; @import "./fonts.css";
@import "./base.css"; @import "./base.css";
@import "./header.css"; @import "./header.css";
@ -180,6 +181,17 @@
* PROMPT * * PROMPT *
* * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * */
.noty_buttons {
text-align: right;
padding: 0 10px 10px !important;
}
.noty_buttons button {
background: rgba(0, 0, 0, 0.05);
border: 1px solid rgba(0,0,0,0.1);
box-shadow: 0 0 0 0;
font-size: 14px;
}
/* * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * *
* FOOTER * * FOOTER *

View File

@ -31,6 +31,8 @@ buttons:
update: Update update: Update
upload: Upload upload: Upload
permalink: Get Permanent Link permalink: Get Permanent Link
success:
linkCopied: Link copied!
errors: errors:
forbidden: You're not welcome here. forbidden: You're not welcome here.
internal: Something really went wrong. internal: Something really went wrong.

View File

@ -31,6 +31,8 @@ buttons:
update: Atualizar update: Atualizar
upload: Enviar upload: Enviar
permalink: Obter link permanente permalink: Obter link permanente
success:
linkCopied: Link copiado!
errors: errors:
forbidden: Tu não és bem-vindo aqui. forbidden: Tu não és bem-vindo aqui.
internal: Algo correu bastante mal. internal: Algo correu bastante mal.

View File

@ -3,9 +3,47 @@ import App from './App'
import store from './store' import store from './store'
import router from './router' import router from './router'
import i18n from './i18n' import i18n from './i18n'
import Noty from 'noty'
Vue.config.productionTip = true Vue.config.productionTip = true
const notyDefault = {
type: 'info',
layout: 'bottomRight',
timeout: 1000,
progressBar: true
}
Vue.prototype.$noty = function (opts) {
new Noty(Object.assign({}, notyDefault, opts)).show()
}
Vue.prototype.$showSuccess = function (message) {
new Noty(Object.assign({}, notyDefault, {
text: message,
type: 'success'
})).show()
}
Vue.prototype.$showError = function (error) {
// TODO: add btns: close and report issue
let n = new Noty(Object.assign({}, notyDefault, {
text: error,
type: 'error',
timeout: null,
buttons: [
Noty.button(i18n.t('buttons.reportIssue'), 'cancel', function () {
window.open('https://github.com/hacdias/filemanager/issues/new')
}),
Noty.button(i18n.t('buttons.close'), '', function () {
n.close()
})
]
}))
n.show()
}
/* eslint-disable no-new */ /* eslint-disable no-new */
new Vue({ new Vue({
el: '#app', el: '#app',

View File

@ -45,7 +45,7 @@
</template> </template>
<script> <script>
import { mapState, mapMutations } from 'vuex' import { mapState } from 'vuex'
import { getSettings, updateSettings } from '@/utils/api' import { getSettings, updateSettings } from '@/utils/api'
export default { export default {
@ -73,10 +73,9 @@ export default {
}) })
} }
}) })
.catch(error => { this.showError(error) }) .catch(error => { this.$showError(error) })
}, },
methods: { methods: {
...mapMutations([ 'showSuccess', 'showError' ]),
capitalize (name, where = '_') { capitalize (name, where = '_') {
if (where === 'caps') where = /(?=[A-Z])/ if (where === 'caps') where = /(?=[A-Z])/
let splitted = name.split(where) let splitted = name.split(where)
@ -103,8 +102,8 @@ export default {
} }
updateSettings(commands, 'commands') updateSettings(commands, 'commands')
.then(() => { this.showSuccess(this.$t('settings.commandsUpdated')) }) .then(() => { this.$showSuccess(this.$t('settings.commandsUpdated')) })
.catch(error => { this.showError(error) }) .catch(error => { this.$showError(error) })
}, },
saveStaticGen (event) { saveStaticGen (event) {
event.preventDefault() event.preventDefault()
@ -124,8 +123,8 @@ export default {
} }
updateSettings(staticGen, 'staticGen') updateSettings(staticGen, 'staticGen')
.then(() => { this.showSuccess(this.$t('settings.settingsUpdated')) }) .then(() => { this.$showSuccess(this.$t('settings.settingsUpdated')) })
.catch(error => { this.showError(error) }) .catch(error => { this.$showError(error) })
}, },
parseStaticGen (staticgen) { parseStaticGen (staticgen) {
for (let option of staticgen) { for (let option of staticgen) {

View File

@ -28,7 +28,7 @@
</template> </template>
<script> <script>
import { mapState, mapMutations } from 'vuex' import { mapState } from 'vuex'
import { updateUser } from '@/utils/api' import { updateUser } from '@/utils/api'
import Languages from '@/components/Languages' import Languages from '@/components/Languages'
@ -64,7 +64,6 @@ export default {
this.locale = this.user.locale this.locale = this.user.locale
}, },
methods: { methods: {
...mapMutations([ 'showSuccess' ]),
updatePassword (event) { updatePassword (event) {
event.preventDefault() event.preventDefault()
@ -78,9 +77,9 @@ export default {
} }
updateUser(user, 'password').then(location => { updateUser(user, 'password').then(location => {
this.showSuccess(this.$t('settings.passwordUpdated')) this.$showSuccess(this.$t('settings.passwordUpdated'))
}).catch(e => { }).catch(e => {
this.$store.commit('showError', e) this.$showError(e)
}) })
}, },
updateSettings (event) { updateSettings (event) {
@ -93,9 +92,9 @@ export default {
updateUser(user, 'partial').then(location => { updateUser(user, 'partial').then(location => {
this.$store.commit('setUser', user) this.$store.commit('setUser', user)
this.$emit('css-updated') this.$emit('css-updated')
this.showSuccess(this.$t('settings.settingsUpdated')) this.$showSuccess(this.$t('settings.settingsUpdated'))
}).catch(e => { }).catch(e => {
this.$store.commit('showError', e) this.$showError(e)
}) })
} }
} }

View File

@ -203,9 +203,9 @@ export default {
deleteUser(this.id).then(location => { deleteUser(this.id).then(location => {
this.$router.push({ path: '/users' }) this.$router.push({ path: '/users' })
this.$store.commit('showSuccess', this.$t('settings.userDeleted')) this.$showSuccess(this.$t('settings.userDeleted'))
}).catch(e => { }).catch(e => {
this.$store.commit('showError', e) this.$showError(e)
}) })
}, },
save (event) { save (event) {
@ -215,9 +215,9 @@ export default {
if (this.$route.path === '/users/new') { if (this.$route.path === '/users/new') {
newUser(user).then(location => { newUser(user).then(location => {
this.$router.push({ path: location }) this.$router.push({ path: location })
this.$store.commit('showSuccess', this.$t('settings.userCreated')) this.$showSuccess(this.$t('settings.userCreated'))
}).catch(e => { }).catch(e => {
this.$store.commit('showError', e) this.$showError(e)
}) })
return return
@ -228,9 +228,9 @@ export default {
this.$store.commit('setUser', user) this.$store.commit('setUser', user)
} }
this.$store.commit('showSuccess', this.$t('settings.userUpdated')) this.$showSuccess(this.$t('settings.userUpdated'))
}).catch(e => { }).catch(e => {
this.$store.commit('showError', e) this.$showError(e)
}) })
}, },
parseForm () { parseForm () {

View File

@ -44,7 +44,7 @@ export default {
api.getUsers().then(users => { api.getUsers().then(users => {
this.users = users this.users = users
}).catch(error => { }).catch(error => {
this.$store.commit('showError', error) this.$showError(error)
}) })
} }
} }

5
package-lock.json generated
View File

@ -4941,6 +4941,11 @@
"resolved": "https://registry.npmjs.org/normalize.css/-/normalize.css-7.0.0.tgz", "resolved": "https://registry.npmjs.org/normalize.css/-/normalize.css-7.0.0.tgz",
"integrity": "sha1-q/sd2CRwZ04DIrU86xqvQSk45L8=" "integrity": "sha1-q/sd2CRwZ04DIrU86xqvQSk45L8="
}, },
"noty": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/noty/-/noty-3.1.2.tgz",
"integrity": "sha512-5Rn8695fMcGTJdn8gIrG0sYXXNIEwc8BFq4EpyHF3rFwoAt7/kgN2lKrIZ0bUxtFZuYFcnfqwU+4uF6vm21bVg=="
},
"npm-run-path": { "npm-run-path": {
"version": "2.0.2", "version": "2.0.2",
"resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz",

View File

@ -14,6 +14,7 @@
"filesize": "^3.5.10", "filesize": "^3.5.10",
"moment": "^2.18.1", "moment": "^2.18.1",
"normalize.css": "^7.0.0", "normalize.css": "^7.0.0",
"noty": "^3.1.2",
"vue": "^2.3.3", "vue": "^2.3.3",
"vue-i18n": "^7.1.0", "vue-i18n": "^7.1.0",
"vue-router": "^2.7.0", "vue-router": "^2.7.0",

View File

@ -1 +1 @@
60f3c5fb4e901be9b2920d60643c26ad4d414706 8cd7343b99621ae03aa9fae0a5cb69dcf5b31963