mirror of
https://github.com/ansible/awx.git
synced 2026-03-25 04:45:03 -02:30
add basic output expand-collapse
This commit is contained in:
@@ -67,14 +67,6 @@ function onFrames (events) {
|
|||||||
|
|
||||||
const capacity = slide.getCapacity();
|
const capacity = slide.getCapacity();
|
||||||
|
|
||||||
if (capacity >= events.length) {
|
|
||||||
return slide.pushFront(events);
|
|
||||||
}
|
|
||||||
|
|
||||||
delete render.record;
|
|
||||||
|
|
||||||
render.record = {};
|
|
||||||
|
|
||||||
return slide.popBack(events.length - capacity)
|
return slide.popBack(events.length - capacity)
|
||||||
.then(() => slide.pushFront(events))
|
.then(() => slide.pushFront(events))
|
||||||
.then(() => {
|
.then(() => {
|
||||||
@@ -131,10 +123,6 @@ function last () {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function compile (html) {
|
|
||||||
return $compile(html)($scope);
|
|
||||||
}
|
|
||||||
|
|
||||||
function follow () {
|
function follow () {
|
||||||
scroll.pause();
|
scroll.pause();
|
||||||
// scroll.hide();
|
// scroll.hide();
|
||||||
@@ -149,6 +137,69 @@ function unfollow () {
|
|||||||
scroll.resume();
|
scroll.resume();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function togglePanelExpand () {
|
||||||
|
vm.isPanelExpanded = !vm.isPanelExpanded;
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleMenuExpand () {
|
||||||
|
if (scroll.isPaused()) return;
|
||||||
|
|
||||||
|
const recordList = Object.keys(render.record).map(key => render.record[key]);
|
||||||
|
const minLevel = Math.min(...recordList.map(({ level }) => level));
|
||||||
|
|
||||||
|
const toggled = recordList
|
||||||
|
.filter(({ level }) => level === minLevel)
|
||||||
|
.map(({ uuid }) => getToggleElements(uuid))
|
||||||
|
.filter(({ icon }) => icon.length > 0)
|
||||||
|
.map(({ icon, lines }) => setExpanded(icon, lines, !vm.isMenuExpanded));
|
||||||
|
|
||||||
|
if (toggled.length > 0) {
|
||||||
|
vm.isMenuExpanded = !vm.isMenuExpanded;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleLineExpand (uuid) {
|
||||||
|
if (scroll.isPaused()) return;
|
||||||
|
|
||||||
|
const { icon, lines } = getToggleElements(uuid);
|
||||||
|
const isExpanded = icon.hasClass('fa-angle-down');
|
||||||
|
|
||||||
|
setExpanded(icon, lines, !isExpanded);
|
||||||
|
|
||||||
|
vm.isMenuExpanded = !isExpanded;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getToggleElements (uuid) {
|
||||||
|
const record = render.record[uuid];
|
||||||
|
const lines = $(`.child-of-${uuid}`);
|
||||||
|
|
||||||
|
const iconSelector = '.at-Stdout-toggle > i';
|
||||||
|
const additionalSelector = `#${(record.children || []).join(', #')}`;
|
||||||
|
|
||||||
|
let icon = $(`#${uuid} ${iconSelector}`);
|
||||||
|
if (additionalSelector) {
|
||||||
|
icon = icon.add($(additionalSelector).find(iconSelector));
|
||||||
|
}
|
||||||
|
|
||||||
|
return { icon, lines };
|
||||||
|
}
|
||||||
|
|
||||||
|
function setExpanded (icon, lines, expanded) {
|
||||||
|
if (expanded) {
|
||||||
|
icon.removeClass('fa-angle-right');
|
||||||
|
icon.addClass('fa-angle-down');
|
||||||
|
lines.removeClass('hidden');
|
||||||
|
} else {
|
||||||
|
icon.removeClass('fa-angle-down');
|
||||||
|
icon.addClass('fa-angle-right');
|
||||||
|
lines.addClass('hidden');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function compile (html) {
|
||||||
|
return $compile(html)($scope);
|
||||||
|
}
|
||||||
|
|
||||||
function showHostDetails (id, uuid) {
|
function showHostDetails (id, uuid) {
|
||||||
$state.go('output.host-event.json', { eventId: id, taskUuid: uuid });
|
$state.go('output.host-event.json', { eventId: id, taskUuid: uuid });
|
||||||
}
|
}
|
||||||
@@ -203,13 +254,11 @@ function OutputIndexController (
|
|||||||
vm = this || {};
|
vm = this || {};
|
||||||
|
|
||||||
// Panel
|
// Panel
|
||||||
|
vm.title = $filter('sanitize')(resource.model.get('name'));
|
||||||
vm.strings = strings;
|
vm.strings = strings;
|
||||||
vm.resource = resource;
|
vm.resource = resource;
|
||||||
vm.title = $filter('sanitize')(resource.model.get('name'));
|
vm.isPanelExpanded = false;
|
||||||
|
vm.togglePanelExpand = togglePanelExpand;
|
||||||
vm.expanded = false;
|
|
||||||
vm.showHostDetails = showHostDetails;
|
|
||||||
vm.toggleExpanded = () => { vm.expanded = !vm.expanded; };
|
|
||||||
|
|
||||||
// Stdout Navigation
|
// Stdout Navigation
|
||||||
vm.menu = {
|
vm.menu = {
|
||||||
@@ -218,6 +267,11 @@ function OutputIndexController (
|
|||||||
up: previous,
|
up: previous,
|
||||||
down: next,
|
down: next,
|
||||||
};
|
};
|
||||||
|
vm.isMenuExpanded = true;
|
||||||
|
vm.toggleMenuExpand = toggleMenuExpand;
|
||||||
|
vm.toggleLineExpand = toggleLineExpand;
|
||||||
|
vm.showHostDetails = showHostDetails;
|
||||||
|
vm.toggleLineEnabled = resource.model.get('type') === 'job';
|
||||||
|
|
||||||
render.requestAnimationFrame(() => {
|
render.requestAnimationFrame(() => {
|
||||||
bufferInit();
|
bufferInit();
|
||||||
@@ -225,7 +279,7 @@ function OutputIndexController (
|
|||||||
status.init(resource);
|
status.init(resource);
|
||||||
slide.init(render, resource.events);
|
slide.init(render, resource.events);
|
||||||
|
|
||||||
render.init({ compile });
|
render.init({ compile, toggles: vm.toggleLineEnabled });
|
||||||
scroll.init({ previous, next });
|
scroll.init({ previous, next });
|
||||||
|
|
||||||
stream.init({
|
stream.init({
|
||||||
|
|||||||
@@ -1,25 +1,25 @@
|
|||||||
<div ui-view></div>
|
<div ui-view></div>
|
||||||
<div class="JobResults-container">
|
<div class="JobResults-container">
|
||||||
<at-panel ng-show="!vm.expanded">
|
<at-panel ng-show="!vm.isPanelExpanded">
|
||||||
<at-job-details
|
<at-job-details
|
||||||
resource="vm.resource">
|
resource="vm.resource">
|
||||||
</at-job-details>
|
</at-job-details>
|
||||||
</at-panel>
|
</at-panel>
|
||||||
|
|
||||||
<at-panel class="at-Stdout" ng-class="{'at-Stdout--fullscreen': vm.expanded}">
|
<at-panel class="at-Stdout" ng-class="{'at-Stdout--fullscreen': vm.isPanelExpanded}">
|
||||||
<div class="at-Panel-headingTitle">
|
<div class="at-Panel-headingTitle">
|
||||||
{{ vm.title }}
|
{{ vm.title }}
|
||||||
</div>
|
</div>
|
||||||
<at-job-stats
|
<at-job-stats
|
||||||
resource="vm.resource"
|
resource="vm.resource"
|
||||||
expanded="vm.expanded">
|
expanded="vm.isPanelExpanded">
|
||||||
</at-job-stats>
|
</at-job-stats>
|
||||||
<at-job-search></at-job-search>
|
<at-job-search></at-job-search>
|
||||||
|
|
||||||
<div class="at-Stdout-menuTop">
|
<div class="at-Stdout-menuTop">
|
||||||
<div class="pull-left" ng-click="vm.toggleExpand()">
|
<div class="pull-left" ng-click="vm.toggleMenuExpand()">
|
||||||
<i class="at-Stdout-menuIcon fa"
|
<i class="at-Stdout-menuIcon fa" ng-if="vm.toggleLineEnabled"
|
||||||
ng-class="{ 'fa-minus': vm.expanded, 'fa-plus': !vm.expanded }"></i>
|
ng-class="{ 'fa-minus': vm.isMenuExpanded, 'fa-plus': !vm.isMenuExpanded }"></i>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="pull-right" ng-click="vm.menu.end()">
|
<div class="pull-right" ng-click="vm.menu.end()">
|
||||||
|
|||||||
@@ -30,13 +30,13 @@ const re = new RegExp(pattern);
|
|||||||
const hasAnsi = input => re.test(input);
|
const hasAnsi = input => re.test(input);
|
||||||
|
|
||||||
function JobRenderService ($q, $sce, $window) {
|
function JobRenderService ($q, $sce, $window) {
|
||||||
this.init = ({ compile }) => {
|
this.init = ({ compile, toggles }) => {
|
||||||
this.parent = null;
|
this.parent = null;
|
||||||
this.record = {};
|
this.record = {};
|
||||||
this.el = $(ELEMENT_TBODY);
|
this.el = $(ELEMENT_TBODY);
|
||||||
this.hooks = { compile };
|
this.hooks = { compile };
|
||||||
|
|
||||||
this.createToggles = false;
|
this.createToggles = toggles;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.sortByLineNumber = (a, b) => {
|
this.sortByLineNumber = (a, b) => {
|
||||||
@@ -164,6 +164,24 @@ function JobRenderService ($q, $sce, $window) {
|
|||||||
return info;
|
return info;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.deleteRecord = uuid => {
|
||||||
|
delete this.record[uuid];
|
||||||
|
};
|
||||||
|
|
||||||
|
this.getParentEvents = (uuid, list) => {
|
||||||
|
list = list || [];
|
||||||
|
|
||||||
|
if (this.record[uuid]) {
|
||||||
|
list.push(uuid);
|
||||||
|
|
||||||
|
if (this.record[uuid].parents) {
|
||||||
|
list = list.concat(this.record[uuid].parents);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
};
|
||||||
|
|
||||||
this.createRow = (current, ln, content) => {
|
this.createRow = (current, ln, content) => {
|
||||||
let id = '';
|
let id = '';
|
||||||
let timestamp = '';
|
let timestamp = '';
|
||||||
@@ -180,7 +198,7 @@ function JobRenderService ($q, $sce, $window) {
|
|||||||
if (current) {
|
if (current) {
|
||||||
if (this.createToggles && current.isParent && current.line === ln) {
|
if (this.createToggles && current.isParent && current.line === ln) {
|
||||||
id = current.uuid;
|
id = current.uuid;
|
||||||
tdToggle = `<td class="at-Stdout-toggle" ng-click="vm.toggle('${id}')"><i class="fa fa-angle-down can-toggle"></i></td>`;
|
tdToggle = `<td class="at-Stdout-toggle" ng-click="vm.toggleLineExpand('${id}')"><i class="fa fa-angle-down can-toggle"></i></td>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (current.isHost) {
|
if (current.isHost) {
|
||||||
@@ -226,20 +244,6 @@ function JobRenderService ($q, $sce, $window) {
|
|||||||
return `${hour}:${minute}:${second}`;
|
return `${hour}:${minute}:${second}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getParentEvents = (uuid, list) => {
|
|
||||||
list = list || [];
|
|
||||||
|
|
||||||
if (this.record[uuid]) {
|
|
||||||
list.push(uuid);
|
|
||||||
|
|
||||||
if (this.record[uuid].parents) {
|
|
||||||
list = list.concat(this.record[uuid].parents);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return list;
|
|
||||||
};
|
|
||||||
|
|
||||||
this.remove = elements => this.requestAnimationFrame(() => elements.remove());
|
this.remove = elements => this.requestAnimationFrame(() => elements.remove());
|
||||||
|
|
||||||
this.requestAnimationFrame = fn => $q(resolve => {
|
this.requestAnimationFrame = fn => $q(resolve => {
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ function getOverlapArray (range, other) {
|
|||||||
|
|
||||||
function SlidingWindowService ($q) {
|
function SlidingWindowService ($q) {
|
||||||
this.init = (storage, api) => {
|
this.init = (storage, api) => {
|
||||||
const { prepend, append, shift, pop } = storage;
|
const { prepend, append, shift, pop, deleteRecord } = storage;
|
||||||
const { getMaxCounter, getRange, getFirst, getLast } = api;
|
const { getMaxCounter, getRange, getFirst, getLast } = api;
|
||||||
|
|
||||||
this.api = {
|
this.api = {
|
||||||
@@ -74,10 +74,12 @@ function SlidingWindowService ($q) {
|
|||||||
prepend,
|
prepend,
|
||||||
append,
|
append,
|
||||||
shift,
|
shift,
|
||||||
pop
|
pop,
|
||||||
|
deleteRecord,
|
||||||
};
|
};
|
||||||
|
|
||||||
this.records = {};
|
this.records = {};
|
||||||
|
this.uuids = {};
|
||||||
this.chain = $q.resolve();
|
this.chain = $q.resolve();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -87,8 +89,9 @@ function SlidingWindowService ($q) {
|
|||||||
|
|
||||||
return this.storage.append(newEvents)
|
return this.storage.append(newEvents)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
newEvents.forEach(({ counter, start_line, end_line }) => {
|
newEvents.forEach(({ counter, start_line, end_line, uuid }) => {
|
||||||
this.records[counter] = { start_line, end_line };
|
this.records[counter] = { start_line, end_line };
|
||||||
|
this.uuids[counter] = uuid;
|
||||||
});
|
});
|
||||||
|
|
||||||
return $q.resolve();
|
return $q.resolve();
|
||||||
@@ -102,8 +105,9 @@ function SlidingWindowService ($q) {
|
|||||||
|
|
||||||
return this.storage.prepend(newEvents)
|
return this.storage.prepend(newEvents)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
newEvents.forEach(({ counter, start_line, end_line }) => {
|
newEvents.forEach(({ counter, start_line, end_line, uuid }) => {
|
||||||
this.records[counter] = { start_line, end_line };
|
this.records[counter] = { start_line, end_line };
|
||||||
|
this.uuids[counter] = uuid;
|
||||||
});
|
});
|
||||||
|
|
||||||
return $q.resolve();
|
return $q.resolve();
|
||||||
@@ -130,6 +134,9 @@ function SlidingWindowService ($q) {
|
|||||||
.then(() => {
|
.then(() => {
|
||||||
for (let i = max; i >= min; --i) {
|
for (let i = max; i >= min; --i) {
|
||||||
delete this.records[i];
|
delete this.records[i];
|
||||||
|
|
||||||
|
this.storage.deleteRecord(this.uuids[i]);
|
||||||
|
delete this.uuids[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $q.resolve();
|
return $q.resolve();
|
||||||
@@ -156,6 +163,9 @@ function SlidingWindowService ($q) {
|
|||||||
.then(() => {
|
.then(() => {
|
||||||
for (let i = min; i <= max; ++i) {
|
for (let i = min; i <= max; ++i) {
|
||||||
delete this.records[i];
|
delete this.records[i];
|
||||||
|
|
||||||
|
this.storage.deleteRecord(this.uuids[i]);
|
||||||
|
delete this.uuids[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $q.resolve();
|
return $q.resolve();
|
||||||
|
|||||||
Reference in New Issue
Block a user