color, messages, logs, object groups
color fixed scrollbar; messages fixes & added date type; object groups changed button layout; logs fixes & added logs delition
This commit is contained in:
parent
72e973cd71
commit
c998dbb68e
12
db.js
12
db.js
|
@ -37,6 +37,18 @@ module.exports.dl = (table,key,value,callback,prevs = false) => {
|
|||
})
|
||||
}
|
||||
|
||||
module.exports.dl_con = (table,condision,callback,prevs = false) => {
|
||||
// console.log('SELECT * FROM `'+table+'` WHERE `'+key+'` = '+value);
|
||||
db(prevs).query(`DELETE FROM ${table} WHERE ${condision}`, (err, rows, fields) => {
|
||||
if (err) {
|
||||
console.log("sql err");
|
||||
throw err;
|
||||
}else{
|
||||
if(callback)callback(rows);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// get values where
|
||||
module.exports.gv = (table,key,value,callback,prevs = false) => {
|
||||
// console.log(`SELECT * FROM ${table} WHERE ${key} = ${value}`);
|
||||
|
|
24
func.js
24
func.js
|
@ -129,14 +129,26 @@ module.exports.logs_file = (res)=>{
|
|||
module.exports.get_logs = (res)=>{
|
||||
db.gav("logs","0",(db_logs)=>{
|
||||
let logs_str = "";
|
||||
for (let i = Object.keys(db_logs).length-1; i >= 0; i--) {
|
||||
const log = Object.values(db_logs)[i];
|
||||
let date = moment(log[`date_time`]).utc().format('YYYY-MM-DD');
|
||||
logs_str+=`${date}_${log.time}|${log.log} \n`;
|
||||
if(i == 0){
|
||||
res.send(logs_str);
|
||||
if(Object.keys(db_logs).length > 0){
|
||||
for (let i = Object.keys(db_logs).length-1; i >= 0; i--) {
|
||||
const log = Object.values(db_logs)[i];
|
||||
let date = moment(log[`date_time`]).format('YYYY-MM-DD');
|
||||
logs_str+=`${date}_${log.time}|${log.log} \n`;
|
||||
if(i == 0){
|
||||
res.send({out:"good",body:logs_str});
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
res.send({out:"good",body:logs_str});
|
||||
}
|
||||
},true);
|
||||
}
|
||||
|
||||
module.exports.del_logs = (inp,res)=>{
|
||||
if(inp["date"] == '')inp["date"] = moment().format('YYYY-MM-DD');
|
||||
db.dl_con("logs",`date = '${inp["date"]}'`,(db_logs)=>{
|
||||
this.get_logs(res);
|
||||
},true);
|
||||
}
|
||||
|
||||
|
|
21
index.js
21
index.js
|
@ -389,7 +389,7 @@ app.post("/template/loads", (req,res) => {try{
|
|||
|
||||
// main routes
|
||||
app.get('/', (req, res) => {
|
||||
let inp = req.body;
|
||||
let inp = req.query;
|
||||
let cook = req.cookies;
|
||||
func.sid(cook,res,(include)=>{
|
||||
if(include){
|
||||
|
@ -401,28 +401,35 @@ app.get('/', (req, res) => {
|
|||
},false)
|
||||
});
|
||||
app.get("/main", (req,res) =>{try{
|
||||
let inp = req.body;let cook = req.cookies;
|
||||
let inp = req.query;let cook = req.cookies;
|
||||
func.sid(cook,res,()=>{
|
||||
res.render('main');
|
||||
})
|
||||
} catch (error) {route_err({req:req,error:error});}
|
||||
});
|
||||
app.get("/logs", (req,res) =>{try{
|
||||
let inp = req.body;let cook = req.cookies;
|
||||
app.get("/logs/get", (req,res) =>{try{
|
||||
let inp = req.query;let cook = req.cookies;
|
||||
func.sid(cook,res,()=>{
|
||||
func.get_logs(res);
|
||||
})
|
||||
},true,true)
|
||||
} catch (error) {route_err({req:req,error:error});}
|
||||
});
|
||||
app.get("/logs/del", (req,res) =>{try{
|
||||
let inp = req.query;let cook = req.cookies;
|
||||
func.sid(cook,res,()=>{
|
||||
func.del_logs(inp,res);
|
||||
},true,true)
|
||||
} catch (error) {route_err({req:req,error:error});}
|
||||
});
|
||||
app.get("/help", (req,res) =>{try{
|
||||
let inp = req.body;let cook = req.cookies;
|
||||
let inp = req.query;let cook = req.cookies;
|
||||
func.sid(cook,res,()=>{
|
||||
res.render('help');
|
||||
})
|
||||
} catch (error) {route_err({req:req,error:error});}
|
||||
});
|
||||
app.get("/temp", (req,res) =>{try{
|
||||
let inp = req.body;let cook = req.cookies;
|
||||
let inp = req.query;let cook = req.cookies;
|
||||
func.sid(cook,res,()=>{
|
||||
res.render('templates');
|
||||
})
|
||||
|
|
|
@ -23,10 +23,10 @@
|
|||
<section style="display: flex;">
|
||||
<div style="width: 7.5vw;">
|
||||
<h1>Логи</h1>
|
||||
<button onclick="logs();" class="btn_white">Обновить</button>
|
||||
<br>
|
||||
<label for="logs_check" style="font-size: calc(var(--main-font-size)/1.5);">Автозагрузка</label>
|
||||
<input type="checkbox" id="logs_check" oninput="logs_check(event)">
|
||||
<button onclick="get_logs();" class="btn_blue" style="margin-block: 0.5vh;">Обновить</button>
|
||||
<button onclick="del_logs()" class="btn_blue" style="margin-block: 0.5vh; font-size: calc(var(--main-font-size)/1.4);">Удалить логи</button>
|
||||
<label for="logs_check" style="font-size: calc(var(--main-font-size)/1.5);" style="margin-block: 0.5vh;">Автозагрузка</label>
|
||||
<input type="checkbox" id="logs_check" oninput="logs_check(event)" style="margin-block: 0.5vh;">
|
||||
</div>
|
||||
<div id="logs" style="background-color: white;width: 70vw;font-size: calc(var(--main-font-size)/1.4);overflow: auto;height: 80vh;"></div>
|
||||
</section>
|
||||
|
@ -37,7 +37,7 @@
|
|||
function log_check(){
|
||||
if($.cookie("auto_log") != null){
|
||||
if(JSON.parse($.cookie("auto_log")) == true){
|
||||
logs();
|
||||
get_logs();
|
||||
}
|
||||
document.getElementById("logs_check").checked = JSON.parse($.cookie("auto_log"));
|
||||
}else{
|
||||
|
@ -46,16 +46,29 @@
|
|||
}
|
||||
}
|
||||
|
||||
function logs() {
|
||||
function get_logs() {
|
||||
let wait_msg = msg("Загрузка логов",{type:"wait"});
|
||||
$.get("/logs")
|
||||
$.get("/logs/get")
|
||||
.done(function( res ) {
|
||||
document.getElementById("logs").innerText = res;
|
||||
document.getElementById("logs").innerText = res["body"];
|
||||
msg_del(wait_msg.id);
|
||||
msg("Логи загружены")
|
||||
})
|
||||
}
|
||||
|
||||
function del_logs() {
|
||||
msg("date",{type:"date",res:(date)=>{if(date != false){
|
||||
let wait_msg = msg(`Удаление логов за ${date}`,{type:"wait"});
|
||||
$.get("/logs/del",{date:date})
|
||||
.done(function( res ) {
|
||||
document.getElementById("logs").innerText = res["body"];
|
||||
msg_del(wait_msg.id);
|
||||
msg("Логи удалены")
|
||||
})
|
||||
}
|
||||
}})
|
||||
}
|
||||
|
||||
function logs_check(event){
|
||||
let log_inp = event.target;
|
||||
let check = log_inp.checked;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<div id="admin_colors" style="display: flex;justify-content: space-between;margin-top: 4vh;">
|
||||
<div id="obj_color_div" style="justify-content: space-between; width: 50vw;display: flex;">
|
||||
<label for="obj_colors" style="min-width: 10vw;float: left;">цвет объекта</label>
|
||||
<div id="obj_colors" style="display: flex; width: 30vw;overflow: auto;"></div>
|
||||
<div id="obj_colors" style="display: flex; width: 30vw;overflow: auto;height: 4.5vh;"></div>
|
||||
</div>
|
||||
<div id="inp">
|
||||
<input type="color" id="new_color" style="margin: auto;">
|
||||
|
@ -24,6 +24,7 @@
|
|||
color_div.classList.add("color_palette");
|
||||
color_div.id=`color_${value["color"]}`;
|
||||
color_div.setAttribute("color_id",`${value["id"]}`)
|
||||
color_div.setAttribute("color",`${value["color"]}`)
|
||||
color_div.setAttribute("onclick",`clear_palette();document.getElementById('color_${value["color"]}').style.border = "1px blue solid";cur_color = 'color_${value["color"]}';`)
|
||||
color_div.title = `#${value["color"]}`;
|
||||
div.append(color_div);
|
||||
|
@ -48,17 +49,23 @@
|
|||
});
|
||||
}
|
||||
function del_color(){
|
||||
let color_id = document.getElementById(cur_color).getAttribute("color_id")
|
||||
msg("Удалить этот цвет?",{type:"ask",res:(out)=>{if(out){
|
||||
$.post( "/admin/colors/delete", {id:color_id})
|
||||
.done(function( res ) {
|
||||
if(res["out"] == "good"){
|
||||
msg("цвет удалён");
|
||||
obj_colors_load();
|
||||
console.log(res["body"]);
|
||||
}
|
||||
});
|
||||
}}})
|
||||
if(document.getElementById(cur_color) == null){
|
||||
msg("Цвет не выбран",{type:"warning"});
|
||||
}
|
||||
else{
|
||||
let color_id = document.getElementById(cur_color).getAttribute("color_id")
|
||||
let color = document.getElementById(cur_color).getAttribute("color")
|
||||
msg("Удалить этот цвет?",{type:"ask",res:(out)=>{if(out){
|
||||
$.post( "/admin/colors/delete", {id:color_id,color:color})
|
||||
.done(function( res ) {
|
||||
if(res["out"] == "good"){
|
||||
msg("цвет удалён");
|
||||
obj_colors_load();
|
||||
console.log(res["body"]);
|
||||
}
|
||||
});
|
||||
}}})
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
|
@ -45,16 +45,16 @@
|
|||
}
|
||||
</style>
|
||||
|
||||
<h1>Изменение объектов</h1>
|
||||
<div style="display: flex;justify-content: space-between;padding-block: 1vw;">
|
||||
<h1>Изменение объектов</h1>
|
||||
<div id="find_obj_btns">
|
||||
<button onclick="edit_get_objs(true)" class="btn_blue">Найти по имени</button>
|
||||
<button onclick='gids = [];edit_get_objs();' class="btn_blue">Сбосить</button>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div id="objs_in_group"></div>
|
||||
</div>
|
||||
<div style="display: flex;justify-content: space-between;float: right;">
|
||||
<div id="find_obj_btns">
|
||||
<button onclick="edit_get_objs(true)" class="btn_blue">найти по имени</button>
|
||||
<button onclick='gids = [];edit_get_objs();' class="btn_blue">очистить</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// load_groups(()=>{
|
||||
|
@ -304,10 +304,10 @@
|
|||
`<td>${divs["width"]}</td>`+
|
||||
`<td>${divs["cost"]}</td>`+
|
||||
`<td><a href='${divs["link"]}'>${divs["link"]}</a></td>`+
|
||||
`<td>${divs["color"]}</td>`+
|
||||
`<td><input type='checkbox' id='obj_edit_color_check' ${(divs["color"] == true)? "checked":""} onclick='return false' onkeydown='return false'/></td>`+
|
||||
`<td><button onclick='${divs["edit"]}' class='btn_blue'>Выбрать</button></td>`+
|
||||
"</tr>";
|
||||
|
||||
|
||||
obj_list.append(obj)
|
||||
|
||||
// console.log("obj");
|
||||
|
|
|
@ -36,6 +36,11 @@
|
|||
border: 0px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.yes-ans:hover, .no-ans:hover{
|
||||
transition-duration: 200ms;
|
||||
color: rgba(0, 144, 0, 0.5);
|
||||
transform: scale(1.05);
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
|
@ -44,6 +49,9 @@
|
|||
<script>
|
||||
let msg_int = 0;
|
||||
function msg(text,params = {type:null,time:null,res:null,def:null}){
|
||||
Object.values(document.getElementsByClassName("message")).forEach(element => {
|
||||
element.setAttribute("ans","false");
|
||||
});
|
||||
params.time = (params.time == null)? 8:params.time;
|
||||
params.type = (params.type == null)? "msg":params.type;
|
||||
msg_int++;
|
||||
|
@ -74,6 +82,9 @@
|
|||
case "wait":
|
||||
msg_div.style.borderColor = "rgba(0, 0, 255, 0.5)";
|
||||
break;
|
||||
case "date":
|
||||
msg_div.style.borderColor = "rgba(0, 255, 0, 0.5)";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -89,6 +100,8 @@
|
|||
no.innerText = "Нет";
|
||||
yes.classList.add("yes-ans")
|
||||
no.classList.add("no-ans")
|
||||
yes.classList.add("ans")
|
||||
no.classList.add("ans")
|
||||
yes.id = `${msg_div.id}-yes`;
|
||||
no.id = `${msg_div.id}-no`;
|
||||
q_div.append(yes)
|
||||
|
@ -101,10 +114,21 @@
|
|||
msg_div.setAttribute("ans","null")
|
||||
yes.setAttribute("onclick",`document.getElementById('${msg_div.id}').setAttribute("ans","true")`)
|
||||
no.setAttribute("onclick",`document.getElementById('${msg_div.id}').setAttribute("ans","false")`)
|
||||
yes.focus();
|
||||
yes.addEventListener('keydown', function(e) {
|
||||
if (e.keyCode === 13) {
|
||||
document.getElementById(`${msg_div.id}`).setAttribute("ans","true")
|
||||
}
|
||||
else if (e.keyCode === 27) {
|
||||
document.getElementById(`${msg_div.id}`).setAttribute("ans","false")
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
var observer = new MutationObserver(function(mutations) {
|
||||
mutations.forEach(function(mutation) {
|
||||
if (mutation.type = "attributes" && mutation.target.getAttribute("ans") != "null") {
|
||||
console.log(mutation);
|
||||
// console.log(mutation);
|
||||
if(mutation.target.getAttribute("ans") == "true"){
|
||||
params.res(true);fin();
|
||||
}
|
||||
|
@ -143,6 +167,8 @@
|
|||
no.innerText = "Отменить";
|
||||
yes.classList.add("yes-ans")
|
||||
no.classList.add("no-ans")
|
||||
yes.classList.add("ans")
|
||||
no.classList.add("ans")
|
||||
yes.id = `${msg_div.id}-yes`;
|
||||
no.id = `${msg_div.id}-no`;
|
||||
q_div.append(yes)
|
||||
|
@ -152,13 +178,22 @@
|
|||
msg_div.setAttribute("ans","null")
|
||||
yes.setAttribute("onclick",`document.getElementById('${msg_div.id}').setAttribute("ans","true")`)
|
||||
no.setAttribute("onclick",`document.getElementById('${msg_div.id}').setAttribute("ans","false")`)
|
||||
text.focus();
|
||||
text.addEventListener('keydown', function(e) {
|
||||
if (e.keyCode === 13) {
|
||||
document.getElementById(`${msg_div.id}`).setAttribute("ans","true")
|
||||
}
|
||||
else if (e.keyCode === 27) {
|
||||
document.getElementById(`${msg_div.id}`).setAttribute("ans","false")
|
||||
}
|
||||
})
|
||||
// document.getElementById("message_div").style.pointerEvents = "all";
|
||||
// document.getElementById("message_div").setAttribute("onclick",`document.getElementById('${msg_div.id}').setAttribute("ans","false")`)
|
||||
|
||||
var observer = new MutationObserver(function(mutations) {
|
||||
mutations.forEach(function(mutation) {
|
||||
if (mutation.type = "attributes" && mutation.target.getAttribute("ans") != "null") {
|
||||
console.log(mutation);
|
||||
// console.log(mutation);
|
||||
if(mutation.target.getAttribute("ans") == "true"){
|
||||
params.res(text.value);fin();
|
||||
}
|
||||
|
@ -182,7 +217,74 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
else if(params.type != "wait" && params.type != "ask"){
|
||||
if (params.type == "date"){
|
||||
// msg_div.setAttribute("onclick",`msg_del("msg_${msg_int}")`);
|
||||
let yes = document.createElement("button");
|
||||
let no = document.createElement("button");
|
||||
let q_div = document.createElement("div");
|
||||
let date = document.createElement("input");
|
||||
q_div.style = "display:flex;justify-content: space-between;z-index:20000";
|
||||
yes.innerText = "Да";
|
||||
no.innerText = "Нет";
|
||||
yes.classList.add("yes-ans")
|
||||
no.classList.add("no-ans")
|
||||
yes.classList.add("ans")
|
||||
no.classList.add("ans")
|
||||
yes.id = `${msg_div.id}-yes`;
|
||||
no.id = `${msg_div.id}-no`;
|
||||
q_div.append(yes)
|
||||
q_div.append(no)
|
||||
msg_div.append(date)
|
||||
msg_div.append(q_div)
|
||||
date.setAttribute("type","date");
|
||||
|
||||
// document.getElementById("message_div").style.pointerEvents = "all";
|
||||
// document.getElementById("message_div").setAttribute("onclick",`document.getElementById('${msg_div.id}').setAttribute("ans","false")`)
|
||||
let now = new Date().toLocaleDateString().split(".").reverse().join('-');;
|
||||
date.value = now;
|
||||
|
||||
msg_div.setAttribute("ans","null")
|
||||
yes.setAttribute("onclick",`document.getElementById('${msg_div.id}').setAttribute("ans","true")`)
|
||||
no.setAttribute("onclick",`document.getElementById('${msg_div.id}').setAttribute("ans","false")`)
|
||||
yes.focus();
|
||||
yes.addEventListener('keydown', function(e) {
|
||||
if (e.keyCode === 13) {
|
||||
document.getElementById(`${msg_div.id}`).setAttribute("ans","true")
|
||||
}
|
||||
else if (e.keyCode === 27) {
|
||||
document.getElementById(`${msg_div.id}`).setAttribute("ans","false")
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
var observer = new MutationObserver(function(mutations) {
|
||||
mutations.forEach(function(mutation) {
|
||||
if (mutation.type = "attributes" && mutation.target.getAttribute("ans") != "null") {
|
||||
// console.log(mutation);
|
||||
if(mutation.target.getAttribute("ans") == "true"){
|
||||
params.res(date.value);fin();
|
||||
}
|
||||
else if (mutation.target.getAttribute("ans") == "false"){
|
||||
params.res(false);fin();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
observer.observe(msg_div, {attributes: true });
|
||||
|
||||
|
||||
function fin(){
|
||||
observer.disconnect();
|
||||
// document.getElementById("message_div").style.pointerEvents = "none";
|
||||
if (document.getElementById(msg_div.id) != null){
|
||||
msg_div.style.transform = "translateX(120%)";
|
||||
setTimeout(() => {
|
||||
msg_root.removeChild(msg_div);
|
||||
}, 200);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(params.type != "wait" && params.type != "ask" && params.type != "date"){
|
||||
msg_div.setAttribute("onclick",`msg_del("msg_${msg_int}")`);
|
||||
setTimeout(()=>{
|
||||
if (document.getElementById(msg_div.id) != null){
|
||||
|
|
|
@ -190,7 +190,7 @@
|
|||
<div class="inputs" style="display: flex;justify-content: space-between;height: 5vh;">
|
||||
<div id="obj_color_div" style="justify-content: space-evenly; width: 50vw;display: none;transform: translateX(30%);">
|
||||
<label for="obj_colors" style="min-width: 10vw;">цвет объекта</label>
|
||||
<div id="obj_colors" style="display: flex; width: 30vw;overflow: auto;"></div>
|
||||
<div id="obj_colors" style="display: flex; width: 30vw;overflow: auto;height: 4.5vh;"></div>
|
||||
<!-- <input id="obj_color" type="color" onchange="obj_color_change(event)"> -->
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue
Block a user