mirror of
https://github.com/ansible/awx.git
synced 2026-02-28 16:28:43 -03:30
remove unused lib code
This commit is contained in:
@@ -1,104 +0,0 @@
|
|||||||
import Ansi from 'ansi-to-html';
|
|
||||||
import hasAnsi from 'has-ansi';
|
|
||||||
|
|
||||||
const templateUrl = require('~components/code/events.partial.html');
|
|
||||||
|
|
||||||
let $sce;
|
|
||||||
let $timeout;
|
|
||||||
let ansi;
|
|
||||||
|
|
||||||
function atOutputEventLink (scope, element, attrs, controller) {
|
|
||||||
controller.init(scope, element);
|
|
||||||
}
|
|
||||||
|
|
||||||
function AtOutputEventController (_$sce_, _$timeout_) {
|
|
||||||
const vm = this || {};
|
|
||||||
|
|
||||||
$timeout = _$timeout_;
|
|
||||||
$sce = _$sce_;
|
|
||||||
ansi = new Ansi();
|
|
||||||
|
|
||||||
let scope;
|
|
||||||
let element;
|
|
||||||
|
|
||||||
vm.init = (_scope_, _element_) => {
|
|
||||||
scope = _scope_;
|
|
||||||
element = _element_;
|
|
||||||
|
|
||||||
scope.$watch('state.stdout', curr => {
|
|
||||||
if (!curr) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
render(scope.state.stdout);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
vm.scroll = position => {
|
|
||||||
const container = element.find('.at-Stdout-container')[0];
|
|
||||||
|
|
||||||
if (position === 'bottom') {
|
|
||||||
container.scrollTop = container.scrollHeight;
|
|
||||||
} else {
|
|
||||||
container.scrollTop = 0;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
AtOutputEventController.$inject = [
|
|
||||||
'$sce',
|
|
||||||
'$timeout',
|
|
||||||
];
|
|
||||||
|
|
||||||
function render (stdout) {
|
|
||||||
const html = $sce.trustAsHtml(parseStdout(stdout));
|
|
||||||
|
|
||||||
$timeout(() => {
|
|
||||||
const table = $('#atStdoutTBody');
|
|
||||||
|
|
||||||
table.html($sce.getTrustedHtml(html));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function parseStdout (stdout) {
|
|
||||||
const lines = stdout.split('\r\n');
|
|
||||||
|
|
||||||
let ln = 0;
|
|
||||||
|
|
||||||
return lines.reduce((html, line) => {
|
|
||||||
ln++;
|
|
||||||
|
|
||||||
return `${html}${createRow(ln, line)}`;
|
|
||||||
}, '');
|
|
||||||
}
|
|
||||||
|
|
||||||
function createRow (ln, content) {
|
|
||||||
content = content || '';
|
|
||||||
|
|
||||||
if (hasAnsi(content)) {
|
|
||||||
content = ansi.toHtml(content);
|
|
||||||
}
|
|
||||||
|
|
||||||
return `
|
|
||||||
<tr>
|
|
||||||
<td class="at-Stdout-line">${ln}</td>
|
|
||||||
<td class="at-Stdout-event">${content}</td>
|
|
||||||
</tr>`;
|
|
||||||
}
|
|
||||||
function atOutputEvent () {
|
|
||||||
return {
|
|
||||||
restrict: 'E',
|
|
||||||
transclude: true,
|
|
||||||
replace: true,
|
|
||||||
require: 'atOutputEvent',
|
|
||||||
templateUrl,
|
|
||||||
controller: AtOutputEventController,
|
|
||||||
controllerAs: 'vm',
|
|
||||||
link: atOutputEventLink,
|
|
||||||
scope: {
|
|
||||||
state: '=',
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export default atOutputEvent;
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
const templateUrl = require('~components/code/menu-bottom.partial.html');
|
|
||||||
|
|
||||||
function atCodeMenuBottomLink (scope, element, attrs, controller) {
|
|
||||||
controller.init(scope, element);
|
|
||||||
}
|
|
||||||
|
|
||||||
function AtCodeMenuBottomController () {
|
|
||||||
const vm = this || {};
|
|
||||||
|
|
||||||
let element;
|
|
||||||
|
|
||||||
vm.init = (_scope_, _element_) => {
|
|
||||||
element = _element_;
|
|
||||||
};
|
|
||||||
|
|
||||||
vm.scroll = () => {
|
|
||||||
const container = element.find('.at-Stdout-container')[0];
|
|
||||||
|
|
||||||
container.scrollTop = container.scrollHeight;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
AtCodeMenuBottomController.$inject = [];
|
|
||||||
|
|
||||||
function atCodeMenuBottom () {
|
|
||||||
return {
|
|
||||||
restrict: 'E',
|
|
||||||
transclude: true,
|
|
||||||
replace: true,
|
|
||||||
require: 'atCodeMenuBottom',
|
|
||||||
templateUrl,
|
|
||||||
controller: AtCodeMenuBottomController,
|
|
||||||
controllerAs: 'vm',
|
|
||||||
link: atCodeMenuBottomLink,
|
|
||||||
scope: {
|
|
||||||
state: '=',
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export default atCodeMenuBottom;
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
<div class="at-Stdout-menuBottom">
|
|
||||||
<div class="pull-right" ng-click="vm.scroll()">
|
|
||||||
<i class="at-Stdout-menuIcon fa fa-arrow-up"></i>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="at-u-clear"></div>
|
|
||||||
</div>
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
const templateUrl = require('~components/code/menu-top.partial.html');
|
|
||||||
|
|
||||||
function atCodeMenuTopLink (scope, element, attrs, controller) {
|
|
||||||
controller.init(scope, element);
|
|
||||||
}
|
|
||||||
|
|
||||||
function AtCodeMenuTopController () {
|
|
||||||
const vm = this || {};
|
|
||||||
|
|
||||||
let element;
|
|
||||||
let scope;
|
|
||||||
|
|
||||||
vm.init = (_scope_, _element_) => {
|
|
||||||
scope = _scope_;
|
|
||||||
element = _element_;
|
|
||||||
|
|
||||||
scope.state.isExpanded = scope.state.isExpanded || false;
|
|
||||||
};
|
|
||||||
|
|
||||||
vm.scroll = () => {
|
|
||||||
const container = element.parent().find('.at-Stdout-container')[0];
|
|
||||||
|
|
||||||
container.scrollTop = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
vm.expand = () => {
|
|
||||||
scope.state.isExpanded = !scope.state.isExpanded;
|
|
||||||
scope.state.expand();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
AtCodeMenuTopController.$inject = [];
|
|
||||||
|
|
||||||
function atCodeMenuTop () {
|
|
||||||
return {
|
|
||||||
restrict: 'E',
|
|
||||||
transclude: true,
|
|
||||||
replace: true,
|
|
||||||
require: 'atCodeMenuTop',
|
|
||||||
templateUrl,
|
|
||||||
controller: AtCodeMenuTopController,
|
|
||||||
controllerAs: 'vm',
|
|
||||||
link: atCodeMenuTopLink,
|
|
||||||
scope: {
|
|
||||||
state: '=',
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export default atCodeMenuTop;
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
<div class="at-Stdout-menuTop">
|
|
||||||
<div class="pull-left" ng-click="vm.expand()">
|
|
||||||
<i class="at-Stdout-menuIcon fa"
|
|
||||||
ng-class="{ 'fa-minus': state.isExpanded, 'fa-plus': !state.isExpanded }"></i>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="pull-right" ng-click="vm.scroll()">
|
|
||||||
<i class="at-Stdout-menuIcon fa fa-arrow-down"></i>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="at-u-clear"></div>
|
|
||||||
</div>
|
|
||||||
@@ -1,105 +0,0 @@
|
|||||||
import Ansi from 'ansi-to-html';
|
|
||||||
import hasAnsi from 'has-ansi';
|
|
||||||
|
|
||||||
const templateUrl = require('~components/code/stdout.partial.html');
|
|
||||||
|
|
||||||
let $sce;
|
|
||||||
let $timeout;
|
|
||||||
let ansi;
|
|
||||||
|
|
||||||
function atCodeStdoutLink (scope, element, attrs, controller) {
|
|
||||||
controller.init(scope, element);
|
|
||||||
}
|
|
||||||
|
|
||||||
function AtCodeStdoutController (_$sce_, _$timeout_) {
|
|
||||||
const vm = this || {};
|
|
||||||
|
|
||||||
$timeout = _$timeout_;
|
|
||||||
$sce = _$sce_;
|
|
||||||
ansi = new Ansi();
|
|
||||||
|
|
||||||
let scope;
|
|
||||||
let element;
|
|
||||||
|
|
||||||
vm.init = (_scope_, _element_) => {
|
|
||||||
scope = _scope_;
|
|
||||||
element = _element_;
|
|
||||||
|
|
||||||
scope.$watch('state.stdout', curr => {
|
|
||||||
if (!curr) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
render(scope.state.stdout);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
vm.scroll = position => {
|
|
||||||
const container = element.find('.at-Stdout-container')[0];
|
|
||||||
|
|
||||||
if (position === 'bottom') {
|
|
||||||
container.scrollTop = container.scrollHeight;
|
|
||||||
} else {
|
|
||||||
container.scrollTop = 0;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
AtCodeStdoutController.$inject = [
|
|
||||||
'$sce',
|
|
||||||
'$timeout',
|
|
||||||
];
|
|
||||||
|
|
||||||
function render (stdout) {
|
|
||||||
const html = $sce.trustAsHtml(parseStdout(stdout));
|
|
||||||
|
|
||||||
$timeout(() => {
|
|
||||||
const table = $('#atStdoutTBody');
|
|
||||||
|
|
||||||
table.html($sce.getTrustedHtml(html));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function parseStdout (stdout) {
|
|
||||||
const lines = stdout.split('\r\n');
|
|
||||||
|
|
||||||
let ln = 0;
|
|
||||||
|
|
||||||
return lines.reduce((html, line) => {
|
|
||||||
ln++;
|
|
||||||
|
|
||||||
return `${html}${createRow(ln, line)}`;
|
|
||||||
}, '');
|
|
||||||
}
|
|
||||||
|
|
||||||
function createRow (ln, content) {
|
|
||||||
content = content || '';
|
|
||||||
|
|
||||||
if (hasAnsi(content)) {
|
|
||||||
content = ansi.toHtml(content);
|
|
||||||
}
|
|
||||||
|
|
||||||
return `
|
|
||||||
<tr>
|
|
||||||
<td class="at-Stdout-line">${ln}</td>
|
|
||||||
<td class="at-Stdout-event">${content}</td>
|
|
||||||
</tr>`;
|
|
||||||
}
|
|
||||||
|
|
||||||
function atCodeStdout () {
|
|
||||||
return {
|
|
||||||
restrict: 'E',
|
|
||||||
transclude: true,
|
|
||||||
replace: true,
|
|
||||||
require: 'atCodeStdout',
|
|
||||||
templateUrl,
|
|
||||||
controller: AtCodeStdoutController,
|
|
||||||
controllerAs: 'vm',
|
|
||||||
link: atCodeStdoutLink,
|
|
||||||
scope: {
|
|
||||||
state: '=',
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export default atCodeStdout;
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
<div class="at-Stdout">
|
|
||||||
<div ng-if="state.menu" class="at-Stdout-menuTop">
|
|
||||||
<div class="pull-right" ng-click="vm.scroll('bottom')">
|
|
||||||
<i class="at-Stdout-menuIcon fa fa-arrow-down"></i>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="at-u-clear"></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<pre class="at-Stdout-container"><table><thead><tr><th class="at-Stdout-line"></th><th class="at-Stdout-event"></th></tr></thead><tbody id="atStdoutTBody"></tbody></table></pre>
|
|
||||||
|
|
||||||
<div ng-if="state-menu" class="at-Stdout-menuBottom">
|
|
||||||
<div class="pull-right" ng-click="vm.scroll('top')">
|
|
||||||
<i class="at-Stdout-menuIcon fa fa-arrow-up"></i>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="at-u-clear"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@@ -1,10 +1,6 @@
|
|||||||
import atLibServices from '~services';
|
import atLibServices from '~services';
|
||||||
|
|
||||||
import actionGroup from '~components/action/action-group.directive';
|
import actionGroup from '~components/action/action-group.directive';
|
||||||
import codeMenuBottom from '~components/code/menu-bottom.directive';
|
|
||||||
import codeMenuTop from '~components/code/menu-top.directive';
|
|
||||||
import codeEvents from '~components/code/events.directive';
|
|
||||||
import codeStdout from '~components/code/stdout.directive';
|
|
||||||
import divider from '~components/utility/divider.directive';
|
import divider from '~components/utility/divider.directive';
|
||||||
import form from '~components/form/form.directive';
|
import form from '~components/form/form.directive';
|
||||||
import formAction from '~components/form/action.directive';
|
import formAction from '~components/form/action.directive';
|
||||||
@@ -49,10 +45,6 @@ angular
|
|||||||
atLibServices
|
atLibServices
|
||||||
])
|
])
|
||||||
.directive('atActionGroup', actionGroup)
|
.directive('atActionGroup', actionGroup)
|
||||||
.directive('atCodeEvents', codeEvents)
|
|
||||||
.directive('atCodeMenuBottom', codeMenuBottom)
|
|
||||||
.directive('atCodeMenuTop', codeMenuTop)
|
|
||||||
.directive('atCodeStdout', codeStdout)
|
|
||||||
.directive('atDivider', divider)
|
.directive('atDivider', divider)
|
||||||
.directive('atForm', form)
|
.directive('atForm', form)
|
||||||
.directive('atFormAction', formAction)
|
.directive('atFormAction', formAction)
|
||||||
|
|||||||
@@ -1,118 +0,0 @@
|
|||||||
import uuid from 'uuid';
|
|
||||||
|
|
||||||
import {
|
|
||||||
get,
|
|
||||||
post,
|
|
||||||
} from '../api';
|
|
||||||
import {
|
|
||||||
getAdminMachineCredential,
|
|
||||||
getInventory,
|
|
||||||
getOrCreate,
|
|
||||||
getOrganization,
|
|
||||||
waitForJob,
|
|
||||||
} from '../fixtures';
|
|
||||||
|
|
||||||
// AWX_E2E_URL='https://localhost:3000' npm --prefix awx/ui run e2e -- --filter="*jobz*"
|
|
||||||
|
|
||||||
const session = `e2e-${uuid().substr(0, 8)}`;
|
|
||||||
|
|
||||||
const SCM_URL = 'https://github.com/jakemcdermott/ansible-playbooks';
|
|
||||||
const PLAYBOOK = 'setfact_50.yml';
|
|
||||||
const PARAMS = '?job_event_search=page_size:200;order_by:start_line;not__event__in:playbook_on_start,playbook_on_play_start,playbook_on_task_start,playbook_on_stats;task:set';
|
|
||||||
|
|
||||||
let data;
|
|
||||||
|
|
||||||
const waitForJobz = endpoint => {
|
|
||||||
const interval = 2000;
|
|
||||||
const statuses = ['successful', 'failed', 'error', 'canceled'];
|
|
||||||
|
|
||||||
let attempts = 20;
|
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
(function pollStatus () {
|
|
||||||
get(endpoint).then(update => {
|
|
||||||
const completed = statuses.indexOf(update.data.status) > -1;
|
|
||||||
|
|
||||||
if (completed) {
|
|
||||||
return resolve(update.data);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (--attempts <= 0) {
|
|
||||||
return reject(new Error('Retry limit exceeded.'));
|
|
||||||
}
|
|
||||||
|
|
||||||
return setTimeout(pollStatus, interval);
|
|
||||||
});
|
|
||||||
}());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const getProject = (namespace = session) => getOrganization(namespace)
|
|
||||||
.then(organization => getOrCreate('/projects/', {
|
|
||||||
name: `${namespace}-project`,
|
|
||||||
description: namespace,
|
|
||||||
organization: organization.id,
|
|
||||||
scm_url: SCM_URL,
|
|
||||||
scm_type: 'git'
|
|
||||||
})
|
|
||||||
.then(project => {
|
|
||||||
if (project.related.current_update) {
|
|
||||||
return waitForJobz(project.related.current_update)
|
|
||||||
.then(() => project);
|
|
||||||
}
|
|
||||||
return project;
|
|
||||||
}));
|
|
||||||
|
|
||||||
const getJobTemplate = (namespace = session) => {
|
|
||||||
const promises = [
|
|
||||||
getInventory(namespace),
|
|
||||||
getAdminMachineCredential(namespace),
|
|
||||||
getProject(namespace)
|
|
||||||
];
|
|
||||||
|
|
||||||
return Promise.all(promises)
|
|
||||||
.then(([inventory, credential, project]) => getOrCreate('/job_templates/', {
|
|
||||||
name: `${namespace}-job-template`,
|
|
||||||
description: namespace,
|
|
||||||
inventory: inventory.id,
|
|
||||||
credential: credential.id,
|
|
||||||
project: project.id,
|
|
||||||
playbook: PLAYBOOK,
|
|
||||||
}));
|
|
||||||
};
|
|
||||||
|
|
||||||
const getJob = (namespace = session) => getJobTemplate(namespace)
|
|
||||||
.then(template => {
|
|
||||||
if (template.related.last_job) {
|
|
||||||
return waitForJobz(template.related.last_job);
|
|
||||||
}
|
|
||||||
|
|
||||||
return post(template.related.launch, {})
|
|
||||||
.then(res => waitForJobz(res.data.url));
|
|
||||||
});
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
before: (client, done) => {
|
|
||||||
getJob()
|
|
||||||
.then(job => {
|
|
||||||
data = { job };
|
|
||||||
done();
|
|
||||||
})
|
|
||||||
},
|
|
||||||
'test jobz': client => {
|
|
||||||
const location = `${client.globals.launch_url}/#/jobz/playbook/${data.job.id}`;
|
|
||||||
const templates = client.page.templates();
|
|
||||||
|
|
||||||
client.useCss();
|
|
||||||
client.resizeWindow(1200, 800);
|
|
||||||
client.login();
|
|
||||||
client.waitForAngular();
|
|
||||||
|
|
||||||
// client.url(location);
|
|
||||||
client.url(`${location}${PARAMS}`);
|
|
||||||
|
|
||||||
client.pause();
|
|
||||||
|
|
||||||
client.end();
|
|
||||||
},
|
|
||||||
};
|
|
||||||
Reference in New Issue
Block a user