Skip to content

armgit / dashy

Public Imported from GitHub
0

πŸš€ A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!

:fast_forward: Rebased from master

Alicia Sykeseae8dc476c0a
diff --cc src/components/MinimalView/MinimalSearch.vue
index 729c27e2,bf88a8db..ab7d012a
--- a/src/components/MinimalView/MinimalSearch.vue
+++ b/src/components/MinimalView/MinimalSearch.vue
@@@ -35,110 -12,28 +12,40 @@@ import SearchBar from '@/components/Set
export default {
name: 'MinimalSearch',
- inject: ['config'],
+ components: {
+ SearchBar,
+ },
props: {
active: Boolean,
},
data() {
return {
input: '', // Users current search term
- akn: new ArrowKeyNavigation(), // Class that manages arrow key naviagtion
- getCustomKeyShortcuts,
};
},
+ computed: {
+ appConfig() {
+ return this.$store.getters.appConfig;
+ },
+ webSearchEnabled() {
+ if (this.appConfig && this.appConfig.webSearch) {
+ return !this.appConfig.webSearch.disableWebSearch;
+ }
+ return true;
+ },
+ },
methods: {
/* Emmits users's search term up to parent */
- userIsTypingSomething() {
- this.$emit('user-is-searchin', this.input);
- },
- /* Resets everything to initial state, when user is finished */
- clearFilterInput() {
- this.input = ''; // Clear input model
- this.userIsTypingSomething(); // Emmit new empty value
- document.activeElement.blur(); // Remove focus
- this.akn.resetIndex(); // Reset current element index
- },
- /* Launches a given app when hotkey pressed */
- handleHotKey(key) {
- const usersHotKeys = this.getCustomKeyShortcuts();
- usersHotKeys.forEach((hotkey) => {
- if (hotkey.hotkey === parseInt(key, 10)) {
- if (hotkey.url) window.open(hotkey.url, '_blank');
- }
- });
- },
- /* Filter results as user types */
- startFiltering(event) {
- const currentElem = document.activeElement.id;
- const { key, keyCode } = event;
- /* If a modal is open, then do nothing */
- if (!this.active) return;
- if (/^[a-zA-Z]$/.test(key) && currentElem !== 'filter-tiles') {
- /* Letter key pressed - start searching */
- if (this.$refs.filter) this.$refs.filter.focus();
- this.userIsTypingSomething();
- } else if (/^[0-9]$/.test(key)) {
- /* Number key pressed, check if user has a custom binding */
- this.handleHotKey(key);
- } else if (keyCode >= 37 && keyCode <= 40) {
- /* Arrow key pressed - start navigation */
- this.akn.arrowNavigation(keyCode);
- } else if (keyCode === 27) {
- /* Esc key pressed - reset form */
- this.clearFilterInput();
- }
- },
- /* Open web search results in users desired method */
- launchWebSearch(url, method) {
- switch (method) {
- case 'newtab':
- window.open(url, '_blank');
- break;
- case 'sametab':
- window.open(url, '_self');
- break;
- case 'workspace':
- router.push({ name: 'workspace', query: { url } });
- break;
- default:
- ErrorHandler(`Unknown opening method: ${method}`);
- window.open(url, '_blank');
- }
- },
- /* If web search enabled, then launch search results when enter is pressed */
- searchSubmitted() {
- // Get search preferences from appConfig
- const searchPrefs = this.appConfig.webSearch || {};
- if (this.webSearchEnabled) { // Only proceed if user hasn't disabled web search
- const openingMethod = searchPrefs.openingMethod || defaultSearchOpeningMethod;
- // Get search engine, and make URL
- const searchEngine = searchPrefs.searchEngine || defaultSearchEngine;
- let searchUrl = searchEngineUrls[searchEngine];
- if (!searchUrl) ErrorHandler(`Search engine not found - ${searchEngine}`);
- if (searchEngine === 'custom' && searchPrefs.customSearchEngine) {
- searchUrl = searchPrefs.customSearchEngine;
- }
- // Append users encoded query onto search URL, and launch
- searchUrl += encodeURIComponent(this.input);
- this.launchWebSearch(searchUrl, openingMethod);
- }
+ userIsTypingSomething(searchValue) {
+ this.input = searchValue;
+ this.$emit('user-is-searchin', searchValue);
},
- /* Emmits an event to reset state when user is finished searching */
- clearMinFilterInput() {
- this.$refs.MinimalSearchBar.clearFilterInput();
- },
+ },
+ mounted() {
+ window.addEventListener('keydown', this.startFiltering);
+ },
+ beforeDestroy() {
+ window.removeEventListener('keydown', this.startFiltering);
},
};
</script>
diff --cc src/components/Settings/SearchBar.vue
index 2ce30569,d1ca73ba..f65447fd
--- a/src/components/Settings/SearchBar.vue
+++ b/src/components/Settings/SearchBar.vue
@@@ -35,6 -35,11 +35,9 @@@ import
export default {
name: 'FilterTile',
- inject: ['config'],
+ props: {
- active: Boolean,
+ minimalSearch: Boolean, // If true, then keep it simple
+ },
data() {
return {
input: '', // Users current search term