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>

View File

@ -60,9 +60,9 @@
}
});
}
function new_proj(){
function new_proj(objs = null){
let name = ask("please enter project name");
let objs = { height:"2",width:"4"};
objs = (objs == null)? { height:"2",width:"4"}:objs;
if(name != null && name!= "" && name!=" " && typeof name != "undefined" && name!="undefined"){
$.post( "/save_proj", {proj:JSON.stringify(objs),name:name,img:"/img/proj_placeholder.webp"})
.done(function( res ) {
@ -84,7 +84,7 @@
projs.forEach(proj => {
console.log(proj);
let div = document.getElementById("projs_div");
div.innerHTML += `<button id='proj_${proj["name"]}' class='proj'>
div.innerHTML += `<button id='proj_${proj["name"]}' proj_id='${proj["id"]}' class='proj'>
<img src='${proj["img"]}' alt='${proj["name"]}' class="p_img" onclick="goto('/proj/load/${proj["name"]}')">
<div class="p_props">
<div class="p_left" style="text-align:left">
@ -93,8 +93,8 @@
</div>
<div class="p_right">
<img src="/img/icon/edit.svg" style="width:24px;height:24px" onclick="">
<img src="/img/icon/copy.svg" style="width:24px;height:24px" onclick="">
<img src="/img/icon/download.svg" style="width:24px;height:24px" onclick="download_proj('${proj["id"]}','${proj["name"]}')">
<img src="/img/icon/copy.svg" style="width:24px;height:24px" onclick="copy_proj('${proj["name"]}')">
<img src="/img/icon/download.svg" style="width:24px;height:24px" onclick="downloadImg('${proj["img"]}','${proj["name"]}');msg('скачивание');">
<img src="/img/icon/trash.svg" style="width:24px;height:24px" onclick="del_proj('${proj["name"]}')">
</div>
</div>
@ -122,5 +122,14 @@
})
}
}
function copy_proj(proj){
$.post( "/load_proj",{name:proj})
.done(function( res ) {
if(res["out"] == "good"){
new_proj(JSON.parse(res["body"]))
}
})
}
</script>
<%- include('./static/end.ejs',{soc:true}) %>

View File

@ -189,22 +189,9 @@
<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_color" style="width: 10vw;">цвет объекта</label>
<label for="obj_colors" style="min-width: 10vw;">цвет объекта</label>
<div id="obj_colors" style="display: flex; width: 30vw;overflow: auto;"></div>
<!-- <input id="obj_color" type="color" onchange="obj_color_change(event)"> -->
<div style="display: flex;justify-content: space-evenly; width: 30vw;">
<div style="background-color: #43368D; border-radius: 50%;height: 2vw;width: 2vw;" color="#43368D" onclick="obj_color_change('43368D')"></div>
<div style="background-color: #41AB34; border-radius: 50%;height: 2vw;width: 2vw;" color="#41AB34" onclick="obj_color_change('41AB34')"></div>
<div style="background-color: #F7EA55; border-radius: 50%;height: 2vw;width: 2vw;" color="#F7EA55" onclick="obj_color_change('F7EA55')"></div>
<div style="background-color: #E5231F; border-radius: 50%;height: 2vw;width: 2vw;" color="#E5231F" onclick="obj_color_change('E5231F')"></div>
<div style="background-color: #F39223; border-radius: 50%;height: 2vw;width: 2vw;" color="#F39223" onclick="obj_color_change('F39223')"></div>
<div style="background-color: #009FE3; border-radius: 50%;height: 2vw;width: 2vw;" color="#009FE3" onclick="obj_color_change('009FE3')"></div>
<div style="background-color: #CEE8EA; border-radius: 50%;height: 2vw;width: 2vw;" color="#CEE8EA" onclick="obj_color_change('CEE8EA')"></div>
<div style="background-color: #B9D585; border-radius: 50%;height: 2vw;width: 2vw;" color="#B9D585" onclick="obj_color_change('B9D585')"></div>
<div style="background-color: #F4F2C7; border-radius: 50%;height: 2vw;width: 2vw;" color="#F4F2C7" onclick="obj_color_change('F4F2C7')"></div>
<div style="background-color: #E699A7; border-radius: 50%;height: 2vw;width: 2vw;" color="#E699A7" onclick="obj_color_change('E699A7')"></div>
<div style="background-color: #F9C771; border-radius: 50%;height: 2vw;width: 2vw;" color="#F9C771" onclick="obj_color_change('F9C771')"></div>
<div style="background-color: #B7A3C7; border-radius: 50%;height: 2vw;width: 2vw;" color="#B7A3C7" onclick="obj_color_change('B7A3C7')"></div>
</div>
</div>
</div>
<div class="inputs" style="display: flex;justify-content: space-between;">
@ -309,7 +296,7 @@
}
function img_download(){
msg("добавить на фото стоимость ?",{type:"ask",res:(out)=>{
msg("добавить на фото стоимость?",{type:"ask",res:(out)=>{
let wait_msg = msg("делаем фото",{type:"wait"})
proj_img((src)=>{
msg("изображение проекта готово",{time:3})
@ -331,6 +318,7 @@
}
html2canvas(document.getElementById("drags"),{
y:7,
x:2,
width:width,
logging:false,
scale:5
@ -348,6 +336,27 @@
});
}
function obj_colors_load(callback) {
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",`${value["color"]}`)
color_div.setAttribute("onclick",`clear_palette();document.getElementById('color_${value["color"]}').style.border = "1px blue solid";obj_color_change('${value["color"]}')`)
color_div.title = `#${value["color"]}`;
div.append(color_div);
if(key = Object.keys(colors).at(-1)){
if(callback)callback();
}
});
})
}
function obj_color_change(color,in_obj = null){
if(color != "null"){
if (proj_state == "loaded"){objs_back.push(JSON.parse(JSON.stringify(objs)));}
@ -355,6 +364,7 @@
// console.log(color);
color_change(color,obj.getAttribute("img"),(img)=>{
obj.src = img;
obj.setAttribute("color",color)
objs[obj.classList[0]][obj.id]["color"] = color;
});
}

View File

@ -88,7 +88,4 @@
</style>
</head>
<body>
<script>
let domen = "puzzle.nor.su";
</script>