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

803: Complete collection view

Task-Url: https://pm.winseda.de/issues/803
parent 0139f805
......@@ -55,6 +55,20 @@
background-color: white;
}
/*!
* Recent functionality additions (no-refactor-zone)
*/
.inline-button {
cursor: pointer;
display: inline;
}
.inline-button:hover,
.inline-button:focus {
text-decoration: underline;
}
/*!
* Some basic table layout
*/
......@@ -228,7 +242,7 @@ table.state-table tbody tr.state-row-ok td {
.state-default { color: #ABABAB; font-weight: normal; }
.state-ok { color: #419641; font-weight: normal; }
.state-info { color: #2AABD2; font-weight: bold; }
.state-warning { color: #EB9316; font-weight: bold; }
.state-warning { color: /*#EB9316*/#D97F00; font-weight: bold; }
.state-danger, .state-error { color: #AC2925; font-weight: bold; }
.state-table tbody td {
......
var _csrf = $('meta[name=_csrf]').attr("content");
var _csrfHeader = $('meta[name=_csrf_header]').attr("content");
var lang = $('html').attr("lang");
/*$.ajaxSetup({
beforeSend: function(xhr, settings) {
......
......@@ -23,17 +23,17 @@ CollectionsEditor.prototype = new BaseTable(__util.getBaseUrl() + "collections/a
CollectionsEditor.prototype.createTable = function() {
var _this = this;
this._base.table = $('#collections-table').DataTable($.extend(true, {
"order": [[1, "asc"]],
"order": [[5, "asc"]],
"columnDefs": [
{
"targets": [0], "class": "center", "cellType": "th",
"data": function (row, type, val, meta) { return editor.renderStateColumn(row, type, val, meta); }
}, {
"targets": [1], "class": "center",
"data": function (row, type, val, meta) { return row.entity.dataset.docs.toLocaleString(); }
"data": function (row, type, val, meta) { return row.entity.dataset.docs.toLocaleString(lang); }
}, {
"targets": [2],
"data": "entity.endpoint.url"
"data": function (row, type, val, meta) { return editor.renderUrlColumn(row, type, val, meta); }
}, {
"targets": [3],
"data": "entity.endpoint.method"
......@@ -52,14 +52,14 @@ CollectionsEditor.prototype.createTable = function() {
}
}, this.baseSettings));
/*$('#collections-table tbody').on('click', 'tr', function () {
$('#collections-table tbody').on('click', 'tr', function () {
var data = _this._base.table.row(this).data()
if (data===undefined) {
window.location = __util.composeRelativeUrl($(this).prop("id") + "/");
} else {
window.location = __util.composeRelativeUrl(data.entity.id);
}
});*/
});
};
CollectionsEditor.prototype.setGroupRow = function(rows, group) {
......@@ -80,7 +80,6 @@ CollectionsEditor.prototype.setGroupRow = function(rows, group) {
.append( '<th class="state-' + overallState + '"></th>' )
.append( '<td colspan="4">' +
'<span class="group-heading">' + rows.data()[0].entity.collection.name + '</span><br />' +
'ID:' + group +
'</td>' );
}
......@@ -101,6 +100,13 @@ CollectionsEditor.prototype.renderStateColumn = function(row, type, val, meta) {
}
};
CollectionsEditor.prototype.renderUrlColumn = function(row, type, val, meta) {
if (row.entity.endpoint.set!==undefined && row.entity.endpoint.set!==null && row.entity.endpoint.set.length>0) {
return row.entity.endpoint.url + " [" + row.entity.endpoint.set + "]";
}
return row.entity.endpoint.url
};
CollectionsEditor.prototype.getIcon = function(entity) {
if (entity.error || entity.warning) {
return "exclamation";
......
......@@ -14,7 +14,8 @@ var SchemaEditor = function() {
"~eu.dariah.de.minfba.common.status.deleted",
"~eu.dariah.de.minfba.common.status.ok",
"~eu.dariah.de.minfba.common.status.outdated",
"~eu.dariah.de.minfba.search.view.api.status_code"
"~eu.dariah.de.minfba.search.view.api.status_code",
"~eu.dariah.de.minfba.search.view.models.show_in_DME"
]);
this.createTable();
......@@ -30,18 +31,17 @@ SchemaEditor.prototype.createTable = function() {
"order": [[1, "asc"]],
"columnDefs": [
{
"targets": [0],
"class" : "td-no-wrap",
"targets": [0], "class": "center", "cellType": "th",
"sortable" : false,
"data": function (row, type, val, meta) { return editor.renderBadgeColumn(row, type, val, meta); }
"data": function (row, type, val, meta) { return editor.renderStateColumn(row, type, val, meta); }
}, {
"targets": [1],
"data": function (row, type, val, meta) { return editor.renderNameColumn(row, type, val, meta); },
"width" : "75%"
}, {
"targets": [2],
"data" : "entity.indexName",
"width" : "25%"
}, {
"targets": [3],
"data" : "entity.docs",
......@@ -53,12 +53,46 @@ SchemaEditor.prototype.createTable = function() {
"class" : "td-no-wrap",
"data": function (row, type, val, meta) { return editor.renderActionColumn(row, type, val, meta); }
}
]
],
"rowCallback": this.setRowState
}, this.baseSettings));
};
SchemaEditor.prototype.assignEvents = function() { };
SchemaEditor.prototype.setRowState = function(row, data) {
var state = editor.getState(data.entity);
$(row).addClass("state-row-" + state);
};
SchemaEditor.prototype.getState = function(entity) {
if (entity.error) {
return "error"
} else if (entity.warning || entity.deleted || !entity.available || entity.outdated) {
return "warning";
} else if (entity.processing || entity.waiting || entity.busy) {
return "info";
} else {
return "ok";
}
};
SchemaEditor.prototype.getIcon = function(entity) {
if (entity.error || entity.warning) {
return "exclamation";
} else if (entity.deleted) {
return "trash";
} else if (!entity.available) {
return "question";
} else if (entity.processing || entity.busy || entity.outdated) {
return "refresh";
} else if (entity.waiting) {
return "clock-o";
} else {
return "check";
}
};
SchemaEditor.prototype.getScheregStatus = function() {
$.ajax({
url: __util.composeRelativeUrl("getScheregStatus"),
......@@ -103,26 +137,21 @@ SchemaEditor.prototype.getScheregStatus = function() {
SchemaEditor.prototype.renderNameColumn = function(row, type, val, meta) {
var result = row.entity.name;
if (type==="display") {
result += ' <a title="' + __translator.translate("~eu.dariah.de.minfba.search.view.schemas.show_in_SR") + '" href="' + row.entity.linkUrl + '" target="_blank"><span class="glyphicon glyphicon-new-window" aria-hidden="true"></span></a>';
result += ' <a title="' + __translator.translate("~eu.dariah.de.minfba.search.view.models.show_in_DME") + '" href="' + row.entity.linkUrl + '" target="_blank"><span class="glyphicon glyphicon-new-window" aria-hidden="true"></span></a>';
}
return result;
};
SchemaEditor.prototype.renderBadgeColumn = function(row, type, val, meta) {
var result = "";
if (type==="display") {
SchemaEditor.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));
if (row.entity.deleted) {
result += '<span class="label label-danger">' + __translator.translate("~eu.dariah.de.minfba.common.status.deleted") + '</span> ';
} else if (row.entity.outdated) {
result += '<span class="label label-warning">' + __translator.translate("~eu.dariah.de.minfba.common.status.outdated") + '</span> ';
} else {
result += '<span class="label label-success">' + __translator.translate("~eu.dariah.de.minfba.common.status.ok") + '</span> ';
}
} else if (type==="filter" || type==="sort") {
// ?
return "<i class='fa fa-lg fa-" + this.getIcon(row.entity) + "' aria-hidden='true'></i>";
} else {
// TODO: render some status message instead
return this.getIcon(row.entity);
}
return result;
};
SchemaEditor.prototype.renderActionColumn = function(row, type, val, meta) {
......@@ -131,8 +160,8 @@ SchemaEditor.prototype.renderActionColumn = function(row, type, val, meta) {
}
var result = "";
result += "<button type='button' onclick='editor.triggerClearIndex(\"" + row.entity.id + "\"); return false;' class='btn btn-xs btn-default'><span class='glyphicon glyphicon-retweet'></span> " + __translator.translate("~eu.dariah.de.minfba.search.actions.schemas.clear") + "</button>";
result += "<button type='button' onclick='editor.triggerDropSchema(\"" + row.entity.id + "\"); return false;' class='btn btn-xs btn-default'><span class='glyphicon glyphicon-trash'></span> ~Delete</button>";
result += "<button type='button' onclick='editor.triggerClearIndex(\"" + row.entity.id + "\"); return false;' class='btn btn-xs btn-link'><span class='glyphicon glyphicon-retweet'></span> " + __translator.translate("~eu.dariah.de.minfba.search.actions.schemas.clear") + "</button>";
result += "<button type='button' onclick='editor.triggerDropSchema(\"" + row.entity.id + "\"); return false;' class='btn btn-xs btn-link'><span class='glyphicon glyphicon-trash'></span> ~Delete</button>";
/*result += "<div class='btn-group'>" +
"<button type='button' class='btn btn-default btn-xs'>~ View stats</button>" +
......
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