mirror of
https://github.com/Lissy93/dashy.git
synced 2025-12-06 08:34:14 +01:00
add widget for Chuck Norris quotes and sort some lines of WidgetBase.vue alphabetically.
This commit is contained in:
parent
c1f27c64b6
commit
877ec0060d
3 changed files with 83 additions and 15 deletions
66
src/components/Widgets/ChuckNorris.vue
Normal file
66
src/components/Widgets/ChuckNorris.vue
Normal file
|
|
@ -0,0 +1,66 @@
|
||||||
|
<template>
|
||||||
|
<div class="chuckNorris-wrapper">
|
||||||
|
<p class="chuckNorris chuckNorris-line">{{ chuckNorrisLine }}</p>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import axios from 'axios';
|
||||||
|
import WidgetMixin from '@/mixins/WidgetMixin';
|
||||||
|
import { widgetApiEndpoints } from '@/utils/defaults';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
mixins: [WidgetMixin],
|
||||||
|
components: {},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
chuckNorrisLine: null,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
/* Format the users preferred categories */
|
||||||
|
categories() {
|
||||||
|
let usersChoice = this.options.categories;
|
||||||
|
if (!usersChoice) return '';
|
||||||
|
if (Array.isArray(usersChoice)) usersChoice = usersChoice.join(',');
|
||||||
|
const categories = ["animal","career","celebrity","dev","explicit","fashion","food","history","money","movie","music","political","religion","science","sport","travel"];
|
||||||
|
if (categories.some((cat) => usersChoice.toLowerCase().includes(cat))) return usersChoice;
|
||||||
|
return '';
|
||||||
|
},
|
||||||
|
/* Combine data parameters for the API endpoint */
|
||||||
|
endpoint() {
|
||||||
|
if (this.categories != '') return `${widgetApiEndpoints.chuckNorris}`+`?category=${this.categories}`;
|
||||||
|
if (this.categories == '') return `${widgetApiEndpoints.chuckNorris}`;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
/* Make GET request to ChuckNorris API endpoint */
|
||||||
|
fetchData() {
|
||||||
|
axios.get(this.endpoint)
|
||||||
|
.then((response) => {
|
||||||
|
this.processData(response.data);
|
||||||
|
})
|
||||||
|
.catch((dataFetchError) => {
|
||||||
|
this.error('Unable to fetch any Chuck Norris quote', dataFetchError);
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.finishLoading();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/* Assign data variables to the returned data */
|
||||||
|
processData(data) {
|
||||||
|
this.chuckNorrisLine = data.value;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.chuckNorris-wrapper {
|
||||||
|
p.chuckNorris {
|
||||||
|
color: var(--widget-text-color);
|
||||||
|
font-size: 1.2rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
|
|
@ -46,20 +46,21 @@ const COMPAT = {
|
||||||
'adguard-filter-status': 'AdGuardFilterStatus',
|
'adguard-filter-status': 'AdGuardFilterStatus',
|
||||||
'adguard-stats': 'AdGuardStats',
|
'adguard-stats': 'AdGuardStats',
|
||||||
'adguard-top-domains': 'AdGuardTopDomains',
|
'adguard-top-domains': 'AdGuardTopDomains',
|
||||||
anonaddy: 'addy.io',
|
'anonaddy': 'addy.io',
|
||||||
apod: 'Apod',
|
'apod': 'Apod',
|
||||||
'blacklist-check': 'BlacklistCheck',
|
'blacklist-check': 'BlacklistCheck',
|
||||||
clock: 'Clock',
|
'chucknorris': 'ChuckNorris',
|
||||||
|
'clock': 'Clock',
|
||||||
|
'code-stats': 'CodeStats',
|
||||||
|
'covid-stats': 'CovidStats',
|
||||||
'crypto-price-chart': 'CryptoPriceChart',
|
'crypto-price-chart': 'CryptoPriceChart',
|
||||||
'crypto-watch-list': 'CryptoWatchList',
|
'crypto-watch-list': 'CryptoWatchList',
|
||||||
'custom-search': 'CustomSearch',
|
'custom-search': 'CustomSearch',
|
||||||
'custom-list': 'CustomList',
|
'custom-list': 'CustomList',
|
||||||
'cve-vulnerabilities': 'CveVulnerabilities',
|
'cve-vulnerabilities': 'CveVulnerabilities',
|
||||||
'domain-monitor': 'DomainMonitor',
|
'domain-monitor': 'DomainMonitor',
|
||||||
'code-stats': 'CodeStats',
|
|
||||||
'covid-stats': 'CovidStats',
|
|
||||||
'drone-ci': 'DroneCi',
|
'drone-ci': 'DroneCi',
|
||||||
embed: 'EmbedWidget',
|
'embed': 'EmbedWidget',
|
||||||
'eth-gas-prices': 'EthGasPrices',
|
'eth-gas-prices': 'EthGasPrices',
|
||||||
'exchange-rates': 'ExchangeRates',
|
'exchange-rates': 'ExchangeRates',
|
||||||
'flight-data': 'Flights',
|
'flight-data': 'Flights',
|
||||||
|
|
@ -81,16 +82,16 @@ const COMPAT = {
|
||||||
'gl-network-traffic': 'GlNetworkTraffic',
|
'gl-network-traffic': 'GlNetworkTraffic',
|
||||||
'gl-system-load': 'GlSystemLoad',
|
'gl-system-load': 'GlSystemLoad',
|
||||||
'gl-cpu-temp': 'GlCpuTemp',
|
'gl-cpu-temp': 'GlCpuTemp',
|
||||||
|
'gluetun-status': 'GluetunStatus',
|
||||||
'health-checks': 'HealthChecks',
|
'health-checks': 'HealthChecks',
|
||||||
'hackernews-trending': 'HackernewsTrending',
|
'hackernews-trending': 'HackernewsTrending',
|
||||||
'gluetun-status': 'GluetunStatus',
|
'iframe': 'IframeWidget',
|
||||||
iframe: 'IframeWidget',
|
'image': 'ImageWidget',
|
||||||
image: 'ImageWidget',
|
'joke': 'Jokes',
|
||||||
joke: 'Jokes',
|
'linkding': 'Linkding',
|
||||||
'minecraft-status': 'MinecraftStatus',
|
'minecraft-status': 'MinecraftStatus',
|
||||||
'mullvad-status': 'MullvadStatus',
|
'mullvad-status': 'MullvadStatus',
|
||||||
mvg: 'Mvg',
|
'mvg': 'Mvg',
|
||||||
linkding: 'Linkding',
|
|
||||||
'mvg-connection': 'MvgConnection',
|
'mvg-connection': 'MvgConnection',
|
||||||
'nd-cpu-history': 'NdCpuHistory',
|
'nd-cpu-history': 'NdCpuHistory',
|
||||||
'nd-load-history': 'NdLoadHistory',
|
'nd-load-history': 'NdLoadHistory',
|
||||||
|
|
@ -113,17 +114,17 @@ const COMPAT = {
|
||||||
'public-ip': 'PublicIp',
|
'public-ip': 'PublicIp',
|
||||||
'rescue-time': 'RescueTime',
|
'rescue-time': 'RescueTime',
|
||||||
'rss-feed': 'RssFeed',
|
'rss-feed': 'RssFeed',
|
||||||
sabnzbd: 'Sabnzbd',
|
'sabnzbd': 'Sabnzbd',
|
||||||
'sports-scores': 'SportsScores',
|
'sports-scores': 'SportsScores',
|
||||||
'stat-ping': 'StatPing',
|
'stat-ping': 'StatPing',
|
||||||
'stock-price-chart': 'StockPriceChart',
|
'stock-price-chart': 'StockPriceChart',
|
||||||
'synology-download': 'SynologyDownload',
|
'synology-download': 'SynologyDownload',
|
||||||
'system-info': 'SystemInfo',
|
'system-info': 'SystemInfo',
|
||||||
'tfl-status': 'TflStatus',
|
'tfl-status': 'TflStatus',
|
||||||
trmm: 'TacticalRMM',
|
'trmm': 'TacticalRMM',
|
||||||
'uptime-kuma': 'UptimeKuma',
|
'uptime-kuma': 'UptimeKuma',
|
||||||
'wallet-balance': 'WalletBalance',
|
'wallet-balance': 'WalletBalance',
|
||||||
weather: 'Weather',
|
'weather': 'Weather',
|
||||||
'weather-forecast': 'WeatherForecast',
|
'weather-forecast': 'WeatherForecast',
|
||||||
'xkcd-comic': 'XkcdComic',
|
'xkcd-comic': 'XkcdComic',
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -227,6 +227,7 @@ module.exports = {
|
||||||
anonAddy: 'https://app.addy.io',
|
anonAddy: 'https://app.addy.io',
|
||||||
astronomyPictureOfTheDay: 'https://apod.as93.net/apod',
|
astronomyPictureOfTheDay: 'https://apod.as93.net/apod',
|
||||||
blacklistCheck: 'https://api.blacklistchecker.com/check',
|
blacklistCheck: 'https://api.blacklistchecker.com/check',
|
||||||
|
chuckNorris: 'https://api.chucknorris.io/jokes/random',
|
||||||
codeStats: 'https://codestats.net/',
|
codeStats: 'https://codestats.net/',
|
||||||
covidStats: 'https://disease.sh/v3/covid-19',
|
covidStats: 'https://disease.sh/v3/covid-19',
|
||||||
cryptoPrices: 'https://api.coingecko.com/api/v3/coins/',
|
cryptoPrices: 'https://api.coingecko.com/api/v3/coins/',
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue