Skip to content

Commit

Permalink
Implement Read more and Follow buttons in journey page
Browse files Browse the repository at this point in the history
  • Loading branch information
panispani committed Jun 15, 2017
1 parent 4b18084 commit 0a87376
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
4 changes: 2 additions & 2 deletions aurelia-app/src/components/journey/journey.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
<h6 class="category text-gray">Software Architect</h6>
<h2 class="card-title">${owner.name} ${owner.surname} | ${name}</h2>
<p class="card-content journey-description">${shortDescription}</p>
<a class="btn btn-primary btn-round" href="#pablo">Follow</a>
<a class="btn btn-round" href="#pablo">Read more</a>
<div class="btn btn-primary btn-round" click.delegate="follow()">Follow</div>
<div class="btn btn-round" click.delegate="gotoProfile()">Read more</div>
</div>
</div>
</div>
Expand Down
24 changes: 22 additions & 2 deletions aurelia-app/src/components/journey/journey.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,24 @@ import { CaloriesAnalyticsService } from 'services/caloriesAnalytics'
import { HeartRateAnalyticsService } from 'services/heartRateAnalytics'
import io from 'socket.io'
import { Router } from 'aurelia-router';
import {AuthService} from 'aurelia-authentication';
import {Login} from "../login/login";
import {Config} from "aurelia-api";


var socket = io.connect();

export class Journey {

static inject = [RestApi, WeatherApi, EventAggregator, Router]
static inject = [RestApi, WeatherApi, EventAggregator, Router, AuthService, Login, Config]

constructor(api, weatherApi, eventAggregator, router) {
constructor(api, weatherApi, eventAggregator, router, authService, login, config) {
Object.assign(this, { api, weatherApi, eventAggregator, router })

this.authService = authService
this.login = login
this.apiEndpoint = config.getEndpoint('api')

this.heartRateOptions = ['Week', 'Live', 'All']
this.heartRateSelection = this.heartRateOptions[0]

Expand Down Expand Up @@ -135,6 +143,18 @@ export class Journey {
}
}

follow() {
if (!this.authService.authenticated) {
this.login.authenticate('facebook')
if (!this.authService.authenticated) {
return
}
}
return this.authService.getMe().then(
profile => this.apiEndpoint.post(`/users/${profile.id}/followers`, { "id": this.owner.id })
)
}

setup_twitter_feed = function() {
!function (d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0],
Expand Down

0 comments on commit 0a87376

Please sign in to comment.