diff --git a/res/app/components/stf/logcat-table/index.js b/res/app/components/stf/logcat-table/index.js index 191244f8..3364691d 100644 --- a/res/app/components/stf/logcat-table/index.js +++ b/res/app/components/stf/logcat-table/index.js @@ -3,4 +3,5 @@ require('./logcat-table.css') module.exports = angular.module('stf.logcat-table', [ ]) + .value('logcatAutoScroll', true) .directive('logcatTable', require('./logcat-table-directive')) diff --git a/res/app/components/stf/logcat-table/logcat-table-directive.js b/res/app/components/stf/logcat-table/logcat-table-directive.js index f6d70398..1529f325 100644 --- a/res/app/components/stf/logcat-table/logcat-table-directive.js +++ b/res/app/components/stf/logcat-table/logcat-table-directive.js @@ -1,12 +1,93 @@ -module.exports = function logcatTableDirective() { +var _ = require('lodash') + +module.exports = function logcatTableDirective($rootScope, $timeout, logcatAutoScroll) { return { restrict: 'E', replace: true, - scope: { - - }, template: require('./logcat-table.jade'), link: function (scope, element, attrs) { + var parent = element[0] + var body = element.find('tbody')[0] + + function scrollToBottom() { + parent.scrollTop = parent.scrollHeight + 20 + $timeout(function () { + parent.scrollTop = parent.scrollHeight + }, 10) + } + + function addRow(data, batchRequest) { + var newRow = body.insertRow(-1) + +// newRow.insertCell(-1) +// .appendChild($document.createTextNode(DeviceLogService.linesCounter)); +// newRow.insertCell(-1) +// .appendChild($document.createTextNode(data.deviceName)); +// newRow.insertCell(-1) +// .appendChild($document.createTextNode(data.levelName)); +// newRow.insertCell(-1) +// .appendChild($document.createTextNode(data.dateFormatted)); +// if ($rootScope.platform === 'native') { + newRow.insertCell(-1) + .appendChild(document.createTextNode(data.pid)) + newRow.insertCell(-1) + .appendChild(document.createTextNode(data.tid)) + newRow.insertCell(-1) + .appendChild(document.createTextNode(data.app)) + newRow.insertCell(-1) + .appendChild(document.createTextNode(data.tag)) +// } + newRow.insertCell(-1) + .appendChild(document.createTextNode(data.message)) + + if (logcatAutoScroll && !batchRequest) { + _.throttle(scrollToBottom, 10)() + } + } + + function clearTable() { + var oldBody = body + var newBody = document.createElement('tbody') + oldBody.parentNode.replaceChild(newBody, oldBody) + body = newBody + } + + addRow({ + "serial": "1cd49783", + "date": 1399964036.984, + "pid": 9246, + "tid": 9540, + "priority": 3, + "tag": "MobileDataStateTracker", + "message": "default: setPolicyDataEnable(enabled=true)" + }) + + for (var i = 0; i < 50; i++) { + addRow({ + "serial": "14141cd49783", + "date": 1399964036.984, + "pid": 9246, + "tid": 9540, + "priority": 3, + "tag": "MobileDataStateTracker", + "message": "XXdefault: setPolicyDataEnable(enabled=true)" + }) + } + + $timeout(function () { + for (var i = 0; i < 10; i++) { + addRow({ + "serial": "14141cd49783", + "date": 1399964036.984, + "pid": 9246, + "tid": 9540, + "priority": 3, + "tag": "MobileDataStateTracker", + "message": "XXdefault: setPolicyDataEnable(enabled=true)" + }) + } + }, 1000) + } } diff --git a/res/app/components/stf/logcat-table/logcat-table.css b/res/app/components/stf/logcat-table/logcat-table.css index 05c719a9..fc7a642a 100644 --- a/res/app/components/stf/logcat-table/logcat-table.css +++ b/res/app/components/stf/logcat-table/logcat-table.css @@ -1,3 +1,71 @@ .stf-logcat-table { + background: #fff; + position: absolute; + top: 69px; + left: 0; + right: 0; + bottom: 0; + overflow-y: auto; + box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); + /*z-index: -10;*/ +} -} \ No newline at end of file +.stf-logcat-table table { + table-layout: fixed !important; +} + +.stf-logcat-table tbody tr { + border-bottom: 1px solid rgb(240, 240, 240); +} + +.stf-logcat-table tbody td { + padding-left: 5px; + padding-right: 5px; +} + +.stf-logcat-table .console-message-text { + font-size: 11px !important; + font-family: Menlo, monospace; + white-space: pre-wrap; +} + +.stf-logcat-table .console-message-text td { + /*color: rgb(48, 57, 66);*/ +} + +/** + Logging colors +*/ + +.stf-logcat-table .log-unknown { + color: bisque; +} + +.stf-logcat-table .log-default, +.stf-logcat-table .log-silent { + color: darkolivegreen; +} + +.stf-logcat-table .log-verbose { + color: blueviolet; +} + +.stf-logcat-table .log-debug { + color: rgb(48, 57, 66); +} + +.stf-logcat-table .log-info { + color: blue; +} + +.stf-logcat-table .log-warn { + color: coral; +} + +.stf-logcat-table .log-error { + color: red; +} + +.stf-logcat-table .log-fatal { + color: darkcyan; +} diff --git a/res/app/components/stf/logcat-table/logcat-table.jade b/res/app/components/stf/logcat-table/logcat-table.jade index 16b9583f..cbbbd84f 100644 --- a/res/app/components/stf/logcat-table/logcat-table.jade +++ b/res/app/components/stf/logcat-table/logcat-table.jade @@ -1 +1,3 @@ -div.stf-logcat-table \ No newline at end of file +.stf-logcat-table.force-gpu + table.console-message-text.tableX.table-condensedX.selectableX + tbody diff --git a/res/app/control-panes/logs/logs.jade b/res/app/control-panes/logs/logs.jade index a48e95cb..7bde4f1a 100644 --- a/res/app/control-panes/logs/logs.jade +++ b/res/app/control-panes/logs/logs.jade @@ -60,7 +60,8 @@ i.fa.fa-trash-o span(translate) Clear - #logcatParent.force-gpu + logcat-table + //#logcatParent.force-gpu table#logcatTable.console-message-text.tableX.table-condensedX.selectableX //thead tr diff --git a/res/app/control-panes/logs/logs.less b/res/app/control-panes/logs/logs.less index 57a21b4e..d990cf8e 100644 --- a/res/app/control-panes/logs/logs.less +++ b/res/app/control-panes/logs/logs.less @@ -1,26 +1,5 @@ .stf-logs { - #logcatSingle { - height: 600px; - overflow-y: auto; - } - - #logcatParent { - background: #fff; - position: absolute; - top: 69px; - left: 0; - right: 0; - bottom: 0; - overflow-y: auto; - box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); - /*z-index: -10;*/ - } - - #logcatTable { - table-layout: fixed !important; - } - .logcat-filters-table { margin-bottom: 0; box-shadow: 0 1px 5px rgba(0, 0, 0, 0.1); @@ -39,60 +18,6 @@ border-top: none; } - #logcatBody tr { - border-bottom: 1px solid rgb(240, 240, 240); - } - - #logcatBody td { - padding-left: 5px; - padding-right: 5px; - } - - .console-message-text { - font-size: 11px !important; - font-family: Menlo, monospace; - white-space: pre-wrap; - } - - .console-message-text td { - /*color: rgb(48, 57, 66);*/ - } - - /** - Logging colors - */ - - .log-unknown { - color: bisque; - } - - .log-default, .log-silent { - color: darkolivegreen; - } - - .log-verbose { - color: blueviolet; - } - - .log-debug { - color: rgb(48, 57, 66); - } - - .log-info { - color: blue; - } - - .log-warn { - color: coral; - } - - .log-error { - color: red; - } - - .log-fatal { - color: darkcyan; - } }