migration start

This commit is contained in:
2023-09-18 16:36:07 +05:00
parent 898391ef3b
commit ba9bfda202
31 changed files with 451 additions and 15740 deletions

View File

@ -11,6 +11,7 @@
<!-- <h1 style="text-align: center;">объект</h1> -->
<%- include('../admin/objects/object_groups.ejs') %>
<%- include('../admin/objects/object_creation.ejs') %>
<%- include('../admin/objects/object_colors.ejs') %>
<%- include('../admin/objects/object_edit.ejs') %>
</section>

View File

@ -0,0 +1,63 @@
<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>
<div id="inp">
<input type="color" id="new_color" style="margin: auto;">
<button onclick="new_color()" class="btn_blue">добавить цвет</button>
<button onclick="del_color()" class="btn_blue">удалить цвет</button>
</div>
</div>
<script>
let cur_color = "";
obj_colors_load();
function obj_colors_load() {
let div = document.getElementById("obj_colors");
div.innerHTML = "";
load_colors((colors)=>{
Object.entries(colors).forEach(([key,value]) => {
// console.log(value);
let color_div = document.createElement("div");
color_div.style = `background-color: #${value["color"]}; border-radius: 50%;height: 2vw;min-width: 2vw;margin-inline: 0.5vw;`;
color_div.classList.add("color_palette");
color_div.id=`color_${value["color"]}`;
color_div.setAttribute("color_id",`${value["id"]}`)
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);
});
})
}
function new_color(){
let color = document.getElementById("new_color").value.replace("#","");
let wait_msg = msg("добавление цвета",{type:"wait"})
$.post( "/admin/colors/new", {color:color})
.done(function( res ) {
if(res["out"] == "good"){
msg_del(wait_msg.id);
msg("цвет добавлен");
obj_colors_load();
console.log(res["body"]);
}
else if (res["out"] == "bad"){
msg_del(wait_msg.id);
msg("цвет уже добавлен");
}
});
}
function del_color(){
let color_id = document.getElementById(cur_color).getAttribute("color_id")
let wait_msg = msg("удаление цвета",{type:"wait"})
$.post( "/admin/colors/delete", {id:color_id})
.done(function( res ) {
if(res["out"] == "good"){
msg_del(wait_msg.id);
msg("цвет удалён");
obj_colors_load();
console.log(res["body"]);
}
});
}
</script>

View File

@ -48,10 +48,11 @@
let color_check = document.getElementById("obj_color_check");
let old_prev = document.getElementById("img_prev").src;
if(color_check.checked == true){
obj_colors_load();
removeImageBackground(document.getElementById("img_prev").src).then((out)=>{
document.getElementById("img_prev").src = out;
})
msg("при измении цвета все цвета кроме прозрачного изменятся",{type:"help",time:10});
msg("помните что только hex:#c8c8c8 или rgb:200,200,200 цвета будут заменины при смене цвета ",{type:"help",time:10});
}
else{
document.getElementById("img_prev").src = old_prev;
@ -235,9 +236,7 @@
}
else if(res["out"] == "good"){
msg("товар добавлен");
setTimeout(()=>{
edit_get_objs();
},5000)
edit_get_objs();
}
});
}

View File

@ -43,15 +43,15 @@
</div>
</div>
<section id="users_section">
<div style="height: 430px;">
<div style="height: 360px;">
<li id="first_user"><div>Логин</div><div>Превилегии</div><div>Функции</div></li>
<ul id="user_list"></ul>
</div>
<div style="display: flex;justify-content: space-between;margin: auto;">
<div style="display: flex;"><h1>Всего:&nbsp;</h1> <h1 id="users_count">0</h1></div>
<div style="display: flex;margin: auto 0px;">с&nbsp;<div id="users_from">0</div>&nbsp;по&nbsp;<div id="users_to">10</div></div>
<div style="margin: auto 0px;"><button onclick="if(users_from-load_interval>=0){users_from-=load_interval;load_users_data(users_from);}" class="btn_gray">< 10 назад</button></div>
<div style="margin: auto 0px;"><button onclick="users_from+=load_interval;load_users_data(users_from);" class="btn_gray">даллее ></button></div>
<div style="margin: auto 0px;"><button id="back_btn" class="btn_gray">< 10 назад</button></div>
<div style="margin: auto 0px;"><button id="forw_btn" class="btn_gray">даллее ></button></div>
</div>
</section>
@ -59,10 +59,32 @@
<script>
let users_from = 0;
let load_interval = 5;
function user_count_check(){
if(parseInt(document.getElementById("users_count").innerText) >= parseInt(document.getElementById("users_to").innerText)){
document.getElementById("forw_btn").classList = "btn_blue";
document.getElementById("forw_btn").setAttribute("onclick",`users_from+=load_interval;load_users_data(users_from);`);
}
else{
document.getElementById("forw_btn").setAttribute("onclick",``);
document.getElementById("forw_btn").classList = "btn_gray";
}
if(parseInt(document.getElementById("users_from").innerText) == 0){
document.getElementById("back_btn").setAttribute("onclick",``);
document.getElementById("back_btn").classList = "btn_gray";
}
else{
document.getElementById("back_btn").setAttribute("onclick",`if(users_from-load_interval>=0){users_from-=load_interval;load_users_data(users_from);};`);
document.getElementById("back_btn").classList = "btn_blue";
}
}
load_users_data(users_from);
function load_users_data(from,by_name=false){
// if(to == "forward") {users_from+=load_interval;}
// else if(to == "back") {users_from-=load_interval;}
document.getElementById("back_btn").setAttribute("onclick",``);
document.getElementById("forw_btn").setAttribute("onclick",``);
document.getElementById("user_list").innerHTML = "";
document.getElementById("users_from").innerText = from;
document.getElementById("users_to").innerText = from+load_interval;
@ -80,6 +102,7 @@
user_sec.append(user_pass);user_sec.append(user_name);user_sec.append(user_prevs);user_sec.append(user_buttons);
document.getElementById("user_list").append(user_sec);
user_count_check();
});
}
else if (res["out"] == "bad"){
@ -90,6 +113,7 @@
else{
let login = ask("имя");
if (login != ""){
form = 0;
$.post( "/admin/users/find",{login:login,from:from,load_interval:load_interval})
.done(function( res ) {
if(res["out"] == "good"){
@ -104,6 +128,10 @@
document.getElementById("user_list").append(user_sec);
});
}
else if(res["out"] == "bad"){
msg("нет пользователя с таким иминем")
load_users_data(users_from);
}
});
}
}

View File

@ -12,7 +12,7 @@
<input type="text" id="login" name="login" value="" placeholder="Логин" class="btn_white" style="text-align: center; padding-inline: 5vw;">
<input type="submit" onclick='reg();' value="Зарегистрировать" class="btn_blue">
<div>
<label for="admin_check">Админ. привелегии</label>
<label for="admin_check" style="margin: auto;">Админ. привелегии</label>
<input type="checkbox" name="admin" value='false' id="admin_check" onchange="admin_ch()">
</div>
</div>