Skip to content

armgit / dashy

Public Imported from GitHub
0

πŸš€ A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!

:sparkles: Added basic RescueTime widget to see time spent on activities

wozbozf7a0fb24a9bc
diff --git a/docs/widgets.md b/docs/widgets.md
index ec80a466..ba064d01 100644
--- a/docs/widgets.md
+++ b/docs/widgets.md
@@ -39,6 +39,7 @@ Dashy has support for displaying dynamic content in the form of widgets. There a
- [Mvg Departure](#mvg-departure)
- [Mvg Connection](#mvg-connection)
- [Custom search](#custom-search)
+ - [Rescuetime overview] (#rescuetime-overview)
- **[Self-Hosted Services Widgets](#self-hosted-services-widgets)**
- [System Info](#system-info)
- [Cron Monitoring](#cron-monitoring-health-checks)
@@ -1339,6 +1340,38 @@ This widget allows searching multiple search engines from dashy.
---
+### RescueTime Overview
+
+Show an overview of how you have spent your time for the current day.
+
+<p align="center"><img width="400" src="https://i.ibb.co/bvx3PQM/rescuetime.png" /></p>
+
+#### Options
+
+**Field** | **Type** | **Required** | **Description**
+--- | --- | --- | ---
+**`apiKey`** | `string` | required | The API-Key generated in the RescueTime UI.
+
+
+#### Example
+
+```yaml
+ - type: rescue-time
+ useProxy: true
+ options:
+ apiKey: abcdefghijkl_mnop
+```
+#### Info
+
+- **CORS**: 🟒 Required
+- **Auth**: πŸ”΄ Required
+- **Price**: 🟠 Depends on user subscription
+- **Host**: [RescueTime](https://www.rescuetime.com)
+- **Privacy**: _See [RescueTime Privacy](https://www.rescuetime.com/privacy)_
+
+---
+
+
## Self-Hosted Services Widgets
diff --git a/src/components/Widgets/RescueTime.vue b/src/components/Widgets/RescueTime.vue
new file mode 100644
index 00000000..952508b4
--- /dev/null
+++ b/src/components/Widgets/RescueTime.vue
@@ -0,0 +1,111 @@
+<template>
+ <div class="rescuetime-wrapper">
+ <div class="title-row">
+ <p class="title-rank">Rank</p>
+ <p class="title-name">Category</p>
+ <p class="title-time">Time spent</p>
+ </div>
+ <div
+ v-for="(category, indx) in categories"
+ :key="indx"
+ class="category-row"
+ >
+ <p class="category-rank">{{ category.rank }}</p>
+ <p class="category-name">{{ indx }}</p>
+ <p class="category-time">{{ category.minutes }} min</p>
+ </div>
+ </div>
+ </template>
+<script>
+
+// import axios from 'axios';
+import WidgetMixin from '@/mixins/WidgetMixin';
+import { widgetApiEndpoints } from '@/utils/defaults';
+
+export default {
+ mixins: [WidgetMixin],
+ data() {
+ return {
+ categories: [],
+ };
+ },
+ mounted() {
+ this.checkOptions();
+ },
+ computed: {
+ endpoint() {
+ const todaystring = this.getDate();
+ return `${widgetApiEndpoints.rescueTime}?key=${this.options.apiKey}&restrict_begin=${todaystring}&restrict_end=${todaystring}&restrict_kind=overview&format=json`;
+ },
+ },
+ methods: {
+ fetchData() {
+ this.makeRequest(this.endpoint).then(this.processData);
+ },
+ processData(data) {
+ const formateddata = this.calculateTimeCategories(data);
+ this.categories = formateddata;
+ },
+ checkOptions() {
+ const ops = this.options;
+ if (!ops.apiKey) this.error('Missing API key for RescueTime');
+ },
+ getDate() {
+ const today = new Date();
+ let day = today.getDate();
+ let month = today.getMonth() + 1;
+ const year = today.getFullYear();
+ if (day < 10) {
+ day = `0${day}`;
+ }
+ if (month < 10) {
+ month = `0${month}`;
+ }
+ return `${day}-${month}-${year}`;
+ },
+ calculateTimeCategories(timeArray) {
+ const results = {};
+ // console.log(timeArray.rows[0]);
+ for (let i = 0; i < timeArray.rows.length; i += 1) {
+ const [rank, seconds, persons, category] = timeArray.rows[i];
+ const minutes = (parseInt(seconds, 10) / 60).toFixed(2);
+ results[category] = { minutes, rank, persons };
+ }
+ return results;
+ },
+ },
+};
+
+</script>
+
+<style scoped lang="scss">
+.rescuetime-wrapper {
+ padding: 0.5rem 0;
+ .title-row {
+ display: flex;
+ justify-content: space-between;
+ p {
+ margin: 0.25rem 0;
+ color: var(--widget-text-color);
+ font-weight: 700;
+ font-size: 1.15rem;
+ }
+ &:not(:last-child) {
+ border-bottom: 1px dashed var(--widget-text-color);
+ }
+ }
+ .category-rank {
+ font-weight: 700;
+ }
+ .category-row {
+ display: flex;
+ justify-content: space-between;
+ p {
+ margin: 0.25rem 0;
+ color: var(--widget-text-color);
+ opacity: var(--dimming-factor);
+ }
+ }
+}
+
+</style>
diff --git a/src/components/Widgets/WidgetBase.vue b/src/components/Widgets/WidgetBase.vue
index ac9a0b60..dc536303 100644
--- a/src/components/Widgets/WidgetBase.vue
+++ b/src/components/Widgets/WidgetBase.vue
@@ -104,6 +104,7 @@ const COMPAT = {
'proxmox-lists': 'Proxmox',
'public-holidays': 'PublicHolidays',
'public-ip': 'PublicIp',
+ 'rescue-time': 'RescueTime',
'rss-feed': 'RssFeed',
sabnzbd: 'Sabnzbd',
'sports-scores': 'SportsScores',
diff --git a/src/utils/defaults.js b/src/utils/defaults.js
index 69e0ff3e..3f0675d7 100644
--- a/src/utils/defaults.js
+++ b/src/utils/defaults.js
@@ -238,6 +238,7 @@ module.exports = {
publicIp2: 'https://api.ipgeolocation.io/ipgeo',
publicIp3: 'http://ip-api.com/json',
readMeStats: 'https://github-readme-stats.vercel.app/api',
+ rescueTime: 'https://www.rescuetime.com/anapi/data',
rssToJson: 'https://api.rss2json.com/v1/api.json',
sportsScores: 'https://www.thesportsdb.com/api/v1/json',
stockPriceChart: 'https://www.alphavantage.co/query',