mirror of https://github.com/Lissy93/dashy.git
🎨 Improved code style in Section
This commit is contained in:
parent
080e68445c
commit
c9f2483c3e
|
@ -13,7 +13,7 @@
|
||||||
>
|
>
|
||||||
<!-- If no items, show message -->
|
<!-- If no items, show message -->
|
||||||
<div v-if="(!items || items.length < 1) && !isEditMode" class="no-items">
|
<div v-if="(!items || items.length < 1) && !isEditMode" class="no-items">
|
||||||
No Items to Show Yet
|
{{ $t('home.no-items-section') }}
|
||||||
</div>
|
</div>
|
||||||
<!-- Item Container -->
|
<!-- Item Container -->
|
||||||
<div v-else
|
<div v-else
|
||||||
|
@ -33,12 +33,12 @@
|
||||||
:backgroundColor="item.backgroundColor"
|
:backgroundColor="item.backgroundColor"
|
||||||
:statusCheckUrl="item.statusCheckUrl"
|
:statusCheckUrl="item.statusCheckUrl"
|
||||||
:statusCheckHeaders="item.statusCheckHeaders"
|
:statusCheckHeaders="item.statusCheckHeaders"
|
||||||
:itemSize="newItemSize"
|
:itemSize="itemSize"
|
||||||
:hotkey="item.hotkey"
|
:hotkey="item.hotkey"
|
||||||
:provider="item.provider"
|
:provider="item.provider"
|
||||||
:parentSectionTitle="title"
|
:parentSectionTitle="title"
|
||||||
:enableStatusCheck="shouldEnableStatusCheck(item.statusCheck)"
|
:enableStatusCheck="item.statusCheck !== undefined ? item.statusCheck : enableStatusCheck"
|
||||||
:statusCheckInterval="getStatusCheckInterval()"
|
:statusCheckInterval="statusCheckInterval"
|
||||||
:statusCheckAllowInsecure="item.statusCheckAllowInsecure"
|
:statusCheckAllowInsecure="item.statusCheckAllowInsecure"
|
||||||
@itemClicked="$emit('itemClicked')"
|
@itemClicked="$emit('itemClicked')"
|
||||||
@triggerModal="triggerModal"
|
@triggerModal="triggerModal"
|
||||||
|
@ -54,9 +54,8 @@
|
||||||
description="Click to add new item"
|
description="Click to add new item"
|
||||||
key="add-new"
|
key="add-new"
|
||||||
class="add-new-item"
|
class="add-new-item"
|
||||||
:itemSize="newItemSize"
|
:itemSize="itemSize"
|
||||||
/>
|
/>
|
||||||
<div ref="modalContainer"></div>
|
|
||||||
</div>
|
</div>
|
||||||
<!-- Modal for opening in modal view -->
|
<!-- Modal for opening in modal view -->
|
||||||
<IframeModal
|
<IframeModal
|
||||||
|
@ -108,7 +107,6 @@ export default {
|
||||||
icon: String,
|
icon: String,
|
||||||
displayData: Object,
|
displayData: Object,
|
||||||
items: Array,
|
items: Array,
|
||||||
itemSize: String,
|
|
||||||
index: Number,
|
index: Number,
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
|
@ -132,6 +130,12 @@ export default {
|
||||||
appConfig() {
|
appConfig() {
|
||||||
return this.$store.getters.appConfig;
|
return this.$store.getters.appConfig;
|
||||||
},
|
},
|
||||||
|
isEditMode() {
|
||||||
|
return this.$store.state.editMode;
|
||||||
|
},
|
||||||
|
itemSize() {
|
||||||
|
return this.$store.getters.iconSize;
|
||||||
|
},
|
||||||
sortOrder() {
|
sortOrder() {
|
||||||
return this.displayData.sortBy || defaultSortOrder;
|
return this.displayData.sortBy || defaultSortOrder;
|
||||||
},
|
},
|
||||||
|
@ -146,7 +150,7 @@ export default {
|
||||||
} else if (this.sortOrder === 'most-used') {
|
} else if (this.sortOrder === 'most-used') {
|
||||||
items = this.sortByMostUsed(items);
|
items = this.sortByMostUsed(items);
|
||||||
} else if (this.sortOrder === 'last-used') {
|
} else if (this.sortOrder === 'last-used') {
|
||||||
items = this.sortBLastUsed(items);
|
items = this.sortByLastUsed(items);
|
||||||
} else if (this.sortOrder === 'random') {
|
} else if (this.sortOrder === 'random') {
|
||||||
items = this.sortRandomly(items);
|
items = this.sortRandomly(items);
|
||||||
} else if (this.sortOrder && this.sortOrder !== 'default') {
|
} else if (this.sortOrder && this.sortOrder !== 'default') {
|
||||||
|
@ -154,9 +158,6 @@ export default {
|
||||||
}
|
}
|
||||||
return items;
|
return items;
|
||||||
},
|
},
|
||||||
newItemSize() {
|
|
||||||
return this.displayData.itemSize || this.itemSize;
|
|
||||||
},
|
|
||||||
isGridLayout() {
|
isGridLayout() {
|
||||||
return this.displayData.sectionLayout === 'grid'
|
return this.displayData.sectionLayout === 'grid'
|
||||||
|| !!(this.displayData.itemCountX || this.displayData.itemCountY);
|
|| !!(this.displayData.itemCountX || this.displayData.itemCountY);
|
||||||
|
@ -171,8 +172,17 @@ export default {
|
||||||
}
|
}
|
||||||
return styles;
|
return styles;
|
||||||
},
|
},
|
||||||
isEditMode() {
|
/* Determines if user has enabled online status checks */
|
||||||
return this.$store.state.editMode;
|
enableStatusCheck() {
|
||||||
|
return this.appConfig.statusCheck || false;
|
||||||
|
},
|
||||||
|
/* Determine how often to re-fire status checks */
|
||||||
|
statusCheckInterval() {
|
||||||
|
let interval = this.appConfig.statusCheckInterval;
|
||||||
|
if (!interval) return 0;
|
||||||
|
if (interval > 60) interval = 60;
|
||||||
|
if (interval < 1) interval = 0;
|
||||||
|
return interval;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -180,19 +190,6 @@ export default {
|
||||||
triggerModal(url) {
|
triggerModal(url) {
|
||||||
this.$refs[`iframeModal-${this.groupId}`].show(url);
|
this.$refs[`iframeModal-${this.groupId}`].show(url);
|
||||||
},
|
},
|
||||||
/* Determines if user has enabled online status checks */
|
|
||||||
shouldEnableStatusCheck(itemPreference) {
|
|
||||||
const globalPreference = this.appConfig.statusCheck || false;
|
|
||||||
return itemPreference !== undefined ? itemPreference : globalPreference;
|
|
||||||
},
|
|
||||||
/* Determine how often to re-fire status checks */
|
|
||||||
getStatusCheckInterval() {
|
|
||||||
let interval = this.appConfig.statusCheckInterval;
|
|
||||||
if (!interval) return 0;
|
|
||||||
if (interval > 60) interval = 60;
|
|
||||||
if (interval < 1) interval = 0;
|
|
||||||
return interval;
|
|
||||||
},
|
|
||||||
/* Sorts items alphabetically using the title attribute */
|
/* Sorts items alphabetically using the title attribute */
|
||||||
sortAlphabetically(items) {
|
sortAlphabetically(items) {
|
||||||
return items.sort((a, b) => (a.title > b.title ? 1 : -1));
|
return items.sort((a, b) => (a.title > b.title ? 1 : -1));
|
||||||
|
@ -205,7 +202,7 @@ export default {
|
||||||
return items;
|
return items;
|
||||||
},
|
},
|
||||||
/* Sorts items by most recently used */
|
/* Sorts items by most recently used */
|
||||||
sortBLastUsed(items) {
|
sortByLastUsed(items) {
|
||||||
const usageCount = JSON.parse(localStorage.getItem(localStorageKeys.LAST_USED) || '{}');
|
const usageCount = JSON.parse(localStorage.getItem(localStorageKeys.LAST_USED) || '{}');
|
||||||
const glu = (item) => usageCount[item.id] || 0;
|
const glu = (item) => usageCount[item.id] || 0;
|
||||||
items.reverse().sort((a, b) => (glu(a) < glu(b) ? 1 : -1));
|
items.reverse().sort((a, b) => (glu(a) < glu(b) ? 1 : -1));
|
||||||
|
|
Loading…
Reference in New Issue