mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2025-01-16 21:10:35 +00:00
Compare commits
3 Commits
e93449ba73
...
62d20409ea
Author | SHA1 | Date | |
---|---|---|---|
|
62d20409ea | ||
|
8aeafc33bd | ||
|
a54ff2e35a |
@ -52,10 +52,12 @@ def users():
|
||||
@register_breadcrumb(bp, '.users.entity', '', dynamic_list_constructor=user_dlc)
|
||||
def user(user_id):
|
||||
user = User.query.get_or_404(user_id)
|
||||
corpora = Corpus.query.filter(Corpus.user == user).all()
|
||||
return render_template(
|
||||
'admin/user.html.j2',
|
||||
title=user.username,
|
||||
user=user
|
||||
user=user,
|
||||
corpora=corpora
|
||||
)
|
||||
|
||||
|
||||
|
@ -84,12 +84,18 @@ class CreateTesseractOCRPipelineJobForm(CreateJobBaseForm):
|
||||
del self.binarization.render_kw['disabled']
|
||||
if 'ocropus_nlbin_threshold' in service_info['methods']:
|
||||
del self.ocropus_nlbin_threshold.render_kw['disabled']
|
||||
user_models = [
|
||||
x for x in current_user.tesseract_ocr_pipeline_models.order_by(TesseractOCRPipelineModel.title).all()
|
||||
]
|
||||
models = [
|
||||
x for x in TesseractOCRPipelineModel.query.order_by(TesseractOCRPipelineModel.title).all()
|
||||
if version in x.compatible_service_versions and (x.is_public == True or x.user == current_user)
|
||||
]
|
||||
self.model.choices = [('', 'Choose your option')]
|
||||
self.model.choices += [(x.hashid, f'{x.title} [{x.version}]') for x in models]
|
||||
self.model.choices = {
|
||||
'': [('', 'Choose your option')],
|
||||
'Your models': [(x.hashid, f'{x.title} [{x.version}]') for x in user_models] if user_models else [(0, 'Nothing here yet...')],
|
||||
'Public models': [(x.hashid, f'{x.title} [{x.version}]') for x in models]
|
||||
}
|
||||
self.model.default = ''
|
||||
self.version.choices = [(x, x) for x in service_manifest['versions']]
|
||||
self.version.data = version
|
||||
@ -177,7 +183,7 @@ class CreateSpacyNLPPipelineJobForm(CreateJobBaseForm):
|
||||
]
|
||||
self.model.choices = {
|
||||
'': [('', 'Choose your option')],
|
||||
'Your models': [(x.hashid, f'{x.title} [{x.version}]') for x in user_models],
|
||||
'Your models': [(x.hashid, f'{x.title} [{x.version}]') for x in user_models] if user_models else [(0, 'Nothing here yet...')],
|
||||
'Public models': [(x.hashid, f'{x.title} [{x.version}]') for x in models]
|
||||
}
|
||||
self.model.default = ''
|
||||
|
@ -107,11 +107,13 @@ def tesseract_ocr_pipeline():
|
||||
x for x in TesseractOCRPipelineModel.query.all()
|
||||
if version in x.compatible_service_versions and (x.is_public == True or x.user == current_user)
|
||||
]
|
||||
user_tesseract_ocr_pipeline_models_count = len(current_user.tesseract_ocr_pipeline_models.all())
|
||||
return render_template(
|
||||
'services/tesseract_ocr_pipeline.html.j2',
|
||||
title=service_manifest['name'],
|
||||
form=form,
|
||||
tesseract_ocr_pipeline_models=tesseract_ocr_pipeline_models
|
||||
tesseract_ocr_pipeline_models=tesseract_ocr_pipeline_models,
|
||||
user_tesseract_ocr_pipeline_models_count=user_tesseract_ocr_pipeline_models_count
|
||||
)
|
||||
|
||||
|
||||
@ -183,6 +185,7 @@ def spacy_nlp_pipeline():
|
||||
abort(404)
|
||||
form = CreateSpacyNLPPipelineJobForm(prefix='create-job-form', version=version)
|
||||
spacy_nlp_pipeline_models = SpaCyNLPPipelineModel.query.all()
|
||||
user_spacy_nlp_pipeline_models_count = len(current_user.spacy_nlp_pipeline_models.all())
|
||||
if form.is_submitted():
|
||||
if not form.validate():
|
||||
response = {'errors': form.errors}
|
||||
@ -214,7 +217,8 @@ def spacy_nlp_pipeline():
|
||||
'services/spacy_nlp_pipeline.html.j2',
|
||||
title=service_manifest['name'],
|
||||
form=form,
|
||||
spacy_nlp_pipeline_models=spacy_nlp_pipeline_models
|
||||
spacy_nlp_pipeline_models=spacy_nlp_pipeline_models,
|
||||
user_spacy_nlp_pipeline_models_count=user_spacy_nlp_pipeline_models_count
|
||||
)
|
||||
|
||||
|
||||
|
@ -246,17 +246,18 @@ class CorpusList extends ResourceList {
|
||||
this.selectedItemIds.forEach(selectedItemId => {
|
||||
let listItem = this.listjs.get('id', selectedItemId)[0].elm;
|
||||
let values = this.listjs.get('id', listItem.dataset.id)[0].values();
|
||||
if (!values['is-owner']) {
|
||||
Requests.corpora.entity.followers.entity.delete(selectedItemId, currentUserId);
|
||||
} else {
|
||||
if (values['is-owner']) {
|
||||
Requests.corpora.entity.delete(selectedItemId);
|
||||
} else {
|
||||
Requests.corpora.entity.followers.entity.delete(selectedItemId, currentUserId);
|
||||
setTimeout(() => {
|
||||
window.location.reload();
|
||||
}, 1000);
|
||||
}
|
||||
});
|
||||
this.selectedItemIds.clear();
|
||||
this.renderingItemSelection();
|
||||
setTimeout(() => {
|
||||
window.location.reload();
|
||||
}, 1000);
|
||||
|
||||
});
|
||||
modal.open();
|
||||
break;
|
||||
|
@ -21,7 +21,7 @@
|
||||
corpusList.add(
|
||||
[
|
||||
{% for corpus in corpora %}
|
||||
{{ corpus.to_json_serializeable(backrefs=True)|tojson }},
|
||||
{{ corpus.to_json_serializeable(backrefs=True,relationships=True)|tojson }},
|
||||
{% endfor %}
|
||||
]
|
||||
);
|
||||
|
@ -56,7 +56,7 @@
|
||||
<div class="col s12" id="user-corpora">
|
||||
<div class="card">
|
||||
<div class="card-content">
|
||||
<div class="corpus-list" data-user-id="{{ user.hashid }}"></div>
|
||||
<div class="corpus-list no-autoinit" data-user-id="{{ user.hashid }}"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -107,6 +107,16 @@
|
||||
{% block scripts %}
|
||||
{{ super() }}
|
||||
<script>
|
||||
|
||||
let corpusList = new CorpusList(document.querySelector('.corpus-list'));
|
||||
corpusList.add(
|
||||
[
|
||||
{% for corpus in corpora %}
|
||||
{{ corpus.to_json_serializeable(backrefs=True, relationships=True)|tojson }},
|
||||
{% endfor %}
|
||||
]
|
||||
);
|
||||
|
||||
let userRoleChip = document.querySelector('#user-role-chip');
|
||||
let userRoleChipTooltip = M.Tooltip.init(
|
||||
userRoleChip,
|
||||
|
@ -163,3 +163,14 @@
|
||||
</div>
|
||||
</div>
|
||||
{% endblock modals %}
|
||||
|
||||
{% block scripts %}
|
||||
{{ super() }}
|
||||
<script>
|
||||
// Disable user model selection if no models are available
|
||||
{% if user_spacy_nlp_pipeline_models_count == 0 %}
|
||||
optionGroupOptions = document.querySelectorAll(".optgroup-option");
|
||||
optionGroupOptions[0].classList.add("disabled");
|
||||
{% endif %}
|
||||
</script>
|
||||
{% endblock scripts %}
|
||||
|
@ -147,6 +147,13 @@
|
||||
{% block scripts %}
|
||||
{{ super() }}
|
||||
<script>
|
||||
|
||||
// Disable user model selection if no models are available
|
||||
{% if user_tesseract_ocr_pipeline_models_count == 0 %}
|
||||
optionGroupOptions = document.querySelectorAll(".optgroup-option");
|
||||
optionGroupOptions[0].classList.add("disabled");
|
||||
{% endif %}
|
||||
|
||||
document.querySelector('#create-job-form-binarization').addEventListener('change', (event) => {
|
||||
document.querySelector('#create-job-form-ocropus_nlbin_threshold-container').classList.toggle('hide');
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user