mirror of
https://github.com/ansible/awx.git
synced 2026-05-06 17:07:36 -02:30
move constants to a file
This commit is contained in:
@@ -1,10 +1,12 @@
|
|||||||
const API_PAGE_SIZE = 200;
|
import {
|
||||||
const PAGE_SIZE = 50;
|
API_MAX_PAGE_SIZE,
|
||||||
const ORDER_BY = 'counter';
|
OUTPUT_ORDER_BY,
|
||||||
|
OUTPUT_PAGE_SIZE,
|
||||||
|
} from './constants';
|
||||||
|
|
||||||
const BASE_PARAMS = {
|
const BASE_PARAMS = {
|
||||||
page_size: PAGE_SIZE,
|
order_by: OUTPUT_ORDER_BY,
|
||||||
order_by: ORDER_BY,
|
page_size: OUTPUT_PAGE_SIZE,
|
||||||
};
|
};
|
||||||
|
|
||||||
const merge = (...objs) => _.merge({}, ...objs);
|
const merge = (...objs) => _.merge({}, ...objs);
|
||||||
@@ -77,7 +79,7 @@ function JobEventsApiService ($http, $q) {
|
|||||||
return $q.resolve(this.cache.last);
|
return $q.resolve(this.cache.last);
|
||||||
}
|
}
|
||||||
|
|
||||||
const params = merge(this.params, { page: 1, order_by: `-${ORDER_BY}` });
|
const params = merge(this.params, { page: 1, order_by: `-${OUTPUT_ORDER_BY}` });
|
||||||
|
|
||||||
return $http.get(this.endpoint, { params })
|
return $http.get(this.endpoint, { params })
|
||||||
.then(({ data }) => {
|
.then(({ data }) => {
|
||||||
@@ -86,8 +88,8 @@ function JobEventsApiService ($http, $q) {
|
|||||||
|
|
||||||
let rotated = results;
|
let rotated = results;
|
||||||
|
|
||||||
if (count > PAGE_SIZE) {
|
if (count > OUTPUT_PAGE_SIZE) {
|
||||||
rotated = results.splice(count % PAGE_SIZE);
|
rotated = results.splice(count % OUTPUT_PAGE_SIZE);
|
||||||
|
|
||||||
if (results.length > 0) {
|
if (results.length > 0) {
|
||||||
rotated = results;
|
rotated = results;
|
||||||
@@ -112,7 +114,7 @@ function JobEventsApiService ($http, $q) {
|
|||||||
const [low, high] = range;
|
const [low, high] = range;
|
||||||
const params = merge(this.params, { counter__gte: [low], counter__lte: [high] });
|
const params = merge(this.params, { counter__gte: [low], counter__lte: [high] });
|
||||||
|
|
||||||
params.page_size = API_PAGE_SIZE;
|
params.page_size = API_MAX_PAGE_SIZE;
|
||||||
|
|
||||||
return $http.get(this.endpoint, { params })
|
return $http.get(this.endpoint, { params })
|
||||||
.then(({ data }) => {
|
.then(({ data }) => {
|
||||||
@@ -127,7 +129,7 @@ function JobEventsApiService ($http, $q) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getLastPageNumber = () => Math.ceil(this.state.count / PAGE_SIZE);
|
this.getLastPageNumber = () => Math.ceil(this.state.count / OUTPUT_PAGE_SIZE);
|
||||||
this.getMaxCounter = () => this.state.maxCounter;
|
this.getMaxCounter = () => this.state.maxCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
30
awx/ui/client/features/output/constants.js
Normal file
30
awx/ui/client/features/output/constants.js
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
export const API_MAX_PAGE_SIZE = 200;
|
||||||
|
export const API_ROOT = '/api/v2/';
|
||||||
|
|
||||||
|
export const EVENT_START_TASK = 'playbook_on_task_start';
|
||||||
|
export const EVENT_START_PLAY = 'playbook_on_play_start';
|
||||||
|
export const EVENT_START_PLAYBOOK = 'playbook_on_start';
|
||||||
|
export const EVENT_STATS_PLAY = 'playbook_on_stats';
|
||||||
|
|
||||||
|
export const HOST_STATUS_KEYS = ['dark', 'failures', 'changed', 'ok', 'skipped'];
|
||||||
|
|
||||||
|
export const JOB_STATUS_COMPLETE = ['successful', 'failed', 'unknown'];
|
||||||
|
export const JOB_STATUS_INCOMPLETE = ['canceled', 'error'];
|
||||||
|
export const JOB_STATUS_UNSUCCESSFUL = ['failed'].concat(JOB_STATUS_INCOMPLETE);
|
||||||
|
export const JOB_STATUS_FINISHED = JOB_STATUS_COMPLETE.concat(JOB_STATUS_INCOMPLETE);
|
||||||
|
|
||||||
|
export const OUTPUT_ELEMENT_CONTAINER = '.at-Stdout-container';
|
||||||
|
export const OUTPUT_ELEMENT_TBODY = '#atStdoutResultTable';
|
||||||
|
export const OUTPUT_MAX_LAG = 120;
|
||||||
|
export const OUTPUT_ORDER_BY = 'counter';
|
||||||
|
export const OUTPUT_PAGE_CACHE = true;
|
||||||
|
export const OUTPUT_PAGE_LIMIT = 5;
|
||||||
|
export const OUTPUT_PAGE_SIZE = 50;
|
||||||
|
export const OUTPUT_SCROLL_DELAY = 100;
|
||||||
|
export const OUTPUT_SCROLL_THRESHOLD = 0.1;
|
||||||
|
export const OUTPUT_SEARCH_DOCLINK = 'https://docs.ansible.com/ansible-tower/3.3.0/html/userguide/search_sort.html';
|
||||||
|
export const OUTPUT_SEARCH_FIELDS = ['changed', 'created', 'failed', 'host_name', 'stdout', 'task', 'role', 'playbook', 'play'];
|
||||||
|
export const OUTPUT_SEARCH_KEY_EXAMPLES = ['host_name:localhost', 'task:set', 'created:>=2000-01-01'];
|
||||||
|
export const OUTPUT_EVENT_LIMIT = OUTPUT_PAGE_LIMIT * OUTPUT_PAGE_SIZE;
|
||||||
|
|
||||||
|
export const WS_PREFIX = 'ws';
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
/* eslint camelcase: 0 */
|
/* eslint camelcase: 0 */
|
||||||
const EVENT_START_TASK = 'playbook_on_task_start';
|
import {
|
||||||
const EVENT_START_PLAY = 'playbook_on_play_start';
|
EVENT_START_PLAY,
|
||||||
|
EVENT_START_TASK,
|
||||||
|
} from './constants';
|
||||||
|
|
||||||
let $compile;
|
let $compile;
|
||||||
let $q;
|
let $q;
|
||||||
|
|||||||
@@ -18,16 +18,15 @@ import SearchComponent from '~features/output/search.component';
|
|||||||
import StatsComponent from '~features/output/stats.component';
|
import StatsComponent from '~features/output/stats.component';
|
||||||
import HostEvent from './host-event/index';
|
import HostEvent from './host-event/index';
|
||||||
|
|
||||||
const Template = require('~features/output/index.view.html');
|
import {
|
||||||
|
API_ROOT,
|
||||||
|
OUTPUT_ORDER_BY,
|
||||||
|
OUTPUT_PAGE_SIZE,
|
||||||
|
WS_PREFIX,
|
||||||
|
} from './constants';
|
||||||
|
|
||||||
const MODULE_NAME = 'at.features.output';
|
const MODULE_NAME = 'at.features.output';
|
||||||
|
const Template = require('~features/output/index.view.html');
|
||||||
const PAGE_CACHE = true;
|
|
||||||
const PAGE_LIMIT = 5;
|
|
||||||
const PAGE_SIZE = 50;
|
|
||||||
const ORDER_BY = 'counter';
|
|
||||||
const WS_PREFIX = 'ws';
|
|
||||||
const API_ROOT = '/api/v2/';
|
|
||||||
|
|
||||||
function resolveResource (
|
function resolveResource (
|
||||||
$state,
|
$state,
|
||||||
@@ -80,23 +79,16 @@ function resolveResource (
|
|||||||
}
|
}
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
page_size: PAGE_SIZE,
|
page_size: OUTPUT_PAGE_SIZE,
|
||||||
order_by: ORDER_BY,
|
order_by: OUTPUT_ORDER_BY,
|
||||||
};
|
|
||||||
|
|
||||||
const config = {
|
|
||||||
params,
|
|
||||||
pageCache: PAGE_CACHE,
|
|
||||||
pageLimit: PAGE_LIMIT,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (job_event_search) { // eslint-disable-line camelcase
|
if (job_event_search) { // eslint-disable-line camelcase
|
||||||
const query = qs.encodeQuerysetObject(qs.decodeArr(job_event_search));
|
const query = qs.encodeQuerysetObject(qs.decodeArr(job_event_search));
|
||||||
|
Object.assign(params, query);
|
||||||
Object.assign(config.params, query);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Events.init(`${API_ROOT}${related}`, config.params);
|
Events.init(`${API_ROOT}${related}`, params);
|
||||||
|
|
||||||
Wait('start');
|
Wait('start');
|
||||||
const promise = Promise.all([new Resource(['get', 'options'], [id, id]), Events.fetch()])
|
const promise = Promise.all([new Resource(['get', 'options'], [id, id]), Events.fetch()])
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* eslint camelcase: 0 */
|
/* eslint camelcase: 0 */
|
||||||
const PAGE_LIMIT = 5;
|
import { OUTPUT_PAGE_LIMIT } from './constants';
|
||||||
|
|
||||||
function PageService ($q) {
|
function PageService ($q) {
|
||||||
this.init = (storage, api, { getScrollHeight }) => {
|
this.init = (storage, api, { getScrollHeight }) => {
|
||||||
@@ -150,7 +150,7 @@ function PageService ($q) {
|
|||||||
|
|
||||||
const pageCount = this.state.head - this.state.tail;
|
const pageCount = this.state.head - this.state.tail;
|
||||||
|
|
||||||
if (pageCount >= PAGE_LIMIT) {
|
if (pageCount >= OUTPUT_PAGE_LIMIT) {
|
||||||
this.chain = this.chain
|
this.chain = this.chain
|
||||||
.then(() => this.popBack())
|
.then(() => this.popBack())
|
||||||
.then(() => {
|
.then(() => {
|
||||||
@@ -185,7 +185,7 @@ function PageService ($q) {
|
|||||||
|
|
||||||
const pageCount = this.state.head - this.state.tail;
|
const pageCount = this.state.head - this.state.tail;
|
||||||
|
|
||||||
if (pageCount >= PAGE_LIMIT) {
|
if (pageCount >= OUTPUT_PAGE_LIMIT) {
|
||||||
this.chain = this.chain
|
this.chain = this.chain
|
||||||
.then(() => this.popFront())
|
.then(() => this.popFront())
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
|||||||
@@ -1,20 +1,22 @@
|
|||||||
import Ansi from 'ansi-to-html';
|
import Ansi from 'ansi-to-html';
|
||||||
import Entities from 'html-entities';
|
import Entities from 'html-entities';
|
||||||
|
|
||||||
const ELEMENT_TBODY = '#atStdoutResultTable';
|
import {
|
||||||
const EVENT_START_TASK = 'playbook_on_task_start';
|
EVENT_START_PLAY,
|
||||||
const EVENT_START_PLAY = 'playbook_on_play_start';
|
EVENT_STATS_PLAY,
|
||||||
const EVENT_STATS_PLAY = 'playbook_on_stats';
|
EVENT_START_TASK,
|
||||||
|
OUTPUT_ELEMENT_TBODY,
|
||||||
|
} from './constants';
|
||||||
|
|
||||||
const EVENT_GROUPS = [
|
const EVENT_GROUPS = [
|
||||||
EVENT_START_TASK,
|
EVENT_START_TASK,
|
||||||
EVENT_START_PLAY
|
EVENT_START_PLAY,
|
||||||
];
|
];
|
||||||
|
|
||||||
const TIME_EVENTS = [
|
const TIME_EVENTS = [
|
||||||
EVENT_START_TASK,
|
EVENT_START_TASK,
|
||||||
EVENT_START_PLAY,
|
EVENT_START_PLAY,
|
||||||
EVENT_STATS_PLAY
|
EVENT_STATS_PLAY,
|
||||||
];
|
];
|
||||||
|
|
||||||
const ansi = new Ansi();
|
const ansi = new Ansi();
|
||||||
@@ -33,7 +35,7 @@ function JobRenderService ($q, $sce, $window) {
|
|||||||
this.init = ({ compile, toggles }) => {
|
this.init = ({ compile, toggles }) => {
|
||||||
this.parent = null;
|
this.parent = null;
|
||||||
this.record = {};
|
this.record = {};
|
||||||
this.el = $(ELEMENT_TBODY);
|
this.el = $(OUTPUT_ELEMENT_TBODY);
|
||||||
this.hooks = { compile };
|
this.hooks = { compile };
|
||||||
|
|
||||||
this.createToggles = toggles;
|
this.createToggles = toggles;
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
const ELEMENT_CONTAINER = '.at-Stdout-container';
|
import {
|
||||||
const ELEMENT_TBODY = '#atStdoutResultTable';
|
OUTPUT_ELEMENT_CONTAINER,
|
||||||
const DELAY = 100;
|
OUTPUT_ELEMENT_TBODY,
|
||||||
const THRESHOLD = 0.1;
|
OUTPUT_SCROLL_DELAY,
|
||||||
|
OUTPUT_SCROLL_THRESHOLD,
|
||||||
|
} from './constants';
|
||||||
|
|
||||||
function JobScrollService ($q, $timeout) {
|
function JobScrollService ($q, $timeout) {
|
||||||
this.init = ({ next, previous }) => {
|
this.init = ({ next, previous }) => {
|
||||||
this.el = $(ELEMENT_CONTAINER);
|
this.el = $(OUTPUT_ELEMENT_CONTAINER);
|
||||||
this.timer = null;
|
this.timer = null;
|
||||||
|
|
||||||
this.position = {
|
this.position = {
|
||||||
@@ -37,7 +39,7 @@ function JobScrollService ($q, $timeout) {
|
|||||||
$timeout.cancel(this.timer);
|
$timeout.cancel(this.timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.timer = $timeout(this.register, DELAY);
|
this.timer = $timeout(this.register, OUTPUT_SCROLL_DELAY);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.register = () => {
|
this.register = () => {
|
||||||
@@ -76,10 +78,10 @@ function JobScrollService ($q, $timeout) {
|
|||||||
if (downward) {
|
if (downward) {
|
||||||
current += this.getViewableHeight();
|
current += this.getViewableHeight();
|
||||||
|
|
||||||
if (current >= height || ((height - current) / height) < THRESHOLD) {
|
if (current >= height || ((height - current) / height) < OUTPUT_SCROLL_THRESHOLD) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (current <= 0 || (current / height) < THRESHOLD) {
|
} else if (current <= 0 || (current / height) < OUTPUT_SCROLL_THRESHOLD) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,7 +179,7 @@ function JobScrollService ($q, $timeout) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.isLocked = () => this.state.locked;
|
this.isLocked = () => this.state.locked;
|
||||||
this.isMissing = () => $(ELEMENT_TBODY)[0].clientHeight < this.getViewableHeight();
|
this.isMissing = () => $(OUTPUT_ELEMENT_TBODY)[0].clientHeight < this.getViewableHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
JobScrollService.$inject = ['$q', '$timeout'];
|
JobScrollService.$inject = ['$q', '$timeout'];
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
const templateUrl = require('~features/output/search.partial.html');
|
import {
|
||||||
|
OUTPUT_SEARCH_DOCLINK,
|
||||||
|
OUTPUT_SEARCH_FIELDS,
|
||||||
|
OUTPUT_SEARCH_KEY_EXAMPLES,
|
||||||
|
} from './constants';
|
||||||
|
|
||||||
const searchKeyExamples = ['host_name:localhost', 'task:set', 'created:>=2000-01-01'];
|
const templateUrl = require('~features/output/search.partial.html');
|
||||||
const searchKeyFields = ['changed', 'created', 'failed', 'host_name', 'stdout', 'task', 'role', 'playbook', 'play'];
|
|
||||||
const searchKeyDocLink = 'https://docs.ansible.com/ansible-tower/3.3.0/html/userguide/search_sort.html';
|
|
||||||
|
|
||||||
let $state;
|
let $state;
|
||||||
let qs;
|
let qs;
|
||||||
@@ -50,7 +52,7 @@ function reloadQueryset (queryset, rejection = strings.get('search.REJECT_DEFAUL
|
|||||||
|
|
||||||
const isFilterable = term => {
|
const isFilterable = term => {
|
||||||
const field = term[0].split('.')[0].replace(/^-/, '');
|
const field = term[0].split('.')[0].replace(/^-/, '');
|
||||||
return (searchKeyFields.indexOf(field) > -1);
|
return (OUTPUT_SEARCH_FIELDS.indexOf(field) > -1);
|
||||||
};
|
};
|
||||||
|
|
||||||
function removeSearchTag (index) {
|
function removeSearchTag (index) {
|
||||||
@@ -94,9 +96,9 @@ function JobSearchController (_$state_, _qs_, _strings_, { subscribe }) {
|
|||||||
vm = this || {};
|
vm = this || {};
|
||||||
vm.strings = strings;
|
vm.strings = strings;
|
||||||
|
|
||||||
vm.examples = searchKeyExamples;
|
vm.examples = OUTPUT_SEARCH_KEY_EXAMPLES;
|
||||||
vm.fields = searchKeyFields;
|
vm.fields = OUTPUT_SEARCH_FIELDS;
|
||||||
vm.docLink = searchKeyDocLink;
|
vm.docLink = OUTPUT_SEARCH_DOCLINK;
|
||||||
vm.relatedFields = [];
|
vm.relatedFields = [];
|
||||||
|
|
||||||
vm.clearSearch = clearSearch;
|
vm.clearSearch = clearSearch;
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
/* eslint camelcase: 0 */
|
/* eslint camelcase: 0 */
|
||||||
const PAGE_SIZE = 50;
|
import {
|
||||||
const PAGE_LIMIT = 5;
|
OUTPUT_EVENT_LIMIT,
|
||||||
const EVENT_LIMIT = PAGE_LIMIT * PAGE_SIZE;
|
OUTPUT_PAGE_SIZE,
|
||||||
|
} from './constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a range overlaps another range
|
* Check if a range overlaps another range
|
||||||
@@ -266,7 +267,7 @@ function SlidingWindowService ($q) {
|
|||||||
return this.chain;
|
return this.chain;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getNext = (displacement = PAGE_SIZE) => {
|
this.getNext = (displacement = OUTPUT_PAGE_SIZE) => {
|
||||||
const [head, tail] = this.getRange();
|
const [head, tail] = this.getRange();
|
||||||
|
|
||||||
const tailRoom = this.getMaxCounter() - tail;
|
const tailRoom = this.getMaxCounter() - tail;
|
||||||
@@ -276,14 +277,14 @@ function SlidingWindowService ($q) {
|
|||||||
|
|
||||||
let headDisplacement = 0;
|
let headDisplacement = 0;
|
||||||
|
|
||||||
if (newTail - head > EVENT_LIMIT) {
|
if (newTail - head > OUTPUT_EVENT_LIMIT) {
|
||||||
headDisplacement = (newTail - EVENT_LIMIT) - head;
|
headDisplacement = (newTail - OUTPUT_EVENT_LIMIT) - head;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.move([head + headDisplacement, tail + tailDisplacement]);
|
return this.move([head + headDisplacement, tail + tailDisplacement]);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getPrevious = (displacement = PAGE_SIZE) => {
|
this.getPrevious = (displacement = OUTPUT_PAGE_SIZE) => {
|
||||||
const [head, tail] = this.getRange();
|
const [head, tail] = this.getRange();
|
||||||
|
|
||||||
const headRoom = head - 1;
|
const headRoom = head - 1;
|
||||||
@@ -293,8 +294,8 @@ function SlidingWindowService ($q) {
|
|||||||
|
|
||||||
let tailDisplacement = 0;
|
let tailDisplacement = 0;
|
||||||
|
|
||||||
if (tail - newHead > EVENT_LIMIT) {
|
if (tail - newHead > OUTPUT_EVENT_LIMIT) {
|
||||||
tailDisplacement = tail - (newHead + EVENT_LIMIT);
|
tailDisplacement = tail - (newHead + OUTPUT_EVENT_LIMIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.move([newHead, tail - tailDisplacement]);
|
return this.move([newHead, tail - tailDisplacement]);
|
||||||
@@ -332,12 +333,12 @@ function SlidingWindowService ($q) {
|
|||||||
this.getFirst = () => this.clear()
|
this.getFirst = () => this.clear()
|
||||||
.then(() => this.api.getFirst())
|
.then(() => this.api.getFirst())
|
||||||
.then(events => this.pushFront(events))
|
.then(events => this.pushFront(events))
|
||||||
.then(() => this.moveTail(PAGE_SIZE));
|
.then(() => this.moveTail(OUTPUT_PAGE_SIZE));
|
||||||
|
|
||||||
this.getLast = () => this.clear()
|
this.getLast = () => this.clear()
|
||||||
.then(() => this.api.getLast())
|
.then(() => this.api.getLast())
|
||||||
.then(events => this.pushBack(events))
|
.then(events => this.pushBack(events))
|
||||||
.then(() => this.moveHead(-PAGE_SIZE));
|
.then(() => this.moveHead(-OUTPUT_PAGE_SIZE));
|
||||||
|
|
||||||
this.getTailCounter = () => {
|
this.getTailCounter = () => {
|
||||||
const tail = Math.max(...Object.keys(this.records));
|
const tail = Math.max(...Object.keys(this.records));
|
||||||
@@ -360,7 +361,7 @@ function SlidingWindowService ($q) {
|
|||||||
|
|
||||||
this.getRange = () => [this.getHeadCounter(), this.getTailCounter()];
|
this.getRange = () => [this.getHeadCounter(), this.getTailCounter()];
|
||||||
this.getRecordCount = () => Object.keys(this.records).length;
|
this.getRecordCount = () => Object.keys(this.records).length;
|
||||||
this.getCapacity = () => EVENT_LIMIT - this.getRecordCount();
|
this.getCapacity = () => OUTPUT_EVENT_LIMIT - this.getRecordCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
SlidingWindowService.$inject = ['$q'];
|
SlidingWindowService.$inject = ['$q'];
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
/* eslint camelcase: 0 */
|
/* eslint camelcase: 0 */
|
||||||
const JOB_START = 'playbook_on_start';
|
import {
|
||||||
const JOB_END = 'playbook_on_stats';
|
EVENT_START_PLAYBOOK,
|
||||||
const PLAY_START = 'playbook_on_play_start';
|
EVENT_STATS_PLAY,
|
||||||
const TASK_START = 'playbook_on_task_start';
|
EVENT_START_PLAY,
|
||||||
|
EVENT_START_TASK,
|
||||||
const HOST_STATUS_KEYS = ['dark', 'failures', 'changed', 'ok', 'skipped'];
|
HOST_STATUS_KEYS,
|
||||||
const COMPLETE = ['successful', 'failed', 'unknown'];
|
JOB_STATUS_COMPLETE,
|
||||||
const INCOMPLETE = ['canceled', 'error'];
|
JOB_STATUS_INCOMPLETE,
|
||||||
const UNSUCCESSFUL = ['failed'].concat(INCOMPLETE);
|
JOB_STATUS_UNSUCCESSFUL,
|
||||||
const FINISHED = COMPLETE.concat(INCOMPLETE);
|
JOB_STATUS_FINISHED,
|
||||||
|
} from './constants';
|
||||||
|
|
||||||
function JobStatusService (moment, message) {
|
function JobStatusService (moment, message) {
|
||||||
this.dispatch = () => message.dispatch('status', this.state);
|
this.dispatch = () => message.dispatch('status', this.state);
|
||||||
@@ -62,11 +63,11 @@ function JobStatusService (moment, message) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.createHostStatusCounts = status => {
|
this.createHostStatusCounts = status => {
|
||||||
if (UNSUCCESSFUL.includes(status)) {
|
if (JOB_STATUS_UNSUCCESSFUL.includes(status)) {
|
||||||
return { failures: 1 };
|
return { failures: 1 };
|
||||||
}
|
}
|
||||||
|
|
||||||
if (COMPLETE.includes(status)) {
|
if (JOB_STATUS_COMPLETE.includes(status)) {
|
||||||
return { ok: 1 };
|
return { ok: 1 };
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,7 +93,7 @@ function JobStatusService (moment, message) {
|
|||||||
|
|
||||||
let changed = false;
|
let changed = false;
|
||||||
|
|
||||||
if (!this.active && !(data.event === JOB_END)) {
|
if (!this.active && !(data.event === EVENT_STATS_PLAY)) {
|
||||||
this.active = true;
|
this.active = true;
|
||||||
this.setJobStatus('running');
|
this.setJobStatus('running');
|
||||||
changed = true;
|
changed = true;
|
||||||
@@ -105,22 +106,22 @@ function JobStatusService (moment, message) {
|
|||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.event === JOB_START) {
|
if (data.event === EVENT_START_PLAYBOOK) {
|
||||||
this.setStarted(this.state.started || data.created);
|
this.setStarted(this.state.started || data.created);
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.event === PLAY_START) {
|
if (data.event === EVENT_START_PLAY) {
|
||||||
this.state.counts.plays++;
|
this.state.counts.plays++;
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.event === TASK_START) {
|
if (data.event === EVENT_START_TASK) {
|
||||||
this.state.counts.tasks++;
|
this.state.counts.tasks++;
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.event === JOB_END) {
|
if (data.event === EVENT_STATS_PLAY) {
|
||||||
this.setStatsEvent(data);
|
this.setStatsEvent(data);
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
@@ -193,9 +194,9 @@ function JobStatusService (moment, message) {
|
|||||||
|
|
||||||
this.setJobStatus = status => {
|
this.setJobStatus = status => {
|
||||||
const isExpectingStats = this.isExpectingStatsEvent();
|
const isExpectingStats = this.isExpectingStatsEvent();
|
||||||
const isIncomplete = INCOMPLETE.includes(status);
|
const isIncomplete = JOB_STATUS_INCOMPLETE.includes(status);
|
||||||
const isFinished = FINISHED.includes(status);
|
const isFinished = JOB_STATUS_FINISHED.includes(status);
|
||||||
const isAlreadyFinished = FINISHED.includes(this.state.status);
|
const isAlreadyFinished = JOB_STATUS_FINISHED.includes(this.state.status);
|
||||||
|
|
||||||
if (isAlreadyFinished) {
|
if (isAlreadyFinished) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
/* eslint camelcase: 0 */
|
/* eslint camelcase: 0 */
|
||||||
const PAGE_SIZE = 50;
|
import {
|
||||||
const MAX_LAG = 120;
|
EVENT_STATS_PLAY,
|
||||||
const JOB_END = 'playbook_on_stats';
|
OUTPUT_MAX_LAG,
|
||||||
|
OUTPUT_PAGE_SIZE,
|
||||||
|
} from './constants';
|
||||||
|
|
||||||
function OutputStream ($q) {
|
function OutputStream ($q) {
|
||||||
this.init = ({ bufferAdd, bufferEmpty, onFrames, onStop }) => {
|
this.init = ({ bufferAdd, bufferEmpty, onFrames, onStop }) => {
|
||||||
@@ -28,7 +30,7 @@ function OutputStream ($q) {
|
|||||||
this.lag = 0;
|
this.lag = 0;
|
||||||
this.chain = $q.resolve();
|
this.chain = $q.resolve();
|
||||||
|
|
||||||
this.factors = this.calcFactors(PAGE_SIZE);
|
this.factors = this.calcFactors(OUTPUT_PAGE_SIZE);
|
||||||
this.setFramesPerRender();
|
this.setFramesPerRender();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -47,7 +49,7 @@ function OutputStream ($q) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.setFramesPerRender = () => {
|
this.setFramesPerRender = () => {
|
||||||
const index = Math.floor((this.lag / MAX_LAG) * this.factors.length);
|
const index = Math.floor((this.lag / OUTPUT_MAX_LAG) * this.factors.length);
|
||||||
const boundedIndex = Math.min(this.factors.length - 1, index);
|
const boundedIndex = Math.min(this.factors.length - 1, index);
|
||||||
|
|
||||||
this.framesPerRender = this.factors[boundedIndex];
|
this.framesPerRender = this.factors[boundedIndex];
|
||||||
@@ -96,7 +98,7 @@ function OutputStream ($q) {
|
|||||||
|
|
||||||
this.chain = this.chain
|
this.chain = this.chain
|
||||||
.then(() => {
|
.then(() => {
|
||||||
if (data.event === JOB_END) {
|
if (data.event === EVENT_STATS_PLAY) {
|
||||||
this.state.ending = true;
|
this.state.ending = true;
|
||||||
this.counters.final = data.counter;
|
this.counters.final = data.counter;
|
||||||
}
|
}
|
||||||
@@ -104,7 +106,7 @@ function OutputStream ($q) {
|
|||||||
const [minReady, maxReady] = this.updateCounterState(data);
|
const [minReady, maxReady] = this.updateCounterState(data);
|
||||||
const count = this.hooks.bufferAdd(data);
|
const count = this.hooks.bufferAdd(data);
|
||||||
|
|
||||||
if (count % PAGE_SIZE === 0) {
|
if (count % OUTPUT_PAGE_SIZE === 0) {
|
||||||
this.setFramesPerRender();
|
this.setFramesPerRender();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user