From 356defff09d61fb1241dafcd4b496141dddc5d84 Mon Sep 17 00:00:00 2001 From: Jake McDermott Date: Tue, 3 Apr 2018 22:53:30 -0400 Subject: [PATCH] remove unused lib code --- .../lib/components/code/events.directive.js | 104 --------------- .../lib/components/code/events.partial.html | 0 .../components/code/menu-bottom.directive.js | 41 ------ .../components/code/menu-bottom.partial.html | 7 -- .../lib/components/code/menu-top.directive.js | 50 -------- .../lib/components/code/menu-top.partial.html | 12 -- .../lib/components/code/stdout.directive.js | 105 ---------------- .../lib/components/code/stdout.partial.html | 19 --- awx/ui/client/lib/components/index.js | 8 -- awx/ui/test/e2e/tests/test-jobz.js | 118 ------------------ 10 files changed, 464 deletions(-) delete mode 100644 awx/ui/client/lib/components/code/events.directive.js delete mode 100644 awx/ui/client/lib/components/code/events.partial.html delete mode 100644 awx/ui/client/lib/components/code/menu-bottom.directive.js delete mode 100644 awx/ui/client/lib/components/code/menu-bottom.partial.html delete mode 100644 awx/ui/client/lib/components/code/menu-top.directive.js delete mode 100644 awx/ui/client/lib/components/code/menu-top.partial.html delete mode 100644 awx/ui/client/lib/components/code/stdout.directive.js delete mode 100644 awx/ui/client/lib/components/code/stdout.partial.html delete mode 100644 awx/ui/test/e2e/tests/test-jobz.js diff --git a/awx/ui/client/lib/components/code/events.directive.js b/awx/ui/client/lib/components/code/events.directive.js deleted file mode 100644 index 8426bf3ae6..0000000000 --- a/awx/ui/client/lib/components/code/events.directive.js +++ /dev/null @@ -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 ` - - ${ln} - ${content} - `; -} -function atOutputEvent () { - return { - restrict: 'E', - transclude: true, - replace: true, - require: 'atOutputEvent', - templateUrl, - controller: AtOutputEventController, - controllerAs: 'vm', - link: atOutputEventLink, - scope: { - state: '=', - } - }; -} - -export default atOutputEvent; diff --git a/awx/ui/client/lib/components/code/events.partial.html b/awx/ui/client/lib/components/code/events.partial.html deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/awx/ui/client/lib/components/code/menu-bottom.directive.js b/awx/ui/client/lib/components/code/menu-bottom.directive.js deleted file mode 100644 index 5b15a7bc10..0000000000 --- a/awx/ui/client/lib/components/code/menu-bottom.directive.js +++ /dev/null @@ -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; diff --git a/awx/ui/client/lib/components/code/menu-bottom.partial.html b/awx/ui/client/lib/components/code/menu-bottom.partial.html deleted file mode 100644 index 1a0717a360..0000000000 --- a/awx/ui/client/lib/components/code/menu-bottom.partial.html +++ /dev/null @@ -1,7 +0,0 @@ -
-
- -
- -
-
diff --git a/awx/ui/client/lib/components/code/menu-top.directive.js b/awx/ui/client/lib/components/code/menu-top.directive.js deleted file mode 100644 index e78ead1bae..0000000000 --- a/awx/ui/client/lib/components/code/menu-top.directive.js +++ /dev/null @@ -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; diff --git a/awx/ui/client/lib/components/code/menu-top.partial.html b/awx/ui/client/lib/components/code/menu-top.partial.html deleted file mode 100644 index 2e21dc1b8b..0000000000 --- a/awx/ui/client/lib/components/code/menu-top.partial.html +++ /dev/null @@ -1,12 +0,0 @@ -
-
- -
- -
- -
- -
-
diff --git a/awx/ui/client/lib/components/code/stdout.directive.js b/awx/ui/client/lib/components/code/stdout.directive.js deleted file mode 100644 index c73e90b7e8..0000000000 --- a/awx/ui/client/lib/components/code/stdout.directive.js +++ /dev/null @@ -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 ` - - ${ln} - ${content} - `; -} - -function atCodeStdout () { - return { - restrict: 'E', - transclude: true, - replace: true, - require: 'atCodeStdout', - templateUrl, - controller: AtCodeStdoutController, - controllerAs: 'vm', - link: atCodeStdoutLink, - scope: { - state: '=', - } - }; -} - -export default atCodeStdout; diff --git a/awx/ui/client/lib/components/code/stdout.partial.html b/awx/ui/client/lib/components/code/stdout.partial.html deleted file mode 100644 index ca38d736f4..0000000000 --- a/awx/ui/client/lib/components/code/stdout.partial.html +++ /dev/null @@ -1,19 +0,0 @@ -
-
-
- -
- -
-
- -
- -
-
- -
- -
-
-
diff --git a/awx/ui/client/lib/components/index.js b/awx/ui/client/lib/components/index.js index bf45c63a6d..9ac933628c 100644 --- a/awx/ui/client/lib/components/index.js +++ b/awx/ui/client/lib/components/index.js @@ -1,10 +1,6 @@ import atLibServices from '~services'; 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 form from '~components/form/form.directive'; import formAction from '~components/form/action.directive'; @@ -49,10 +45,6 @@ angular atLibServices ]) .directive('atActionGroup', actionGroup) - .directive('atCodeEvents', codeEvents) - .directive('atCodeMenuBottom', codeMenuBottom) - .directive('atCodeMenuTop', codeMenuTop) - .directive('atCodeStdout', codeStdout) .directive('atDivider', divider) .directive('atForm', form) .directive('atFormAction', formAction) diff --git a/awx/ui/test/e2e/tests/test-jobz.js b/awx/ui/test/e2e/tests/test-jobz.js deleted file mode 100644 index 9f76fc7bec..0000000000 --- a/awx/ui/test/e2e/tests/test-jobz.js +++ /dev/null @@ -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(); - }, -};