-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move git root. Add Status endpoint to API. Initial web form setup.
- Loading branch information
Showing
13 changed files
with
195 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1 @@ | ||
# package directories | ||
node_modules | ||
jspm_packages | ||
|
||
# Serverless directories | ||
.serverless | ||
|
||
# Environment variables | ||
.env | ||
.idea |
File renamed without changes.
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,9 @@ | ||
# package directories | ||
node_modules | ||
jspm_packages | ||
|
||
# Serverless directories | ||
.serverless | ||
|
||
# Environment variables | ||
.env |
File renamed without changes.
File renamed without changes.
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,28 @@ | ||
'use strict'; | ||
|
||
const response = require('../../helper/response'); | ||
const shotstack = require('./lib/shotstack'); | ||
|
||
module.exports.submit = (event, context, callback) => { | ||
const data = JSON.parse(event.body); | ||
|
||
shotstack.submit(data).then((res) => { | ||
console.log('Success'); | ||
callback(null, response(201, 'success', 'OK', res)); | ||
}).catch(function(res) { | ||
console.log('Fail: ', res); | ||
callback(null, response(400, 'fail', 'Bad Request', res)); | ||
}); | ||
}; | ||
|
||
module.exports.status = (event, context, callback) => { | ||
const id = event.pathParameters.id; | ||
|
||
shotstack.status(id).then((res) => { | ||
console.log('Success'); | ||
callback(null, response(201, 'success', 'OK', res)); | ||
}).catch(function(res) { | ||
console.log('Fail: ', res); | ||
callback(null, response(400, 'fail', 'Bad Request', res)); | ||
}); | ||
}; |
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
File renamed without changes.
This file was deleted.
Oops, something went wrong.
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,50 @@ | ||
$(document).ready(function() { | ||
$('form').submit(function(event) { | ||
|
||
//$('.form-group').removeClass('has-error'); // remove the error class | ||
//$('.help-block').remove(); // remove the error text | ||
|
||
var formData = { | ||
'search': $('#search').val(), | ||
'title': $('#title').val(), | ||
'soundtrack': $('#soundtrack option:selected').val() | ||
}; | ||
|
||
console.log(formData); | ||
|
||
// process the form | ||
$.ajax({ | ||
type: 'POST', | ||
url: 'https://dcsgqlt4gd.execute-api.ap-southeast-2.amazonaws.com/dev/shotstack', | ||
data: JSON.stringify(formData), | ||
dataType: 'json', | ||
crossDomain: true, | ||
contentType: 'application/json' | ||
}) | ||
.done(function(data) { | ||
console.log(data); | ||
if (!data.success) { | ||
if (data.errors.name) { | ||
$('#name-group').addClass('has-error'); // add the error class to show red input | ||
$('#name-group').append('<div class="help-block">' + data.errors.name + '</div>'); // add the actual error message under our input | ||
} | ||
if (data.errors.email) { | ||
$('#email-group').addClass('has-error'); // add the error class to show red input | ||
$('#email-group').append('<div class="help-block">' + data.errors.email + '</div>'); // add the actual error message under our input | ||
} | ||
if (data.errors.superheroAlias) { | ||
$('#superhero-group').addClass('has-error'); // add the error class to show red input | ||
$('#superhero-group').append('<div class="help-block">' + data.errors.superheroAlias + '</div>'); // add the actual error message under our input | ||
} | ||
} else { | ||
$('form').append('<div class="alert alert-success">' + data.message + '</div>'); | ||
} | ||
}) | ||
.fail(function(data) { | ||
console.log(data.responseText); | ||
}); | ||
|
||
event.preventDefault(); | ||
}); | ||
|
||
}); |
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,50 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<!-- Required meta tags --> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | ||
|
||
<!-- Bootstrap CSS --> | ||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous"> | ||
<link rel="stylesheet" href="styles.css"> | ||
|
||
<title>Hello, world!</title> | ||
</head> | ||
<body> | ||
<div class="container content"> | ||
<div class="row"> | ||
<div class="col"> | ||
<form class="jumbotron" method="post"> | ||
<div class="form-group"> | ||
<label for="search" class="display-4">Make a video about</label> | ||
<input name="search" type="text" class="form-control form-control-lg" id="search" placeholder="cats, mountains, waves, people, buildings, sport" required> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<label for="title">Add a Title</label> | ||
<input name="title" type="text" class="form-control" id="title" placeholder="My Movie" required> | ||
</div> | ||
<div class="form-group"> | ||
<label for="soundtrack">Choose a Soundtrack</label> | ||
<select name="soundtrack" id="soundtrack" class="custom-select" required> | ||
<option selected>Choose...</option> | ||
<option value="disco">Disco</option> | ||
<option value="freeflow">Freeflow</option> | ||
<option value="melodic">Melodic</option> | ||
</select> | ||
</div> | ||
<button type="submit" class="btn btn-primary">Create Video</button> | ||
</form> | ||
</div> | ||
<div class="col"> | ||
Video | ||
</div> | ||
</div> | ||
</div> | ||
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script> | ||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script> | ||
<script src="app.js"></script> | ||
</body> | ||
</html> |
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,10 @@ | ||
.content { | ||
margin-top: 2rem; | ||
} | ||
.content .jumbotron { | ||
padding-top: 2rem; | ||
padding-bottom: 2rem; | ||
} | ||
.display-4 { | ||
font-size: 2.5rem; | ||
} |