2019-08-20 12:45:43 +00:00
|
|
|
<template>
|
2019-09-24 15:18:29 +00:00
|
|
|
<div class="settings">
|
|
|
|
<input type="file"
|
|
|
|
class="import"
|
|
|
|
size="5"
|
|
|
|
@change="onImportSubmit">
|
|
|
|
<button @click="onImportOpen">
|
2020-04-17 11:22:00 +00:00
|
|
|
<span :class="{'icon-upload': !importing, 'icon-loading-small': importing}" />{{ t('bookmarks', 'Import') }}
|
2019-09-24 15:18:29 +00:00
|
|
|
</button>
|
|
|
|
<button @click="onExport">
|
|
|
|
<span class="icon-download" /> {{ t('bookmarks', 'Export') }}
|
|
|
|
</button>
|
2019-08-20 12:45:43 +00:00
|
|
|
|
2019-09-24 15:18:29 +00:00
|
|
|
<label>{{ t('bookmarks', 'Sorting') }}
|
|
|
|
<select :value="sorting" @change="onChangeSorting">
|
|
|
|
<option id="added" value="added">
|
|
|
|
{{ t('bookmarks', 'Recently added') }}
|
|
|
|
</option>
|
|
|
|
<option id="title" value="title">
|
|
|
|
{{ t('bookmarks', 'Alphabetically') }}
|
|
|
|
</option>
|
|
|
|
<option id="clickcount" value="clickcount">
|
|
|
|
{{ t('bookmarks', 'Most visited') }}
|
|
|
|
</option>
|
|
|
|
<option id="lastmodified" value="lastmodified">
|
|
|
|
{{ t('bookmarks', 'Last modified') }}
|
|
|
|
</option>
|
|
|
|
</select></label>
|
2019-08-20 12:45:43 +00:00
|
|
|
|
2019-09-24 15:18:29 +00:00
|
|
|
<label>{{ t('bookmarks', 'RSS Feed') }}
|
|
|
|
<input
|
|
|
|
v-tooltip="
|
2019-10-26 16:06:12 +00:00
|
|
|
t('bookmarks',
|
2019-09-24 15:18:29 +00:00
|
|
|
'This is an RSS feed of the current result set with access restricted to you.'
|
|
|
|
)
|
|
|
|
"
|
|
|
|
type="text"
|
|
|
|
readonly
|
|
|
|
:value="rssURL"
|
|
|
|
@click="onRssClick"></label>
|
2019-08-28 12:49:51 +00:00
|
|
|
|
2019-09-24 15:18:29 +00:00
|
|
|
<label>{{ t('bookmarks', 'Clear data') }}
|
|
|
|
<button
|
|
|
|
v-tooltip="
|
2019-10-26 16:06:12 +00:00
|
|
|
t('bookmarks',
|
2019-09-24 15:18:29 +00:00
|
|
|
'Permanently remove all bookmarks from your account. There is no going back!'
|
|
|
|
)
|
|
|
|
"
|
|
|
|
class="clear-data"
|
|
|
|
@click="onClearData">
|
2020-04-18 13:18:03 +00:00
|
|
|
<span :class="{'icon-delete': !deleting, 'icon-loading-small': deleting}" />
|
2019-09-24 15:18:29 +00:00
|
|
|
{{ t('bookmarks', 'Delete all bookmarks') }}
|
|
|
|
</button>
|
|
|
|
</label>
|
2019-08-28 12:49:51 +00:00
|
|
|
|
2019-09-24 15:18:29 +00:00
|
|
|
<label>{{ t('bookmarks', 'Bookmarklet') }}
|
|
|
|
<a
|
|
|
|
v-tooltip="
|
2019-10-26 16:06:12 +00:00
|
|
|
t('bookmarks',
|
2019-09-24 15:18:29 +00:00
|
|
|
'Drag this to your browser bookmarks and click it to quickly bookmark a webpage'
|
|
|
|
)
|
|
|
|
"
|
|
|
|
class="button"
|
|
|
|
:href="bookmarklet"
|
|
|
|
@click.prevent="void 0">{{
|
|
|
|
t('bookmarks', 'Add to {instanceName}', {
|
|
|
|
instanceName: oc_defaults.name
|
|
|
|
})
|
|
|
|
}}</a>
|
|
|
|
</label>
|
2019-08-20 12:45:43 +00:00
|
|
|
|
2019-09-24 15:18:29 +00:00
|
|
|
<p>
|
|
|
|
{{
|
2019-10-26 16:06:12 +00:00
|
|
|
t('bookmarks',
|
2019-09-24 15:18:29 +00:00
|
|
|
'Also check out the collection of client apps that integrate with this app: '
|
|
|
|
)
|
|
|
|
}}
|
|
|
|
<a href="https://github.com/nextcloud/bookmarks#third-party-clients">{{
|
|
|
|
t('bookmarks', 'Client apps')
|
|
|
|
}}</a>
|
|
|
|
</p>
|
|
|
|
</div>
|
2019-08-20 12:45:43 +00:00
|
|
|
</template>
|
|
|
|
<script>
|
2020-03-28 17:15:59 +00:00
|
|
|
import { generateUrl } from '@nextcloud/router'
|
|
|
|
import { actions } from '../store/'
|
|
|
|
import { getRequestToken } from '@nextcloud/auth'
|
2020-03-25 12:19:17 +00:00
|
|
|
|
2020-03-28 17:15:59 +00:00
|
|
|
export default {
|
|
|
|
name: 'Settings',
|
|
|
|
components: {},
|
2020-04-17 11:22:00 +00:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
importing: false,
|
2020-04-18 13:18:03 +00:00
|
|
|
deleting: false,
|
2020-04-17 11:22:00 +00:00
|
|
|
}
|
|
|
|
},
|
2020-03-28 17:15:59 +00:00
|
|
|
computed: {
|
|
|
|
oc_defaults() {
|
|
|
|
return window.oc_defaults
|
|
|
|
},
|
|
|
|
bookmarklet() {
|
|
|
|
const bookmarkletUrl
|
2020-03-25 12:19:17 +00:00
|
|
|
= window.location.origin + generateUrl('/apps/bookmarks/bookmarklet')
|
2020-03-28 17:15:59 +00:00
|
|
|
return `javascript:(function(){var a=window,b=document,c=encodeURIComponent,e=c(document.title),d=a.open('${bookmarkletUrl}?url='+c(b.location)+'&title='+e,'bkmk_popup','left='+((a.screenX||a.screenLeft)+10)+',top='+((a.screenY||a.screenTop)+10)+',height=500px,width=550px,resizable=1,alwaysRaised=1');a.setTimeout(function(){d.focus()},300);})();`
|
2019-08-20 12:45:43 +00:00
|
|
|
},
|
|
|
|
rssURL() {
|
2019-08-25 10:54:53 +00:00
|
|
|
return (
|
2019-08-26 12:29:07 +00:00
|
|
|
window.location.origin
|
2019-08-26 14:38:25 +00:00
|
|
|
+ generateUrl(
|
2019-08-26 12:29:07 +00:00
|
|
|
'/apps/bookmarks/public/rest/v2/bookmark?'
|
2019-09-11 12:07:15 +00:00
|
|
|
+ new URLSearchParams(
|
|
|
|
Object.assign({}, this.$store.state.fetchState.query, {
|
|
|
|
format: 'rss',
|
2019-12-10 21:33:54 +00:00
|
|
|
page: -1,
|
2019-09-11 12:07:15 +00:00
|
|
|
})
|
2019-08-29 09:34:48 +00:00
|
|
|
).toString()
|
2019-08-25 10:54:53 +00:00
|
|
|
)
|
2019-09-24 15:18:29 +00:00
|
|
|
)
|
2019-08-20 12:45:43 +00:00
|
|
|
},
|
|
|
|
viewMode() {
|
2019-09-24 15:18:29 +00:00
|
|
|
return this.$store.state.settings.viewMode
|
2019-08-20 12:45:43 +00:00
|
|
|
},
|
|
|
|
sorting() {
|
2019-09-24 15:18:29 +00:00
|
|
|
return this.$store.state.settings.sorting
|
2019-12-10 21:33:54 +00:00
|
|
|
},
|
2019-08-20 12:45:43 +00:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
onImportOpen(e) {
|
2019-09-24 15:18:29 +00:00
|
|
|
e.target.previousElementSibling.click()
|
2019-08-20 12:45:43 +00:00
|
|
|
},
|
2020-04-17 11:22:00 +00:00
|
|
|
async onImportSubmit(e) {
|
|
|
|
this.importing = true
|
|
|
|
try {
|
|
|
|
await this.$store.dispatch(actions.IMPORT_BOOKMARKS, e.target.files[0])
|
|
|
|
this.$router.push({ name: this.routes.HOME })
|
|
|
|
} finally {
|
|
|
|
this.importing = false
|
|
|
|
}
|
2019-08-20 12:45:43 +00:00
|
|
|
},
|
|
|
|
onExport() {
|
2019-08-26 12:29:07 +00:00
|
|
|
window.location
|
|
|
|
= 'bookmark/export?requesttoken='
|
2020-03-25 12:19:17 +00:00
|
|
|
+ encodeURIComponent(getRequestToken())
|
2019-08-20 12:45:43 +00:00
|
|
|
},
|
|
|
|
async onChangeSorting(e) {
|
|
|
|
await this.$store.dispatch(actions.SET_SETTING, {
|
|
|
|
key: 'sorting',
|
2019-12-10 21:33:54 +00:00
|
|
|
value: e.target.value,
|
2019-09-24 15:18:29 +00:00
|
|
|
})
|
2019-10-12 18:00:15 +00:00
|
|
|
await this.$store.dispatch(actions.FETCH_PAGE)
|
2019-08-20 12:45:43 +00:00
|
|
|
},
|
2019-09-11 12:07:15 +00:00
|
|
|
onChangeViewMode(e) {},
|
2019-08-20 12:45:43 +00:00
|
|
|
onRssClick(e) {
|
|
|
|
setTimeout(() => {
|
2019-09-24 15:18:29 +00:00
|
|
|
e.target.select()
|
|
|
|
}, 100)
|
2019-08-20 12:45:43 +00:00
|
|
|
},
|
|
|
|
async onClearData() {
|
|
|
|
if (
|
|
|
|
!confirm(
|
|
|
|
t('bookmarks', 'Do you really want to delete all your bookmarks?')
|
|
|
|
)
|
|
|
|
) {
|
2019-09-24 15:18:29 +00:00
|
|
|
return
|
2019-08-20 12:45:43 +00:00
|
|
|
}
|
2020-04-18 13:18:03 +00:00
|
|
|
this.deleting = true
|
2019-09-24 15:18:29 +00:00
|
|
|
await this.$store.dispatch(actions.DELETE_BOOKMARKS)
|
2020-04-17 11:22:00 +00:00
|
|
|
await this.$router.push({ name: this.routes.HOME })
|
2020-04-18 13:18:03 +00:00
|
|
|
this.deleting = false
|
2019-12-10 21:33:54 +00:00
|
|
|
},
|
|
|
|
},
|
2019-09-24 15:18:29 +00:00
|
|
|
}
|
2019-08-20 12:45:43 +00:00
|
|
|
</script>
|
|
|
|
<style>
|
|
|
|
.import {
|
|
|
|
opacity: 0;
|
|
|
|
position: absolute;
|
2019-08-26 22:38:02 +00:00
|
|
|
top: 0;
|
|
|
|
left: -1000px;
|
2019-08-20 12:45:43 +00:00
|
|
|
}
|
2019-08-26 22:38:02 +00:00
|
|
|
|
2019-08-28 12:49:51 +00:00
|
|
|
.settings label,
|
|
|
|
.settings input,
|
|
|
|
.settings select,
|
|
|
|
.settings label button,
|
|
|
|
.settings label a.button {
|
2019-08-29 09:23:35 +00:00
|
|
|
display: block;
|
2019-08-28 12:49:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.settings label {
|
2019-08-29 09:23:35 +00:00
|
|
|
margin-top: 10px;
|
2019-08-28 12:49:51 +00:00
|
|
|
}
|
|
|
|
|
2019-08-26 12:57:02 +00:00
|
|
|
.settings a:link:not(.button) {
|
2019-08-25 12:24:46 +00:00
|
|
|
text-decoration: underline;
|
|
|
|
}
|
2019-08-20 12:45:43 +00:00
|
|
|
</style>
|