mirror of
https://github.com/Lissy93/dashy.git
synced 2025-09-24 10:18:50 +02:00
add widget for Chuck Norris quotes and sort some lines of WidgetBase.vue alphabetically.
This commit is contained in:
parent
c1f27c64b6
commit
877ec0060d
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-stats': 'AdGuardStats',
|
||||
'adguard-top-domains': 'AdGuardTopDomains',
|
||||
anonaddy: 'addy.io',
|
||||
apod: 'Apod',
|
||||
'anonaddy': 'addy.io',
|
||||
'apod': 'Apod',
|
||||
'blacklist-check': 'BlacklistCheck',
|
||||
clock: 'Clock',
|
||||
'chucknorris': 'ChuckNorris',
|
||||
'clock': 'Clock',
|
||||
'code-stats': 'CodeStats',
|
||||
'covid-stats': 'CovidStats',
|
||||
'crypto-price-chart': 'CryptoPriceChart',
|
||||
'crypto-watch-list': 'CryptoWatchList',
|
||||
'custom-search': 'CustomSearch',
|
||||
'custom-list': 'CustomList',
|
||||
'cve-vulnerabilities': 'CveVulnerabilities',
|
||||
'domain-monitor': 'DomainMonitor',
|
||||
'code-stats': 'CodeStats',
|
||||
'covid-stats': 'CovidStats',
|
||||
'drone-ci': 'DroneCi',
|
||||
embed: 'EmbedWidget',
|
||||
'embed': 'EmbedWidget',
|
||||
'eth-gas-prices': 'EthGasPrices',
|
||||
'exchange-rates': 'ExchangeRates',
|
||||
'flight-data': 'Flights',
|
||||
@ -81,16 +82,16 @@ const COMPAT = {
|
||||
'gl-network-traffic': 'GlNetworkTraffic',
|
||||
'gl-system-load': 'GlSystemLoad',
|
||||
'gl-cpu-temp': 'GlCpuTemp',
|
||||
'gluetun-status': 'GluetunStatus',
|
||||
'health-checks': 'HealthChecks',
|
||||
'hackernews-trending': 'HackernewsTrending',
|
||||
'gluetun-status': 'GluetunStatus',
|
||||
iframe: 'IframeWidget',
|
||||
image: 'ImageWidget',
|
||||
joke: 'Jokes',
|
||||
'iframe': 'IframeWidget',
|
||||
'image': 'ImageWidget',
|
||||
'joke': 'Jokes',
|
||||
'linkding': 'Linkding',
|
||||
'minecraft-status': 'MinecraftStatus',
|
||||
'mullvad-status': 'MullvadStatus',
|
||||
mvg: 'Mvg',
|
||||
linkding: 'Linkding',
|
||||
'mvg': 'Mvg',
|
||||
'mvg-connection': 'MvgConnection',
|
||||
'nd-cpu-history': 'NdCpuHistory',
|
||||
'nd-load-history': 'NdLoadHistory',
|
||||
@ -113,17 +114,17 @@ const COMPAT = {
|
||||
'public-ip': 'PublicIp',
|
||||
'rescue-time': 'RescueTime',
|
||||
'rss-feed': 'RssFeed',
|
||||
sabnzbd: 'Sabnzbd',
|
||||
'sabnzbd': 'Sabnzbd',
|
||||
'sports-scores': 'SportsScores',
|
||||
'stat-ping': 'StatPing',
|
||||
'stock-price-chart': 'StockPriceChart',
|
||||
'synology-download': 'SynologyDownload',
|
||||
'system-info': 'SystemInfo',
|
||||
'tfl-status': 'TflStatus',
|
||||
trmm: 'TacticalRMM',
|
||||
'trmm': 'TacticalRMM',
|
||||
'uptime-kuma': 'UptimeKuma',
|
||||
'wallet-balance': 'WalletBalance',
|
||||
weather: 'Weather',
|
||||
'weather': 'Weather',
|
||||
'weather-forecast': 'WeatherForecast',
|
||||
'xkcd-comic': 'XkcdComic',
|
||||
};
|
||||
|
@ -227,6 +227,7 @@ module.exports = {
|
||||
anonAddy: 'https://app.addy.io',
|
||||
astronomyPictureOfTheDay: 'https://apod.as93.net/apod',
|
||||
blacklistCheck: 'https://api.blacklistchecker.com/check',
|
||||
chuckNorris: 'https://api.chucknorris.io/jokes/random',
|
||||
codeStats: 'https://codestats.net/',
|
||||
covidStats: 'https://disease.sh/v3/covid-19',
|
||||
cryptoPrices: 'https://api.coingecko.com/api/v3/coins/',
|
||||
|
Loading…
x
Reference in New Issue
Block a user