XYZ 2
This commit is contained in:
78
metadata/dbms/data.json
Normal file
78
metadata/dbms/data.json
Normal file
@ -0,0 +1,78 @@
|
||||
{
|
||||
"type":{
|
||||
"n":"Terminals",
|
||||
"d":"trt('Terminal')",
|
||||
"ObjectID":"id",
|
||||
"edit_object":{
|
||||
"columns":[
|
||||
{"d":"id", "n":"id", "vt":"i4", "visible":"0"},
|
||||
{"d":"trt('Company')", "n":"company_id", "vt":"object", "maybenull":"0", "ot":"Companies", "FieldCaption":"name", "selector":"combo"},
|
||||
{"d":"trt('Phone')", "n":"phone", "vt":"string", "size":"20"},
|
||||
{"d":"trt('Serial_number')", "n":"serial", "vt":"string", "size":"50"},
|
||||
{"d":"IMEI", "n":"imei", "vt":"string", "size":"50", "maybenull":"0"},
|
||||
{"d":"trt('Terminal model')", "n":"terminal_model_id", "vt":"object", "maybenull":"0", "ot":"TerminalsModels", "FieldCaption":"name", "selector":"combo"},
|
||||
{"d":"trt('Description')", "n":"description", "vt":"text", "size":"500"}
|
||||
],
|
||||
"insert-query":"select * from main.p_Terminals_i(${_user_id},${company_id},${phone},${serial},${imei},${terminal_model_id},${description});",
|
||||
"update-query":"select * from main.p_Terminals_u(${_user_id},${id},${company_id},${phone},${serial},${imei},${terminal_model_id},${description});",
|
||||
"delete-query":"select * from main.p_Terminals_d(${_user_id},${id});",
|
||||
"select-query":"select * from main.p_Terminals_s(${_user_id},${id},0,NULL);"
|
||||
},
|
||||
"show-object":{
|
||||
"d":"trt('Terminals')",
|
||||
"width":"1000",
|
||||
"sql-query":"select * from main.p_terminals_ss(${_user_id},${id},${company_id},${terminal_id},${install},${imei},${serial});",
|
||||
"filter":{
|
||||
"columns":[
|
||||
{"d":"id","n":"id","vt":"string","visible":"0"},
|
||||
{"d":"trt('Company')","n":"company_id","vt":"object","object":"Companies","FieldCaption":"name","selector":"combo"},
|
||||
{"d":"terminal_id","n":"terminal_id","vt":"i4","visible":"0"},
|
||||
{"d":"trt('Installed')","n":"install","vt":"b"},
|
||||
{"d":"trt('IMEI')","n":"imei","vt":"string"},
|
||||
{"d":"trt('Serial_number')","n":"serial","vt":"string"}
|
||||
]
|
||||
},
|
||||
"columns":[
|
||||
{"d":"trt('Terminal_model')", "n":"terminal_model_name", "width":"150"},
|
||||
{"d":"trt('Company')", "n":"campany_name", "width":"150"},
|
||||
{"d":"trt('Installed_on')", "n":"object_name", "width":"150"},
|
||||
{"d":"trt('Phone')", "n":"phone", "width":"150"},
|
||||
{"d":"trt('Serial_number')", "n":"serial", "width":"120"},
|
||||
{"d":"IMEI", "n":"imei", "width":"300"},
|
||||
{"d":"trt('Description')", "n":"description", "width":"300"},
|
||||
{"d":"trt('Count_sensors')", "n":"tscnt", "width":"120",
|
||||
"type":{
|
||||
"n":"TerminalsSensors",
|
||||
"show-object":{
|
||||
"d":"trt('Sensors_types')",
|
||||
"filter":{
|
||||
"height":"1",
|
||||
"columns":[
|
||||
{
|
||||
"n":"terminal_id",
|
||||
"data":"${id}"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{"d":"Настройки", "n":"tstcnt", "width":"120",
|
||||
"type":{
|
||||
"n":"TerminalsSettings",
|
||||
"show-object":{
|
||||
"filter":{
|
||||
"columns":[
|
||||
{
|
||||
"n":"terminal_id",
|
||||
"data":"${id}"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
1450
metadata/dbms/dbms.xyz
Normal file
1450
metadata/dbms/dbms.xyz
Normal file
File diff suppressed because it is too large
Load Diff
0
metadata/dbms/edit_object.js
Normal file
0
metadata/dbms/edit_object.js
Normal file
40
metadata/dbms/edit_object.vue
Normal file
40
metadata/dbms/edit_object.vue
Normal file
@ -0,0 +1,40 @@
|
||||
<template>
|
||||
<h1>{{ type.d }}</h1>
|
||||
<div v-for="(column,index) in type.edit_object.columns">
|
||||
<div v-if="column.vt=='i4'" :style="{ backgroundColor: index % 2 === 0 ? 'var(--row-color-1)' : 'var(--row-color-2)' }">
|
||||
<div style="width:150px;display:inline-block;">{{column.d}}</div>
|
||||
<input type="text" v-model="column.value">
|
||||
<input type="button" class="button-secondary" style="width:22px;margin:0px;padding:0px;" :click="column.value += 1" value="+" title="trt('Increase_by_1')">
|
||||
<input type="button" class="button-secondary" style="width:22px;margin:0px;padding:0px;" :click="column.value -= 1" value="-" title="trt('Decrease_by_1')">
|
||||
</div>
|
||||
<div v-if="column.vt=='object'" :style="{ backgroundColor: index % 2 === 0 ? 'var(--row-color-1)' : 'var(--row-color-2)' }">
|
||||
<div style="width:150px;display:inline-block;">{{column.d}}</div>
|
||||
<input type="text">
|
||||
</div>
|
||||
<div v-if="column.vt=='string'" :style="{ backgroundColor: index % 2 === 0 ? 'var(--row-color-1)' : 'var(--row-color-2)' }">
|
||||
<div style="width:150px;display:inline-block;">{{column.d}}</div>
|
||||
<input type="text">
|
||||
</div>
|
||||
</div>
|
||||
<div style="display: flex; justify-content: space-between;">
|
||||
<div>
|
||||
<label><input type="checkbox">trt('Repeat_the_addition_of_the_entry')</label>
|
||||
</div>
|
||||
<div>
|
||||
<div style="display: inline-block;">
|
||||
<input type="button" class="button-secondary" value="trt('Apply')">
|
||||
<input type="button" class="button-secondary" value="trt('Cancel')">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "show_object"
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
1450
metadata/dbms/records.xyz
Normal file
1450
metadata/dbms/records.xyz
Normal file
File diff suppressed because it is too large
Load Diff
44
metadata/dbms/session.xyz
Normal file
44
metadata/dbms/session.xyz
Normal file
@ -0,0 +1,44 @@
|
||||
<?
|
||||
//Скрипт должен возвращять время в секундах когда умрёт сесия
|
||||
//Скрипт работающий как AJAX в связке с javascript функцией 1 после загрузки выдать наименование сессионной переменной потом проверять на существование соответствующего файла в базе данных
|
||||
//Проверить обновляется ли файлик сесии
|
||||
//http://leopard.in.ua/2008/09/20/otslezhivanie-istecheniya-sroka-dejstviya-sessij/
|
||||
//session_save_path('C:\ses');
|
||||
|
||||
require_once("../include/tools.php");
|
||||
|
||||
$host = $_SERVER['HTTP_HOST'];
|
||||
$host = '.'.cutAfterLast($host,'.',2);
|
||||
ini_set('session.cookie_domain', $host);
|
||||
|
||||
error_reporting(E_ALL);
|
||||
|
||||
if(isset($_GET['fn'])) $fn=$_GET['fn']; else $fn='';
|
||||
|
||||
if($fn=='0')
|
||||
{
|
||||
echo session_name();
|
||||
exit;
|
||||
}else
|
||||
if($fn=='1')
|
||||
{
|
||||
@session_start(['cookie_lifetime' => 43200,'cookie_secure' => true,'cookie_httponly' => true]);
|
||||
echo session_id();
|
||||
exit;
|
||||
}else
|
||||
if($fn=='2') //Вернуть время до смерти сесии в секундах
|
||||
{
|
||||
if(isset($_GET[session_name()])) $id=$_GET[session_name()]; else exit;
|
||||
|
||||
$sessionfile = ini_get('session.save_path') . DIRECTORY_SEPARATOR . 'sess_'.$id;
|
||||
if ( file_exists($sessionfile) )
|
||||
{
|
||||
//echo ini_get('session.gc_maxlifetime') - (time() - filemtime($sessionfile));
|
||||
echo '1'; //Чтоб только если файл удалился
|
||||
|
||||
}else echo '-1';
|
||||
exit;
|
||||
}else
|
||||
{
|
||||
echo 'error';
|
||||
}
|
||||
0
metadata/dbms/show_object.js
Normal file
0
metadata/dbms/show_object.js
Normal file
13
metadata/dbms/show_object.vue
Normal file
13
metadata/dbms/show_object.vue
Normal file
@ -0,0 +1,13 @@
|
||||
<template>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "show_object"
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
488
metadata/dbms/window.js
Normal file
488
metadata/dbms/window.js
Normal file
@ -0,0 +1,488 @@
|
||||
//Класс окна
|
||||
|
||||
class TWin
|
||||
{
|
||||
constructor(dialog,path)
|
||||
{
|
||||
this.dialog=dialog; //Показывать окно как диалог (без возможности изменения размеров)
|
||||
if(typeof path !== 'undefined')
|
||||
this.path=path;
|
||||
else
|
||||
this.path='../resources';
|
||||
|
||||
this.disableClosing=false;
|
||||
|
||||
this.closed=false; //Закрыли (те. удалили из родителя и детей и из DOM)
|
||||
this.onClose=null; //слушатель закрытия окна
|
||||
this.childs=new Array(); //Подчинёные окна
|
||||
this.parent=null; //родительское окно
|
||||
this.name="TWin";
|
||||
this.tWinId=0;
|
||||
this.dx=0;
|
||||
this.dy=0;
|
||||
this.sel=false;
|
||||
this.obj=null; //user data
|
||||
|
||||
this.div=document.createElement('div'); //Окно
|
||||
this.divsh=document.createElement('div'); //Тень для модального окна
|
||||
this.tbl=null;
|
||||
this.h0=null;
|
||||
this.ca=null;
|
||||
this.co=null;
|
||||
this.shadow = false; //Показывать ли тень вокруг окошка
|
||||
this.uid=getUID(); //Уникальныйидентификатор
|
||||
|
||||
this.pBarCnt=0; //Прогресс бар
|
||||
this.pBarDiv=null; //Прогресс бар
|
||||
|
||||
this.fnResizeListener=null;
|
||||
}
|
||||
|
||||
addResizeListener(func)
|
||||
{
|
||||
this.fnResizeListener=func;
|
||||
this.fnResizeListener();
|
||||
}
|
||||
|
||||
onResize(x,y)
|
||||
{
|
||||
let win=this;
|
||||
return function(e){
|
||||
if(!e) e = window.event;
|
||||
win.dx=e.pageX || e.x
|
||||
win.dy=e.pageY || e.y
|
||||
|
||||
document.onmousedown = function() {
|
||||
|
||||
if(win.fnResizeListener!=null) win.fnResizeListener();
|
||||
|
||||
return false;
|
||||
};
|
||||
document.onmousemove = function(e) {
|
||||
if(!e) e = window.event;
|
||||
let x2 = e.pageX || e.x;
|
||||
let y2 = e.pageY || e.y;
|
||||
let w=parseInt(win.div.style.width)-(win.dx-x2)*x;
|
||||
let h=parseInt(win.div.style.height)-(win.dy-y2)*y;
|
||||
if(w<0)w=0;
|
||||
if(h<0)h=0;
|
||||
win.setWidth(w+"px");
|
||||
win.setHeight(h+"px");
|
||||
if(x<0)win.div.style.left=parseInt(win.div.style.left)-(win.dx-x2)+"px";
|
||||
if(y<0)win.div.style.top=parseInt(win.div.style.top)-(win.dy-y2)+"px";
|
||||
win.dx=x2;
|
||||
win.dy=y2;
|
||||
|
||||
if(win.fnResizeListener!=null) win.fnResizeListener();
|
||||
|
||||
return false;
|
||||
};
|
||||
document.onmouseup = function() {
|
||||
document.onmousedown = null;
|
||||
document.onmousemove = MMove//null;
|
||||
|
||||
if(win.fnResizeListener!=null) win.fnResizeListener();
|
||||
|
||||
return false;
|
||||
};
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
Close() //Закрыть и удалить окно из родителя и менеджера
|
||||
{
|
||||
if(this.disableClosing)
|
||||
return;
|
||||
|
||||
//Переместил перед удалением компонент так как бывает нужно поработать с ними перед удалением
|
||||
if(this.onClose!=null)
|
||||
{
|
||||
this.onClose();
|
||||
}
|
||||
|
||||
this.hide(true);
|
||||
this.setParent(null);
|
||||
for(let i=0;i<this.childs.length;i++) if(this.childs[i]!=null) this.childs[i].parent=null
|
||||
|
||||
//??? зачем коментил (пояснение не понятное)? раскоментил потому что после пересоздания формы HTML id сохранялись (Вот непонятный комент: Закоментил потому что в магазине могут закрыть окно а оно больше не появится...)
|
||||
if(this.div.parentNode!=null) this.div.parentNode.removeChild(this.div);
|
||||
if(this.divsh.parentNode!=null) this.divsh.parentNode.removeChild(this.divsh);
|
||||
|
||||
this.closed=true;
|
||||
};
|
||||
|
||||
//Типа конструктор создать окно с заданой позицией
|
||||
BuildGUI(x,y)
|
||||
{
|
||||
this.tWinId=g_wins.add(this);
|
||||
/*
|
||||
let hd='';
|
||||
hd+='<table style="width: 100%;">';
|
||||
hd+=' <tr>';
|
||||
hd+=' <td style="vertical-align:bottom;cursor:move;" id="TWin_H1_'+this.tWinId+'"><img src="'+this.path+'/metadata/dbms/form/t1.gif" style="width: 20px; height: 20px; display: block;" alt="" border="0px" draggable="false"/></td>';
|
||||
hd+=' <td align="center" width="100%" bgcolor="#3366CC" style="font-weight: bold; cursor:move; background: #92b5df url('+this.path+'/metadata/dbms/form/1.gif) repeat-x top;" id="TWin_H2_'+this.tWinId+'"><nobr id="TWin_Ca_'+this.tWinId+'"></nobr></td>';
|
||||
hd+=' <td style="vertical-align:bottom;cursor:move;" id="TWin_H3_'+this.tWinId+'"><img src="'+this.path+'/metadata/dbms/form/t2.gif" alt="" style="width: 20px; height: 20px; display: block;" border="0px" draggable="false"/></td>';
|
||||
//hd+=' <td width="100%"> </td>';
|
||||
hd+=' <td style="vertical-align:bottom;cursor:pointer;"><img src="'+this.path+'/metadata/dbms/form/none.gif" alt="" style="width: 21px; height: 21px; display: block;" border="0px" draggable="false"/></td>';
|
||||
hd+=' <td style="vertical-align:bottom;cursor:pointer;"><img src="'+this.path+'/metadata/dbms/form/none.gif" alt="" style="width: 21px; height: 21px; display: block;" border="0px" draggable="false"/></td>';
|
||||
hd+=' <td style="vertical-align:bottom;cursor:pointer;"><img src="'+this.path+'/metadata/dbms/form/close.gif" alt="X" style="width: 21px; height: 21px; display: block;" border="0px" draggable="false" id="TWin_CL_'+this.tWinId+'"/></td>';
|
||||
hd+=' <td style="vertical-align:bottom;"><img src="'+this.path+'/metadata/dbms/form/none.gif" alt="" style="width: 21px; height: 21px; display: block;" border="0px" draggable="false"/></td>';
|
||||
hd+=' </tr>';
|
||||
hd+='</table>';
|
||||
|
||||
let str='';
|
||||
str+='<table id="TWin_TBL_'+this.tWinId+'" border="0px" style="width: 100%; height: 100%;">';
|
||||
str+=' <tr id="TWin_H0_'+this.tWinId+'"><td colspan=3>'+hd+'</td></tr>';
|
||||
str+=' <tr>';
|
||||
str+=' <td style="width: 10px; height: 10px; cursor:nw-resize;"><img src="'+this.path+'/metadata/dbms/form/_t-l.gif" alt="" style="width: 10px; height: 10px; display: block;" border="0px" draggable="false" id="TWin_TL_'+this.tWinId+'"></td>';
|
||||
str+=' <td style="vertical-align:top; height: 10px; cursor:n-resize;" background="'+this.path+'/metadata/dbms/form/t.gif" id="TWin_T_'+this.tWinId+'"></td>';
|
||||
str+=' <td style="width: 10px; height: 10px; cursor:ne-resize;" id="TWin_TR_'+this.tWinId+'"><img src="'+this.path+'/metadata/dbms/form/t-r.gif" alt="" style="width: 10px; height: 10px; display: block;" border="0px" draggable="false"></td>';
|
||||
str+=' </tr>';
|
||||
str+=' <tr style="height: 100%">';
|
||||
str+=' <td style="vertical-align:top;height: 10px; cursor:w-resize;" background="'+this.path+'/metadata/dbms/form/l.gif" id="TWin_L_'+this.tWinId+'"></td>';
|
||||
str+=' <td style="vertical-align:top;cursor:default;"><table style="width: 100%; height: 100%;"><tr><td id="TWin_Co_'+this.tWinId+'" style="vertical-align:top;"> </td></tr></table></td>';
|
||||
str+=' <td style="vertical-align: top; height: 10px; cursor:e-resize;" background="'+this.path+'/metadata/dbms/form/r.gif" id="TWin_R_'+this.tWinId+'"></td>';
|
||||
str+=' </tr>';
|
||||
str+=' <tr>';
|
||||
str+=' <td style="width: 10px; height: 10px; cursor:sw-resize;" id="TWin_BL_'+this.tWinId+'"><img src="'+this.path+'/metadata/dbms/form/b-l.gif" alt="" style="width: 10px; height: 10px; display: block;" border="0px" draggable="false"></td>';
|
||||
str+=' <td style="vertical-align: top; height: 10px; cursor:s-resize;" background="'+this.path+'/metadata/dbms/form/b.gif" id="TWin_B_'+this.tWinId+'"></td>';
|
||||
str+=' <td style="width: 10px; height: 10px; cursor:se-resize;" id="TWin_BR_'+this.tWinId+'"><img src="'+this.path+'/metadata/dbms/form/b-r.gif" alt="" style="width: 10px; height: 10px; display: block;" border="0px" draggable="false"></td>';
|
||||
str+=' </tr>';
|
||||
str+='</table>';
|
||||
*/
|
||||
/*
|
||||
let str='';
|
||||
str+='<table id="TWin_TBL_'+this.tWinId+'" class="TWin">';
|
||||
str+=' <tr id="TWin_H0_'+this.tWinId+'" style="border-bottom: 1px solid #b3b3b3;"><td></td><td><table style="width: 100%; height: 29px;"><tr><td id="TWin_Ca_'+this.tWinId+'" style="vertical-align: middle; cursor: move; font-weight: bold; white-space: nowrap;"></td><td style="width: 10px; vertical-align: middle;"><img src="'+this.path+'/metadata/dbms/form/x.gif" id="TWin_CL_'+this.tWinId+'" style="cursor:pointer;"></td></tr></table></td><td></td></tr>';
|
||||
str+=' <tr>';
|
||||
str+=' <td style="width: 5px; height: 5px;'+(!this.dialog ? ' cursor:nw-resize;' : '')+'" id="TWin_TL_'+this.tWinId+'"><img src="'+this.path+'/metadata/dbms/form/5.gif" alt="" style="display: block;" border="0px" draggable="false"></td>';
|
||||
str+=' <td style="vertical-align: top; height: 5px;'+(!this.dialog ? ' cursor: n-resize;' : '')+'" id="TWin_T_'+this.tWinId+'"></td>';
|
||||
str+=' <td style="width: 5px; height: 5px;'+(!this.dialog ? ' cursor:ne-resize;' : '')+'" id="TWin_TR_'+this.tWinId+'"><img src="'+this.path+'/metadata/dbms/form/5.gif" alt="" style="display: block;" border="0px" draggable="false"></td>';
|
||||
str+=' </tr>';
|
||||
str+=' <tr style="height: 100%">';
|
||||
str+=' <td style="height: 5px;'+(!this.dialog ? ' cursor:w-resize;' : '')+'" id="TWin_L_'+this.tWinId+'"></td>';
|
||||
str+=' <td style="vertical-align:top; cursor: default;"><table style="width: 100%; height: 100%;"><tr><td id="TWin_Co_'+this.tWinId+'" style="vertical-align:top;"></td></tr></table></td>';
|
||||
str+=' <td style="height: 5px;'+(!this.dialog ? ' cursor:e-resize;' : '')+'" id="TWin_R_'+this.tWinId+'"></td>';
|
||||
str+=' </tr>';
|
||||
str+=' <tr>';
|
||||
str+=' <td style="width: 5px; height: 5px;'+(!this.dialog ? ' cursor:sw-resize;' : '')+'" id="TWin_BL_'+this.tWinId+'"><img src="'+this.path+'/metadata/dbms/form/5.gif" alt="" style="display: block;" border="0px" draggable="false"></td>';
|
||||
str+=' <td style="vertical-align:top;height: 5px;'+(!this.dialog ? ' cursor: s-resize;' : '')+'" id="TWin_B_'+this.tWinId+'"></td>';
|
||||
str+=' <td style="width: 5px; height: 5px;'+(!this.dialog ? ' cursor:se-resize;' : '')+'" id="TWin_BR_'+this.tWinId+'"><img src="'+this.path+'/metadata/dbms/form/5.gif" alt="" style="display: block;" border="0px" draggable="false"></td>';
|
||||
str+=' </tr>';
|
||||
str+='</table>';
|
||||
*/
|
||||
|
||||
let str='';
|
||||
str+='<table id="TWin_TBL_'+this.tWinId+'" class="DBMSShadow" style="width: 100%; height: 100%; border: 1px solid #000000;">';
|
||||
str+=' <tr id="TWin_H0_'+this.tWinId+'" style="background: var(--path-grad) repeat-x;"><td></td><td><table style="width: 100%; height: 29px;"><tr><td id="TWin_Ca_'+this.tWinId+'" style="vertical-align: middle; cursor: move; font-weight: bold; white-space: nowrap;"></td><td style="width: 10px; vertical-align: middle;">'+(this.disableClosing ? '' : '<div id="TWin_CL_'+this.tWinId+'" style="display: inline-block; width: 10px; height: 10px; background-image: var(--path-X); background-repeat: no-repeat; cursor:pointer;padding-right: 5px;"></div>')+'</td></tr></table></td><td></td></tr>';
|
||||
str+=' <tr>';
|
||||
str+=' <td style="width: 5px; height: 5px;'+(!this.dialog ? ' cursor:nw-resize;' : '')+'" id="TWin_TL_'+this.tWinId+'"><img src="'+this.path+'/metadata/dbms/form/5.gif" alt="" style="display: block;" border="0px" draggable="false"></td>';
|
||||
str+=' <td style="vertical-align:top;height: 5px;'+(!this.dialog ? ' cursor:n-resize;' : '')+'" id="TWin_T_'+this.tWinId+'"></td>';
|
||||
str+=' <td style="width: 5px; height: 5px;'+(!this.dialog ? ' cursor:ne-resize;' : '')+'" id="TWin_TR_'+this.tWinId+'"><img src="'+this.path+'/metadata/dbms/form/5.gif" alt="" style="display: block;" border="0px" draggable="false"></td>';
|
||||
str+=' </tr>';
|
||||
str+=' <tr style="height: 100%">';
|
||||
str+=' <td style="height: 5px;'+(!this.dialog ? ' cursor:w-resize;' : '')+'" id="TWin_L_'+this.tWinId+'"></td>';
|
||||
str+=' <td style="vertical-align:top;cursor:default;"><table style="width: 100%; height: 100%;"><tr><td id="TWin_Co_'+this.tWinId+'" style="vertical-align:top;"></td></tr></table></td>';
|
||||
str+=' <td style="height: 5px;'+(!this.dialog ? ' cursor:e-resize;' : '')+'" id="TWin_R_'+this.tWinId+'"></td>';
|
||||
str+=' </tr>';
|
||||
str+=' <tr>';
|
||||
str+=' <td style="width: 5px; height: 5px;'+(!this.dialog ? ' cursor:sw-resize;' : '')+'" id="TWin_BL_'+this.tWinId+'"><img src="'+this.path+'/metadata/dbms/form/5.gif" alt="" style="display: block;" border="0px" draggable="false"></td>';
|
||||
str+=' <td style="vertical-align:top; height: 5px;'+(!this.dialog ? ' cursor:s-resize;' : '')+'" id="TWin_B_'+this.tWinId+'"></td>';
|
||||
str+=' <td style="width: 5px; height: 5px;'+(!this.dialog ? ' cursor:se-resize;' : '')+'" id="TWin_BR_'+this.tWinId+'"><img src="'+this.path+'/metadata/dbms/form/5.gif" alt="" style="display: block;" border="0px" draggable="false"></td>';
|
||||
str+=' </tr>';
|
||||
str+='</table>';
|
||||
|
||||
//создаём невидемую тень
|
||||
this.divsh.style.cssText="display: none; position: fixed; top:0; left:0; height: 100%; width: 100%; background: rgba(0,0,0,0.3);";
|
||||
this.divsh.onclick=function(win){return function(){ win.Close(); };}(this);
|
||||
|
||||
document.body.appendChild( this.divsh );
|
||||
|
||||
//Создаём родительский элемент для окна
|
||||
this.div = document.createElement('div');
|
||||
this.div.setAttribute("id","TWin_"+this.tWinId);
|
||||
this.div.style.cssText="position:absolute; height:50px; width:640px;";
|
||||
this.div.innerHTML=str;
|
||||
document.body.appendChild( this.div );
|
||||
this.tbl=document.getElementById('TWin_TBL_'+this.tWinId);
|
||||
this.h0=document.getElementById('TWin_H0_'+this.tWinId);
|
||||
this.co=document.getElementById('TWin_Co_'+this.tWinId);
|
||||
this.ca=document.getElementById('TWin_Ca_'+this.tWinId);
|
||||
this.setSel();
|
||||
|
||||
this.div.onmousedown=(e)=>this.setSel();
|
||||
//Кнопка закрыть окно
|
||||
let obj=document.getElementById('TWin_CL_'+this.tWinId);
|
||||
if(obj!=null){
|
||||
//obj.onclick=function(win){return function(){ win.Close(); };}(this);
|
||||
obj.onclick=(function(){ this.Close(); }).bind(this);
|
||||
}
|
||||
|
||||
if(!this.dialog)
|
||||
{
|
||||
document.getElementById('TWin_B_'+this.tWinId).onmousedown=this.onResize(0,1);
|
||||
document.getElementById('TWin_T_'+this.tWinId).onmousedown=this.onResize(0,-1);
|
||||
document.getElementById('TWin_BR_'+this.tWinId).onmousedown=this.onResize(1,1);
|
||||
document.getElementById('TWin_TL_'+this.tWinId).onmousedown=this.onResize(-1,-1);
|
||||
document.getElementById('TWin_BL_'+this.tWinId).onmousedown=this.onResize(-1,1);
|
||||
document.getElementById('TWin_R_'+this.tWinId).onmousedown=this.onResize(1,0);
|
||||
document.getElementById('TWin_L_'+this.tWinId).onmousedown=this.onResize(-1,0);
|
||||
document.getElementById('TWin_TR_'+this.tWinId).onmousedown=this.onResize(1,-1);
|
||||
}
|
||||
|
||||
this.setMove(document.getElementById('TWin_H0_'+this.tWinId));
|
||||
//this.setMove(document.getElementById('TWin_H1_'+this.tWinId));
|
||||
//this.setMove(document.getElementById('TWin_H2_'+this.tWinId));
|
||||
//this.setMove(document.getElementById('TWin_H3_'+this.tWinId));
|
||||
|
||||
this.setLeftTop(x,y);
|
||||
}
|
||||
|
||||
getCaption()
|
||||
{
|
||||
return document.getElementById('TWin_Ca_'+this.tWinId);
|
||||
}
|
||||
|
||||
setCaption(val)
|
||||
{
|
||||
if(val==null) val='';
|
||||
let obj=document.getElementById('TWin_Ca_'+this.tWinId);
|
||||
if (typeof val === 'string' || val instanceof String)
|
||||
obj.innerHTML=val;
|
||||
else
|
||||
obj.appendChild(val);
|
||||
}
|
||||
|
||||
//Присвоить содержимое в виде строки
|
||||
setContent(html)
|
||||
{
|
||||
let obj=document.getElementById('TWin_Co_'+this.tWinId);
|
||||
if(obj!=null)
|
||||
{
|
||||
obj.innerHTML=html;
|
||||
if(this.tbl.offsetHeight>this.div.offsetHeight) this.div.style.height=this.tbl.offsetHeight+"px";
|
||||
if(this.tbl.offsetWidth>this.div.offsetWidth) this.div.style.width=this.tbl.offsetWidth+"px";
|
||||
}
|
||||
}
|
||||
//Выбрать (активизировать) окно
|
||||
setSel()
|
||||
{
|
||||
for(let i=0;i<g_wins.mas.length;i++) if(g_wins.mas[i]!=null)
|
||||
{
|
||||
g_wins.mas[i].sel=false;
|
||||
g_wins.mas[i].ca.style.color="var(--inactive-font-color)";
|
||||
}
|
||||
this.sel=true;
|
||||
this.ca.style.color="var(--main-font-color)";
|
||||
this.setWinZ(true);
|
||||
}
|
||||
//Получить значение Z индекса TODO сделать через геттер
|
||||
getZ()
|
||||
{
|
||||
return parseInt(this.div.style.zIndex);
|
||||
}
|
||||
//Установить значение Z индекса TODO сделать через setter
|
||||
setZ(z)
|
||||
{
|
||||
this.div.style.zIndex=z;
|
||||
this.divsh.style.zIndex=z-1;
|
||||
};
|
||||
setMove(elm)
|
||||
{
|
||||
elm.onmousedown=function(win){
|
||||
return function(event){
|
||||
move_me(event,win);
|
||||
};
|
||||
}(this);
|
||||
};
|
||||
//В центр видимой части экрана
|
||||
setCenter()
|
||||
{
|
||||
let scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;
|
||||
let scrollTop = window.pageYOffset || document.documentElement.scrollTop;
|
||||
|
||||
this.div.style.left=(scrollLeft+((document.documentElement.clientWidth || document.body.clientWidth)-parseInt(this.div.style.width))/2)+"px"
|
||||
this.div.style.top=(scrollTop+((document.documentElement.clientHeight || document.body.clientHeight)-parseInt(this.div.style.height))/2)+"px"
|
||||
if(parseInt(this.div.style.top)<0) this.div.style.top="1px";
|
||||
if(parseInt(this.div.style.left)<0) this.div.style.left="1px";
|
||||
};
|
||||
setLeftTop(x,y)
|
||||
{
|
||||
this.div.style.left=x+"px"
|
||||
if(y<0) y=0;this.div.style.top=y+"px"
|
||||
};
|
||||
setTop(y){if(y<0) y=0;this.div.style.top=y+"px"};
|
||||
getTop(){return parseInt(this.div.style.top)};
|
||||
getLeft(){return parseInt(this.div.style.left)};
|
||||
|
||||
setSize(w,h)
|
||||
{
|
||||
this.setWidth(w)
|
||||
this.setHeight(h)
|
||||
};
|
||||
//Где w вида '100px' или '100%'
|
||||
setWidth(w)
|
||||
{ if(w==null || w=='') return;
|
||||
w=''+w;
|
||||
if(w.indexOf('px')<0 && w.indexOf('%')<0) w+='px'; //По умолчанию пиксели
|
||||
this.div.style.width=w
|
||||
if(this.tbl.offsetWidth>this.div.offsetWidth) this.div.style.width=this.tbl.offsetWidth+"px"
|
||||
};
|
||||
|
||||
getWidth(){
|
||||
if(this.tbl!=null)
|
||||
return parseInt(this.tbl.offsetWidth);
|
||||
else
|
||||
return 0;
|
||||
};
|
||||
|
||||
setHeight(h)
|
||||
{
|
||||
if(h==null || h=='') return;
|
||||
h=''+h;
|
||||
if(h.indexOf('%')>-1) h=(this.div.parentNode.offsetHeight/100*parseInt(h));
|
||||
|
||||
this.co.style.height=(parseInt(h)-20-this.h0.offsetHeight)+"px";
|
||||
this.div.style.height=parseInt(h)+'px';
|
||||
|
||||
if(this.tbl.offsetHeight>this.div.offsetHeight)
|
||||
this.div.style.height=this.tbl.offsetHeight+"px";
|
||||
};
|
||||
|
||||
//Подстроить размер окна по содержимому
|
||||
/*adjustHeight()
|
||||
{
|
||||
|
||||
}*/
|
||||
|
||||
//Подгрузить содержимое окна из указаного места
|
||||
//json - объект который передастца в виде JSON строки по URL
|
||||
//func - функция которая выполниться после загрузки данных в форму
|
||||
load(url,json,func,tr)
|
||||
{
|
||||
this.showProgressBar();
|
||||
var r=createRequestObject();
|
||||
r.onreadystatechange = function(r,w,thiz,func)
|
||||
{
|
||||
return function(){
|
||||
if(r.readyState == 4){
|
||||
if(tr) w.innerHTML=trts(r.responseText);
|
||||
else w.innerHTML=r.responseText;
|
||||
thiz.hideProgressBar();
|
||||
if(func !== undefined && func!=null) func();
|
||||
|
||||
//Для подстройки формы под новый размер, а то showProgressBar не по размеру было
|
||||
thiz.div.style.width=thiz.tbl.offsetWidth+"px"
|
||||
thiz.div.style.height=thiz.tbl.offsetHeight+"px";
|
||||
|
||||
thiz.setCenter();
|
||||
}
|
||||
}
|
||||
}(r,this.co,this,func,tr)
|
||||
r.open( "POST", url, true );
|
||||
if(json!=null)
|
||||
r.send(JSON.stringify(json));
|
||||
else
|
||||
r.send();
|
||||
};
|
||||
|
||||
//Переместить окно на передний план (Обычно при щелчке на нём)
|
||||
setWinZ(s)
|
||||
{
|
||||
let i;
|
||||
this.setZ(g_wins.getMaxZ()+2); //+2 это для тени
|
||||
if(s && this.parent!=null) //Переносим текущий элемент в 0й элемент массива детей родительского
|
||||
{
|
||||
var tmp=this.parent.childs[0];
|
||||
for(i=1;i<this.parent.childs.length;i++)
|
||||
{
|
||||
if(tmp==this) break;
|
||||
let t=this.parent.childs[i];
|
||||
this.parent.childs[i]=tmp;
|
||||
tmp=t;
|
||||
}
|
||||
this.parent.childs[0]=tmp;
|
||||
}
|
||||
for(i=this.childs.length;i>0;i--) if(this.childs[i-1]!=null) this.childs[i-1].setWinZ(false) //Забыл зачем это делаю
|
||||
}
|
||||
setParent(w)
|
||||
{
|
||||
if(this.parent!=null)
|
||||
{
|
||||
for(let i=0;i<this.parent.childs.length;i++) if(this.parent.childs[i]==this) this.parent.childs[i]=null;
|
||||
}
|
||||
if(typeof w !== 'undefined' && w!=null)
|
||||
{
|
||||
this.parent=w;
|
||||
w.childs[w.childs.length]=this;
|
||||
}
|
||||
}
|
||||
hide(val)
|
||||
{
|
||||
if(val)
|
||||
{ this.div.style.display='none';
|
||||
this.divsh.style.display='none';
|
||||
}else
|
||||
{
|
||||
this.div.style.display='inline';
|
||||
if(this.shadow) this.divsh.style.display='block';
|
||||
}
|
||||
}
|
||||
|
||||
//Показать прогрес бар
|
||||
showProgressBar()
|
||||
{
|
||||
this.pBarCnt++;
|
||||
if(this.pBarDiv==null)
|
||||
{
|
||||
var img='loading.gif';
|
||||
if(this.getWidth()<230) img='loading3.gif';
|
||||
|
||||
this.pBarDiv=document.createElement('div');
|
||||
this.pBarDiv.style.cssText='position: absolute; left: 0px; top: 0px; z-index: 1; width:100%; height: 100%; margin-top:30px; padding-bottom:30px;';
|
||||
this.pBarDiv.innerHTML='<table style="background-color: rgba(0,0,0,0.5);" width="100%" height="100%" cellpadding="0" cellspacing="0"><tr><td align="center" style="vertical-align: middle;"><img src="'+this.path+'/metadata/dbms/images/'+img+'" alt=""></td></tr></table>';
|
||||
|
||||
//var eDiv=document.getElementById('eDiv'+this.uid);
|
||||
this.div.appendChild(this.pBarDiv);
|
||||
}
|
||||
}
|
||||
|
||||
//Спрятать прогрес бар
|
||||
hideProgressBar()
|
||||
{
|
||||
this.pBarCnt--;
|
||||
if(this.pBarCnt<=0)
|
||||
{
|
||||
if(this.pBarDiv!==null) deleteHTML(this.pBarDiv);
|
||||
this.pBarCnt=0;
|
||||
this.pBarDiv=null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class TWins
|
||||
{
|
||||
constructor()
|
||||
{
|
||||
this.mas = new Array();
|
||||
}
|
||||
add(win) //Добавить окно в список
|
||||
{
|
||||
this.mas.push(win);
|
||||
return this.mas.length-1;
|
||||
};
|
||||
getMaxZ() //Получить максимальный Z индекс
|
||||
{
|
||||
var z=100; //По умолчанию
|
||||
for(var i=0;i<this.mas.length;i++) if(this.mas[i]!==null && this.mas[i].getZ()>z) z=this.mas[i].getZ();
|
||||
return z;
|
||||
};
|
||||
getSel() //Получить выделенное окно
|
||||
{
|
||||
for(var i=0;i<this.mas.length;i++) if(this.mas[i].sel) return this.mas[i];
|
||||
return null;
|
||||
};
|
||||
}
|
||||
var g_wins=new TWins(); //Global object
|
||||
|
||||
148
metadata/dbms/xmltojson.js
Normal file
148
metadata/dbms/xmltojson.js
Normal file
@ -0,0 +1,148 @@
|
||||
|
||||
class xmltojson {
|
||||
constructor(xml) {
|
||||
let parser = new DOMParser();
|
||||
let xmlDoc = parser.parseFromString(xml, "text/xml");
|
||||
|
||||
this.xType = xmlDoc.documentElement;
|
||||
this.jType = {};
|
||||
|
||||
this.setType(this.xType, this.jType);
|
||||
}
|
||||
toString(){
|
||||
return JSON.stringify(this.jType);
|
||||
}
|
||||
|
||||
setType(xType, jType) {
|
||||
jType.n = xType.getAttribute("n");
|
||||
jType.d = xType.getAttribute("d");
|
||||
jType.ObjectID = xType.getAttribute("ObjectID");
|
||||
|
||||
let nodeProperties = findNodeOnPath(xType, 'properties');
|
||||
if (nodeProperties != null) {
|
||||
jType.edit_object = {};
|
||||
jType.edit_object.width = nodeProperties.getAttribute("width");
|
||||
|
||||
jType.edit_object.columns = [];
|
||||
let nodeProp = nodeProperties.firstChild;
|
||||
while (nodeProp != null) {
|
||||
if (nodeProp.nodeName == "prop") {
|
||||
let jProp = {};
|
||||
let column = this.setProp(nodeProp, jProp);
|
||||
jType.edit_object.columns.push(column);
|
||||
}
|
||||
nodeProp = nodeProp.nextSibling;
|
||||
}
|
||||
let node;
|
||||
node = findFirstNodeOnAttribute(nodeProperties, 'sql-query', 't', 'i');
|
||||
if (node != null)
|
||||
jType.edit_object.insert_query = getCdataValue(node);
|
||||
node = findFirstNodeOnAttribute(nodeProperties, 'sql-query', 't', 'u');
|
||||
if (node != null)
|
||||
jType.edit_object.update_query = getCdataValue(node);
|
||||
node = findFirstNodeOnAttribute(nodeProperties, 'sql-query', 't', 'd');
|
||||
if (node != null)
|
||||
jType.edit_object.delete_query = getCdataValue(node);
|
||||
node = findFirstNodeOnAttribute(nodeProperties, 'sql-query', 't', 's');
|
||||
if (node != null)
|
||||
jType.edit_object.select_query = getCdataValue(node);
|
||||
}
|
||||
|
||||
let nodeObjectsList = findNodeOnPath(xType, 'objects-list');
|
||||
if (nodeObjectsList != null) {
|
||||
jType.show_object = {};
|
||||
jType.show_object.width = nodeObjectsList.getAttribute("width");
|
||||
jType.show_object.d = nodeObjectsList.getAttribute("d");
|
||||
|
||||
let node;
|
||||
node = findFirstNode(nodeObjectsList, 'sql-query');
|
||||
if (node != null)
|
||||
jType.show_object.select_query = getCdataValue(node);
|
||||
|
||||
let nFilter = findFirstNode(nodeObjectsList, 'filter');
|
||||
if (nFilter != null) {
|
||||
jType.show_object.filter = {};
|
||||
if (nFilter.hasAttribute("height"))
|
||||
jType.show_object.filter.height = nFilter.getAttribute("height");
|
||||
|
||||
jType.show_object.filter.columns = [];
|
||||
let nextNode = nFilter.firstChild;
|
||||
while (nextNode != null) {
|
||||
if (nextNode.nodeName == "column") {
|
||||
let jColumn = {};
|
||||
let column = this.setFilterColumn(nextNode, jColumn);
|
||||
jType.show_object.filter.columns.push(column);
|
||||
}
|
||||
nextNode = nextNode.nextSibling;
|
||||
}
|
||||
}
|
||||
|
||||
//jType.show_object.columns = [];
|
||||
}
|
||||
//this.win.setWidth(nodeProperties.getAttribute("width"));
|
||||
|
||||
}
|
||||
|
||||
//Переписываю колонки редактирования
|
||||
setProp(xProp, jProp) {
|
||||
|
||||
if (xProp.hasAttribute("d"))
|
||||
jProp.d = xProp.getAttribute("d");
|
||||
if (xProp.hasAttribute("n"))
|
||||
jProp.n = xProp.getAttribute("n");
|
||||
if (xProp.hasAttribute("vt"))
|
||||
jProp.vt = xProp.getAttribute("vt");
|
||||
if (xProp.hasAttribute("maybenull"))
|
||||
jProp.maybenull = xProp.getAttribute("maybenull");
|
||||
if (xProp.hasAttribute("ot"))
|
||||
jProp.ot = xProp.getAttribute("ot");
|
||||
if (xProp.hasAttribute("FieldCaption"))
|
||||
jProp.FieldCaption = xProp.getAttribute("FieldCaption");
|
||||
if (xProp.hasAttribute("selector"))
|
||||
jProp.selector = xProp.getAttribute("selector");
|
||||
|
||||
jProp.value = getCdataValue(xProp);
|
||||
|
||||
|
||||
/*
|
||||
if (nodeFilter.getAttribute("n")==nodeProp.getAttribute("n"))
|
||||
{
|
||||
let cdata1=findFirstNode(nodeFilter,'#cdata-section');
|
||||
if((cdata1!=null)&&(cdata1.nodeValue!=""))
|
||||
{
|
||||
let cdata2=findFirstNode(nodeProp,'#cdata-section');
|
||||
if (cdata2==null)
|
||||
{
|
||||
cdata2 = nodeProp.ownerDocument.createCDATASection("");
|
||||
nodeProp.appendChild(cdata2);
|
||||
}
|
||||
cdata2.nodeValue=cdata1.nodeValue;
|
||||
}
|
||||
}
|
||||
* */
|
||||
return jProp;
|
||||
}
|
||||
|
||||
//Переписать из "type->objects-list->filter"
|
||||
setFilterColumn(xColumn, jColumn) {
|
||||
|
||||
if (xColumn.hasAttribute("d"))
|
||||
jColumn.d = xColumn.getAttribute("d");
|
||||
if (xColumn.hasAttribute("n"))
|
||||
jColumn.n = xColumn.getAttribute("n");
|
||||
if (xColumn.hasAttribute("vt"))
|
||||
jColumn.vt = xColumn.getAttribute("vt");
|
||||
if (xColumn.hasAttribute("object"))
|
||||
jColumn.object = xColumn.getAttribute("object");
|
||||
if (xColumn.hasAttribute("FieldCaption"))
|
||||
jColumn.FieldCaption = xColumn.getAttribute("FieldCaption");
|
||||
if (xColumn.hasAttribute("selector"))
|
||||
jColumn.selector = xColumn.getAttribute("selector");
|
||||
if (xColumn.hasAttribute("visible"))
|
||||
jColumn.visible = xColumn.getAttribute("visible");
|
||||
|
||||
jColumn.value = getCdataValue(xColumn);
|
||||
|
||||
return jColumn;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user