mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2025-06-13 17:40:40 +00:00
Merge branch 'following-mechanics' into development
This commit is contained in:
@ -20,6 +20,7 @@
|
||||
<li><a href="{{ url_for('main.dashboard') }}"><i class="material-icons">dashboard</i>Dashboard</a></li>
|
||||
<li><a href="{{ url_for('main.dashboard', _anchor='corpora') }}" style="padding-left: 47px;"><i class="nopaque-icons">I</i>My Corpora</a></li>
|
||||
<li><a href="{{ url_for('main.dashboard', _anchor='jobs') }}" style="padding-left: 47px;"><i class="nopaque-icons">J</i>My Jobs</a></li>
|
||||
<li><a href="{{ url_for('main.dashboard', _anchor='social') }}" style="padding-left: 47px;"><i class="material-icons">groups</i>Social</a></li>
|
||||
<li><a href="{{ url_for('contributions.contributions') }}"><i class="material-icons">new_label</i>Contribute</a></li>
|
||||
<li><div class="divider"></div></li>
|
||||
<li><a class="subheader">Processes & Services</a></li>
|
||||
|
@ -1,4 +1,5 @@
|
||||
{% extends "base.html.j2" %}
|
||||
{% import "materialize/wtf.html.j2" as wtf %}
|
||||
{% from "corpora/_breadcrumbs.html.j2" import breadcrumbs with context %}
|
||||
|
||||
{% block main_attribs %} class="service-scheme" data-service="corpus-analysis"{% endblock main_attribs %}
|
||||
@ -9,7 +10,15 @@
|
||||
<div class="col s12" data-corpus-id="{{ corpus.hashid }}" data-user-id="{{ corpus.user.hashid }}" id="corpus-display">
|
||||
<div class="row">
|
||||
<div class="col s8 m9 l10">
|
||||
<h1 id="title"><span class="corpus-title"></span></h1>
|
||||
{# <h1 id="title"><span class="corpus-title"></span></h1> #}
|
||||
<h1 id="title">{{ corpus.title }}</h1>
|
||||
{% if not corpus.user == current_user %}
|
||||
{% if current_user.is_following_corpus(corpus) %}
|
||||
<a class="btn waves-effect waves-light" id="follow-corpus-request"><i class="material-icons left">add</i>Unfollow Corpus</a>
|
||||
{% elif not current_user.is_following_corpus(corpus) %}
|
||||
<a class="btn waves-effect waves-light" id="follow-corpus-request"><i class="material-icons left">add</i>Follow Corpus</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="col s4 m3 l2 right-align">
|
||||
<p> </p>
|
||||
@ -76,6 +85,33 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% if current_user.can(Permission.ADMINISTRATE) or current_user.hashid == corpus.user.hashid %}
|
||||
<div class="col s12">
|
||||
<form method="POST">
|
||||
{{ corpus_settings_form.hidden_tag() }}
|
||||
<div class="card">
|
||||
<div class="card-content">
|
||||
<span class="card-title" id="files">Corpus settings</span>
|
||||
<br>
|
||||
<p></p>
|
||||
{{ wtf.render_field(corpus_settings_form.is_public) }}
|
||||
<br>
|
||||
</div>
|
||||
<div class="card-action right-align">
|
||||
{{ wtf.render_field(corpus_settings_form.submit, material_icon='send') }}
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="col s12">
|
||||
<div class="card">
|
||||
<div class="card-content">
|
||||
<span class="card-title" id="files">Corpus followers</span>
|
||||
<div class="user-list no-autoinit"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock page_content %}
|
||||
@ -84,5 +120,56 @@
|
||||
{{ super() }}
|
||||
<script>
|
||||
let corpusDisplay = new CorpusDisplay(document.querySelector('#corpus-display'));
|
||||
let corpusFollowingRequest = document.querySelector('#follow-corpus-request');
|
||||
|
||||
{# let followingUserList = new UserList(document.querySelector('.user-list'));
|
||||
followingUserList.add({{ following_users|tojson }}); #}
|
||||
|
||||
corpusFollowingRequest.addEventListener('click', function() {
|
||||
corpusFollowingRequest.innerHTML = '<i class="material-icons left">add</i>Unfollow Corpus';
|
||||
if ("{{ current_user.is_following_corpus(corpus) }}" === "False") {
|
||||
corpusFollowingRequest.lastChild.textContent = 'Unfollow Corpus';
|
||||
return new Promise((resolve, reject) => {
|
||||
fetch(`/corpora/{{ corpus.hashid }}/follow`, {method: 'POST', headers: {Accept: 'application/json'}})
|
||||
.then(
|
||||
(response) => {
|
||||
if (response.status === 403) {app.flash('Forbidden', 'error'); reject(response);}
|
||||
if (response.status === 404) {app.flash('Not Found', 'error'); reject(response);}
|
||||
if (response.status === 409) {app.flash('Conflict', 'error'); reject(response);}
|
||||
app.flash(`You follow "{{ corpus.title }}" now`, 'corpus');
|
||||
window.location.href = '{{ url_for("corpora.corpus", corpus_id=corpus.id) }}'
|
||||
resolve(response);
|
||||
},
|
||||
(response) => {
|
||||
app.flash('Something went wrong', 'error');
|
||||
reject(response);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
} else {
|
||||
corpusFollowingRequest.innerHTML = '<i class="material-icons left">add</i>Unfollow Corpus';
|
||||
return new Promise((resolve, reject) => {
|
||||
fetch(`/corpora/{{ corpus.hashid }}/unfollow`, {method: 'POST', headers: {Accept: 'application/json'}})
|
||||
.then(
|
||||
(response) => {
|
||||
if (response.status === 403) {app.flash('Forbidden', 'error'); reject(response);}
|
||||
if (response.status === 404) {app.flash('Not Found', 'error'); reject(response);}
|
||||
if (response.status === 409) {app.flash('Conflict', 'error'); reject(response);}
|
||||
app.flash(`You are not following "{{ corpus.title }}" anymore`, 'corpus');
|
||||
resolve(response);
|
||||
window.location.href = '{{ url_for("corpora.corpus", corpus_id=corpus.id) }}'
|
||||
},
|
||||
(response) => {
|
||||
app.flash('Something went wrong', 'error');
|
||||
reject(response);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
{% endblock scripts %}
|
||||
|
@ -42,6 +42,23 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col s12" id="social">
|
||||
<h3>Social</h3>
|
||||
<div class="card">
|
||||
<div class="card-content">
|
||||
<span class="card-title">Other users</span>
|
||||
<p>Find other users and follow them to see their corpora.</p>
|
||||
<div class="user-list no-autoinit"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-content">
|
||||
<span class="card-title">Public corpora</span>
|
||||
<p>Find public corpora</p>
|
||||
<div class="public-corpus-list no-autoinit"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock page_content %}
|
||||
@ -96,3 +113,14 @@
|
||||
</div>
|
||||
</div>
|
||||
{% endblock modals %}
|
||||
|
||||
{% block scripts %}
|
||||
{{ super() }}
|
||||
<script>
|
||||
let userList = new UserList(document.querySelector('.user-list'));
|
||||
userList.add({{ users|tojson }});
|
||||
let publicCorpusList = new CorpusList(document.querySelector('.public-corpus-list'));
|
||||
publicCorpusList.add({{ corpora|tojson }});
|
||||
</script>
|
||||
{% endblock scripts %}
|
||||
|
||||
|
@ -89,6 +89,24 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col s6">
|
||||
<div class="card">
|
||||
<div class="card-content">
|
||||
<h4>Groups</h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col s6">
|
||||
<div class="card">
|
||||
<div class="card-content">
|
||||
<h4>Public corpora</h4>
|
||||
<div class="public-corpora-list" data-user-id="{{ user.hashid }}"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
{% endblock page_content %}
|
||||
|
||||
|
Reference in New Issue
Block a user