Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
nopaque
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SFB 1288 - INF
nopaque
Commits
50273ea4
Commit
50273ea4
authored
5 years ago
by
Patrick Jentsch
Browse files
Options
Downloads
Patches
Plain Diff
Use links as list items for corpora and jobs. Add colors for service types. Link jobs to job page.
parent
136f2ee2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/main/views.py
+23
-14
23 additions, 14 deletions
app/main/views.py
app/templates/main/dashboard.html.j2
+12
-10
12 additions, 10 deletions
app/templates/main/dashboard.html.j2
with
35 additions
and
24 deletions
app/main/views.py
+
23
−
14
View file @
50273ea4
from
flask
import
current_app
,
flash
,
redirect
,
render_template
,
url_for
from
flask
import
abort
,
current_app
,
flash
,
redirect
,
render_template
,
url_for
from
flask_login
import
current_user
,
login_required
from
flask_login
import
current_user
,
login_required
from
..models
import
User
,
Corpus
from
..models
import
Corpus
,
User
,
Job
from
..tables
import
AdminUserTable
,
AdminUserItem
from
..tables
import
AdminUserTable
,
AdminUserItem
from
.
import
main
from
.
import
main
from
.forms
import
CreateCorpusForm
from
.forms
import
CreateCorpusForm
...
@@ -14,9 +14,16 @@ def index():
...
@@ -14,9 +14,16 @@ def index():
return
render_template
(
'
main/index.html.j2
'
,
title
=
'
Opaque
'
)
return
render_template
(
'
main/index.html.j2
'
,
title
=
'
Opaque
'
)
@main.route
(
'
/corpora/<corpus>
'
)
@main.route
(
'
/admin
'
,
methods
=
[
'
GET
'
,
'
POST
'
])
def
corpora
(
corpus
):
@login_required
return
render_template
(
'
main/corpus.html.j2
'
,
title
=
corpus
)
@admin_required
def
for_admins_only
():
users
=
User
.
query
.
order_by
(
User
.
username
).
all
()
items
=
[
AdminUserItem
(
u
.
username
,
u
.
email
,
u
.
role_id
,
u
.
confirmed
)
for
u
in
users
]
table
=
AdminUserTable
(
items
).
__html__
()
# converts table object to html string
table
=
table
.
replace
(
'
tbody
'
,
'
tbody class=
"
list
"'
,
1
)
# add class list to tbody element. Needed by list.js
return
render_template
(
'
main/admin.html.j2
'
,
title
=
'
Administration tools
'
,
table
=
table
)
@main.route
(
'
/dashboard
'
,
methods
=
[
'
GET
'
,
'
POST
'
])
@main.route
(
'
/dashboard
'
,
methods
=
[
'
GET
'
,
'
POST
'
])
...
@@ -54,13 +61,15 @@ def dashboard():
...
@@ -54,13 +61,15 @@ def dashboard():
)
)
@main.route
(
'
/
admin
'
,
methods
=
[
'
GET
'
,
'
POST
'
]
)
@main.route
(
'
/
jobs/<int:job_id>
'
)
@login_required
@login_required
@admin_required
def
job
(
job_id
):
def
for_admins_only
():
job
=
Job
.
query
.
filter_by
(
id
=
job_id
).
first
()
users
=
User
.
query
.
order_by
(
User
.
username
).
all
()
if
not
job
:
items
=
[
AdminUserItem
(
u
.
username
,
u
.
email
,
u
.
role_id
,
u
.
confirmed
)
for
u
in
users
]
print
(
'
Job not found.
'
)
table
=
AdminUserTable
(
items
).
__html__
()
# converts table object to html string
abort
(
404
)
table
=
table
.
replace
(
'
tbody
'
,
'
tbody class=
"
list
"'
,
1
)
# add class list to tbody element. Needed by list.js
elif
not
job
.
user_id
==
current_user
.
id
:
return
render_template
(
'
main/admin.html.j2
'
,
title
=
'
Administration tools
'
,
print
(
'
Job does not belong to current user.
'
)
table
=
table
)
abort
(
403
)
print
(
job
)
return
render_template
(
'
main/corpus.html.j2
'
,
title
=
job
.
title
)
This diff is collapsed.
Click to expand it.
app/templates/main/dashboard.html.j2
+
12
−
10
View file @
50273ea4
...
@@ -27,16 +27,15 @@
...
@@ -27,16 +27,15 @@
</div>
</div>
</div>
</div>
</div>
</div>
<
ul
class="collection list">
<
div
class="collection list">
{% for corpus in current_user.corpora.all() %}
{% for corpus in current_user.corpora.all() %}
<
li
class="collection-item avatar">
<
a href="#!"
class="collection-item avatar">
<i class="material-icons circle">book</i>
<i class="material-icons circle">book</i>
<span class="title">{{ corpus.title }}</span>
<span class="title">{{ corpus.title }}</span>
<p>{{ corpus.description }}</p>
<p>{{ corpus.description }}</p>
<a href="#!" class="secondary-content"><i class="material-icons">send</i></a>
</a>
</li>
{% endfor %}
{% endfor %}
</
ul
>
</
div
>
</div>
</div>
</div>
</div>
<script>
<script>
...
@@ -78,13 +77,16 @@
...
@@ -78,13 +77,16 @@
</div>
</div>
</div>
</div>
</div>
</div>
<
ul
class="collection list">
<
div
class="collection list">
{% for job in current_user.jobs.all() %}
{% for job in current_user.jobs.all() %}
{% if job.service == 'nlp' %}
{% if job.service == 'nlp' %}
{% set service_color = 'blue' %}
{% set service_icon = 'format_textdirection_l_to_r' %}
{% set service_icon = 'format_textdirection_l_to_r' %}
{% elif job.service =='ocr' %}
{% elif job.service =='ocr' %}
{% set service_color = 'green' %}
{% set service_icon = 'find_in_page' %}
{% set service_icon = 'find_in_page' %}
{% else %}
{% else %}
{% set service_color = 'red' %}
{% set service_icon = 'help' %}
{% set service_icon = 'help' %}
{% endif %}
{% endif %}
{% if job.status == 'pending' %}
{% if job.status == 'pending' %}
...
@@ -96,14 +98,14 @@
...
@@ -96,14 +98,14 @@
{% else %}
{% else %}
{% set badge_color = 'red' %}
{% set badge_color = 'red' %}
{% endif %}
{% endif %}
<
li
class="collection-item avatar">
<
a href="{{ url_for('main.job', job_id=job.id) }}"
class="collection-item avatar">
<i class="material-icons circle">{{ service_icon }}</i>
<i class="material-icons circle
{{ service_color }}
">{{ service_icon }}</i>
<span class="new badge {{ badge_color }}" data-badge-caption="">{{ job.status }}</span>
<span class="new badge {{ badge_color }}" data-badge-caption="">{{ job.status }}</span>
<span class="title">{{ job.title }}</span>
<span class="title">{{ job.title }}</span>
<p>{{ job.description }}</p>
<p>{{ job.description }}</p>
</
li
>
</
a
>
{% endfor %}
{% endfor %}
</
ul
>
</
div
>
</div>
</div>
</div>
</div>
<script>
<script>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment