Added showBitrateTags and showSearchButton options

Re-added executeCommand as read-only
This commit is contained in:
RemixDev 2021-10-05 14:32:02 +02:00
parent 6c88cc9bb8
commit 96232e1907
8 changed files with 177 additions and 22 deletions

View File

@ -1,6 +1,6 @@
<template> <template>
<header id="search" aria-label="searchbar"> <header id="search" aria-label="searchbar" :class="{ showSearchButton }">
<div class="search__icon"> <div v-if="!showSearchButton" class="search__icon">
<i class="material-icons">search</i> <i class="material-icons">search</i>
</div> </div>
@ -14,14 +14,22 @@
value="" value=""
:placeholder="$t('searchbar')" :placeholder="$t('searchbar')"
autofocus autofocus
@keyup="performSearch($event)" @keyup="keyPerformSearch($event)"
/> />
<!-- @keyup.enter.exact="onEnter" <!-- @keyup.enter.exact="onEnter"
@keyup.ctrl.enter="onCTRLEnter" --> @keyup.ctrl.enter="onCTRLEnter" -->
<a
href="#"
class="searchButton"
@contextmenu="rightClickPerformSearch"
@click="clickPerformSearch"
v-if="showSearchButton"
><i class="material-icons">search</i></a>
</header> </header>
</template> </template>
<script> <script>
import { mapGetters } from 'vuex'
import { defineComponent, ref } from '@vue/composition-api' import { defineComponent, ref } from '@vue/composition-api'
import { isValidURL } from '@/utils/utils' import { isValidURL } from '@/utils/utils'
import { sendAddToQueue } from '@/utils/downloads' import { sendAddToQueue } from '@/utils/downloads'
@ -57,25 +65,48 @@ export default defineComponent({
document.removeEventListener('keyup', deleteSearchBarContent) document.removeEventListener('keyup', deleteSearchBarContent)
}) })
}, },
computed: {
...mapGetters({
showSearchButton: 'getShowSearchButton',
})
},
methods: { methods: {
async performSearch(keyEvent) { async clickPerformSearch(ev) {
const isEnterPressed = keyEvent.keyCode === 13 ev.preventDefault()
const term = this.$refs.searchbar.value
const isEmptySearch = term === ''
if (isEmptySearch) return
await this.performSearch(term, false)
},
async rightClickPerformSearch(ev){
ev.preventDefault()
ev.stopPropagation()
const term = this.$refs.searchbar.value
const isEmptySearch = term === ''
if (isEmptySearch) return
await this.performSearch(term, true)
},
async keyPerformSearch(keyEvent) {
const isEnterPressed = keyEvent.keyCode === 13
if (!isEnterPressed) return if (!isEnterPressed) return
const term = this.$refs.searchbar.value const term = this.$refs.searchbar.value
const isEmptySearch = term === '' const isEmptySearch = term === ''
if (isEmptySearch) return if (isEmptySearch) return
const isSearchingURL = isValidURL(term)
const isCtrlPressed = keyEvent.ctrlKey const isCtrlPressed = keyEvent.ctrlKey
await this.performSearch(term, isCtrlPressed)
},
async performSearch(term, modifierKey){
const isSearchingURL = isValidURL(term)
const isShowingAnalyzer = this.$route.name === 'Link Analyzer' const isShowingAnalyzer = this.$route.name === 'Link Analyzer'
const isShowingSearch = this.$route.name === 'Search' const isShowingSearch = this.$route.name === 'Search'
const isSameAsLastSearch = term === this.lastTextSearch const isSameAsLastSearch = term === this.lastTextSearch
if (isSearchingURL) { if (isSearchingURL) {
if (isCtrlPressed) { if (modifierKey) {
this.$root.$emit('ContextMenu:searchbar', term) this.$root.$emit('ContextMenu:searchbar', term)
return return
} }
@ -153,6 +184,7 @@ input[type='search']::-webkit-search-cancel-button {
transition: border 200ms ease-in-out; transition: border 200ms ease-in-out;
border-radius: 15px; border-radius: 15px;
margin: 10px 10px 20px 10px; margin: 10px 10px 20px 10px;
overflow: hidden;
.search__icon { .search__icon {
width: $icon-dimension; width: $icon-dimension;
@ -201,8 +233,33 @@ input[type='search']::-webkit-search-cancel-button {
} }
} }
.searchButton {
background-color: var(--primary-color);
color: var(--primary-text);
height: 100%;
width: 48px;
display: flex;
text-decoration: none;
align-items: center;
justify-content: center;
border-radius: 0px 15px 15px 0px;
margin-left: 1em;
i {
font-size: $icon-dimension;
&::selection {
background: none;
}
}
}
&:focus-within { &:focus-within {
border: 1px solid var(--foreground); border: 1px solid var(--foreground);
} }
&.showSearchButton {
padding: 0 0 0 1em;
}
} }
</style> </style>

View File

@ -3,7 +3,7 @@
<div class="download-info"> <div class="download-info">
<div class="relative coverart rounded"> <div class="relative coverart rounded">
<img width="75px" :src="queueItem.cover" :alt="`Cover ${queueItem.title}`"> <img width="75px" :src="queueItem.cover" :alt="`Cover ${queueItem.title}`">
<span class="tag">{{ bitrateText }}</span> <span v-if="showTags" class="tag">{{ bitrateText }}</span>
</div> </div>
<div class="download-info-data"> <div class="download-info-data">
@ -55,7 +55,8 @@ export default {
queueItem: { queueItem: {
type: Object, type: Object,
default: () => ({}) default: () => ({})
} },
showTags: Boolean
}, },
data() { data() {
return { return {

View File

@ -56,6 +56,7 @@
v-for="item in queueList" v-for="item in queueList"
:key="item.uuid" :key="item.uuid"
:queue-item="item" :queue-item="item"
:show-tags="showTags"
@show-errors="showErrorsTab" @show-errors="showErrorsTab"
@remove-item="onRemoveItem" @remove-item="onRemoveItem"
/> />
@ -90,7 +91,8 @@ export default {
computed: { computed: {
...mapGetters({ ...mapGetters({
clientMode: 'getClientMode', clientMode: 'getClientMode',
isSlim: 'getSlimDownloads' isSlim: 'getSlimDownloads',
showTags: 'getShowBitrateTags'
}), }),
finishedWithoutErrors() { finishedWithoutErrors() {
const isCompletedWithoutErrors = el => (el.status || '') === 'download finished' && el.errors.length === 0 const isCompletedWithoutErrors = el => (el.status || '') === 'download finished' && el.errors.length === 0

View File

@ -133,6 +133,14 @@
<input v-model="modelSlimSidebar" type="checkbox" /> <input v-model="modelSlimSidebar" type="checkbox" />
<span class="checkbox-text">{{ $t('settings.appearance.slimSidebar') }}</span> <span class="checkbox-text">{{ $t('settings.appearance.slimSidebar') }}</span>
</label> </label>
<label class="mb-4 with-checkbox">
<input v-model="modelShowBitrateTags" type="checkbox" />
<span class="checkbox-text">{{ $t('settings.appearance.bitrateTags') }}</span>
</label>
<label class="mb-4 with-checkbox">
<input v-model="modelShowSearchButton" type="checkbox" />
<span class="checkbox-text">{{ $t('settings.appearance.searchButton') }}</span>
</label>
</BaseAccordion> </BaseAccordion>
<BaseAccordion class="settings-group"> <BaseAccordion class="settings-group">
@ -666,13 +674,12 @@
<span>{{ previewVolume }}%</span> <span>{{ previewVolume }}%</span>
</div> </div>
<!--
<div class="input-group"> <div class="input-group">
<p class="input-group-text">{{ $t('settings.other.executeCommand.title') }}</p> <p class="input-group-text">{{ $t('settings.other.executeCommand.title') }}</p>
<p class="secondary-text">{{ $t('settings.other.executeCommand.description') }}</p> <p class="secondary-text">{{ $t('settings.other.executeCommand.description') }}</p>
<input v-model="settings.executeCommand" type="text" /> <p v-if="settings.executeCommand"> {{ settings.executeCommand }} </p>
<p v-else>{{ $t('globals.empty').capitalize() }}</p>
</div> </div>
-->
</BaseAccordion> </BaseAccordion>
<BaseAccordion class="settings-group"> <BaseAccordion class="settings-group">
@ -781,7 +788,9 @@ export default {
clientMode: 'getClientMode', clientMode: 'getClientMode',
previewVolume: 'getPreviewVolume', previewVolume: 'getPreviewVolume',
hasSlimDownloads: 'getSlimDownloads', hasSlimDownloads: 'getSlimDownloads',
hasSlimSidebar: 'getSlimSidebar' hasSlimSidebar: 'getSlimSidebar',
showBitrateTags: 'getShowBitrateTags',
showSearchButton: 'getShowSearchButton',
}), }),
needToWait() { needToWait() {
return Object.keys(this.getSettings).length === 0 return Object.keys(this.getSettings).length === 0
@ -810,6 +819,22 @@ export default {
this.setSlimSidebar(wantSlimSidebar) this.setSlimSidebar(wantSlimSidebar)
} }
}, },
modelShowBitrateTags: {
get() {
return this.showBitrateTags
},
set(wantShowBitrateTags) {
this.setShowBitrateTags(wantShowBitrateTags)
}
},
modelShowSearchButton: {
get() {
return this.showSearchButton
},
set(wantShowSearchButton) {
this.setShowSearchButton(wantShowSearchButton)
}
},
pictureHref() { pictureHref() {
// Default image: https://e-cdns-images.dzcdn.net/images/user/125x125-000000-80-0-0.jpg // Default image: https://e-cdns-images.dzcdn.net/images/user/125x125-000000-80-0-0.jpg
return `https://e-cdns-images.dzcdn.net/images/user/${this.user.picture}/125x125-000000-80-0-0.jpg` return `https://e-cdns-images.dzcdn.net/images/user/${this.user.picture}/125x125-000000-80-0-0.jpg`
@ -865,6 +890,8 @@ export default {
setPreviewVolume: 'setPreviewVolume', setPreviewVolume: 'setPreviewVolume',
setSlimDownloads: 'setSlimDownloads', setSlimDownloads: 'setSlimDownloads',
setSlimSidebar: 'setSlimSidebar', setSlimSidebar: 'setSlimSidebar',
setShowBitrateTags: 'setShowBitrateTags',
setShowSearchButton: 'setShowSearchButton',
dispatchLogout: 'logout', dispatchLogout: 'logout',
dispatchLogin: 'login', dispatchLogin: 'login',
setSpotifyUserId: 'setSpotifyUserId', setSpotifyUserId: 'setSpotifyUserId',

View File

@ -41,3 +41,17 @@ export function checkInitialSlimDownloads() {
export function checkInitialSlimSidebar() { export function checkInitialSlimSidebar() {
return localStorage.getItem('slimSidebar') === 'true' return localStorage.getItem('slimSidebar') === 'true'
} }
/**
* @returns {boolean}
*/
export function checkInitialShowBitrateTags() {
return localStorage.getItem('showBitrateTags') === 'true'
}
/**
* @returns {boolean}
*/
export function checkInitialShowSearchButton() {
return localStorage.getItem('showSearchButton') === 'true'
}

View File

@ -43,7 +43,8 @@ const en = {
playlistN: '0 playlists | {n} playlist | {n} playlists' playlistN: '0 playlists | {n} playlist | {n} playlists'
}, },
yes: 'yes', yes: 'yes',
no: 'no' no: 'no',
empty: 'empty'
}, },
about: { about: {
appStatus: { appStatus: {
@ -235,7 +236,9 @@ const en = {
appearance: { appearance: {
title: 'Appearance', title: 'Appearance',
slimDownloadTab: 'Slim download tab', slimDownloadTab: 'Slim download tab',
slimSidebar: 'Slim Sidebar' slimSidebar: 'Slim Sidebar',
searchButton: 'Show search button',
bitrateTags: 'Show quality tag in download queue'
}, },
downloadPath: { downloadPath: {
title: 'Download Path' title: 'Download Path'

View File

@ -43,7 +43,8 @@ const it = {
playlistN: '{n} playlist' playlistN: '{n} playlist'
}, },
yes: 'sì', yes: 'sì',
no: 'no' no: 'no',
empty: 'vuoto'
}, },
about: { about: {
appStatus: { appStatus: {
@ -235,7 +236,9 @@ const it = {
appearance: { appearance: {
title: 'Aspetto', title: 'Aspetto',
slimDownloadTab: 'Tab dei download slim', slimDownloadTab: 'Tab dei download slim',
slimSidebar: 'Sidebar slim' slimSidebar: 'Sidebar slim',
searchButton: 'Mostra bottone di ricerca',
bitrateTags: 'Mostra targhetta qualità nei download'
}, },
downloadPath: { downloadPath: {
title: 'Cartella di download' title: 'Cartella di download'

View File

@ -9,7 +9,13 @@
* @property {boolean} hasSlimSidebar * @property {boolean} hasSlimSidebar
*/ */
import { getInitialPreviewVolume, checkInitialSlimDownloads, checkInitialSlimSidebar } from '@/data/settings' import {
getInitialPreviewVolume,
checkInitialSlimDownloads,
checkInitialSlimSidebar,
checkInitialShowBitrateTags,
checkInitialShowSearchButton
} from '@/data/settings'
/** /**
* @returns {AppInfo} * @returns {AppInfo}
@ -21,7 +27,9 @@ const state = () => ({
deemixVersion: null, deemixVersion: null,
previewVolume: getInitialPreviewVolume(), previewVolume: getInitialPreviewVolume(),
hasSlimDownloads: checkInitialSlimDownloads(), hasSlimDownloads: checkInitialSlimDownloads(),
hasSlimSidebar: checkInitialSlimSidebar() hasSlimSidebar: checkInitialSlimSidebar(),
showBitrateTags: checkInitialShowBitrateTags(),
showSearchButton: checkInitialShowSearchButton()
}) })
const actions = { const actions = {
@ -63,6 +71,22 @@ const actions = {
Array.from(document.getElementsByClassName('toastify')).forEach(toast => { Array.from(document.getElementsByClassName('toastify')).forEach(toast => {
toast.style.transform = `translate(${payload ? '3rem' : '14rem'}, 0)` toast.style.transform = `translate(${payload ? '3rem' : '14rem'}, 0)`
}) })
},
/**
* @param {any} action
* @param {AppInfo['showBitrateTags']} payload
*/
setShowBitrateTags({ commit }, payload) {
commit('SET_SHOW_BITRATE_TAGS', payload)
localStorage.setItem('showBitrateTags', payload.toString())
},
/**
* @param {any} action
* @param {AppInfo['showBitrateTags']} payload
*/
setShowSearchButton({ commit }, payload) {
commit('SET_SHOW_SEARCH_BUTTON', payload)
localStorage.setItem('showSearchButton', payload.toString())
} }
} }
@ -86,7 +110,17 @@ const getters = {
* @param {AppInfo} state * @param {AppInfo} state
* @returns {AppInfo['hasSlimSidebar']} * @returns {AppInfo['hasSlimSidebar']}
*/ */
getSlimSidebar: state => state.hasSlimSidebar getSlimSidebar: state => state.hasSlimSidebar,
/**
* @param {AppInfo} state
* @returns {AppInfo['showBitrateTags']}
*/
getShowBitrateTags: state => state.showBitrateTags,
/**
* @param {AppInfo} state
* @returns {AppInfo['showSearchButton']}
*/
getShowSearchButton: state => state.showSearchButton
} }
const mutations = { const mutations = {
@ -138,6 +172,20 @@ const mutations = {
*/ */
SET_SLIM_SIDEBAR(state, payload) { SET_SLIM_SIDEBAR(state, payload) {
state.hasSlimSidebar = payload state.hasSlimSidebar = payload
},
/**
* @param {AppInfo} state
* @param {AppInfo['showBitrateTags']} payload
*/
SET_SHOW_BITRATE_TAGS(state, payload) {
state.showBitrateTags = payload
},
/**
* @param {AppInfo} state
* @param {AppInfo['showSearchButton']} payload
*/
SET_SHOW_SEARCH_BUTTON(state, payload) {
state.showSearchButton = payload
} }
} }