mirror of
https://github.com/ansible/awx.git
synced 2026-03-19 01:47:31 -02:30
Add dynamic angular interaction after HTML insertion
This commit is contained in:
committed by
Jake McDermott
parent
aaec3474b0
commit
0a66d1c3fc
@@ -20,6 +20,7 @@
|
|||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
|
|
||||||
padding: 0 20px 0 10px;
|
padding: 0 20px 0 10px;
|
||||||
|
user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
&-line {
|
&-line {
|
||||||
@@ -30,30 +31,24 @@
|
|||||||
|
|
||||||
padding-right: 5px;
|
padding-right: 5px;
|
||||||
border-right: 1px solid @at-gray-dark;
|
border-right: 1px solid @at-gray-dark;
|
||||||
|
user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
&-event {
|
&-event {
|
||||||
padding-left: 2ch;
|
padding: 0 10px;
|
||||||
width: 83ch;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&-time {
|
&-time {
|
||||||
padding-left: 20px;
|
padding-right: 2ch;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
|
user-select: none;
|
||||||
|
width: 11ch;
|
||||||
|
border-left: 1px dashed @at-gray-dark;
|
||||||
}
|
}
|
||||||
|
|
||||||
&-container {
|
&-container {
|
||||||
& > table {
|
max-height: 80vh;
|
||||||
table-layout: fixed;
|
|
||||||
|
|
||||||
td {
|
|
||||||
vertical-align: top;
|
|
||||||
word-wrap: break-word;
|
|
||||||
white-space: pre-wrap;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
border: 1px solid @at-gray-dark-2x;
|
border: 1px solid @at-gray-dark-2x;
|
||||||
background-color: @at-gray-light-3x;
|
background-color: @at-gray-light-3x;
|
||||||
@@ -61,5 +56,19 @@
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
border-top-left-radius: 0;
|
border-top-left-radius: 0;
|
||||||
border-top-right-radius: 0;
|
border-top-right-radius: 0;
|
||||||
|
|
||||||
|
& > table {
|
||||||
|
table-layout: fixed;
|
||||||
|
|
||||||
|
tr:hover > td {
|
||||||
|
background: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
td {
|
||||||
|
vertical-align: top;
|
||||||
|
word-wrap: break-word;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,10 @@ import Ansi from 'ansi-to-html';
|
|||||||
import hasAnsi from 'has-ansi';
|
import hasAnsi from 'has-ansi';
|
||||||
|
|
||||||
let ansi;
|
let ansi;
|
||||||
|
let $timeout;
|
||||||
|
let $sce;
|
||||||
|
let $compile;
|
||||||
|
let $scope;
|
||||||
|
|
||||||
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';
|
||||||
@@ -18,22 +22,30 @@ const TIME_EVENTS = [
|
|||||||
EVENT_STATS_PLAY
|
EVENT_STATS_PLAY
|
||||||
];
|
];
|
||||||
|
|
||||||
function JobsIndexController (job, $sce) {
|
function JobsIndexController (job, _$sce_, _$timeout_, _$scope_, _$compile_) {
|
||||||
|
ansi = new Ansi();
|
||||||
|
$timeout = _$timeout_;
|
||||||
|
$sce = _$sce_;
|
||||||
|
$compile = _$compile_;
|
||||||
|
$scope = _$scope_;
|
||||||
|
|
||||||
const vm = this || {};
|
const vm = this || {};
|
||||||
const events = job.get('related.job_events.results');
|
const events = job.get('related.job_events.results');
|
||||||
|
const html = $sce.trustAsHtml(parseEvents(events));
|
||||||
|
|
||||||
ansi = new Ansi();
|
|
||||||
|
|
||||||
const html = parseEvents(events);
|
|
||||||
|
|
||||||
vm.html = $sce.trustAsHtml(html);
|
|
||||||
vm.toggle = toggle;
|
vm.toggle = toggle;
|
||||||
|
|
||||||
|
$timeout(() => {
|
||||||
|
const table = $('#result-table');
|
||||||
|
|
||||||
|
table.html($sce.getTrustedHtml(html));
|
||||||
|
$compile(table.contents())($scope);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseEvents (events) {
|
function parseEvents (events) {
|
||||||
events.sort(orderByLineNumber);
|
events.sort(orderByLineNumber);
|
||||||
|
|
||||||
console.log(events);
|
|
||||||
return events.reduce((html, event) => `${html}${parseLine(event)}`, '');
|
return events.reduce((html, event) => `${html}${parseLine(event)}`, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,12 +102,12 @@ function createRow (ln, content, time, group) {
|
|||||||
|
|
||||||
let expand = '';
|
let expand = '';
|
||||||
if (group.parent) {
|
if (group.parent) {
|
||||||
expand = '<i class="fa fa-chevron-down" ng-click="vm.toggle(group.level)"></i>';
|
expand = '<i class="fa fa-chevron-down can-toggle"></i>';
|
||||||
}
|
}
|
||||||
|
|
||||||
return `
|
return `
|
||||||
<tr class="${group.classList}">
|
<tr class="${group.classList}">
|
||||||
<td class="at-Stdout-toggle">${expand}</td>
|
<td class="at-Stdout-toggle" ng-click="vm.toggle(${group.id})">${expand}</td>
|
||||||
<td class="at-Stdout-line">${ln}</td>
|
<td class="at-Stdout-line">${ln}</td>
|
||||||
<td class="at-Stdout-event">${content}</td>
|
<td class="at-Stdout-event">${content}</td>
|
||||||
<td class="at-Stdout-time">${time}</td>
|
<td class="at-Stdout-time">${time}</td>
|
||||||
@@ -108,6 +120,7 @@ function getGroup (event, i) {
|
|||||||
if (EVENT_GROUPS.includes(event.event) && i === 1) {
|
if (EVENT_GROUPS.includes(event.event) && i === 1) {
|
||||||
group.parent = true;
|
group.parent = true;
|
||||||
group.classList = `parent parent-${event.event_level}`;
|
group.classList = `parent parent-${event.event_level}`;
|
||||||
|
group.id = i;
|
||||||
} else {
|
} else {
|
||||||
group.classList = '';
|
group.classList = '';
|
||||||
}
|
}
|
||||||
@@ -130,17 +143,7 @@ function getTime (event, i) {
|
|||||||
function toggle (id) {
|
function toggle (id) {
|
||||||
console.log(id);
|
console.log(id);
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
*
|
JobsIndexController.$inject = ['job', '$sce', '$timeout', '$scope', '$compile'];
|
||||||
*function getTruncatedEvent () {
|
|
||||||
*
|
|
||||||
*}
|
|
||||||
*
|
|
||||||
*function addDynamic (start) {
|
|
||||||
* document.getElementsByClassName('parent')
|
|
||||||
*}
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
JobsIndexController.$inject = ['job', '$sce'];
|
|
||||||
|
|
||||||
module.exports = JobsIndexController;
|
module.exports = JobsIndexController;
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ function JobsRun ($stateExtender, strings) {
|
|||||||
return new Jobs('get', id)
|
return new Jobs('get', id)
|
||||||
.then(job => job.extend('job_events', {
|
.then(job => job.extend('job_events', {
|
||||||
params: {
|
params: {
|
||||||
page_size: 200,
|
page_size: 10000,
|
||||||
order_by: 'start_line'
|
order_by: 'start_line'
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -12,23 +12,7 @@
|
|||||||
<div class="at-u-clear"></div>
|
<div class="at-u-clear"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<pre class="at-Stdout-container"><table>
|
<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>
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th class="at-Stdout-toggle"> </th>
|
|
||||||
<th class="at-Stdout-line"></th>
|
|
||||||
<th class="at-Stdout-event"></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody ng-bind-html="vm.html"></tbody>
|
|
||||||
<tfoot>
|
|
||||||
<tr>
|
|
||||||
<td class="at-Stdout-toggle"> </td>
|
|
||||||
<td class="at-Stdout-line"></td>
|
|
||||||
<td class="at-Stdout-event"></td>
|
|
||||||
<td class="at-Stdout-backToTop"><i class="fa fa-caret-up"></i> <span>Back to Top</span></td>
|
|
||||||
</tr>
|
|
||||||
</tfoot></table></pre>
|
|
||||||
</at-panel>
|
</at-panel>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user