Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a web frontend for TinyTodo #122

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tinytodo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ notify = { version = "5.1.0", default-features = false, features = ["macos_kqueu
use-templates = []

[dependencies.cedar-policy]
features = ["partial-eval"]
version = "4.0.0"
git = "https://github.com/cedar-policy/cedar"
branch = "main"
Expand Down
9 changes: 9 additions & 0 deletions tinytodo/entities.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,27 @@
"teams": {
"Team::\"temp\"": {
"uid": "Team::\"temp\"",
"owner": "User::\"emina\"",
"admins": ["User::\"emina\""],
"name": "temp",
"parents": [
"Application::\"TinyTodo\""
]
},
"Team::\"admin\"": {
"uid": "Team::\"admin\"",
"owner": "User::\"emina\"",
"admins": ["User::\"emina\""],
"name": "admin",
"parents": [
"Application::\"TinyTodo\""
]
},
"Team::\"interns\"": {
"uid": "Team::\"interns\"",
"owner": "User::\"emina\"",
"admins": ["User::\"emina\""],
"name": "interns",
"parents": [
"Application::\"TinyTodo\"",
"Team::\"temp\""
Expand Down
28 changes: 28 additions & 0 deletions tinytodo/frontend/static/hello.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

ul.navbar {
list-style: none
}

ul.navbar li {
display: inline-block;
padding: 0 7px;
position: relative;
}

ul.navbar li:not(:last-child)::after {
content: "";
border: 1px solid #e2e2e2;
border-width: 1px 1px 0 0 ;
position: absolute;
right: -3px;
top: 0;
height: 100%;
}

.inlineSubmit {
background: none;
border: none;
color: blue;
text-decoration: underline;
cursor: pointer;
}
5 changes: 5 additions & 0 deletions tinytodo/frontend/templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% extends "main.html" %}
{% block title %}Home{% endblock %}
{% block body %}
Tiny Todo Home
{% endblock %}
10 changes: 10 additions & 0 deletions tinytodo/frontend/templates/list/create.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{% extends "main.html" %}
{% block title %}Create List{% endblock %}
{% block body %}
<h1> Create A List</h1>
<form method="POST">
<p><input type="text" name="name"/></p>
<p><input type="submit" value="Create"/></p>
</form>

{% endblock %}
101 changes: 101 additions & 0 deletions tinytodo/frontend/templates/list/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{% extends "main.html" %}
{% block title %} List Viewer {% endblock %}
{% block body %}

<h1>{{name}}</h1>
<h2>Contents</h2>
<ul>
{% for item in items %}
<li>{{item.name}}
<form style="display:inline" action="/list/delete_task" method="POST">
<input type="hidden" name="task_id" value="{{item.id}}"/>
<input type="hidden" name="name" value="{{id}}"/>
<input class="inlineSubmit" type="submit" value="[X]"/>
</form>
</li>
{% endfor %}
</ul>
<h3> Add item: </h3>
<form action="/list/add_item" method="POST">
<p><input type="hidden" name="name" value="{{id}}"/></p>
<p><input type="text" name="item"/></p>
<p><input type="submit" value="add"/></p>
</form>
<h2>Sharing</h2>
Add reader:
<form action="/list/share_with" method="POST">
<p><input type="hidden" name="list_id" value="{{id}}"/></p>
<p><input type="hidden" name="share_kind" value="Reader"/></p>
<p><input type="text" name="user"/></p>
<p><input type="submit" value="add"/></p>
</form>
Add editor:
<form action="/list/share_with" method="POST">
<p><input type="hidden" name="list_id" value="{{id}}"/></p>
<p><input type="hidden" name="share_kind" value="Editor"/></p>
<p><input type="text" name="user"/></p>
<p><input type="submit" value="add"/></p>
</form>

<!--
<h2>Sharing</h2>
<h3>Readers</h3>
Current Readers<br/>
<ul>
{% for user in readers %}
<li>
{{ user.username }}
<form action="/list/unshare" method="post" style="display: inline;">
<input type="hidden" name="list_id" value="{{id}}"/>
<input type="hidden" name="share_kind" value="reader"/>
<input type="hidden" name="user_id" value="{{user.id}}"/>
<input class="inlineSubmit" type="submit" value="[remove]"/>
</form>
</li>
{% endfor %}
</ul>
Add reader:
<form action="/list/share_with" method="POST">
<p><input type="hidden" name="list_id" value="{{id}}"/></p>
<p><input type="hidden" name="share_kind" value="reader"/></p>
<p><select name="user_id">
{% for user in users %}
<option value="{{user.id}}">
{{user.username}}
</option>
{% endfor %}
</select></p>
<p><input type="submit" value="add"/></p>
</form>

<h3>Editors</h3>
Current Editors<br/>
<ul>
{% for user in editors%}
<li>
{{ user.username }}
<form action="/list/unshare" method="post" style="display: inline;">
<input type="hidden" name="list_id" value="{{id}}"/>
<input type="hidden" name="share_kind" value="editor"/>
<input type="hidden" name="user_id" value="{{user.id}}"/>
<input class="inlineSubmit" type="submit" value="[remove]"/>
</form>
</li>
{% endfor %}
</ul>
Add editor:
<form action="/list/share_with" method="POST">
<p><input type="hidden" name="list_id" value="{{id}}"/></p>
<p><input type="hidden" name="share_kind" value="editor"/></p>
<p><select name="user_id">
{% for user in users %}
<option value="{{user.id}}">
{{user.username}}
</option>
{% endfor %}
</select></p>
<p><input type="submit" value="add"/></p>
</form>
-->

{% endblock %}
15 changes: 15 additions & 0 deletions tinytodo/frontend/templates/lists.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{% extends "main.html" %}
{% block title %}
Lists
{% endblock %}
{% block body %}
<a href="/list/create">Create a new list</a>
<h1>My Lists</h1>
<ul>
{% for list in lists %}
<li>
<a href="/list/read?name={{list.uid}}">{{list.name}}</a>
</li>
{% endfor %}
</ul>
{% endblock %}
8 changes: 8 additions & 0 deletions tinytodo/frontend/templates/login.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% extends "main.html" %}
{% block title %} Login {% endblock %}
{% block body %}
<form method="post">
<p><input type=text name=username></p>
<p><input type=submit value=login></p>
</form>
{% endblock %}
30 changes: 30 additions & 0 deletions tinytodo/frontend/templates/main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>>TinyTodo - {% block title %}{% endblock %} </title>
<link type="text/css" rel="stylesheet"
href="{{ url_for('static', filename='hello.css')}}"
/>
</head>
<body>
<ul class="navbar">
<li><a href="/">home</a></li>
<!--{% if user is defined %}
<li>
<a href="/user?name={{uid}}">user info</a>
</li>
{% endif %}-->
<li><a href="/lists">my lists</a></li>
<li><a href="/teams">my teams</a></li>
<li>
{% if user is defined %}
Welcome {{user}}. <a href="/logout">logout</a>
{% else %}
<a href="/login">login</a>
{% endif %}
</li>
</ul>
{% block body %} {% endblock %}
</body>
</html>
10 changes: 10 additions & 0 deletions tinytodo/frontend/templates/team/create.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{% extends "main.html" %}
{% block title %}Create List{% endblock %}
{% block body %}
<h1> Create A Team</h1>
<form method="POST">
<p><input type="text" name="name"/></p>
<p><input type="submit" value="Create"/></p>
</form>

{% endblock %}
38 changes: 38 additions & 0 deletions tinytodo/frontend/templates/team/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{% extends "main.html" %}
{% block title %} List Viewer {% endblock %}
{% block body %}

<h1>{{name}}</h1>

<h2>Admins</h2>

<h3> Add Admin: </h3>
<form action="/team/add_admin" method="POST">
<p><input type="hidden" name="name" value="{{id}}"/></p>
<p><input type="text" name="candidate"/></p>
<p><input type="submit" value="add"/></p>
</form>

<h3> Remove Admin: </h3>
<form action="/team/remove_admin" method="POST">
<p><input type="hidden" name="name" value="{{id}}"/></p>
<p><input type="text" name="candidate"/></p>
<p><input type="submit" value="remove"/></p>
</form>

<h2>Members</h2>

<h3> Add Member: </h3>
<form action="/team/add_member" method="POST">
<p><input type="hidden" name="name" value="{{id}}"/></p>
<p><input type="text" name="candidate"/></p>
<p><input type="submit" value="add"/></p>
</form>

<h3> Remove Member: </h3>
<form action="/team/remove_member" method="POST">
<p><input type="hidden" name="name" value="{{id}}"/></p>
<p><input type="text" name="candidate"/></p>
<p><input type="submit" value="remove"/></p>
</form>
{% endblock %}
24 changes: 24 additions & 0 deletions tinytodo/frontend/templates/teams.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{% extends "main.html" %}

{% block title %} My Teams {% endblock %}
{% block body %}
<h1> My Teams </h1>
<a href="/team/create">Create a new team</a>
<h1>Teams you can add/remove admins</h1>
<ul>
{% for team in admin_teams %}
<li>
<a href="/team/read?uid={{team.uid}}">{{team.name}}</a>
</li>
{% endfor %}
</ul>
<h1>Teams you can add/remove members</h1>
<ul>
{% for team in member_teams %}
<li>
<a href="/team/read?uid={{team.uid}}">{{team.name}}</a>
</li>
{% endfor %}
</ul>

{% endblock %}
Loading
Loading