Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ export default class Leaderboard extends MetaView {
* by the default shows 10 items, can be changed via itemsToShow prop
*
* @access public
* @returns {LeaderboardItem[]}
* @returns {LeaderboardEntryDTO[]}
*/
get splicedItems() {
get splicedItems(): LeaderboardEntryDTO[] {
if (
this.leaderboardItems &&
this.itemsToShow < this.leaderboardItems.length
Expand All @@ -152,18 +152,27 @@ export default class Leaderboard extends MetaView {
}

/**
* @todo missing method documentation
* Method to handle onTabChange event.
*
* @access public
* @async
* @param {LeaderboardTab} data
* @returns {Promise<void>}
*/
async onTabChange(data: LeaderboardTab) {
async onTabChange(data: LeaderboardTab): Promise<void> {
await this.$store.dispatch("leaderboard/fetchLeaderboard", {
periodFormat: data.value,
});
}

/**
* @todo missing method documentation
* Method to handle mounted event.
*
* @access public
* @async
* @returns {Promise<void>}
*/
public async mounted() {
public async mounted(): Promise<void> {
await this.$store.dispatch("leaderboard/fetchLeaderboard", {
periodFormat: this.leaderBoardTabs[0].value,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ import { LeaderboardEntryDTO } from "@/models/LeaderboardDTO";
import "./LeaderboardRow.scss";

/**
* @todo missing component documentation
*
* @class LeaderboardRow
* @description This class implements a Vue component to display
* a leaderboard row, taking data from the provided {@link LeaderboardEntryDTO}
* instance.
* <br /><br />
* @example Using the LeaderboardRow component
* ```html
* <LeaderboardRow :data="yourData">
Expand Down
79 changes: 68 additions & 11 deletions runtime/dapp-frontend-vue/src/components/Stats/Stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,31 @@ export default class Stats extends MetaView {
public appConfig!: ConfigDTO;

/**
* @todo missing property documentation
* @todo this could also be a Prop assigned by parent
* Property that indicates the number of referral steps that this
* component displays.
* Defaulted to 5.
*
* @access protected
* @var {number}
*/
protected numReferralSteps: number = 5;

/**
* Property to indicate whether statistics data has already
* been requested.
* Defaulted to false.
*
* @access private
* @var {boolean}
*/
private hasRequested: boolean = false;

/**
* @todo missing method documentation
* Getter method to return this component's statistics data.
* Returns undefined if statistics data doesn't exist.
*
* @access public
* @returns {UserDataAggregateDTO | undefined}
*/
public get statisticsData(): UserDataAggregateDTO | undefined {
if (
Expand All @@ -112,7 +125,10 @@ export default class Stats extends MetaView {
}

/**
* @todo missing method documentation
* Getter method to return the total amount earned by this user.
*
* @access public
* @returns {number}
*/
public get totalEarned(): number {
if (!this.hasRequested || undefined === this.statisticsData) {
Expand All @@ -125,7 +141,11 @@ export default class Stats extends MetaView {
}

/**
* @todo missing method documentation
* Getter method to return the total practice (exercise) minutes
* of this user.
*
* @access public
* @returns {number}
*/
public get totalPracticedMinutes(): number {
if (!this.hasRequested || undefined === this.statisticsData) {
Expand All @@ -136,7 +156,11 @@ export default class Stats extends MetaView {
}

/**
* @todo missing method documentation
* Getter method to return the total number of refferals
* the user made.
*
* @access public
* @returns {number}
*/
public get totalReferral(): number {
if (!this.hasRequested || undefined === this.statisticsData) {
Expand All @@ -147,7 +171,11 @@ export default class Stats extends MetaView {
}

/**
* @todo missing method documentation
* Getter method to return the current level of referrals
* the user has.
*
* @access public
* @returns {number}
*/
public get levelReferral(): number {
if (
Expand All @@ -170,6 +198,13 @@ export default class Stats extends MetaView {
return 0;
}

/**
* Getter method to return the remaining refferals the user
* need to make the next referral level.
*
* @access public
* @returns {number}
*/
public get remainingReferralsToNextLevel(): number {
if (!this.hasRequested || undefined === this.statisticsData) {
return 10;
Expand All @@ -180,6 +215,12 @@ export default class Stats extends MetaView {
return level.minReferred - this.totalReferral;
}

/**
* Getter method to return the percentage of the next level.
*
* @access public
* @returns {number}
*/
public get nextLevelPercentage(): number {
if (this.levelReferral === 0) {
return 5;
Expand All @@ -192,6 +233,13 @@ export default class Stats extends MetaView {
return 5;
}

/**
* Getter method to return the top activities that the user
* has participated in.
*
* @access public
* @returns {string[]}
*/
public get topActivities(): string[] {
if (!this.hasRequested || undefined === this.statisticsData) {
return ["Ride", "Swim"];
Expand All @@ -201,9 +249,14 @@ export default class Stats extends MetaView {
}

/**
* @todo missing method documentation
* Getter method to return the total earned amount in a four
* digits format amount. The result is an array of 2 strings,
* indicating the whole amount, and the fractional part.
*
* @access public
* @returns {[string, string]}
*/
public get fourDigitsAmount() {
public get fourDigitsAmount(): [string, string] {
const withFourDecs = `${this.totalEarned.toFixed(4)}`;
const firstDigit = withFourDecs.slice(0, -4);
const secondDigit = withFourDecs.slice(-4);
Expand All @@ -212,9 +265,13 @@ export default class Stats extends MetaView {
}

/**
* @todo missing method documentation
* Method to handle `mounted` event of this component.
*
* @access public
* @async
* @returns {Promise<void>}
*/
public async mounted() {
public async mounted(): Promise<void> {
if (undefined !== this.currentUserAddress) {
await this.$store.dispatch(
"statistics/fetchStatistics",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ export default class TopActivities extends MetaView {
public userStatistics!: UserStatisticsDTO;

/**
* @todo missing method documentation
* Getter method to return this user's statistics data.
*
* @access public
* @returns {UserDataAggregateDTO | undefined}
*/
public get statisticsData(): UserDataAggregateDTO | undefined {
if (!this.userStatistics || !this.userStatistics.data) {
Expand All @@ -83,7 +86,11 @@ export default class TopActivities extends MetaView {
}

/**
* @todo missing method documentation
* Getter method to return all statistic entry items
* of the current statistics data.
*
* @access public
* @returns {string[]}
*/
public get fetchedItems(): string[] {
if (this.items && this.items.length) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ export default class UserBalance extends MetaView {
public userStatistics!: UserStatisticsDTO;

/**
* @todo missing method documentation
* This method checks whether user statistics contains an amount
* and returns the formatted result.
* Returns 0 if amount doesn't exists.
*
* @access public
* @returns {number}
*/
public get userBalance(): number {
if (undefined === this.userStatistics) {
Expand Down
19 changes: 18 additions & 1 deletion runtime/dapp-frontend-vue/src/services/AuthService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,24 @@ import { HttpRequestHandler } from "@/kernel/remote/HttpRequestHandler";
import { User } from "@/models/User";

/**
* @todo missing interface documentation
* @interface AccessTokenDTO
* @description This interface defines the fields that are returned
* by the backend runtime using the `/auth/token` endpoint.
* <br /><br />
* @example Using the `AccessTokenDTO` interface
* ```typescript
* const accessTokenDTO = {
* accessToken: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI3MDk4M2Q2OTJmNjQ4MTg1ZmViZTZkNmZhNjA3NjMwYWU2ODY0OWY3ZTZmYzQ1Yjk0NjgwMDk2YzA2ZTVmYWI3IiwiYWRkcmVzcyI6Ik5CUFFMRktGSkNHSEZTQTJMTlBIVFJaV0dBU0xRQVlXSFdSVlNKQSIsImlhdCI6MTY3NDIwNzgxNywiZXhwIjoxNjc0MjExNDE3fQ.eLn_v_4Ivw97uWQVltSg9NhJfHw9RcP_fmombr6cuQI",
* refreshToken: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI3MDk4M2Q2OTJmNjQ4MTg1ZmViZTZkNmZhNjA3NjMwYWU2ODY0OWY3ZTZmYzQ1Yjk0NjgwMDk2YzA2ZTVmYWI3IiwiYWRkcmVzcyI6Ik5CUFFMRktGSkNHSEZTQTJMTlBIVFJaV0dBU0xRQVlXSFdSVlNKQSIsImlhdCI6MTY3NDIwNzgxNywiZXhwIjoxNzA1NzY1NDE3fQ.7FElWwuRGxJFpeCPDBgPpXefsdp7hkiEqTwYHv-EiuQ"
* }
* ```
* <br /><br />
* #### Properties
*
* @param {string} accessToken Contains the access token from the authentication.
* @param {string} refreshToken Contains the refresh token from the authentication.
*
* @since v0.5.0
*/
export interface AccessTokenDTO {
accessToken: string;
Expand Down
Loading