mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-24 10:34:17 +00:00
Fix contributionslists share toggle
This commit is contained in:
parent
632aab258b
commit
f972c13b81
@ -1331,6 +1331,8 @@ class Corpus(HashidMixin, db.Model):
|
|||||||
@db.event.listens_for(Job, 'after_delete')
|
@db.event.listens_for(Job, 'after_delete')
|
||||||
@db.event.listens_for(JobInput, 'after_delete')
|
@db.event.listens_for(JobInput, 'after_delete')
|
||||||
@db.event.listens_for(JobResult, 'after_delete')
|
@db.event.listens_for(JobResult, 'after_delete')
|
||||||
|
@db.event.listens_for(SpaCyNLPPipelineModel, 'after_delete')
|
||||||
|
@db.event.listens_for(TesseractOCRPipelineModel, 'after_delete')
|
||||||
def ressource_after_delete(mapper, connection, ressource):
|
def ressource_after_delete(mapper, connection, ressource):
|
||||||
jsonpatch = [{'op': 'remove', 'path': ressource.jsonpatch_path}]
|
jsonpatch = [{'op': 'remove', 'path': ressource.jsonpatch_path}]
|
||||||
room = f'users.{ressource.user_hashid}'
|
room = f'users.{ressource.user_hashid}'
|
||||||
@ -1344,6 +1346,8 @@ def ressource_after_delete(mapper, connection, ressource):
|
|||||||
@db.event.listens_for(Job, 'after_insert')
|
@db.event.listens_for(Job, 'after_insert')
|
||||||
@db.event.listens_for(JobInput, 'after_insert')
|
@db.event.listens_for(JobInput, 'after_insert')
|
||||||
@db.event.listens_for(JobResult, 'after_insert')
|
@db.event.listens_for(JobResult, 'after_insert')
|
||||||
|
@db.event.listens_for(SpaCyNLPPipelineModel, 'after_insert')
|
||||||
|
@db.event.listens_for(TesseractOCRPipelineModel, 'after_insert')
|
||||||
def ressource_after_insert_handler(mapper, connection, ressource):
|
def ressource_after_insert_handler(mapper, connection, ressource):
|
||||||
value = ressource.to_json_serializeable()
|
value = ressource.to_json_serializeable()
|
||||||
for attr in mapper.relationships:
|
for attr in mapper.relationships:
|
||||||
@ -1360,6 +1364,8 @@ def ressource_after_insert_handler(mapper, connection, ressource):
|
|||||||
@db.event.listens_for(Job, 'after_update')
|
@db.event.listens_for(Job, 'after_update')
|
||||||
@db.event.listens_for(JobInput, 'after_update')
|
@db.event.listens_for(JobInput, 'after_update')
|
||||||
@db.event.listens_for(JobResult, 'after_update')
|
@db.event.listens_for(JobResult, 'after_update')
|
||||||
|
@db.event.listens_for(SpaCyNLPPipelineModel, 'after_update')
|
||||||
|
@db.event.listens_for(TesseractOCRPipelineModel, 'after_update')
|
||||||
def ressource_after_update_handler(mapper, connection, ressource):
|
def ressource_after_update_handler(mapper, connection, ressource):
|
||||||
jsonpatch = []
|
jsonpatch = []
|
||||||
for attr in db.inspect(ressource).attrs:
|
for attr in db.inspect(ressource).attrs:
|
||||||
|
@ -18,39 +18,33 @@ class SpaCyNLPPipelineModelList extends ResourceList {
|
|||||||
});
|
});
|
||||||
app.getUser(this.userId).then((user) => {
|
app.getUser(this.userId).then((user) => {
|
||||||
this.add(Object.values(user.spacy_nlp_pipeline_models));
|
this.add(Object.values(user.spacy_nlp_pipeline_models));
|
||||||
for (let uncheckedCheckbox of this.listjs.list.querySelectorAll('input[data-checked="True"]')) {
|
|
||||||
uncheckedCheckbox.setAttribute('checked', '');
|
|
||||||
}
|
|
||||||
if (user.role.name !== ('Administrator' || 'Contributor')) {
|
|
||||||
for (let switchElement of this.listjs.list.querySelectorAll('.is_public')) {
|
|
||||||
switchElement.setAttribute('disabled', '');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.isInitialized = true;
|
this.isInitialized = true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
get item() {
|
get item() {
|
||||||
return `
|
return (values) => {
|
||||||
<tr class="list-item clickable hoverable">
|
return `
|
||||||
<td><b><span class="title"></span> <span class="version"></span></b><br><i><span class="description"></span></i></td>
|
<tr class="list-item clickable hoverable">
|
||||||
<td><a class="publisher-url"><span class="publisher"></span></a> (<span class="publishing-year"></span>)<br><a class="publishing-url"><span class="publishing-url-2"></span></a></td>
|
<td><b><span class="title"></span> <span class="version"></span></b><br><i><span class="description"></span></i></td>
|
||||||
<td>
|
<td><a class="publisher-url"><span class="publisher"></span></a> (<span class="publishing-year"></span>)<br><a class="publishing-url publishing-url-2"></a></td>
|
||||||
<div class="list-action-trigger switch center-align" data-list-action="share-request">
|
<td>
|
||||||
<span class="share"></span>
|
<div class="list-action-trigger switch center-align" data-list-action="share-request">
|
||||||
<label>
|
<span class="share"></span>
|
||||||
<input type="checkbox" class="is_public">
|
<label>
|
||||||
<span class="lever"></span>
|
<input class="is-public" ${values['is-public'] ? 'checked' : ''} type="checkbox">
|
||||||
public
|
<span class="lever"></span>
|
||||||
</label>
|
public
|
||||||
</div>
|
</label>
|
||||||
</td>
|
</div>
|
||||||
<td class="right-align">
|
</td>
|
||||||
<a class="list-action-trigger btn-floating red waves-effect waves-light" data-list-action="delete-request"><i class="material-icons">delete</i></a>
|
<td class="right-align">
|
||||||
<a class="list-action-trigger btn-floating service-color darken waves-effect waves-light service-2" data-list-action="view"><i class="material-icons">send</i></a>
|
<a class="list-action-trigger btn-floating red waves-effect waves-light" data-list-action="delete-request"><i class="material-icons">delete</i></a>
|
||||||
</td>
|
<a class="list-action-trigger btn-floating service-color darken waves-effect waves-light service-2" data-list-action="view"><i class="material-icons">send</i></a>
|
||||||
</tr>
|
</td>
|
||||||
`.trim();
|
</tr>
|
||||||
|
`.trim();
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
get valueNames() {
|
get valueNames() {
|
||||||
@ -65,8 +59,7 @@ class SpaCyNLPPipelineModelList extends ResourceList {
|
|||||||
'publishing-year',
|
'publishing-year',
|
||||||
'title',
|
'title',
|
||||||
'title-2',
|
'title-2',
|
||||||
'version',
|
'version'
|
||||||
{name: 'is_public', attr: 'data-checked'}
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,6 +89,7 @@ class SpaCyNLPPipelineModelList extends ResourceList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mapResourceToValue(spaCyNLPPipelineModel) {
|
mapResourceToValue(spaCyNLPPipelineModel) {
|
||||||
|
console.log(spaCyNLPPipelineModel);
|
||||||
return {
|
return {
|
||||||
'id': spaCyNLPPipelineModel.id,
|
'id': spaCyNLPPipelineModel.id,
|
||||||
'creation-date': spaCyNLPPipelineModel.creation_date,
|
'creation-date': spaCyNLPPipelineModel.creation_date,
|
||||||
@ -108,7 +102,7 @@ class SpaCyNLPPipelineModelList extends ResourceList {
|
|||||||
'title': spaCyNLPPipelineModel.title,
|
'title': spaCyNLPPipelineModel.title,
|
||||||
'title-2': spaCyNLPPipelineModel.title,
|
'title-2': spaCyNLPPipelineModel.title,
|
||||||
'version': spaCyNLPPipelineModel.version,
|
'version': spaCyNLPPipelineModel.version,
|
||||||
'is_public': spaCyNLPPipelineModel.is_public ? 'True' : 'False'
|
'is-public': spaCyNLPPipelineModel.is_public
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,14 +111,15 @@ class SpaCyNLPPipelineModelList extends ResourceList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onChange(event) {
|
onChange(event) {
|
||||||
let actionSwitchElement = event.target.closest('.list-action-trigger');
|
let listItemElement = event.target.closest('.list-item[data-id]');
|
||||||
let action = actionSwitchElement.dataset.listAction;
|
if (listItemElement === null) {return;}
|
||||||
let spaCyNLPPipelineModelElement = event.target.closest('tr');
|
let itemId = listItemElement.dataset.id;
|
||||||
let spaCyNLPPipelineModelId = spaCyNLPPipelineModelElement.dataset.id;
|
let listActionElement = event.target.closest('.list-action-trigger[data-list-action]');
|
||||||
switch (action) {
|
if (listActionElement === null) {return;}
|
||||||
|
let listAction = listActionElement.dataset.listAction;
|
||||||
|
switch (listAction) {
|
||||||
case 'share-request': {
|
case 'share-request': {
|
||||||
let is_public = actionSwitchElement.querySelector('input').checked;
|
Utils.spaCyNLPPipelineModelToggleIsPublicRequest(this.userId, itemId);
|
||||||
Utils.shareSpaCyNLPPipelineModelRequest(this.userId, spaCyNLPPipelineModelId, is_public);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
@ -134,24 +129,23 @@ class SpaCyNLPPipelineModelList extends ResourceList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onClick(event) {
|
onClick(event) {
|
||||||
if (event.target.closest('.action-switch')) {
|
let listItemElement = event.target.closest('.list-item[data-id]');
|
||||||
let userRole = app.data.users[this.userId].role.name;
|
if (listItemElement === null) {return;}
|
||||||
if (userRole !== ('Administrator' || 'Contributor')) {
|
let itemId = listItemElement.dataset.id;
|
||||||
app.flash('You need the "Contributor" or "Administrator" role to perform this action.', 'error');
|
let listActionElement = event.target.closest('.list-action-trigger[data-list-action]');
|
||||||
}
|
// ignore switch clicks, handle them by the onChange method instead
|
||||||
return;
|
if (listActionElement.classList.contains('switch')) {
|
||||||
|
event.preventDefault();
|
||||||
|
this.onChange(event);
|
||||||
}
|
}
|
||||||
let actionButtonElement = event.target.closest('.list-action-trigger');
|
let listAction = listActionElement === null ? 'view' : listActionElement.dataset.listAction;
|
||||||
let action = actionButtonElement === null ? 'view' : actionButtonElement.dataset.listAction;
|
switch (listAction) {
|
||||||
let spaCyNLPPipelineModelElement = event.target.closest('tr');
|
|
||||||
let spaCyNLPPipelineModelId = spaCyNLPPipelineModelElement.dataset.id;
|
|
||||||
switch (action) {
|
|
||||||
case 'delete-request': {
|
case 'delete-request': {
|
||||||
Utils.deleteSpaCyNLPPipelineModelRequest(this.userId, spaCyNLPPipelineModelId);
|
Utils.deleteSpaCyNLPPipelineModelRequest(this.userId, itemId);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'view': {
|
case 'view': {
|
||||||
window.location.href = `/contributions/spacy-nlp-pipeline-models/${spaCyNLPPipelineModelId}`;
|
window.location.href = `/contributions/spacy-nlp-pipeline-models/${itemId}`;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
@ -159,4 +153,41 @@ class SpaCyNLPPipelineModelList extends ResourceList {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onPatch(patch) {
|
||||||
|
let re = new RegExp(`^/users/${this.userId}/spacy_nlp_pipeline_models/([A-Za-z0-9]*)`);
|
||||||
|
let filteredPatch = patch.filter(operation => re.test(operation.path));
|
||||||
|
for (let operation of filteredPatch) {
|
||||||
|
switch(operation.op) {
|
||||||
|
case 'add': {
|
||||||
|
let re = new RegExp(`^/users/${this.userId}/spacy_nlp_pipeline_models/([A-Za-z0-9]*)$`);
|
||||||
|
if (re.test(operation.path)) {this.add(operation.value);}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'remove': {
|
||||||
|
let re = new RegExp(`^/users/${this.userId}/spacy_nlp_pipeline_models/([A-Za-z0-9]*)$`);
|
||||||
|
if (re.test(operation.path)) {
|
||||||
|
let [match, itemId] = operation.path.match(re);
|
||||||
|
this.remove(itemId);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'replace': {
|
||||||
|
let re = new RegExp(`^/users/${this.userId}/spacy_nlp_pipeline_models/([A-Za-z0-9]*)/(is_public)$`);
|
||||||
|
if (re.test(operation.path)) {
|
||||||
|
let [match, itemId, valueName] = operation.path.match(re);
|
||||||
|
if (valueName === 'is_public') {
|
||||||
|
this.listjs.list.querySelector(`.list-item[data-id="${itemId}"] .is-public`).checked = operation.value;
|
||||||
|
valueName = 'is-public';
|
||||||
|
}
|
||||||
|
this.replace(itemId, valueName, operation.value);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,26 +31,28 @@ class TesseractOCRPipelineModelList extends ResourceList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get item() {
|
get item() {
|
||||||
return `
|
return (values) => {
|
||||||
<tr class="list-item clickable hoverable">
|
return `
|
||||||
<td><b><span class="title"></span> <span class="version"></span></b><br><i><span class="description"></span></i></td>
|
<tr class="list-item clickable hoverable">
|
||||||
<td><a class="publisher-url"><span class="publisher"></span></a> (<span class="publishing-year"></span>)<br><a class="publishing-url"><span class="publishing-url-2"></span></a></td>
|
<td><b><span class="title"></span> <span class="version"></span></b><br><i><span class="description"></span></i></td>
|
||||||
<td>
|
<td><a class="publisher-url"><span class="publisher"></span></a> (<span class="publishing-year"></span>)<br><a class="publishing-url"><span class="publishing-url-2"></span></a></td>
|
||||||
<div class="list-action-trigger switch center-align" data-list-action="share-request">
|
<td>
|
||||||
<span class="share"></span>
|
<div class="list-action-trigger switch center-align" data-list-action="share-request">
|
||||||
<label>
|
<span class="share"></span>
|
||||||
<input type="checkbox" class="is_public">
|
<label>
|
||||||
<span class="lever"></span>
|
<input ${values['is-public'] ? 'checked' : ''} class="is-public" type="checkbox">
|
||||||
public
|
<span class="lever"></span>
|
||||||
</label>
|
public
|
||||||
</div>
|
</label>
|
||||||
</td>
|
</div>
|
||||||
<td class="right-align">
|
</td>
|
||||||
<a class="list-action-trigger btn-floating red waves-effect waves-light" data-list-action="delete-request"><i class="material-icons">delete</i></a>
|
<td class="right-align">
|
||||||
<a class="list-action-trigger btn-floating service-color darken waves-effect waves-light service-2" data-list-action="view"><i class="material-icons">send</i></a>
|
<a class="list-action-trigger btn-floating red waves-effect waves-light" data-list-action="delete-request"><i class="material-icons">delete</i></a>
|
||||||
</td>
|
<a class="list-action-trigger btn-floating service-color darken waves-effect waves-light service-2" data-list-action="view"><i class="material-icons">send</i></a>
|
||||||
</tr>
|
</td>
|
||||||
`.trim();
|
</tr>
|
||||||
|
`.trim();
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
get valueNames() {
|
get valueNames() {
|
||||||
@ -108,7 +110,7 @@ class TesseractOCRPipelineModelList extends ResourceList {
|
|||||||
'title': tesseractOCRPipelineModel.title,
|
'title': tesseractOCRPipelineModel.title,
|
||||||
'title-2': tesseractOCRPipelineModel.title,
|
'title-2': tesseractOCRPipelineModel.title,
|
||||||
'version': tesseractOCRPipelineModel.version,
|
'version': tesseractOCRPipelineModel.version,
|
||||||
'is_public': tesseractOCRPipelineModel.is_public ? 'True' : 'False'
|
'is-public': tesseractOCRPipelineModel.is_public
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,14 +119,15 @@ class TesseractOCRPipelineModelList extends ResourceList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onChange(event) {
|
onChange(event) {
|
||||||
let actionSwitchElement = event.target.closest('.list-action-trigger');
|
let listItemElement = event.target.closest('.list-item[data-id]');
|
||||||
let action = actionSwitchElement.dataset.listAction;
|
if (listItemElement === null) {return;}
|
||||||
let tesseractOCRPipelineModelElement = event.target.closest('tr');
|
let itemId = listItemElement.dataset.id;
|
||||||
let tesseractOCRPipelineModelId = tesseractOCRPipelineModelElement.dataset.id;
|
let listActionElement = event.target.closest('.list-action-trigger[data-list-action]');
|
||||||
switch (action) {
|
if (listActionElement === null) {return;}
|
||||||
|
let listAction = listActionElement.dataset.listAction;
|
||||||
|
switch (listAction) {
|
||||||
case 'share-request': {
|
case 'share-request': {
|
||||||
let is_public = actionSwitchElement.querySelector('input').checked;
|
Utils.tesseractOCRPipelineModelToggleIsPublicRequest(this.userId, itemId);
|
||||||
Utils.shareTesseractOCRPipelineModelRequest(this.userId, tesseractOCRPipelineModelId, is_public);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
@ -134,24 +137,23 @@ class TesseractOCRPipelineModelList extends ResourceList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onClick(event) {
|
onClick(event) {
|
||||||
if (event.target.closest('.action-switch')) {
|
let listItemElement = event.target.closest('.list-item[data-id]');
|
||||||
let userRole = app.data.users[this.userId].role.name;
|
if (listItemElement === null) {return;}
|
||||||
if (userRole !== ('Administrator' || 'Contributor')) {
|
let itemId = listItemElement.dataset.id;
|
||||||
app.flash('You need the "Contributor" or "Administrator" role to perform this action.', 'error');
|
let listActionElement = event.target.closest('.list-action-trigger[data-list-action]');
|
||||||
}
|
// ignore switch clicks, handle them by the onChange method instead
|
||||||
return;
|
if (listActionElement.classList.contains('switch')) {
|
||||||
|
event.preventDefault();
|
||||||
|
this.onChange(event);
|
||||||
}
|
}
|
||||||
let actionButtonElement = event.target.closest('.list-action-trigger');
|
let listAction = listActionElement === null ? 'view' : listActionElement.dataset.listAction;
|
||||||
let action = actionButtonElement === null ? 'view' : actionButtonElement.dataset.listAction;
|
switch (listAction) {
|
||||||
let tesseractOCRPipelineModelElement = event.target.closest('tr');
|
|
||||||
let tesseractOCRPipelineModelId = tesseractOCRPipelineModelElement.dataset.id;
|
|
||||||
switch (action) {
|
|
||||||
case 'delete-request': {
|
case 'delete-request': {
|
||||||
Utils.deleteTesseractOCRPipelineModelRequest(this.userId, tesseractOCRPipelineModelId);
|
Utils.deleteTesseractOCRPipelineModelRequest(this.userId, itemId);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'view': {
|
case 'view': {
|
||||||
window.location.href = `/contributions/tesseract-ocr-pipeline-models/${tesseractOCRPipelineModelId}`;
|
window.location.href = `/contributions/tesseract-ocr-pipeline-models/${itemId}`;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
@ -159,4 +161,41 @@ class TesseractOCRPipelineModelList extends ResourceList {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onPatch(patch) {
|
||||||
|
let re = new RegExp(`^/users/${this.userId}/tesseract_ocr_pipeline_models/([A-Za-z0-9]*)`);
|
||||||
|
let filteredPatch = patch.filter(operation => re.test(operation.path));
|
||||||
|
for (let operation of filteredPatch) {
|
||||||
|
switch(operation.op) {
|
||||||
|
case 'add': {
|
||||||
|
let re = new RegExp(`^/users/${this.userId}/tesseract_ocr_pipeline_models/([A-Za-z0-9]*)$`);
|
||||||
|
if (re.test(operation.path)) {this.add(operation.value);}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'remove': {
|
||||||
|
let re = new RegExp(`^/users/${this.userId}/tesseract_ocr_pipeline_models/([A-Za-z0-9]*)$`);
|
||||||
|
if (re.test(operation.path)) {
|
||||||
|
let [match, itemId] = operation.path.match(re);
|
||||||
|
this.remove(itemId);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'replace': {
|
||||||
|
let re = new RegExp(`^/users/${this.userId}/tesseract_ocr_pipeline_models/([A-Za-z0-9]*)/(is_public)$`);
|
||||||
|
if (re.test(operation.path)) {
|
||||||
|
let [match, itemId, valueName] = operation.path.match(re);
|
||||||
|
if (valueName === 'is_public') {
|
||||||
|
this.listjs.list.querySelector(`.list-item[data-id="${itemId}"] .is-public`).checked = operation.value;
|
||||||
|
valueName = 'is-public';
|
||||||
|
}
|
||||||
|
this.replace(itemId, valueName, operation.value);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -563,7 +563,7 @@ class Utils {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static shareTesseractOCRPipelineModelRequest(userId, tesseractOCRPipelineModelId, is_public) {
|
static tesseractOCRPipelineModelToggleIsPublicRequest(userId, tesseractOCRPipelineModelId, is_public) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let tesseractOCRPipelineModel;
|
let tesseractOCRPipelineModel;
|
||||||
try {
|
try {
|
||||||
@ -572,28 +572,24 @@ class Utils {
|
|||||||
tesseractOCRPipelineModel = {};
|
tesseractOCRPipelineModel = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
let msg = '';
|
|
||||||
if (is_public) {
|
|
||||||
msg = `Model "${tesseractOCRPipelineModel?.title}" is now public`;
|
|
||||||
} else {
|
|
||||||
msg = `Model "${tesseractOCRPipelineModel?.title}" is now private`;
|
|
||||||
}
|
|
||||||
fetch(`/contributions/tesseract-ocr-pipeline-models/${tesseractOCRPipelineModelId}/toggle-public-status`, {method: 'POST', headers: {Accept: 'application/json'}})
|
fetch(`/contributions/tesseract-ocr-pipeline-models/${tesseractOCRPipelineModelId}/toggle-public-status`, {method: 'POST', headers: {Accept: 'application/json'}})
|
||||||
.then(
|
.then(
|
||||||
(response) => {
|
(response) => {
|
||||||
if (response.status === 403) {app.flash('Forbidden', 'error'); reject(response);}
|
if (response.status === 403) {
|
||||||
app.flash(msg);
|
app.flash('Forbidden', 'error');
|
||||||
resolve(response);
|
reject(response);
|
||||||
},
|
}
|
||||||
(response) => {
|
resolve(response);
|
||||||
app.flash('Something went wrong', 'error');
|
},
|
||||||
reject(response);
|
(response) => {
|
||||||
}
|
app.flash('Something went wrong', 'error');
|
||||||
);
|
reject(response);
|
||||||
|
}
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static shareSpaCyNLPPipelineModelRequest(userId, spaCyNLPPipelineModelId, is_public) {
|
static spaCyNLPPipelineModelToggleIsPublicRequest(userId, spaCyNLPPipelineModelId) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let spaCyNLPPipelineModel;
|
let spaCyNLPPipelineModel;
|
||||||
try {
|
try {
|
||||||
@ -602,24 +598,20 @@ class Utils {
|
|||||||
spaCyNLPPipelineModel = {};
|
spaCyNLPPipelineModel = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
let msg = '';
|
|
||||||
if (is_public) {
|
|
||||||
msg = `Model "${spaCyNLPPipelineModel?.title}" is now public`;
|
|
||||||
} else {
|
|
||||||
msg = `Model "${spaCyNLPPipelineModel?.title}" is now private`;
|
|
||||||
}
|
|
||||||
fetch(`/contributions/spacy-nlp-pipeline-models/${spaCyNLPPipelineModelId}/toggle-public-status`, {method: 'POST', headers: {Accept: 'application/json'}})
|
fetch(`/contributions/spacy-nlp-pipeline-models/${spaCyNLPPipelineModelId}/toggle-public-status`, {method: 'POST', headers: {Accept: 'application/json'}})
|
||||||
.then(
|
.then(
|
||||||
(response) => {
|
(response) => {
|
||||||
if (response.status === 403) {app.flash('Forbidden', 'error'); reject(response);}
|
if (response.status === 403) {
|
||||||
app.flash(msg);
|
app.flash('Forbidden', 'error');
|
||||||
resolve(response);
|
reject(response);
|
||||||
},
|
}
|
||||||
(response) => {
|
resolve(response);
|
||||||
app.flash('Something went wrong', 'error');
|
},
|
||||||
reject(response);
|
(response) => {
|
||||||
}
|
app.flash('Something went wrong', 'error');
|
||||||
);
|
reject(response);
|
||||||
|
}
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user