Skip to content

Commit

Permalink
Merge pull request #21 from joaovitoriasilva/v0.3.2
Browse files Browse the repository at this point in the history
V0.3.2
  • Loading branch information
joaovitoriasilva authored Aug 1, 2024
2 parents 6a4fbc6 + c52896a commit 3e8709b
Show file tree
Hide file tree
Showing 17 changed files with 151 additions and 98 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ Environemnt variable | Default value | Optional | Notes
--- | --- | --- | ---
MY_APP_BACKEND_PROTOCOL | http | Yes | Needs to be https if you want to enable Strava integration. Strava callback relies on this. You may need to update this variable based on docker image spin up (api host or local ip (example: http://192.168.1.10:98))
MY_APP_BACKEND_HOST | localhost:98 | Yes | Needs to be set and be Internet faced/resolved if you want to enable Strava integration. Strava callback relies on this. You may need to update this variable based on docker image spin up (api host or local ip (example: http://192.168.1.10:98))
MY_APP_STRAVA_CLIENT_ID | changeme | Yes | Needs to be set with your Strava API Client ID if you want to enable Strava integration.

Frontend dependencies:
- To check npm dependencies used, use npm file (package.json)
Expand Down
2 changes: 2 additions & 0 deletions backend/app/activities/crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,8 @@ def edit_activity(user_id: int, activity: activities_schema.ActivityEdit, db: Se
db_activity.description = activity.description
if activity.name is not None:
db_activity.name = activity.name
if activity.activity_type is not None:
db_activity.activity_type = activity.activity_type
if activity.visibility is not None:
db_activity.visibility = activity.visibility

Expand Down
3 changes: 2 additions & 1 deletion backend/app/activities/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Activity(BaseModel):
description: str | None = None
distance: int
name: str
activity_type: str
activity_type: int
start_time: str
end_time: str
city: str | None = None
Expand Down Expand Up @@ -39,4 +39,5 @@ class ActivityEdit(BaseModel):
id: int
description: str | None = None
name: str
activity_type: int
visibility: int | None = None
5 changes: 3 additions & 2 deletions backend/app/activities/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,9 @@ def define_activity_type(activity_type):
"virtual_ride": 7,
"Swim": 8,
"swimming": 8,
"open_water_swimming": 8,
"Walk": 9,
"open_water_swimming": 9,
"Walk": 11,
"Hike": 12,
}
# "AlpineSki",
# "BackcountrySki",
Expand Down
2 changes: 1 addition & 1 deletion backend/app/config.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Constant related to version
API_VERSION = "v0.3.1"
API_VERSION = "v0.3.2"
9 changes: 6 additions & 3 deletions backend/app/strava/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@ def refresh_strava_tokens(db: Session):

# Check if user_integrations strava token is not None
if user_integrations.strava_token is not None:
refresh_time = user_integrations.strava_token_expires_at - timedelta(
minutes=60
)
# refresh_time = user_integrations.strava_token_expires_at - timedelta(
# minutes=60
# )
refresh_time = user_integrations.strava_token_expires_at.replace(
tzinfo=timezone.utc
) - timedelta(minutes=60)

if datetime.now(timezone.utc) > refresh_time:
# Strava token refresh endpoint
Expand Down
9 changes: 5 additions & 4 deletions docker-compose.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ services:
frontend:
container_name: frontend
image: ghcr.io/joaovitoriasilva/endurain/frontend:latest
#environment:
#- MY_APP_BACKEND_PROTOCOL=http # http or https, default is http
#- MY_APP_BACKEND_HOST=localhost:98 # api host or local ip (example: 192.168.1.10:98), default is localhost:98
environment:
- MY_APP_BACKEND_PROTOCOL=http # http or https, default is http
- MY_APP_BACKEND_HOST=localhost:98 # api host or local ip (example: 192.168.1.10:98), default is localhost:98
- MY_APP_STRAVA_CLIENT_ID=changeme
# Configure volume if you want to edit the code locally by clomming the repo
#volumes:
# - <local_path>/endurain/frontend/app:/app
Expand All @@ -25,7 +26,7 @@ services:
- STRAVA_AUTH_CODE=changeme
- GEOCODES_MAPS_API=changeme
- FRONTEND_PROTOCOL=http # default is http
- FRONTEND_HOST=frontend:8080 # frontend host or local ip (example: 192.168.1.10:8080), default is localhost:8080
- FRONTEND_HOST=localhost:8080 # frontend host or local ip (example: 192.168.1.10:8080), default is localhost:8080
ports:
- "98:80" # API port, change per your needs
volumes:
Expand Down
1 change: 1 addition & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ EXPOSE 80

ENV VITE_BACKEND_PROTOCOL=http
ENV VITE_BACKEND_HOST=localhost:98
ENV VITE_STRAVA_CLIENT_ID=changeme

CMD ["nginx", "-g", "daemon off;"]
3 changes: 2 additions & 1 deletion frontend/app/.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
VITE_BACKEND_PROTOCOL=MY_APP_BACKEND_PROTOCOL
VITE_BACKEND_HOST=MY_APP_BACKEND_HOST
VITE_BACKEND_HOST=MY_APP_BACKEND_HOST
VITE_STRAVA_CLIENT_ID=MY_APP_STRAVA_CLIENT_ID
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@
<span v-else-if="activity.activity_type == 8 || activity.activity_type == 9">
<font-awesome-icon :icon="['fas', 'fa-person-swimming']" />
</span>
<span v-else-if="activity.activity_type == 11">
<font-awesome-icon :icon="['fas', 'person-walking']" />
</span>
<span v-else-if="activity.activity_type == 12">
<font-awesome-icon :icon="['fas', 'person-hiking']" />
</span>
<span v-else>
<font-awesome-icon :icon="['fas', 'fa-dumbbell']" />
</span>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,48 @@
<template>
<!-- Modal edit activity -->
<div class="modal fade" id="editActivityModal" tabindex="-1" aria-labelledby="editActivityModal" aria-hidden="true">
<div class="modal fade" id="editActivityModal" tabindex="-1" aria-labelledby="editActivityModalComponent" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="editActivityModal">{{ $t("editActivityModal.modalEditActivityTitle") }}</h1>
<h1 class="modal-title fs-5" id="editActivityModal">{{ $t("editActivityModalComponent.modalEditActivityTitle") }}</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<form @submit.prevent="submitEditActivityForm">
<div class="modal-body">
<!-- name fields -->
<label for="activityNameEdit"><b>* {{ $t("editActivityModal.modalEditActivityNameLabel") }}</b></label>
<input class="form-control" type="text" name="activityNameEdit" :placeholder='$t("editActivityModal.modalEditActivityNamePlaceholder")' maxlength="45" v-model="editActivityName" required>
<label for="activityNameEdit"><b>* {{ $t("editActivityModalComponent.modalEditActivityNameLabel") }}</b></label>
<input class="form-control" type="text" name="activityNameEdit" :placeholder='$t("editActivityModalComponent.modalEditActivityNamePlaceholder")' maxlength="45" v-model="editActivityName" required>
<!-- description fields -->
<label for="activityDescriptionEdit"><b>{{ $t("editActivityModal.modalEditActivityDescriptionLabel") }}</b></label>
<input class="form-control" type="text" name="activityDescriptionEdit" :placeholder='$t("editActivityModal.modalEditActivityDescriptionPlaceholder")' maxlength="2500" v-model="editActivityDescription">
<label for="activityDescriptionEdit"><b>{{ $t("editActivityModalComponent.modalEditActivityDescriptionLabel") }}</b></label>
<input class="form-control" type="text" name="activityDescriptionEdit" :placeholder='$t("editActivityModalComponent.modalEditActivityDescriptionPlaceholder")' maxlength="2500" v-model="editActivityDescription">
<!-- type fields -->
<label for="activityTypeEdit"><b>* {{ $t("editActivityModalComponent.modalEditActivityTypeLabel") }}</b></label>
<select class="form-control" name="activityTypeEdit" v-model="editActivityType" required>
<option value="1">{{ $t("editActivityModalComponent.modalEditActivityTypeOption1") }}</option>
<option value="2">{{ $t("editActivityModalComponent.modalEditActivityTypeOption2") }}</option>
<option value="3">{{ $t("editActivityModalComponent.modalEditActivityTypeOption3") }}</option>
<option value="4">{{ $t("editActivityModalComponent.modalEditActivityTypeOption4") }}</option>
<option value="5">{{ $t("editActivityModalComponent.modalEditActivityTypeOption5") }}</option>
<option value="6">{{ $t("editActivityModalComponent.modalEditActivityTypeOption6") }}</option>
<option value="7">{{ $t("editActivityModalComponent.modalEditActivityTypeOption7") }}</option>
<option value="8">{{ $t("editActivityModalComponent.modalEditActivityTypeOption8") }}</option>
<option value="9">{{ $t("editActivityModalComponent.modalEditActivityTypeOption9") }}</option>
<option value="10">{{ $t("editActivityModalComponent.modalEditActivityTypeOption10") }}</option>
<option value="11">{{ $t("editActivityModalComponent.modalEditActivityTypeOption11") }}</option>
<option value="12">{{ $t("editActivityModalComponent.modalEditActivityTypeOption12") }}</option>
</select>
<!-- visibility fields -->
<label for="activityVisibilityEdit"><b>* {{ $t("editActivityModal.modalEditActivityVisibilityPlaceholder") }}</b></label>
<label for="activityVisibilityEdit"><b>* {{ $t("editActivityModalComponent.modalEditActivityVisibilityLabel") }}</b></label>
<select class="form-control" name="activityVisibilityEdit" v-model="editActivityVisibility" required>
<option value="0">{{ $t("editActivityModal.modalEditActivityVisibilityOption0") }}</option>
<option value="1">{{ $t("editActivityModal.modalEditActivityVisibilityOption1") }}</option>
<option value="2">{{ $t("editActivityModal.modalEditActivityVisibilityOption2") }}</option>
<option value="0">{{ $t("editActivityModalComponent.modalEditActivityVisibilityOption0") }}</option>
<option value="1">{{ $t("editActivityModalComponent.modalEditActivityVisibilityOption1") }}</option>
<option value="2">{{ $t("editActivityModalComponent.modalEditActivityVisibilityOption2") }}</option>
</select>
<p>* {{ $t("generalItens.requiredField") }}</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">{{ $t("generalItens.buttonClose") }}</button>
<button type="submit" class="btn btn-success" data-bs-dismiss="modal">{{ $t("editActivityModal.modalEditActivityTitle") }}</button>
<button type="submit" class="btn btn-success" data-bs-dismiss="modal">{{ $t("editActivityModalComponent.modalEditActivityTitle") }}</button>
</div>
</form>
</div>
Expand All @@ -36,6 +52,7 @@

<script>
import { ref } from 'vue';
import { useI18n } from 'vue-i18n';
// Importing the utils
import { addToast } from '@/utils/toastUtils';
Expand All @@ -53,8 +70,10 @@ export default {
},
},
setup(props) {
const { t } = useI18n();
const editActivityDescription = ref(props.activity.description);
const editActivityName = ref(props.activity.name);
const editActivityType = ref(props.activity.activity_type);
const editActivityVisibility = ref(props.activity.visibility);
async function submitEditActivityForm() {
Expand All @@ -63,6 +82,7 @@ export default {
id: props.activity.id,
name: editActivityName.value,
description: editActivityDescription.value,
activity_type: editActivityType.value,
visibility: editActivityVisibility.value,
};
Expand All @@ -72,19 +92,21 @@ export default {
// Set activity new values
props.activity.name = editActivityName.value;
props.activity.description = editActivityDescription.value;
props.activity.activity_type = editActivityType.value;
props.activity.visibility = editActivityVisibility.value;
// show success toast
addToast(t('gear.successGearEdited'), 'success', true);
addToast(t('editActivityModalComponent.successActivityEdit'), 'success', true);
} catch (error) {
// If there is an error, set the error message and show the error alert.
addToast(t('generalItens.errorEditingInfo') + " - " + error.toString(), 'danger', true);
addToast(t('editActivityModalComponent.errorActivityEdit') + " - " + error.toString(), 'danger', true);
}
}
return {
editActivityDescription,
editActivityName,
editActivityType,
editActivityVisibility,
submitEditActivityForm,
};
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/src/components/FooterComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
</form>
</div>
<div class="mt-3 col">
<p class="text-center text-muted">&copy; {{ new Date().getFullYear() === 2023 ? '2023' : '2023 - ' + new Date().getFullYear() }} Endurain • <a class="link-body-emphasis" href="https://github.com/joaovitoriasilva/endurain" role="button"><font-awesome-icon :icon="['fab', 'fa-github']" /></a> • <a class="link-body-emphasis" href="https://fosstodon.org/@endurain"><font-awesome-icon :icon="['fab', 'fa-mastodon']" /></a> • v0.3.1</p>
<p class="text-center text-muted">&copy; {{ new Date().getFullYear() === 2023 ? '2023' : '2023 - ' + new Date().getFullYear() }} Endurain • <a class="link-body-emphasis" href="https://github.com/joaovitoriasilva/endurain" role="button"><font-awesome-icon :icon="['fab', 'fa-github']" /></a> • <a class="link-body-emphasis" href="https://fosstodon.org/@endurain"><font-awesome-icon :icon="['fab', 'fa-mastodon']" /></a> • v0.3.2</p>
<p class="text-center text-muted"><img src="/src/assets/strava/api_logo_cptblWith_strava_horiz_light.png" alt="Compatible with STRAVA image" height="25" /></p>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,23 @@
"modalEditActivityDescriptionPlaceholder": "Description (max 2500 characters)",
"modalEditActivityNameLabel": "Name",
"modalEditActivityNamePlaceholder": "Name (max 250 characters)",
"modalEditActivityTypeLabel": "Type",
"modalEditActivityTypeOption1": "Run",
"modalEditActivityTypeOption2": "Trail run",
"modalEditActivityTypeOption3": "Virtual run",
"modalEditActivityTypeOption4": "Ride",
"modalEditActivityTypeOption5": "Gravel ride",
"modalEditActivityTypeOption6": "Mountain bike ride",
"modalEditActivityTypeOption7": "Virtual ride",
"modalEditActivityTypeOption8": "Swim",
"modalEditActivityTypeOption9": "Open water swim",
"modalEditActivityTypeOption10": "Workout",
"modalEditActivityTypeOption11": "Walk",
"modalEditActivityTypeOption12": "Hike",
"modalEditActivityVisibilityLabel": "Visibility",
"modalEditActivityVisibilityPlaceholder": "Visibility",
"modalEditActivityVisibilityOption0": "Public",
"modalEditActivityVisibilityOption1": "Followers",
"modalEditActivityVisibilityOption2": "Private"
"modalEditActivityVisibilityOption2": "Private",
"successActivityEdit": "Activity edited successfully",
"errorActivityEdit": "Error editing activity"
}
6 changes: 3 additions & 3 deletions frontend/app/src/i18n/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const messages = {
footer: enFooterComponent,
userDistanceStats: enUserDistanceStatsComponent,
activitySummary: enActivitySummaryComponent,
editActivityModal: enEditActivityModalComponent,
editActivityModalComponent: enEditActivityModalComponent,
followersListComponent: enFollowersListComponent,
settingsSideBar: enSettingsSideBarComponent,
settingsUsersZone: enSettingsUsersZoneComponent,
Expand All @@ -53,8 +53,8 @@ const messages = {
generalItens: enGeneralItens,
homeView: enHomeView,
loginView: enLoginView,
gears: enGearsView,
gear: enGearView,
gearsView: enGearsView,
gearView: enGearView,
activity: enActivityView,
notFound: enNotFoundView,
userView: enUserView,
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/src/services/stravaService.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const strava = {
return fetchPutRequest(`strava/unset-user-unique-state`)
},
linkStrava(state) {
const stravaClientId = '115321';
const stravaClientId = `${import.meta.env.VITE_STRAVA_CLIENT_ID}`;
let redirectUri = `${import.meta.env.VITE_BACKEND_PROTOCOL}://${import.meta.env.VITE_BACKEND_HOST}`;
redirectUri = encodeURIComponent(redirectUri);
const scope = 'read,read_all,profile:read_all,activity:read,activity:read_all';
Expand Down
Loading

0 comments on commit 3e8709b

Please sign in to comment.