Commit e3a46b34 authored by Gradl, Tobias's avatar Gradl, Tobias
Browse files

458: Implement datamodel detail page (OPENED)

Task-Url: search#458
parent d8595aa2
var editor;
$(document).ready(function() {
editor = new DatamodelEditor();
});
var DatamodelEditor = function() {
this.init();
}
DatamodelEditor.prototype.init = function() {
this.options = {
refreshInterval: __properties.refreshIntervalMs,
cyclicRefresh: __properties.refreshViews
};
__translator.addTranslations([
"~eu.dariah.de.minfba.search.view.datamodels.confirm_clear_index",
"~eu.dariah.de.minfba.search.view.datamodels.info_resync.head",
"~eu.dariah.de.minfba.search.view.datamodels.info_resync.body",
"~eu.dariah.de.minfba.common.error.servererror.head",
"~eu.dariah.de.minfba.common.error.servererror.body",
"~eu.dariah.de.minfba.search.view.datamodels.confirm_drop",
"~eu.dariah.de.minfba.search.view.crawl.dialog.recreate_index.actions.online",
"~eu.dariah.de.minfba.search.view.crawl.dialog.recreate_index.actions.offline",
"~eu.dariah.de.minfba.search.view.crawl.dialog.recreate_index.head",
"~eu.dariah.de.minfba.search.view.crawl.dialog.recreate_index.body",
"~eu.dariah.de.minfba.common.actions.cancel"
]);
__translator.getTranslations();
var _this = this;
}
DatamodelEditor.prototype.triggerClearIndex = function (id) {
bootbox.confirm(__translator.translate("~eu.dariah.de.minfba.search.view.datamodels.confirm_clear_index"), function(result) {
if(result) {
$.ajax({
url: __util.composeRelativeUrl("async/triggerClear"),
type: "GET",
dataType: "json",
success: function(data) {
__notifications.showTranslatedMessage(NOTIFICATION_TYPES.INFO,
"~eu.dariah.de.minfba.search.view.datamodels.info_resync.head",
"~eu.dariah.de.minfba.search.view.datamodels.info_resync.body");
},
error: function(textStatus) {
__notifications.showTranslatedMessage(NOTIFICATION_TYPES.ERROR,
"~eu.dariah.de.minfba.common.error.servererror.head",
"~eu.dariah.de.minfba.common.error.servererror.body");
}
});
}
});
};
DatamodelEditor.prototype.triggerDropDatamodel = function (datamodelId) {
var _this = this;
bootbox.confirm(__translator.translate("~eu.dariah.de.minfba.search.view.datamodels.confirm_drop"), function(result) {
if(result) {
$.ajax({
url: __util.composeRelativeUrl("dropDatamodel"),
type: "GET",
dataType: "json",
success: function(data) {
_this.refresh();
},
error: __util.processServerError
});
}
});
};
DatamodelEditor.prototype.triggerReindexAll = function (id) {
var _this = this;
var buttons = {
cancel : {
label : __translator.translate("~eu.dariah.de.minfba.common.actions.cancel"),
className : 'btn btn-default',
},
offline : {
label : __translator.translate("~eu.dariah.de.minfba.search.view.crawl.dialog.recreate_index.actions.offline"),
className : 'btn btn-primary',
callback : function() {
_this.triggerClearRebuildIndex(id, false);
}
},
online : {
label : __translator.translate("~eu.dariah.de.minfba.search.view.crawl.dialog.recreate_index.actions.online"),
className : 'btn btn-default',
callback : function() {
_this.triggerClearRebuildIndex(id, true);
}
}
};
bootbox.dialog({
title : __translator.translate("~eu.dariah.de.minfba.search.view.crawl.dialog.recreate_index.head"),
message : __translator.translate("~eu.dariah.de.minfba.search.view.crawl.dialog.recreate_index.body"),
size: 'large',
buttons : buttons
});
};
DatamodelEditor.prototype.triggerClearRebuildIndex = function (id, online) {
$.ajax({
url: __util.composeRelativeUrl("async/triggerReindex"),
data: { online: online },
type: "GET",
dataType: "json",
success: function(data) {
__notifications.showTranslatedMessage(NOTIFICATION_TYPES.INFO,
"~eu.dariah.de.minfba.search.view.datamodels.info_resync.head",
"~eu.dariah.de.minfba.search.view.datamodels.info_resync.body");
},
error: function(textStatus) {
__notifications.showTranslatedMessage(NOTIFICATION_TYPES.ERROR,
"~eu.dariah.de.minfba.common.error.servererror.head",
"~eu.dariah.de.minfba.common.error.servererror.body");
}
});
};
\ No newline at end of file
var editor;
$(document).ready(function() {
editor = new DatamodelEditor();
editor = new DatamodelsEditor();
$("#btn-sync").click(function() { editor.triggerSync(); });
$("#btn-force-offline").click(function() { editor.triggerOffline(); });
//$("#btn-add-collection").click(function() { editor.triggerAddCollection(); });
});
var DatamodelEditor = function() {
var DatamodelsEditor = function() {
this.prepareTranslations([
"~eu.dariah.de.minfba.search.view.datamodels.confirm_resync_dme.head",
"~eu.dariah.de.minfba.search.view.datamodels.confirm_resync_dme.body",
......@@ -33,10 +33,10 @@ var DatamodelEditor = function() {
})
};
DatamodelEditor.prototype = new BaseTable(__util.getBaseUrl() + "datamodels/async/getData", "#datamodels-table-container");
DatamodelsEditor.prototype = new BaseTable(__util.getBaseUrl() + "datamodels/async/getData", "#datamodels-table-container");
DatamodelEditor.prototype.createTable = function() {
DatamodelsEditor.prototype.createTable = function() {
this._base.table = $('#datamodels-table').DataTable($.extend(true, {
"order": [[1, "asc"]],
"columnDefs": [
......@@ -63,20 +63,25 @@ DatamodelEditor.prototype.createTable = function() {
"visible" : __util.uauth,
"class" : "td-no-wrap",
"data": function (row, type, val, meta) { return editor.renderActionColumn(row, type, val, meta); }
}
}, {
"targets": [0,1,2,3,4],
"render": function ( data, type, row, meta ) {
return '<a href="' + __util.composeRelativeUrl(row.entity.id) + '/">' + data + '</a>';
}
}
],
"rowCallback": this.setRowState
}, this.baseSettings));
};
DatamodelEditor.prototype.assignEvents = function() { };
DatamodelsEditor.prototype.assignEvents = function() { };
DatamodelEditor.prototype.setRowState = function(row, data) {
DatamodelsEditor.prototype.setRowState = function(row, data) {
var state = editor.getState(data.entity);
$(row).addClass("state-row-" + state);
};
DatamodelEditor.prototype.getState = function(entity) {
DatamodelsEditor.prototype.getState = function(entity) {
if (entity.error) {
return "error"
} else if (entity.warning || entity.deleted || !entity.available || entity.outdated) {
......@@ -88,7 +93,7 @@ DatamodelEditor.prototype.getState = function(entity) {
}
};
DatamodelEditor.prototype.getIcon = function(entity) {
DatamodelsEditor.prototype.getIcon = function(entity) {
if (entity.deleted) {
return "fas fa-trash-alt";
} else if (entity.error || entity.warning) {
......@@ -104,7 +109,7 @@ DatamodelEditor.prototype.getIcon = function(entity) {
}
};
DatamodelEditor.prototype.getDmeStatus = function() {
DatamodelsEditor.prototype.getDmeStatus = function() {
$.ajax({
url: __util.composeRelativeUrl("getDmeStatus"),
type: "GET",
......@@ -163,7 +168,7 @@ DatamodelEditor.prototype.getDmeStatus = function() {
});
};
DatamodelEditor.prototype.renderStateColumn = function(row, type, val, meta) {
DatamodelsEditor.prototype.renderStateColumn = function(row, type, val, meta) {
if (type==="display") {
var nodes = this._base.table.column(meta.column).nodes();
$(nodes[meta.row]).addClass("state-" + this.getState(row.entity));
......@@ -175,7 +180,7 @@ DatamodelEditor.prototype.renderStateColumn = function(row, type, val, meta) {
}
};
DatamodelEditor.prototype.renderActionColumn = function(row, type, val, meta) {
DatamodelsEditor.prototype.renderActionColumn = function(row, type, val, meta) {
if (type!=="display") {
return "";
}
......@@ -184,8 +189,8 @@ DatamodelEditor.prototype.renderActionColumn = function(row, type, val, meta) {
//result += '<a class="btn btn-link" target="_blank" href="' + row.entity.linkUrl + '"><i class="fas fa-external-link-alt" aria-hidden="true"></i> ' + __translator.translate("~eu.dariah.de.minfba.search.view.models.show_in_DME") + '</a>';
if (__util.ulevel >= 100) {
result += "<button type='button' onclick='editor.triggerClearIndex(\"" + row.entity.id + "\"); return false;' class='btn btn-link'><i class='fas fa-sync-alt'></i> " + __translator.translate("~eu.dariah.de.minfba.search.actions.datamodels.clear") + "</button>";
result += "<button type='button' onclick='editor.triggerDropDatamodel(\"" + row.entity.id + "\"); return false;' class='btn btn-link'><span class='fas fa-trash-alt'></span> " + __translator.translate("~eu.dariah.de.minfba.common.actions.delete") + "</button>";
//result += "<button type='button' onclick='editor.triggerClearIndex(\"" + row.entity.id + "\"); return false;' class='btn btn-link'><i class='fas fa-sync-alt'></i> " + __translator.translate("~eu.dariah.de.minfba.search.actions.datamodels.clear") + "</button>";
//result += "<button type='button' onclick='editor.triggerDropDatamodel(\"" + row.entity.id + "\"); return false;' class='btn btn-link'><span class='fas fa-trash-alt'></span> " + __translator.translate("~eu.dariah.de.minfba.common.actions.delete") + "</button>";
}
/*result += "<div class='btn-group'>" +
......@@ -203,51 +208,7 @@ DatamodelEditor.prototype.renderActionColumn = function(row, type, val, meta) {
return result;
};
DatamodelEditor.prototype.triggerClearIndex = function (id) {
bootbox.confirm(__translator.translate("~eu.dariah.de.minfba.search.view.datamodels.confirm_clear_index"), function(result) {
if(result) {
$.ajax({
url: __util.composeRelativeUrl("async/triggerClear"),
data: { datamodelId: id },
type: "GET",
dataType: "json",
success: function(data) {
__notifications.showTranslatedMessage(NOTIFICATION_TYPES.INFO,
"~eu.dariah.de.minfba.search.view.datamodels.info_resync.head",
"~eu.dariah.de.minfba.search.view.datamodels.info_resync.body");
},
error: function(textStatus) {
__notifications.showTranslatedMessage(NOTIFICATION_TYPES.ERROR,
"~eu.dariah.de.minfba.common.error.servererror.head",
"~eu.dariah.de.minfba.common.error.servererror.body");
}
});
}
});
};
DatamodelEditor.prototype.triggerDropDatamodel = function (datamodelId) {
var _this = this;
bootbox.confirm("~eu.dariah.de.minfba.search.view.datamodels.confirm_drop", function(result) {
if(result) {
$.ajax({
url: __util.composeRelativeUrl("dropDatamodel?datamodelId=" + datamodelId),
type: "GET",
dataType: "json",
success: function(data) {
_this.refresh();
},
error: __util.processServerError
});
}
});
};
DatamodelEditor.prototype.triggerClearRebuildIndex = function (id) {
alert(id);
};
DatamodelEditor.prototype.triggerSync = function () {
DatamodelsEditor.prototype.triggerSync = function () {
bootbox.confirm({
title: __translator.translate("~eu.dariah.de.minfba.search.view.datamodels.confirm_resync_dme.head"),
message: __translator.translate("~eu.dariah.de.minfba.search.view.datamodels.confirm_resync_dme.body"),
......@@ -269,7 +230,7 @@ DatamodelEditor.prototype.triggerSync = function () {
});
};
DatamodelEditor.prototype.triggerOffline = function () {
DatamodelsEditor.prototype.triggerOffline = function () {
bootbox.confirm(__translator.translate("~eu.dariah.de.minfba.search.view.collection.confirm_force_offline"), function(result) {
if(result) {
$.ajax({
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment