Allow custom site title + description, and refactored

This commit is contained in:
Alicia Sykes 2021-04-01 13:06:16 +01:00
parent 1965513096
commit 221324b41e
5 changed files with 36 additions and 18 deletions

View File

@ -14,7 +14,10 @@
title="Clear search" title="Clear search"
@click="clearFilterInput"></i> @click="clearFilterInput"></i>
</form> </form>
<div class="space-filler"></div> <div class="space-filler">
<span>hello</span>
<span>world</span>
</div>
<KeyboardShortcutInfo /> <KeyboardShortcutInfo />
</section> </section>
</template> </template>

View File

@ -1,6 +1,6 @@
<template> <template>
<header> <header>
<PageTitle /> <PageTitle :title="pageInfo.title" :description="pageInfo.description" />
<Nav class="nav"/> <Nav class="nav"/>
</header> </header>
</template> </template>
@ -15,6 +15,9 @@ export default {
PageTitle, PageTitle,
Nav, Nav,
}, },
props: {
pageInfo: Object,
},
}; };
</script> </script>

View File

@ -1,13 +1,17 @@
<template> <template>
<div class="page-titles"> <div class="page-titles">
<h1>Networking Services</h1> <h1>{{ title }}</h1>
<span class="subtitle">Local network management and moniroting</span> <span class="subtitle">{{ description }}</span>
</div> </div>
</template> </template>
<script> <script>
export default { export default {
name: 'PageTitle', name: 'PageTitle',
props: {
title: String,
description: String,
},
}; };
</script> </script>

View File

@ -1,10 +1,9 @@
--- ---
pageInfo: pageInfo:
title: Hello World title: Hello World
description: '' description: 'This is a demo'
sections: sections:
- name: Firewall - name: Firewall
collapsed: false
items: items:
- title: OPNsense - title: OPNsense
description: Firewall Central Management description: Firewall Central Management
@ -47,7 +46,6 @@ sections:
iconType: img iconType: img
url: https://192.168.1.1/ui/wireguard/general url: https://192.168.1.1/ui/wireguard/general
- name: DNS Device - name: DNS Device
collapsed: false
items: items:
- title: Pi-Hole - title: Pi-Hole
description: DNS settings for ad & tracker blocking description: DNS settings for ad & tracker blocking
@ -112,7 +110,6 @@ sections:
icon: networking/grafana icon: networking/grafana
url: http://192.168.130.2:8091/ url: http://192.168.130.2:8091/
- name: Other Devices - name: Other Devices
collapsed: false
items: items:
- title: Modem - title: Modem
description: ISP Router Modem Combo description: ISP Router Modem Combo
@ -136,8 +133,6 @@ sections:
iconType: img iconType: img
url: "/" url: "/"
- name: External Services - name: External Services
collapsed: true
cols: 1
items: items:
- title: DuckDNS - title: DuckDNS
description: Dynamic DNS for fixed public IP description: Dynamic DNS for fixed public IP
@ -170,8 +165,8 @@ sections:
iconType: img iconType: img
url: https://myaccount.vodafone.co.uk/ url: https://myaccount.vodafone.co.uk/
- name: External Utilities - name: External Utilities
collapsed: false displayData:
cols: 1 collapsed: true
items: items:
- title: Public IP - title: Public IP
description: Check public IP and associated data description: Check public IP and associated data

View File

@ -1,6 +1,6 @@
<template> <template>
<div class="home"> <div class="home">
<Header /> <Header :pageInfo="getPageInfo(pageInfo)" />
<FilterTile @user-is-searchin="searching" class="filter-container" /> <FilterTile @user-is-searchin="searching" class="filter-container" />
<div class="item-group-container"> <div class="item-group-container">
<ItemGroup <ItemGroup
@ -24,28 +24,28 @@ import conf from '../data/conf.yml';
export default { export default {
name: 'home', name: 'home',
props: {
title: { default: 'Panel', type: String },
subtitle: { default: 'All your server management tools in one place', type: String },
},
components: { components: {
Header, Header,
FilterTile, FilterTile,
ItemGroup, ItemGroup,
}, },
data: () => ({ data: () => ({
pageInfo: conf.pageInfo,
sections: conf.sections, sections: conf.sections,
searchTile: '', searchTile: '',
}), }),
methods: { methods: {
/* Returns true if the user is currently searching */
searching(searchTile) { searching(searchTile) {
this.searchTile = searchTile; this.searchTile = searchTile;
}, },
/* Extracts the website name from domain, used for the searching functionality */
getDomainFromUrl(url) { getDomainFromUrl(url) {
const urlPattern = /^(?:https?:\/\/)?(?:w{3}\.)?([a-z\d.-]+)\.(?:[a-z.]{2,10})(?:[/\w.-]*)*/; const urlPattern = /^(?:https?:\/\/)?(?:w{3}\.)?([a-z\d.-]+)\.(?:[a-z.]{2,10})(?:[/\w.-]*)*/;
const domainPattern = url.match(urlPattern); const domainPattern = url.match(urlPattern);
return domainPattern ? domainPattern[1] : ''; return domainPattern ? domainPattern[1] : '';
}, },
/* Returns only the tiles that match the users search query */
filterTiles(allTiles) { filterTiles(allTiles) {
return allTiles.filter((tile) => { return allTiles.filter((tile) => {
const { const {
@ -58,9 +58,21 @@ export default {
|| this.getDomainFromUrl(url).includes(searchTerm); || this.getDomainFromUrl(url).includes(searchTerm);
}); });
}, },
/* Returns optional section display preferences if available */
getDisplayData(section) { getDisplayData(section) {
return !section.displayData ? {} : section.displayData; return !section.displayData ? {} : section.displayData;
}, },
/* Returns either page info from the config, or default values */
getPageInfo(pageInfo) {
const defaults = { title: 'Demo', description: '' };
if (pageInfo) {
return {
title: pageInfo.title || defaults.title,
description: pageInfo.description || defaults.description,
};
}
return defaults;
},
}, },
}; };
</script> </script>
@ -77,8 +89,9 @@ export default {
/* Outside container wrapping the item groups*/ /* Outside container wrapping the item groups*/
.item-group-container { .item-group-container {
display: grid; display: grid;
gap: 10px; gap: 0.5rem;
/* Specify number of columns, based on screen size */
@include phone { @include phone {
grid-template-columns: repeat(1, 1fr); grid-template-columns: repeat(1, 1fr);
} }