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}"; -
+
+
+ July 4th, 2042 + at 23:59:59 +
+ +
+ Zac le boss + 192.168.0.0 +
+ +
+ + +
+ info 2 + info 1 +
+
+ +
+ WIP + tag #99 +
+ +
+ +
+
+ detail 1 +
+
+ detail 2 +
+
+ detail 3 +
+
+
+ + {*
July 4th, 2042 at 23:59:59 @@ -193,47 +233,7 @@ const API_METHOD = "{$API_METHOD}"; detail 3
-
- -
-
- July 4th, 2042 - at 23:59:59 -
- -
- Zac le boss - 127.0.0.1 -
- -
- - -
- info 2 - info 1 -
-
- -
- WIP - tag #99 -
- -
- -
-
- detail 1 -
-
- detail 2 -
-
- detail 3 -
-
-
+ *} diff --git a/include/ws_functions/pwg.php b/include/ws_functions/pwg.php index 00fd1e3b1..cd7e23c93 100644 --- a/include/ws_functions/pwg.php +++ b/include/ws_functions/pwg.php @@ -867,6 +867,7 @@ SELECT $user_string = ''; if (isset($username_of[$line['user_id']])) { + $user_name = $username_of[$line['user_id']]; $user_string.= $username_of[$line['user_id']]; } else @@ -961,9 +962,10 @@ SELECT array_push( $result, array( - 'DATE' => $line['date'], + 'DATE' => format_date($line['date']), 'TIME' => $line['time'], 'USER' => $user_string, + 'USERNAME' => $user_name, 'IP' => $line['IP'], 'IMAGE' => $image_string, 'TYPE' => $line['image_type'],