Compare commits

..

No commits in common. "62d20409ea1204a3b1158de2571ba64d00e33382" and "e93449ba731e0715429f1252978611babb10bf7e" have entirely different histories.

8 changed files with 14 additions and 55 deletions

View File

@ -52,12 +52,10 @@ def users():
@register_breadcrumb(bp, '.users.entity', '', dynamic_list_constructor=user_dlc) @register_breadcrumb(bp, '.users.entity', '', dynamic_list_constructor=user_dlc)
def user(user_id): def user(user_id):
user = User.query.get_or_404(user_id) user = User.query.get_or_404(user_id)
corpora = Corpus.query.filter(Corpus.user == user).all()
return render_template( return render_template(
'admin/user.html.j2', 'admin/user.html.j2',
title=user.username, title=user.username,
user=user, user=user
corpora=corpora
) )

View File

@ -84,18 +84,12 @@ class CreateTesseractOCRPipelineJobForm(CreateJobBaseForm):
del self.binarization.render_kw['disabled'] del self.binarization.render_kw['disabled']
if 'ocropus_nlbin_threshold' in service_info['methods']: if 'ocropus_nlbin_threshold' in service_info['methods']:
del self.ocropus_nlbin_threshold.render_kw['disabled'] 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 = [ models = [
x for x in TesseractOCRPipelineModel.query.order_by(TesseractOCRPipelineModel.title).all() 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) if version in x.compatible_service_versions and (x.is_public == True or x.user == current_user)
] ]
self.model.choices = { self.model.choices = [('', 'Choose your option')]
'': [('', 'Choose your option')], self.model.choices += [(x.hashid, f'{x.title} [{x.version}]') for x in 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 = '' self.model.default = ''
self.version.choices = [(x, x) for x in service_manifest['versions']] self.version.choices = [(x, x) for x in service_manifest['versions']]
self.version.data = version self.version.data = version
@ -183,7 +177,7 @@ class CreateSpacyNLPPipelineJobForm(CreateJobBaseForm):
] ]
self.model.choices = { self.model.choices = {
'': [('', 'Choose your option')], '': [('', '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...')], 'Your models': [(x.hashid, f'{x.title} [{x.version}]') for x in user_models],
'Public models': [(x.hashid, f'{x.title} [{x.version}]') for x in models] 'Public models': [(x.hashid, f'{x.title} [{x.version}]') for x in models]
} }
self.model.default = '' self.model.default = ''

View File

@ -107,13 +107,11 @@ def tesseract_ocr_pipeline():
x for x in TesseractOCRPipelineModel.query.all() x for x in TesseractOCRPipelineModel.query.all()
if version in x.compatible_service_versions and (x.is_public == True or x.user == current_user) 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( return render_template(
'services/tesseract_ocr_pipeline.html.j2', 'services/tesseract_ocr_pipeline.html.j2',
title=service_manifest['name'], title=service_manifest['name'],
form=form, 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
) )
@ -185,7 +183,6 @@ def spacy_nlp_pipeline():
abort(404) abort(404)
form = CreateSpacyNLPPipelineJobForm(prefix='create-job-form', version=version) form = CreateSpacyNLPPipelineJobForm(prefix='create-job-form', version=version)
spacy_nlp_pipeline_models = SpaCyNLPPipelineModel.query.all() 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 form.is_submitted():
if not form.validate(): if not form.validate():
response = {'errors': form.errors} response = {'errors': form.errors}
@ -217,8 +214,7 @@ def spacy_nlp_pipeline():
'services/spacy_nlp_pipeline.html.j2', 'services/spacy_nlp_pipeline.html.j2',
title=service_manifest['name'], title=service_manifest['name'],
form=form, 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
) )

View File

@ -246,18 +246,17 @@ class CorpusList extends ResourceList {
this.selectedItemIds.forEach(selectedItemId => { this.selectedItemIds.forEach(selectedItemId => {
let listItem = this.listjs.get('id', selectedItemId)[0].elm; let listItem = this.listjs.get('id', selectedItemId)[0].elm;
let values = this.listjs.get('id', listItem.dataset.id)[0].values(); let values = this.listjs.get('id', listItem.dataset.id)[0].values();
if (values['is-owner']) { if (!values['is-owner']) {
Requests.corpora.entity.delete(selectedItemId);
} else {
Requests.corpora.entity.followers.entity.delete(selectedItemId, currentUserId); Requests.corpora.entity.followers.entity.delete(selectedItemId, currentUserId);
setTimeout(() => { } else {
window.location.reload(); Requests.corpora.entity.delete(selectedItemId);
}, 1000);
} }
}); });
this.selectedItemIds.clear(); this.selectedItemIds.clear();
this.renderingItemSelection(); this.renderingItemSelection();
setTimeout(() => {
window.location.reload();
}, 1000);
}); });
modal.open(); modal.open();
break; break;

View File

@ -21,7 +21,7 @@
corpusList.add( corpusList.add(
[ [
{% for corpus in corpora %} {% for corpus in corpora %}
{{ corpus.to_json_serializeable(backrefs=True,relationships=True)|tojson }}, {{ corpus.to_json_serializeable(backrefs=True)|tojson }},
{% endfor %} {% endfor %}
] ]
); );

View File

@ -56,7 +56,7 @@
<div class="col s12" id="user-corpora"> <div class="col s12" id="user-corpora">
<div class="card"> <div class="card">
<div class="card-content"> <div class="card-content">
<div class="corpus-list no-autoinit" data-user-id="{{ user.hashid }}"></div> <div class="corpus-list" data-user-id="{{ user.hashid }}"></div>
</div> </div>
</div> </div>
</div> </div>
@ -107,16 +107,6 @@
{% block scripts %} {% block scripts %}
{{ super() }} {{ super() }}
<script> <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 userRoleChip = document.querySelector('#user-role-chip');
let userRoleChipTooltip = M.Tooltip.init( let userRoleChipTooltip = M.Tooltip.init(
userRoleChip, userRoleChip,

View File

@ -163,14 +163,3 @@
</div> </div>
</div> </div>
{% endblock modals %} {% 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 %}

View File

@ -147,13 +147,6 @@
{% block scripts %} {% block scripts %}
{{ super() }} {{ super() }}
<script> <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-binarization').addEventListener('change', (event) => {
document.querySelector('#create-job-form-ocropus_nlbin_threshold-container').classList.toggle('hide'); document.querySelector('#create-job-form-ocropus_nlbin_threshold-container').classList.toggle('hide');
}); });