mirror of
https://github.com/ansible/awx.git
synced 2026-03-15 07:57:29 -02:30
Add scrollTo for top and bottom, add better expand/collapse
This commit is contained in:
committed by
Jake McDermott
parent
d914b70bb6
commit
56b6d7e85d
@@ -1,7 +1,7 @@
|
|||||||
.at-Stdout {
|
.at-Stdout {
|
||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
|
|
||||||
&-menu {
|
&-menuTop {
|
||||||
color: @at-gray-dark-4x;
|
color: @at-gray-dark-4x;
|
||||||
border: 1px solid @at-gray-dark-2x;
|
border: 1px solid @at-gray-dark-2x;
|
||||||
border-top-left-radius: 4px;
|
border-top-left-radius: 4px;
|
||||||
@@ -9,9 +9,18 @@
|
|||||||
border-bottom: none;
|
border-bottom: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&-menuBottom {
|
||||||
|
color: @at-gray-dark-4x;
|
||||||
|
border: 1px solid @at-gray-dark-2x;
|
||||||
|
border-bottom-left-radius: 4px;
|
||||||
|
border-bottom-right-radius: 4px;
|
||||||
|
border-top: none;
|
||||||
|
}
|
||||||
|
|
||||||
&-menuIcon {
|
&-menuIcon {
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
&-toggle {
|
&-toggle {
|
||||||
@@ -51,7 +60,6 @@
|
|||||||
text-align: right;
|
text-align: right;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
width: 11ch;
|
width: 11ch;
|
||||||
border-left: 1px dashed @at-gray-dark;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&-container {
|
&-container {
|
||||||
@@ -61,8 +69,7 @@
|
|||||||
background-color: @at-gray-light-3x;
|
background-color: @at-gray-light-3x;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
border-top-left-radius: 0;
|
border-radius: 0;
|
||||||
border-top-right-radius: 0;
|
|
||||||
|
|
||||||
& > table {
|
& > table {
|
||||||
table-layout: fixed;
|
table-layout: fixed;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import Ansi from 'ansi-to-html';
|
import Ansi from 'ansi-to-html';
|
||||||
import hasAnsi from 'has-ansi';
|
import hasAnsi from 'has-ansi';
|
||||||
|
|
||||||
|
let vm;
|
||||||
let ansi;
|
let ansi;
|
||||||
let $timeout;
|
let $timeout;
|
||||||
let $sce;
|
let $sce;
|
||||||
@@ -8,6 +9,7 @@ let $compile;
|
|||||||
let $scope;
|
let $scope;
|
||||||
|
|
||||||
const record = {};
|
const record = {};
|
||||||
|
const meta = {};
|
||||||
|
|
||||||
const EVENT_START_TASK = 'playbook_on_task_start';
|
const EVENT_START_TASK = 'playbook_on_task_start';
|
||||||
const EVENT_START_PLAY = 'playbook_on_play_start';
|
const EVENT_START_PLAY = 'playbook_on_play_start';
|
||||||
@@ -31,11 +33,20 @@ function JobsIndexController (job, _$sce_, _$timeout_, _$scope_, _$compile_) {
|
|||||||
$scope = _$scope_;
|
$scope = _$scope_;
|
||||||
ansi = new Ansi();
|
ansi = new Ansi();
|
||||||
|
|
||||||
const vm = this || {};
|
vm = this || {};
|
||||||
const events = job.get('related.job_events.results');
|
const events = job.get('related.job_events.results');
|
||||||
const html = $sce.trustAsHtml(parseEvents(events));
|
const html = $sce.trustAsHtml(parseEvents(events));
|
||||||
|
|
||||||
vm.toggle = toggle;
|
vm.toggle = toggle;
|
||||||
|
vm.menu = {
|
||||||
|
expand: menuExpand,
|
||||||
|
scrollToBottom: menuScrollToBottom,
|
||||||
|
scrollToTop: menuScrollToTop
|
||||||
|
};
|
||||||
|
|
||||||
|
vm.state = {
|
||||||
|
expand: true
|
||||||
|
};
|
||||||
|
|
||||||
$timeout(() => {
|
$timeout(() => {
|
||||||
const table = $('#result-table');
|
const table = $('#result-table');
|
||||||
@@ -43,8 +54,23 @@ function JobsIndexController (job, _$sce_, _$timeout_, _$scope_, _$compile_) {
|
|||||||
table.html($sce.getTrustedHtml(html));
|
table.html($sce.getTrustedHtml(html));
|
||||||
$compile(table.contents())($scope);
|
$compile(table.contents())($scope);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
console.log(record);
|
function menuExpand () {
|
||||||
|
vm.state.expand = !vm.state.expand;
|
||||||
|
vm.toggle(meta.parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
function menuScrollToBottom () {
|
||||||
|
const container = $('.at-Stdout-container')[0];
|
||||||
|
|
||||||
|
container.scrollTo(0, container.scrollHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
function menuScrollToTop () {
|
||||||
|
const container = $('.at-Stdout-container')[0];
|
||||||
|
|
||||||
|
container.scrollTo(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseEvents (events) {
|
function parseEvents (events) {
|
||||||
@@ -106,7 +132,7 @@ function createRecord (ln, lines, event) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (event.parent_uuid) {
|
if (event.parent_uuid) {
|
||||||
info.childOf = event.parent_uuid;
|
info.parents = getParentEvents(event.parent_uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info.isTruncated) {
|
if (info.isTruncated) {
|
||||||
@@ -115,6 +141,19 @@ function createRecord (ln, lines, event) {
|
|||||||
|
|
||||||
if (EVENT_GROUPS.includes(event.event)) {
|
if (EVENT_GROUPS.includes(event.event)) {
|
||||||
info.isParent = true;
|
info.isParent = true;
|
||||||
|
|
||||||
|
if (event.event_level === 1) {
|
||||||
|
meta.parent = event.uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.parent_uuid) {
|
||||||
|
if (record[event.parent_uuid].children &&
|
||||||
|
!record[event.parent_uuid].children.includes(event.uuid)) {
|
||||||
|
record[event.parent_uuid].children.push(event.uuid);
|
||||||
|
} else {
|
||||||
|
record[event.parent_uuid].children = [event.uuid];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TIME_EVENTS.includes(event.event)) {
|
if (TIME_EVENTS.includes(event.event)) {
|
||||||
@@ -127,6 +166,20 @@ function createRecord (ln, lines, event) {
|
|||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getParentEvents (uuid, list) {
|
||||||
|
list = list || [];
|
||||||
|
|
||||||
|
if (record[uuid]) {
|
||||||
|
list.push(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (record[uuid].parents) {
|
||||||
|
list = list.concat(record[uuid].parents);
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
function createRow (current, ln, content) {
|
function createRow (current, ln, content) {
|
||||||
let expand = '';
|
let expand = '';
|
||||||
let timestamp = '';
|
let timestamp = '';
|
||||||
@@ -151,8 +204,8 @@ function createRow (current, ln, content) {
|
|||||||
timestamp = current.time;
|
timestamp = current.time;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!classList) {
|
if (current.parents) {
|
||||||
classList += `child-of-${current.childOf}`;
|
classList = current.parents.reduce((list, uuid) => `${list} child-of-${uuid}`, '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,18 +233,23 @@ function getTime (created) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function toggle (uuid) {
|
function toggle (uuid) {
|
||||||
const i = $(`#${uuid} .at-Stdout-toggle > i`);
|
const lines = $(`.child-of-${uuid}`);
|
||||||
|
let icon = $(`#${uuid} .at-Stdout-toggle > i`);
|
||||||
|
|
||||||
if (i.hasClass('fa-chevron-down')) {
|
if (record[uuid].children) {
|
||||||
i.addClass('fa-chevron-right');
|
icon = icon.add($(`#${record[uuid].children.join(', #')}`).find('.at-Stdout-toggle > i'));
|
||||||
i.removeClass('fa-chevron-down');
|
}
|
||||||
|
|
||||||
$(`.child-of-${uuid}`).addClass('hidden');
|
if (icon.hasClass('fa-chevron-down')) {
|
||||||
|
icon.addClass('fa-chevron-right');
|
||||||
|
icon.removeClass('fa-chevron-down');
|
||||||
|
|
||||||
|
lines.addClass('hidden');
|
||||||
} else {
|
} else {
|
||||||
i.addClass('fa-chevron-down');
|
icon.addClass('fa-chevron-down');
|
||||||
i.removeClass('fa-chevron-right');
|
icon.removeClass('fa-chevron-right');
|
||||||
|
|
||||||
$(`.child-of-${uuid}`).removeClass('hidden');
|
lines.removeClass('hidden');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,13 +6,27 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-md-8">
|
<div class="col-md-8">
|
||||||
<at-panel class="at-Stdout">
|
<at-panel class="at-Stdout">
|
||||||
<div class="at-Stdout-menu">
|
<div class="at-Stdout-menuTop">
|
||||||
<div class="pull-left"><i class="at-Stdout-menuIcon fa fa-minus"></i></div>
|
<div class="pull-left" ng-click="vm.menu.expand()">
|
||||||
<div class="pull-right"><i class="at-Stdout-menuIcon fa fa-arrow-down"></i></div>
|
<i class="at-Stdout-menuIcon fa"
|
||||||
|
ng-class="{ 'fa-minus': vm.state.expand, 'fa-plus': !vm.state.expand }"></i>
|
||||||
|
</div>
|
||||||
|
<div class="pull-right" ng-click="vm.menu.scrollToBottom()">
|
||||||
|
<i class="at-Stdout-menuIcon fa fa-arrow-down"></i>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="at-u-clear"></div>
|
<div class="at-u-clear"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<pre class="at-Stdout-container"><table><thead><tr><th class="at-Stdout-toggle"> </th><th class="at-Stdout-line"></th><th class="at-Stdout-event"></th></tr></thead><tbody id="result-table"></tbody></table></pre>
|
<pre class="at-Stdout-container"><table><thead><tr><th class="at-Stdout-toggle"> </th><th class="at-Stdout-line"></th><th class="at-Stdout-event"></th></tr></thead><tbody id="result-table"></tbody></table></pre>
|
||||||
|
|
||||||
|
<div class="at-Stdout-menuBottom">
|
||||||
|
<div class="pull-right" ng-click="vm.menu.scrollToTop()">
|
||||||
|
<i class="at-Stdout-menuIcon fa fa-arrow-up"></i>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="at-u-clear"></div>
|
||||||
|
</div>
|
||||||
</at-panel>
|
</at-panel>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user