Skip to content

Commit

Permalink
Bits of refactoring here and there.
Browse files Browse the repository at this point in the history
  • Loading branch information
igoramadas committed May 31, 2024
1 parent ac8ad81 commit 3e7f14e
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 43 deletions.
40 changes: 28 additions & 12 deletions pages/account/download.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
<v-simple-table>
<thead class="accent">
<tr>
<th>File</th>
<th v-if="$breakpoint.mdAndUp">File</th>
<th>Data</th>
</tr>
</thead>
<tbody>
<tr>
<td class="nowrap" width="1">activities.json</td>
<td class="nowrap" width="1" v-if="$breakpoint.mdAndUp">activities.json</td>
<td class="pt-2 pb-2">
<ul class="pl-4">
<li>Processed activities</li>
Expand All @@ -29,23 +29,31 @@
</td>
</tr>
<tr>
<td class="nowrap" width="1">athlete-records.json</td>
<td class="nowrap" width="1" v-if="$breakpoint.mdAndUp">athlete-records.json</td>
<td class="pt-2 pb-2">
<ul class="pl-4">
<li>Personal activity records</li>
</ul>
</td>
</tr>
<tr>
<td class="nowrap" width="1">gearwear.json</td>
<td class="nowrap" width="1" v-if="$breakpoint.mdAndUp">garmin.json</td>
<td class="pt-2 pb-2">
<ul class="pl-4">
<li>GearWear configurations</li>
<li>Processed FIT summaries from Garmin</li>
</ul>
</td>
</tr>
<tr>
<td class="nowrap" width="1">notifications.json</td>
<td class="nowrap" width="1" v-if="$breakpoint.mdAndUp">gearwear.json</td>
<td class="pt-2 pb-2">
<ul class="pl-4">
<li>Gear configurations</li>
</ul>
</td>
</tr>
<tr>
<td class="nowrap" width="1" v-if="$breakpoint.mdAndUp">notifications.json</td>
<td class="pt-2 pb-2">
<ul class="pl-4">
<li>Notifications</li>
Expand All @@ -54,23 +62,23 @@
</td>
</tr>
<tr>
<td class="nowrap" width="1">recipe-stats.json</td>
<td class="nowrap" width="1" v-if="$breakpoint.mdAndUp">recipe-stats.json</td>
<td class="pt-2 pb-2">
<ul class="pl-4">
<li>Automation statistics</li>
</ul>
</td>
</tr>
<tr>
<td class="nowrap" width="1">subscriptions.json</td>
<td class="nowrap" width="1" v-if="$breakpoint.mdAndUp">subscriptions.json</td>
<td class="pt-2 pb-2">
<ul class="pl-4">
<li>PRO subscription details</li>
</ul>
</td>
</tr>
<tr>
<td class="nowrap" width="1">users.json</td>
<td class="nowrap" width="1" v-if="$breakpoint.mdAndUp">users.json</td>
<td class="pt-2 pb-2">
<ul class="pl-4">
<li>Strava profile</li>
Expand All @@ -80,7 +88,15 @@
</td>
</tr>
<tr>
<td class="nowrap" width="1">*.ics</td>
<td class="nowrap" width="1" v-if="$breakpoint.mdAndUp">wahoo.json</td>
<td class="pt-2 pb-2">
<ul class="pl-4">
<li>Processed FIT summaries from Wahoo</li>
</ul>
</td>
</tr>
<tr>
<td class="nowrap" width="1" v-if="$breakpoint.mdAndUp">*.ics</td>
<td class="pt-2 pb-2">
<ul class="pl-4">
<li>Cached exported calendars</li>
Expand All @@ -92,8 +108,8 @@
<v-divider></v-divider>

<div class="pa-4">
Some of the files above might be missing, depending on which features you're using on the website. The download does <span class="font-weight-bold">not</span> include your account tokens, credentials, or access and request
logs.
Some of the files above might be missing, depending on which features you're using on the website. The download does <span class="font-weight-bold">not</span> include your account tokens, credentials, short-lived cache and
access logs.
</div>

<div class="pa-3 text-center text-md-left">
Expand Down
15 changes: 7 additions & 8 deletions pages/account/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,6 @@
<v-icon left>mdi-spotify</v-icon>
{{ user.spotify ? "Unlink Spotify account" : "Link Spotify account" }}
</v-btn>
<v-btn class="ma-1" color="primary" title="My notifications" to="/account/notifications" nuxt small rounded>
<v-icon left>mdi-bell</v-icon>
My notifications
</v-btn>
</div>
</div>
<v-card class="mt-5" outlined>
Expand Down Expand Up @@ -214,17 +210,20 @@
</v-btn>
</div>
<div class="mt-6 text-center text-md-left">
<v-btn color="primary" title="Download my data" to="/account/download" small outlined rounded nuxt>
<v-btn color="primary" class="mr-md-2" title="My notifications" to="/account/notifications" small outlined rounded nuxt>
<v-icon left>mdi-bell</v-icon>
My notifications
</v-btn>
<v-btn color="primary" class="mt-2 mt-md-0 mr-md-2" title="Download my data" to="/account/download" small outlined rounded nuxt>
<v-icon left>mdi-archive-arrow-down</v-icon>
Download my data
</v-btn>
</div>
<div class="mt-4 text-center text-md-left">
<v-btn color="removal" title="Time to say goodbye?" to="/account/goodbye" small outlined rounded nuxt>
<v-btn color="removal" class="mt-2 mt-md-0" title="Time to say goodbye?" to="/account/goodbye" small outlined rounded nuxt>
<v-icon left>mdi-cancel</v-icon>
Close my account
</v-btn>
</div>

<email-dialog :show-dialog="emailDialog" @closed="hideEmailDialog" />
<v-snackbar v-model="emailSaved" class="text-left" color="success" :timeout="5000" rounded bottom>
Please open your inbox and confirm your email address.
Expand Down
12 changes: 6 additions & 6 deletions pages/billing/affiliates.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<v-layout column>
<h1>1 year of PRO</h1>
<h1>2 years of PRO</h1>
<v-container v-if="user.isPro" fluid>
<v-card>
<v-card-text class="text-center text-md-left">
Expand All @@ -16,7 +16,7 @@
</v-container>
<v-container v-else fluid>
<p>
Yes! Want to try Strautomator's PRO features, but not really convinced you should spend money on a yearly subscription yet? You can get the first year for free, by using my referral code to register to one of the affiliated fintech
Yes! Want to try Strautomator's PRO features, but not really convinced you should spend money on a yearly subscription yet? You can get the first 2 years for free, by using a referral code to register to one of my affiliated fintech
services. These are services that I personally use on a daily basis. Here's how it works:
</p>
<ul class="ml-n2">
Expand All @@ -25,15 +25,15 @@
<li>Send me your Strava ID via <a href="mailto:[email protected]" title="Email">email</a></li>
</ul>
<p class="mt-4">Once you have completed the registration and everything is confirmed, your account will be switched to PRO.</p>
<p>After 1 year, if you still wish to keep using PRO features, you'll need to subscribe via PayPal or GitHub.</p>
<p>After 2 years, if you still wish to keep using PRO features, you'll need to subscribe via PayPal or GitHub.</p>

<v-card v-if="revolut" class="mt-5" outlined>
<v-card-title class="accent text-center text-md-left">
<a href="https://links.devv.com/l/revolut" title="Go to Revolut" target="revolut"><img src="https://links.devv.com/images/revolut.png" alt="Revolut" class="mx-auto mx-md-0 card-affiliate-logo color-invert" /></a>
</v-card-title>
<v-card-text>
<div class="mt-3 mb-1">
<p>Revolut is an online bank with more than 30 million customers worldwide. It has all the features and financial services that you could possibly imagine, even on their free account.</p>
<p>Revolut is an online bank with more than 30 million customers worldwide. It has all the features and financial services that you could possibly imagine, from transfers to stocks to crypto to travel eSIM.</p>
<ul class="ml-n2">
<li>Open your Revolut account with my link</li>
<li>Add money to your new account</li>
Expand All @@ -53,7 +53,7 @@
</v-card-title>
<v-card-text>
<div class="mt-3 mb-1">
<p>N26 is an online bank with more than 8 million customers worldwide. The free account offers all the basics, but if you want more features and added insurance, you can opt for one of their paid plans.</p>
<p>N26 is an online bank with more than 9 million customers worldwide. Very similar to Revolut, it also offers many features and added services on top of a regular checking account.</p>
<ul class="ml-n2">
<li>Open your N26 account with my link</li>
<li>Make at least 1 purchase of 10+ EUR</li>
Expand All @@ -71,7 +71,7 @@
</v-card-title>
<v-card-text>
<div class="mt-3 mb-1">
<p>Trade Republic is an online broker with more than 4 million customers in the EU. Commission-free trading for 1 EUR only, and up to 1% savings cashback using their new VISA card.</p>
<p>Trade Republic is an online broker with more than 5 million customers in the EU. Commission-free trading for 1 EUR only, and up to 4% interest and 1% cashback using their VISA card.</p>
<ul class="ml-n2">
<li>Open your account with my link</li>
<li>Trade at least 100+ EUR</li>
Expand Down
4 changes: 2 additions & 2 deletions src/routes/api/garmin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Strautomator API: Garmin

import {garmin, strava, UserData} from "strautomator-core"
import {fitparser, garmin, strava, UserData} from "strautomator-core"
import auth from "../auth"
import express from "express"
import webserver = require("../../webserver")
Expand Down Expand Up @@ -77,7 +77,7 @@ router.post("/:userId/match-activity/:stravaId", async (req: express.Request, re
}

// Fetch processed Garmin activity (if there's one).
const garminActivity = await garmin.activities.getMatchingActivity(user, activity)
const garminActivity = await fitparser.getMatchingActivity(user, "garmin", activity)
if (!garminActivity) {
webserver.renderJson(req, res, {notFound: true})
} else {
Expand Down
24 changes: 12 additions & 12 deletions src/routes/api/spotify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ router.get("/auth/url", async (req: express.Request, res: express.Response) => {
}
})

/**
* Validate authentication and try getting an access token from Spotify.
*/
router.get("/auth/callback", async (req: express.Request, res: express.Response) => {
try {
await spotify.processAuthCode(req)
res.redirect("/account?spotify=linked")
} catch (ex) {
webserver.renderError(req, res, ex)
}
})

/**
* Delete Spotify profile for the user account.
*/
Expand All @@ -39,18 +51,6 @@ router.get("/auth/unlink", async (req: express.Request, res: express.Response) =
}
})

/**
* Validate authentication and try getting an access token from Spotify.
*/
router.get("/auth/callback", async (req: express.Request, res: express.Response) => {
try {
await spotify.processAuthCode(req)
res.redirect("/account?spotify=linked")
} catch (ex) {
webserver.renderError(req, res, ex)
}
})

/**
* Get list of Spotify tracks that played during the specified activity.
*/
Expand Down
14 changes: 11 additions & 3 deletions src/routes/api/strava.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Strautomator API: Strava

import {ai, garmin, maps, strava, users, weather, UserData, StravaAthleteRecords, StravaSport, StravaActivityFilter} from "strautomator-core"
import {ai, fitparser, maps, strava, users, weather, UserData, StravaAthleteRecords, StravaSport, StravaActivityFilter} from "strautomator-core"
import auth from "../auth"
import dayjs from "../../dayjs"
import _ from "lodash"
Expand Down Expand Up @@ -161,15 +161,23 @@ router.get("/:userId/processed-activities", async (req: express.Request, res: ex

const activities = await strava.activityProcessing.getProcessedActivities(user, dateFrom, dateTo, limit)

// If user has a Garmin account linked, append the related Garmin activities as well.
// If user has a Garmin or Wahoo account linked, append the related FIT file activities as well.
if (user.garmin) {
for (let a of activities) {
const garminActivity = await garmin.activities.getMatchingActivity(user, a)
const garminActivity = await fitparser.getMatchingActivity(user, "garmin", a)
if (garminActivity) {
a.garminActivity = garminActivity
}
}
}
if (user.wahoo) {
for (let a of activities) {
const wahooActivity = await fitparser.getMatchingActivity(user, "wahoo", a)
if (wahooActivity) {
a.wahooActivity = wahooActivity
}
}
}

webserver.renderJson(req, res, activities)
} catch (ex) {
Expand Down

0 comments on commit 3e7f14e

Please sign in to comment.