diff --git a/admin/themes/default/js/history.js b/admin/themes/default/js/history.js index 77049cd53..18976b097 100644 --- a/admin/themes/default/js/history.js +++ b/admin/themes/default/js/history.js @@ -1,4 +1,6 @@ $(document).ready(() => { + + fillHistoryResult() $(".filter").submit(function (e) { e.preventDefault(); @@ -35,8 +37,11 @@ $(document).ready(() => { console.log("RESULTS"); console.log(data); + var id = 0; + data.forEach(line => { - lineConstructor(line) + lineConstructor(line, id) + id++ }); }, error: function (e) { @@ -47,10 +52,83 @@ $(document).ready(() => { console.log(dataObj); }); - function lineConstructor(line) { - // console.log(line); + function fillHistoryResult() { + + var dateObj = new Date(); + var month = dateObj.getUTCMonth() + 1; //months from 1-12 + var day = dateObj.getUTCDate(); + var year = dateObj.getUTCFullYear(); + + if (month < 10) month = "0" + month; + if (day < 10) day = "0" + day; + + today = year + "-" + month + "-" + day; + + var dataSend = { + start: "", + end: today, + types: { + 0: "none", + 1: "picture", + 2: "high", + 3: "other" + }, + user: "-1", + image_id: "", + filename: "", + ip: "", + display_thumbnail: "no_display_thumbnail", + } + + $.ajax({ + url: API_METHOD, + method: "POST", + dataType: "JSON", + data: dataSend, + success: function (raw_data) { + $(".loading").removeClass("hide"); + data = raw_data.result; + console.log("RESULTS"); + console.log(data); + + var id = 0; + + data.forEach(line => { + lineConstructor(line, id) + id++ + }); + }, + error: function (e) { + console.log("Something went wrong: " + e); + } + }).done(() => { + $(".loading").addClass("hide"); + }) } + function lineConstructor(line, id) { + let newLine = $("#-1").clone(); + + newLine.removeClass("hide"); + + /* console log to help debug */ + console.log(line); + newLine.attr("id", id); + console.log(id); + + newLine.find(".date-day").html(line.DATE); + newLine.find(".date-hour").html(line.TIME); + + newLine.find(".user-name").html(line.USERNAME); + newLine.find(".user-ip").html(line.IP); + + displayLine(newLine); + } + + function displayLine(line) { + $(".tab").append(line); +} + $(".search-line").find(".img-option").hide(); /* Display the option on the click on "..." */ diff --git a/admin/themes/default/template/history.tpl b/admin/themes/default/template/history.tpl index 6127d3ae0..08a551871 100644 --- a/admin/themes/default/template/history.tpl +++ b/admin/themes/default/template/history.tpl @@ -155,7 +155,47 @@ const API_METHOD = "{$API_METHOD}"; -