Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
OndrejSpanel committed Sep 2, 2017
2 parents a285ad6 + 07c2135 commit 6141ccf
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 36 deletions.
69 changes: 45 additions & 24 deletions src/main/scala/com/github/opengrabeso/stravamat/DefineRequest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,33 @@ abstract class DefineRequest(val handleUri: String, val method: Method = Method.
def bodyHeader(auth: Main.StravaAuthResult): NodeSeq = {
<div id="header" style="background-color:#fca;overflow:auto">
<table>
<tr><td>
Athlete:
<a href={s"https://www.strava.com/athletes/${auth.id}"}>
{auth.name}
</a>
</td>
<td>
<form action={"logout"}>
<input type="submit" value ="Log Out"/>
</form>
</td></tr>
<tr>
<td>
<a href="/"><img src="static/stravaUpload32.png"></img></a>
</td>
<td>
<table>
<tr>
<td>
<a href="/">Stravamat</a>
</td>
</tr>
<tr>
<td>
Athlete:
<a href={s"https://www.strava.com/athletes/${auth.id}"}>
{auth.name}
</a>
</td>
</tr>
</table>
</td>
<td>
<form action={"logout"}>
<input type="submit" value ="Log Out"/>
</form>
</td>
</tr>
</table>
</div>
<p></p>
Expand All @@ -79,7 +95,7 @@ abstract class DefineRequest(val handleUri: String, val method: Method = Method.
<a href="http://labs.strava.com/" id="powered_by_strava" rel="nofollow">
<img align="left" src="static/api_logo_pwrdBy_strava_horiz_white.png" style="max-height:46px"/>
</a>
<p style="color:#fff"2016 <a href="https://github.com/OndrejSpanel" style="color:inherit">Ondřej Španěl</a></p>
<p style="color:#fff"2016 - 2017 <a href="https://github.com/OndrejSpanel/Stravamat" style="color:inherit">Ondřej Španěl</a></p>
<div/>
</div>
}
Expand Down Expand Up @@ -125,6 +141,8 @@ abstract class DefineRequest(val handleUri: String, val method: Method = Method.
}
}

def showSuuntoUploadInstructions = true

def loginPage(request: Request, resp: Response, afterLogin: String, afterLoginParams: Option[String]): NodeSeq = {
resp.cookie("authCode", "", 0) // delete the cookie
<html>
Expand All @@ -142,18 +160,21 @@ abstract class DefineRequest(val handleUri: String, val method: Method = Method.
<h3>Work in progress, use at your own risk.</h3>
<p>
Automated uploading and processing of Suunto data to Strava
</p>


<h4>Suunto Upload</h4>
<p>
If you want to upload Suunto files, start the Stravamat Start application
which will open a new web page with the upload progress.
</p>
<p>
The application can be downloaded from <a href="https://github.com/OndrejSpanel/Stravamat/releases">GitHub Stravamat Releases page</a>.
</p>

</p> ++
{
if (showSuuntoUploadInstructions) {
<h4>Suunto Upload</h4>
<p>
If you want to upload Suunto files, start the Stravamat Start application
which will open a new web page with the upload progress.
</p>
<p>
The application can be downloaded from
<a href="https://github.com/OndrejSpanel/Stravamat/releases">GitHub Stravamat Releases page</a>
.
</p>
} else NodeSeq.Empty
} ++
<h4>Working</h4>
<ul>
<li>Merges Quest and GPS Track Pod data</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,34 +166,43 @@ trait ActivityRequestHandler {
}

function initEvents() {
//console.log("initEvents " + events.toString());
events.forEach(function(e){
if (e[0].lastIndexOf("split",0) == 0) {
addEvent(e);
} else {
removeEvent(e[1])
}
selectOption(e);
});
}

function selectOption(e) {
//console.log("selectOption " + e[1]);
var tableOption = document.getElementById(e[1]);
// select appropriate option
tableOption.value = e[0];

// we need to update the table source, because it is used to create map popups
// http://stackoverflow.com/a/40766724/16673
var opts = tableOption.getElementsByTagName('option');
for (var i = 0; i < opts.length; i++)
opts[i].removeAttribute('selected');
var checked = tableOption.querySelector('option:checked');
checked.setAttribute('selected', 'selected');
if (tableOption) {
// select appropriate option
tableOption.value = e[0];

// we need to update the table source, because it is used to create map popups
// http://stackoverflow.com/a/40766724/16673
var opts = tableOption.getElementsByTagName('option');
for (var i = 0; i < opts.length; i++)
opts[i].removeAttribute('selected');
var checked = tableOption.querySelector('option:checked');
checked.setAttribute('selected', 'selected');
}
}

function addEvent(e) {
//console.log("Add event " + e[1]);
var tableLink = document.getElementById("link" + e[1]);
tableLink.innerHTML = splitLink(id, e);
}

/** @param {String} time */
function removeEvent(time) {
//console.log("Remove event " + time);
var tableLink = document.getElementById("link" + time);
tableLink.innerHTML = "";
}
Expand All @@ -204,6 +213,7 @@ trait ActivityRequestHandler {
* @param {String} itemTime
* */
function changeEvent(item, newValue, itemTime) {
//console.log("changeEvent", item, newValue, itemTime)
events.forEach(function(e) {
if (e[1] == itemTime) {
e[0] = newValue;
Expand All @@ -215,7 +225,7 @@ trait ActivityRequestHandler {
if (e[1] == itemTime && e[0].lastIndexOf("split", 0) === 0){
addEvent(e);
} else {
removeEvent(itemTime);
removeEvent(e[1])
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ abstract class SelectActivity(name: String) extends DefineRequest(name) {
// once any activity is present on Strava, do not offer upload by default any more
// (if some earlier is not present, it was probably already uploaded and deleted)
<tr>
<td>{jsResult(jsDateRange(act.startTime, act.endTime))}</td>
<td>
{
val detected = Main.detectSportBySpeed(actEvents.stats, act.sportName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ object Upload extends DefineRequest.Post("/upload") {
Timing.logTime("Import file")
if (actData.nonEmpty) {
for (act <- actData) {
val actOpt = act // .optimize
val actOpt = act.cleanPositionErrors // .optimize
Storage.store(Main.namespace.stage, act.id.id.filename, userId, actOpt.header, actOpt, "digest" -> digest)
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package push
import spark.{Request, Response}

object PushDo extends DefineRequest("/push-do") with ChangeSettings {
override def showSuuntoUploadInstructions = false // no need to show this, user already launched it
def html(req: Request, resp: Response) = {

withAuth(req, resp) { auth =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import org.joda.time.{DateTime => ZonedDateTime}
import shared.Util._

object PushStart extends DefineRequest("/push-start") {
override def showSuuntoUploadInstructions = false // no need to show this, user already launched it

def storedQueryParam(req: Request, prefix: String, name: String): String = {
val session = req.session()
Expand Down
Binary file added web/static/stravaUpload32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added work/stravaUpload32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6141ccf

Please sign in to comment.