mirror of
https://bitbucket.org/bellord13/kit.git
synced 2026-11-13 19:06:11 +03:00
fix
This commit is contained in:
@@ -284,7 +284,7 @@ kit.PluginManager.register('Collection', function(module, exports, require, glob
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method removes an item from the collection by its key
|
* Method removes/delete an item from the collection by its key
|
||||||
* @param key
|
* @param key
|
||||||
* @return {kit.Collection}
|
* @return {kit.Collection}
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -215,6 +215,7 @@ __PluginManager__.registerPlugins({
|
|||||||
module: '/logger.js',
|
module: '/logger.js',
|
||||||
css: '/logger.css',
|
css: '/logger.css',
|
||||||
type: 'loader',
|
type: 'loader',
|
||||||
|
deps: ['support']
|
||||||
},
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
--logger-color-info: hsl(205, 100%, 61%);
|
--logger-color-info: hsl(205, 100%, 61%);
|
||||||
--logger-color-debug: #909090;
|
--logger-color-debug: #909090;
|
||||||
--logger-color-success: #8bc34a;
|
--logger-color-success: #8bc34a;
|
||||||
|
--logger-lvl: 0;
|
||||||
}
|
}
|
||||||
.kit-logger, #kit-logger {
|
.kit-logger, #kit-logger {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
@@ -25,7 +26,7 @@
|
|||||||
bottom: 0;
|
bottom: 0;
|
||||||
height: 30vh;
|
height: 30vh;
|
||||||
}
|
}
|
||||||
bx_kit_log {
|
logger-item {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
display: -ms-flexbox;
|
display: -ms-flexbox;
|
||||||
display: -webkit-flex;
|
display: -webkit-flex;
|
||||||
@@ -46,34 +47,34 @@ bx_kit_log {
|
|||||||
-ms-flex-align: start;
|
-ms-flex-align: start;
|
||||||
align-items: flex-start;
|
align-items: flex-start;
|
||||||
white-space: pre-line;
|
white-space: pre-line;
|
||||||
|
padding-left: calc(var(--logger-lvl, 0) * 25px);
|
||||||
font-size: 12px !important;
|
font-size: 12px !important;
|
||||||
line-height: 14px !important;
|
line-height: 14px !important;
|
||||||
}
|
}
|
||||||
bx_kit_log_value * {
|
logger-item__value * {
|
||||||
color: inherit;
|
color: inherit;
|
||||||
}
|
}
|
||||||
bx_kit_log_msg {
|
logger-item__msg {
|
||||||
|
|
||||||
}
|
}
|
||||||
bx_kit_log_key {
|
logger-item__key {
|
||||||
min-width: 25px;
|
min-width: 25px;
|
||||||
padding-right: 5px;
|
padding-right: 5px;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
color: var(--logger-color-key, #909090);
|
color: var(--logger-color-key, #909090);
|
||||||
}
|
}
|
||||||
bx_kit_log_key:empty {
|
logger-item__key:empty {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
bx_kit_log_lvl {
|
logger-item__lvl {
|
||||||
min-width: 25px;
|
min-width: 25px;
|
||||||
}
|
}
|
||||||
bx_kit_log_value {
|
logger-item__value {
|
||||||
flex: 1 0 0;
|
flex: 1 0 0;
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
color: var(--logger-color-value, #c1c1c1);
|
color: var(--logger-color-value, #c1c1c1);
|
||||||
}
|
}
|
||||||
bx_kit_log_value * {
|
logger-item__value * {
|
||||||
font-size: inherit !important;
|
font-size: inherit !important;
|
||||||
line-height: inherit !important;
|
line-height: inherit !important;
|
||||||
color: inherit !important;
|
color: inherit !important;
|
||||||
|
|||||||
+37
-29
@@ -1,23 +1,19 @@
|
|||||||
/** @module logger */
|
/** @module logger */
|
||||||
__PluginManager__.register('Logger', function(module, exports, require, global){
|
__PluginManager__.register('Logger', function(module, exports, require, global){
|
||||||
|
|
||||||
function makeNode(html = '') {
|
var support = require('support');
|
||||||
var nodeWrap = document.createElement('div');
|
|
||||||
nodeWrap.innerHTML = html;
|
|
||||||
var r = nodeWrap.firstElementChild;
|
|
||||||
r.remove();
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
var lightMap = [
|
var lightMap = [
|
||||||
{class: '', keys: []},
|
{class: '', keys: []},
|
||||||
{class: 'text-danger', keys: []},
|
{class: 'text-danger', keys: []},
|
||||||
{class: 'text-secondary', keys: []},
|
{class: 'text-secondary', keys: []},
|
||||||
];
|
];
|
||||||
var getLightClass = function(key) {
|
var getLightClass = function(key) {
|
||||||
|
key = ''+key;
|
||||||
var addClass = '', ar;
|
var addClass = '', ar;
|
||||||
for(var i=0; i < lightMap.length; i++){
|
for(var i=0; i < lightMap.length; i++){
|
||||||
ar = lightMap[i]['keys'];
|
ar = lightMap[i]['keys'];
|
||||||
addClass = ar.includes(String(key))?lightMap[i]['class']:addClass;
|
addClass = ar.includes(key)?lightMap[i]['class']:addClass;
|
||||||
}
|
}
|
||||||
return addClass;
|
return addClass;
|
||||||
};
|
};
|
||||||
@@ -32,20 +28,26 @@ __PluginManager__.register('Logger', function(module, exports, require, global){
|
|||||||
// }
|
// }
|
||||||
// return rArray.join(' ');
|
// return rArray.join(' ');
|
||||||
// };
|
// };
|
||||||
function getRowNode(level, key, value, opClass){
|
function getRowNode(level, key, value, opClass = ''){
|
||||||
if(opClass) {
|
if(opClass) {
|
||||||
opClass = ' kit-logger-row--'+opClass;
|
opClass = ' kit-logger-row--'+opClass;
|
||||||
}
|
}
|
||||||
var i = 0, lvlTemplate = '', setStyle = '';
|
var i = 0, lvlTemplate = '';
|
||||||
level = Number(level);
|
|
||||||
key = String(key);
|
key = String(key);
|
||||||
value = String(value);
|
value = String(value);
|
||||||
for(i = 0; i < level; i++){
|
lvlTemplate = level?'style="--logger-lvl:'+level+';" ':'';
|
||||||
lvlTemplate += '<bx_kit_log_lvl></bx_kit_log_lvl>';
|
var result = '<logger-item '+lvlTemplate+'class="'+getLightClass(key)+opClass+'"><logger-item__key>'+key+'</logger-item__key><logger-item__value>'+value+'</logger-item__value></logger-item>';
|
||||||
}
|
|
||||||
var result = '<bx_kit_log class="'+getLightClass(key)+opClass+'" style="'+setStyle+'">'+lvlTemplate+'<bx_kit_log_key class="">'+key+'</bx_kit_log_key><bx_kit_log_value class="text-log-value">'+value+'</bx_kit_log_value></bx_kit_log>';
|
|
||||||
|
|
||||||
return makeNode(result);
|
return support.makeNode(result);
|
||||||
|
}
|
||||||
|
function getItemObjectNode(id = ''){
|
||||||
|
var entity = '', css = '', style = '';
|
||||||
|
if(id) {
|
||||||
|
css = '<style>input#'+id+':checked ~ [data-entity-id="'+id+'"] {display: block !important;}</style>';
|
||||||
|
entity = ' data-entity-id="'+id+'"';
|
||||||
|
style = ' style="display: none"'
|
||||||
|
}
|
||||||
|
return support.makeNode('<logger-item-object'+entity+style+'>'+css+'</logger-item-object>');
|
||||||
}
|
}
|
||||||
|
|
||||||
function args2array(arguments) {
|
function args2array(arguments) {
|
||||||
@@ -70,7 +72,7 @@ __PluginManager__.register('Logger', function(module, exports, require, global){
|
|||||||
/**
|
/**
|
||||||
* @type {HTMLElement}
|
* @type {HTMLElement}
|
||||||
*/
|
*/
|
||||||
this.collection = node || document.getElementById('kit-logger') || document.querySelector('.kit-logger') || makeNode(collectionTemplater);
|
this.collection = node || document.getElementById('kit-logger') || document.querySelector('.kit-logger') || support.makeNode(collectionTemplater);
|
||||||
|
|
||||||
if((this.collection instanceof HTMLElement) && !this.collection.parentElement) {
|
if((this.collection instanceof HTMLElement) && !this.collection.parentElement) {
|
||||||
document.body.appendChild(this.collection)
|
document.body.appendChild(this.collection)
|
||||||
@@ -81,22 +83,28 @@ __PluginManager__.register('Logger', function(module, exports, require, global){
|
|||||||
this.setCollection();
|
this.setCollection();
|
||||||
}
|
}
|
||||||
var log = this.collection;
|
var log = this.collection;
|
||||||
var k = 0, j = 0, i = 0, m = 0, rowNode;
|
var k = 0, j = 0, i = 0, m = 0, rowNode1, valNode1, rowNode2, isObj, val;
|
||||||
|
|
||||||
if(typeof message == 'object') {
|
if(support.isObject(message)) {
|
||||||
for(k in message) {
|
for(k in message) {
|
||||||
log.appendChild(getRowNode(lvl, k, message[k], opClass));
|
log.appendChild(rowNode2 = getRowNode(lvl, k, message[k], opClass));
|
||||||
if(typeof message[k] == 'object') {
|
if(support.isObject(message[k])) {
|
||||||
|
log.appendChild(rowNode1 = getItemObjectNode());
|
||||||
for(j in message[k]) {
|
for(j in message[k]) {
|
||||||
log.appendChild(getRowNode(lvl+1, j, message[k][j]));
|
isObj = support.isObject(message[k][j]);
|
||||||
if(typeof message[k][j] == 'object') {
|
id = support.uniqueId();
|
||||||
|
val = isObj?'<label for="'+id+'">'+message[k][j]+'</label>':message[k][j];
|
||||||
|
rowNode1.appendChild(getRowNode(lvl+1, j, val));
|
||||||
|
rowNode1.appendChild(support.makeNode('<input id="'+id+'" type="checkbox" style="display: none;">'));
|
||||||
|
if(isObj) {
|
||||||
|
rowNode1.appendChild(rowNode2 = getItemObjectNode(id));
|
||||||
for(i in message[k][j]) {
|
for(i in message[k][j]) {
|
||||||
log.appendChild(getRowNode(lvl+2, i, message[k][j][i]));
|
rowNode2.appendChild(getRowNode(lvl+2, i, message[k][j][i]));
|
||||||
if(typeof message[k][j][i] == 'object') {
|
// if(typeof message[k][j][i] == 'object') {
|
||||||
for(m in message[k][j][i]) {
|
// for(m in message[k][j][i]) {
|
||||||
log.appendChild(getRowNode(lvl+3, m, message[k][j][i][m]));
|
// log.appendChild(getRowNode(lvl+3, m, message[k][j][i][m]));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-2
@@ -18,23 +18,36 @@ $APPLICATION->ShowHead();
|
|||||||
<script>
|
<script>
|
||||||
kit.ready(['bsToastService', 'testing', 'date', ], function () {
|
kit.ready(['bsToastService', 'testing', 'date', ], function () {
|
||||||
|
|
||||||
|
var support = kit.support;
|
||||||
|
|
||||||
var unit = new kit.testing.Unit();
|
var unit = new kit.testing.Unit();
|
||||||
unit.logger.info('Тест bootstrap.Toast 5.1.3');
|
unit.logger.info('Тест bootstrap.Toast 5.1.3');
|
||||||
unit.logger.info('Тест service.toast');
|
unit.logger.info('Тест service.toast');
|
||||||
unit.logger.notice(' ');
|
unit.logger.notice(' ');
|
||||||
|
|
||||||
|
kit.service.toast.onShow.add('test', function(toast, node){
|
||||||
|
unit.assertSame('title', toast.data.title, 'Проверка toast.data.title в событии onShow');
|
||||||
|
unit.assertSame('message', toast.data.message, 'Проверка toast.data.message в событии onShow');
|
||||||
|
unit.assertSame('desc', toast.data.desc, 'Проверка toast.data.desc в событии onShow');
|
||||||
|
unit.assertSame(node, toast._element, 'Проверка node в событии onShow');
|
||||||
|
unit.assertSame(support.getKit(node, 'toast'), toast, 'Проверка node.kit.toast в событии onShow');
|
||||||
|
});
|
||||||
|
kit.service.toast.info('title', 'message', 'desc');
|
||||||
|
kit.service.toast.onShow.forget('test');
|
||||||
|
|
||||||
|
|
||||||
var audio = new Audio('https://issue.megapolis-it.ru/local/media/new_message_tone.mp3');
|
var audio = new Audio('https://issue.megapolis-it.ru/local/media/new_message_tone.mp3');
|
||||||
kit.service.toast.onShow.push(function (toast, node) {
|
kit.service.toast.onShow.push(function (toast, node) {
|
||||||
unit.logger.info(toast.data.title, toast.data);
|
unit.logger.info(toast.data.title, toast.data);
|
||||||
audio.play();
|
//audio.play();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
kit.service.toast.option.delay = 18000;
|
||||||
var intervalId = setInterval(function(){
|
var intervalId = setInterval(function(){
|
||||||
kit.service.toast.info('Новая заявка', 'Заявка от Пупкина на дальний склад. Очень срочно! Нужно еще вчера...', kit.date('H:i:s'));
|
kit.service.toast.info('Новая заявка', 'Заявка от Пупкина на дальний склад. Очень срочно! Нужно еще вчера...', kit.date('H:i:s'));
|
||||||
//stop();
|
//stop();
|
||||||
}, 5000);
|
}, 5000);
|
||||||
|
|
||||||
|
|
||||||
var stop = function(){
|
var stop = function(){
|
||||||
clearInterval(intervalId);
|
clearInterval(intervalId);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user