Started working on the client-side code.
This commit is contained in:
parent
0642c18a6e
commit
afca12ecc9
Binary file not shown.
Binary file not shown.
@ -62,20 +62,20 @@ dispatch_user(YArg, Session, [H]) ->
|
|||||||
{'GET', Username} -> get_user(YArg, Username);
|
{'GET', Username} -> get_user(YArg, Username);
|
||||||
|
|
||||||
{_BadMethod, Username} ->
|
{_BadMethod, Username} ->
|
||||||
make_json_405(YArg, [{see_docs, "/ts_api_doc/users"}]);
|
make_json_405(YArg, [{see_docs, "/ts_api_doc/users.html"}]);
|
||||||
|
|
||||||
_Other -> make_json_401(YArg, [{see_docs, "/ts_api_doc/users"}])
|
_Other -> make_json_401(YArg, [{see_docs, "/ts_api_doc/users.html"}])
|
||||||
end.
|
end.
|
||||||
|
|
||||||
dispatch_timeline(YArg, _Session, []) ->
|
dispatch_timeline(YArg, _Session, []) ->
|
||||||
make_json_404(YArg, [{see_docs, "/ts_api_doc/timelines"}]);
|
make_json_404(YArg, [{see_docs, "/ts_api_doc/timelines.html"}]);
|
||||||
|
|
||||||
dispatch_timeline(YArg, Session, [UrlUsername|_T] = PathElements) ->
|
dispatch_timeline(YArg, Session, [UrlUsername|_T] = PathElements) ->
|
||||||
Username = path_element_to_atom(UrlUsername),
|
Username = path_element_to_atom(UrlUsername),
|
||||||
|
|
||||||
case Session#ts_api_session.username of
|
case Session#ts_api_session.username of
|
||||||
Username -> dispatch_timeline(YArg, PathElements);
|
Username -> dispatch_timeline(YArg, PathElements);
|
||||||
_Other -> make_json_404(YArg, [{see_docs, "/ts_api_doc/users"}])
|
_Other -> make_json_404(YArg, [{see_docs, "/ts_api_doc/users.html"}])
|
||||||
end.
|
end.
|
||||||
|
|
||||||
% just username, list timelines
|
% just username, list timelines
|
||||||
@ -85,7 +85,7 @@ dispatch_timeline(YArg, [UrlUsername]) ->
|
|||||||
|
|
||||||
case HTTPMethod of
|
case HTTPMethod of
|
||||||
'GET' -> list_timelines(YArg, Username);
|
'GET' -> list_timelines(YArg, Username);
|
||||||
_Other -> make_json_405(YArg, [{see_docs, "/ts_api_doc/timelines"}])
|
_Other -> make_json_405(YArg, [{see_docs, "/ts_api_doc/timelines.html"}])
|
||||||
end;
|
end;
|
||||||
|
|
||||||
dispatch_timeline(YArg, [UrlUsername, UrlTimelineId]) ->
|
dispatch_timeline(YArg, [UrlUsername, UrlTimelineId]) ->
|
||||||
@ -98,21 +98,21 @@ dispatch_timeline(YArg, [UrlUsername, UrlTimelineId]) ->
|
|||||||
'POST' -> post_timeline(YArg, Username, TimelineId);
|
'POST' -> post_timeline(YArg, Username, TimelineId);
|
||||||
'PUT' -> put_timeline(YArg, Username, TimelineId);
|
'PUT' -> put_timeline(YArg, Username, TimelineId);
|
||||||
'DELETE' -> delete_timeline(YArg, Username, TimelineId);
|
'DELETE' -> delete_timeline(YArg, Username, TimelineId);
|
||||||
_Other -> make_json_405(YArg, [{see_docs, "/ts_api_doc/timelines"}])
|
_Other -> make_json_405(YArg, [{see_docs, "/ts_api_doc/timelines.html"}])
|
||||||
end;
|
end;
|
||||||
|
|
||||||
dispatch_timeline(YArg, _Other) ->
|
dispatch_timeline(YArg, _Other) ->
|
||||||
make_json_404(YArg, [{see_docs, "/ts_api_doc/timelines"}]).
|
make_json_404(YArg, [{see_docs, "/ts_api_doc/timelines.html"}]).
|
||||||
|
|
||||||
dispatch_entry(YArg, _Session, []) ->
|
dispatch_entry(YArg, _Session, []) ->
|
||||||
make_json_404(YArg, [{see_docs, "/ts_aip_doc/entries"}]);
|
make_json_404(YArg, [{see_docs, "/ts_aip_doc/entries.html"}]);
|
||||||
|
|
||||||
dispatch_entry(YArg, Session, [UrlUsername|_T] = PathElements) ->
|
dispatch_entry(YArg, Session, [UrlUsername|_T] = PathElements) ->
|
||||||
Username = path_element_to_atom(UrlUsername),
|
Username = path_element_to_atom(UrlUsername),
|
||||||
|
|
||||||
case Session#ts_api_session.username of
|
case Session#ts_api_session.username of
|
||||||
Username -> dispatch_entry(YArg, PathElements);
|
Username -> dispatch_entry(YArg, PathElements);
|
||||||
_Other -> make_json_404(YArg, [{see_docs, "/ts_api_doc/entries"}])
|
_Other -> make_json_404(YArg, [{see_docs, "/ts_api_doc/entries.html"}])
|
||||||
end.
|
end.
|
||||||
|
|
||||||
dispatch_entry(YArg, [UrlUsername, UrlTimelineId]) ->
|
dispatch_entry(YArg, [UrlUsername, UrlTimelineId]) ->
|
||||||
@ -123,7 +123,7 @@ dispatch_entry(YArg, [UrlUsername, UrlTimelineId]) ->
|
|||||||
case HTTPMethod of
|
case HTTPMethod of
|
||||||
'GET' -> list_entries(YArg, Username, TimelineId);
|
'GET' -> list_entries(YArg, Username, TimelineId);
|
||||||
'PUT' -> put_entry(YArg, Username, TimelineId);
|
'PUT' -> put_entry(YArg, Username, TimelineId);
|
||||||
_Other -> make_json_405(YArg, [{see_docs, "/ts_api_doc/entries"}])
|
_Other -> make_json_405(YArg, [{see_docs, "/ts_api_doc/entries.html"}])
|
||||||
end;
|
end;
|
||||||
|
|
||||||
dispatch_entry(YArg, [UrlUsername, UrlTimelineId, UrlEntryId]) ->
|
dispatch_entry(YArg, [UrlUsername, UrlTimelineId, UrlEntryId]) ->
|
||||||
@ -136,11 +136,11 @@ dispatch_entry(YArg, [UrlUsername, UrlTimelineId, UrlEntryId]) ->
|
|||||||
'GET' -> get_entry(YArg, Username, TimelineId, EntryId);
|
'GET' -> get_entry(YArg, Username, TimelineId, EntryId);
|
||||||
'POST' -> post_entry(YArg, Username, TimelineId, EntryId);
|
'POST' -> post_entry(YArg, Username, TimelineId, EntryId);
|
||||||
'DELETE' -> delete_entry(YArg, Username, TimelineId, EntryId);
|
'DELETE' -> delete_entry(YArg, Username, TimelineId, EntryId);
|
||||||
_Other -> make_json_405(YArg, [{see_docs, "/ts_api_doc/entries"}])
|
_Other -> make_json_405(YArg, [{see_docs, "/ts_api_doc/entries.html"}])
|
||||||
end;
|
end;
|
||||||
|
|
||||||
dispatch_entry(YArg, _Other) ->
|
dispatch_entry(YArg, _Other) ->
|
||||||
make_json_404(YArg, [{see_docs, "/ts_api_doc/entries"}]).
|
make_json_404(YArg, [{see_docs, "/ts_api_doc/entries.html"}]).
|
||||||
|
|
||||||
% ============================== %
|
% ============================== %
|
||||||
% ======== IMPLEMENTATION ====== %
|
% ======== IMPLEMENTATION ====== %
|
||||||
@ -175,7 +175,7 @@ do_login(YArg) ->
|
|||||||
"bad username/password combination"}])
|
"bad username/password combination"}])
|
||||||
end;
|
end;
|
||||||
|
|
||||||
_Other -> make_json_400(YArg, [{see_docs, "/ts_api_doc/login"}])
|
_Other -> make_json_400(YArg, [{see_docs, "/ts_api_doc/login.html"}])
|
||||||
end.
|
end.
|
||||||
|
|
||||||
do_logout(YArg) ->
|
do_logout(YArg) ->
|
||||||
@ -252,7 +252,7 @@ put_timeline(YArg, Username, TimelineId) ->
|
|||||||
JSONResponse = json:encode({struct, [
|
JSONResponse = json:encode({struct, [
|
||||||
{status, "ignored"},
|
{status, "ignored"},
|
||||||
{timeline, EJSONRec},
|
{timeline, EJSONRec},
|
||||||
{see_docs, "/ts_api_doc/timelines#PUT"}
|
{see_docs, "/ts_api_doc/timelines.html#PUT"}
|
||||||
]}),
|
]}),
|
||||||
|
|
||||||
{content, "application/json", JSONResponse};
|
{content, "application/json", JSONResponse};
|
||||||
@ -282,7 +282,7 @@ post_timeline(YArg, Username, TimelineId) ->
|
|||||||
|
|
||||||
no_record -> make_json_404(YArg,
|
no_record -> make_json_404(YArg,
|
||||||
[{status, "no such timeline"},
|
[{status, "no such timeline"},
|
||||||
{see_docs, "/ts_api_doc/timelines#POST"}]);
|
{see_docs, "/ts_api_doc/timelines.html#POST"}]);
|
||||||
|
|
||||||
_Error -> make_json_500(YArg)
|
_Error -> make_json_500(YArg)
|
||||||
end.
|
end.
|
||||||
@ -299,7 +299,7 @@ list_entries(YArg, Username, TimelineId) ->
|
|||||||
|
|
||||||
{no_record, _ByDateField} -> make_json_404(
|
{no_record, _ByDateField} -> make_json_404(
|
||||||
[{status, "no such timeline"},
|
[{status, "no such timeline"},
|
||||||
{see_docs, "/ts_api_doc/entries#LIST"}]);
|
{see_docs, "/ts_api_doc/entries.html#LIST"}]);
|
||||||
|
|
||||||
% listing by date range
|
% listing by date range
|
||||||
{Timeline, {byDate, "true"}} ->
|
{Timeline, {byDate, "true"}} ->
|
||||||
@ -402,7 +402,7 @@ put_entry(YArg, Username, TimelineId) ->
|
|||||||
JSONResponse = json:encode({struct, [
|
JSONResponse = json:encode({struct, [
|
||||||
{status, "ignored"},
|
{status, "ignored"},
|
||||||
{entry, EJSONRec},
|
{entry, EJSONRec},
|
||||||
{see_docs, "/ts_api_doc/entries#PUT"}
|
{see_docs, "/ts_api_doc/entries.html#PUT"}
|
||||||
]}),
|
]}),
|
||||||
|
|
||||||
{content, "application/json", JSONResponse};
|
{content, "application/json", JSONResponse};
|
||||||
@ -425,7 +425,7 @@ post_entry(YArg, Username, TimelineId, EntryId) ->
|
|||||||
ok -> make_json_200(YArg, NewRecord);
|
ok -> make_json_200(YArg, NewRecord);
|
||||||
|
|
||||||
no_record -> make_json_404(YArg,
|
no_record -> make_json_404(YArg,
|
||||||
[{status, "no such entry"}, {see_docs, "/ts_api_doc/entries#POST"}]);
|
[{status, "no such entry"}, {see_docs, "/ts_api_doc/entries.html#POST"}]);
|
||||||
|
|
||||||
_Error -> make_json_500(YArg)
|
_Error -> make_json_500(YArg)
|
||||||
end.
|
end.
|
||||||
|
0
www/css/ts.scss
Normal file
0
www/css/ts.scss
Normal file
24
www/index.yaws
Normal file
24
www/index.yaws
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>TimeStamper - Simple time tracking</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div id="header">
|
||||||
|
<div>
|
||||||
|
<h1>TimeStamper</h1>
|
||||||
|
<h4>Simple time tracking.</h4>
|
||||||
|
</div>
|
||||||
|
<div id="form-panel">
|
||||||
|
<form action="/ts/" method="post">
|
||||||
|
<label for="uname">username: </label>
|
||||||
|
<input name="uname" type="text"/>
|
||||||
|
<label for="pwd">password: </label>
|
||||||
|
<input name="pwd" type="password"/>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
8176
www/js/jquery-1.5.js
vendored
Normal file
8176
www/js/jquery-1.5.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
16
www/js/jquery-1.5.min.js
vendored
Normal file
16
www/js/jquery-1.5.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
4
www/ts/html_only.yaws
Normal file
4
www/ts/html_only.yaws
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
</html>
|
31
www/ts/index.yaws
Normal file
31
www/ts/index.yaws
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div id="user" class="bar">
|
||||||
|
<span id="fullname">Jonathan Bernard</span>
|
||||||
|
<span id="username">jdbernard</span>
|
||||||
|
</div>
|
||||||
|
<div id="user-info" class="bar">
|
||||||
|
<form action="/ts/update-user.yaws" onsubmit="updateUser(); false">
|
||||||
|
<!-- TODO -->
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div id="timeline" class="bar">
|
||||||
|
<span id="timeline_name">work</span>
|
||||||
|
</div>
|
||||||
|
<div id="timeline-info" class="bar">
|
||||||
|
<form action="/ts/update-timeline.yaws" onsubmit="updateTimeline(); false">
|
||||||
|
<!-- TODO -->
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div id="new-entry" class="bar">
|
||||||
|
</div>
|
||||||
|
<div id="new-entry-notes" class="bar">
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
Loading…
x
Reference in New Issue
Block a user