mirror of https://github.com/Lissy93/dashy.git
🚧 ✨ Register a Widget to display stories from HN
This commit is contained in:
parent
2ec404121a
commit
1a42a41a53
|
@ -0,0 +1,54 @@
|
||||||
|
<template>
|
||||||
|
<div class="hackernews-wrapper">
|
||||||
|
<h3>Hackernews Trending</h3>
|
||||||
|
|
||||||
|
<!-- Hackernews Trending Posts-->
|
||||||
|
<div class="posts-wrapper">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
// import axios from 'axios';
|
||||||
|
import WidgetMixin from '@/mixins/WidgetMixin';
|
||||||
|
import { widgetApiEndpoints } from '@/utils/defaults';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
mixins: [WidgetMixin],
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
trendingPosts: null,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
filters: {
|
||||||
|
debug() { console.debug('Not implemented'); },
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
storyType() {
|
||||||
|
// This can be `beststories`, `topstories` or newstories
|
||||||
|
return this.options.stories || 'beststories';
|
||||||
|
},
|
||||||
|
limit() {
|
||||||
|
return this.options.limit || 10;
|
||||||
|
},
|
||||||
|
endpoint() {
|
||||||
|
return `${widgetApiEndpoints.hackernewsTrending}/${this.storyType}.json`
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
fetchData() {
|
||||||
|
console.log("Let's fetch some Data");
|
||||||
|
this.makeRequest(this.endpoint).then(this.fetchPostDetails)
|
||||||
|
},
|
||||||
|
async fetchPostDetails(data) {
|
||||||
|
const topPosts = data.slice(0, this.limit)
|
||||||
|
const allData = topPosts.map((post) => {
|
||||||
|
const url = `${widgetApiEndpoints.hackernewsTrending}/item/${post}.json`;
|
||||||
|
return this.makeRequest(url);
|
||||||
|
})
|
||||||
|
Promise.all(allData).then((values) => console.log(values))
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
|
@ -78,6 +78,7 @@ const COMPAT = {
|
||||||
'gl-system-load': 'GlSystemLoad',
|
'gl-system-load': 'GlSystemLoad',
|
||||||
'gl-cpu-temp': 'GlCpuTemp',
|
'gl-cpu-temp': 'GlCpuTemp',
|
||||||
'health-checks': 'HealthChecks',
|
'health-checks': 'HealthChecks',
|
||||||
|
'hackernews-trending': 'HackernewsTrending',
|
||||||
'gluetun-status': 'GluetunStatus',
|
'gluetun-status': 'GluetunStatus',
|
||||||
iframe: 'IframeWidget',
|
iframe: 'IframeWidget',
|
||||||
image: 'ImageWidget',
|
image: 'ImageWidget',
|
||||||
|
|
|
@ -107,11 +107,7 @@ module.exports = {
|
||||||
footer: true,
|
footer: true,
|
||||||
},
|
},
|
||||||
/* A list of route names that page furniture (header, footer, etc) should be hidden on */
|
/* A list of route names that page furniture (header, footer, etc) should be hidden on */
|
||||||
hideFurnitureOn: [
|
hideFurnitureOn: ['minimal', 'login', 'download'],
|
||||||
'minimal',
|
|
||||||
'login',
|
|
||||||
'download',
|
|
||||||
],
|
|
||||||
/* Key names for local storage identifiers */
|
/* Key names for local storage identifiers */
|
||||||
localStorageKeys: {
|
localStorageKeys: {
|
||||||
LANGUAGE: 'language',
|
LANGUAGE: 'language',
|
||||||
|
@ -166,9 +162,7 @@ module.exports = {
|
||||||
/* Amount of time to show splash screen, when enabled, in milliseconds */
|
/* Amount of time to show splash screen, when enabled, in milliseconds */
|
||||||
splashScreenTime: 1000,
|
splashScreenTime: 1000,
|
||||||
/* Page meta-data, rendered in the header of each view */
|
/* Page meta-data, rendered in the header of each view */
|
||||||
metaTagData: [
|
metaTagData: [{ name: 'description', content: "A simple static homepage for you're server" }],
|
||||||
{ name: 'description', content: 'A simple static homepage for you\'re server' },
|
|
||||||
],
|
|
||||||
/* Default option for Toast messages */
|
/* Default option for Toast messages */
|
||||||
toastedOptions: {
|
toastedOptions: {
|
||||||
position: 'bottom-center',
|
position: 'bottom-center',
|
||||||
|
@ -212,8 +206,10 @@ module.exports = {
|
||||||
generativeFallback: 'https://evatar.io/{icon}',
|
generativeFallback: 'https://evatar.io/{icon}',
|
||||||
localPath: './item-icons',
|
localPath: './item-icons',
|
||||||
faviconName: 'favicon.ico',
|
faviconName: 'favicon.ico',
|
||||||
homeLabIcons: 'https://raw.githubusercontent.com/walkxcode/dashboard-icons/master/png/{icon}.png',
|
homeLabIcons:
|
||||||
homeLabIconsFallback: 'https://raw.githubusercontent.com/NX211/homer-icons/master/png/{icon}.png',
|
'https://raw.githubusercontent.com/walkxcode/dashboard-icons/master/png/{icon}.png',
|
||||||
|
homeLabIconsFallback:
|
||||||
|
'https://raw.githubusercontent.com/NX211/homer-icons/master/png/{icon}.png',
|
||||||
},
|
},
|
||||||
/* API endpoints for widgets that need to fetch external data */
|
/* API endpoints for widgets that need to fetch external data */
|
||||||
widgetApiEndpoints: {
|
widgetApiEndpoints: {
|
||||||
|
@ -231,6 +227,7 @@ module.exports = {
|
||||||
exchangeRates: 'https://v6.exchangerate-api.com/v6/',
|
exchangeRates: 'https://v6.exchangerate-api.com/v6/',
|
||||||
flights: 'https://aerodatabox.p.rapidapi.com/flights/airports/icao/',
|
flights: 'https://aerodatabox.p.rapidapi.com/flights/airports/icao/',
|
||||||
githubTrending: 'https://gh-trending-repos.herokuapp.com/',
|
githubTrending: 'https://gh-trending-repos.herokuapp.com/',
|
||||||
|
hackernewsTrending: 'https://hacker-news.firebaseio.com/v0',
|
||||||
healthChecks: 'https://healthchecks.io/api/v1/checks',
|
healthChecks: 'https://healthchecks.io/api/v1/checks',
|
||||||
holidays: 'https://kayaposoft.com/enrico/json/v2.0/?action=getHolidaysForDateRange',
|
holidays: 'https://kayaposoft.com/enrico/json/v2.0/?action=getHolidaysForDateRange',
|
||||||
jokes: 'https://v2.jokeapi.dev/joke/',
|
jokes: 'https://v2.jokeapi.dev/joke/',
|
||||||
|
|
Loading…
Reference in New Issue