-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#500] Web: Stub out trails front end by crudely copy-pasting submit.
- Loading branch information
Showing
6 changed files
with
82 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import * as React from "react"; | ||
import { Link } from "react-router-dom"; | ||
|
||
import { myGlobals } from "../globals"; | ||
|
||
import { AuthState } from "../auth"; | ||
|
||
export interface QueryProps { | ||
authState: AuthState; | ||
} | ||
|
||
export function SubmitTrail(props: QueryProps) { | ||
const trailEntry = [ | ||
{ | ||
"version": 1, | ||
"timestamp": "2016-07-22T00:00:00Z", | ||
"org": "000000", | ||
"event_id": "00000000-0000-0000-0000-000000000000", | ||
"previous_signatures": [] as string[], | ||
"signature": "todo" | ||
}]; | ||
|
||
const submitTrail = () => { | ||
|
||
return fetch(myGlobals.trailsUrl + '/trail', { | ||
method: 'POST', | ||
body: JSON.stringify(trailEntry), | ||
headers: { | ||
'Accept': 'application/json', | ||
'Content-Type': 'application/json', | ||
'Authorization': 'Bearer ' + props.authState.getToken().idToken, | ||
}, | ||
}).then(function(res: Response) { | ||
if (res.status === 200) { | ||
alert('Success!'); | ||
window.location.href = 'submit'; | ||
} else { | ||
alert('Failed with status: ' + res.status); | ||
} | ||
}).catch(function(err) { | ||
console.log(err); | ||
}); | ||
}; | ||
|
||
return ( | ||
<section> | ||
<div className="border-bottom"> | ||
<div className="container"> | ||
<h3><Link to="/"><i className="fa fa-chevron-left"></i> </Link></h3> | ||
</div> | ||
</div> | ||
<div className="border-bottom pad-tb"> | ||
<div className="container"> | ||
<h3>New Trail Entry</h3> | ||
<div className="row"> | ||
<div className="column border-right"> | ||
<button onClick={submitTrail}>Submit Trail Entry</button> | ||
</div> | ||
<div className="column"> | ||
<label>Raw Trail Entry</label> | ||
<textarea style={({ height: "20em" })} value={JSON.stringify(trailEntry, null, 2)} readOnly></textarea> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</section> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
declare const OR_SERVICE_URL: string; | ||
|
||
export const orUrl: string = OR_SERVICE_URL; | ||
|
||
declare const TRAILS_SERVICE_URL: string; | ||
export const trailsUrl: string = TRAILS_SERVICE_URL; | ||
|
||
declare const GOOGLE_MAPS_API_KEY: string; | ||
export const googleMapsApiKey: string = GOOGLE_MAPS_API_KEY; | ||
|
||
export const myGlobals = { | ||
edapiUrl: 'http://localhost:8020' as string, | ||
orUrl: OR_SERVICE_URL as string, | ||
trailsUrl : TRAILS_SERVICE_URL as string, | ||
googleMapsApiKey: GOOGLE_MAPS_API_KEY as string, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters