summaryrefslogtreecommitdiff
path: root/src/main/webapp/js
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/webapp/js')
-rw-r--r--src/main/webapp/js/common.js120
-rw-r--r--src/main/webapp/js/plan_runs.js63
-rw-r--r--src/main/webapp/js/search_header.js251
-rw-r--r--src/main/webapp/js/test_acknowledgments.js439
-rw-r--r--src/main/webapp/js/test_results.js349
-rw-r--r--src/main/webapp/js/time.js65
6 files changed, 0 insertions, 1287 deletions
diff --git a/src/main/webapp/js/common.js b/src/main/webapp/js/common.js
deleted file mode 100644
index a815868..0000000
--- a/src/main/webapp/js/common.js
+++ /dev/null
@@ -1,120 +0,0 @@
-/**
- * Copyright (c) 2018 Google Inc. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you
- * may not use this file except in compliance with the License. You may
- * obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-/**
- * Display the log links in a modal window.
- * @param linkList A list of [name, url] tuples representing log links.
- */
-function showLinks(container, linkList) {
- if (!linkList || linkList.length == 0) return;
-
- var logCollection = $('<ul class="collection"></ul>');
- var entries = linkList.reduce(function(acc, entry) {
- if (!entry || entry.length == 0) return acc;
- var link = '<a href="' + entry[1] + '"';
- link += 'class="collection-item">' + entry[0] + '</li>';
- return acc + link;
- }, '');
- logCollection.html(entries);
-
- if (container.find('#info-modal').length == 0) {
- var modal =
- $('<div id="info-modal" class="modal modal-fixed-footer"></div>');
- var content = $('<div class="modal-content"></div>');
- content.append('<h4>Links</h4>');
- content.append('<div class="info-container"></div>');
- content.appendTo(modal);
- var footer = $('<div class="modal-footer"></div>');
- footer.append('<a class="btn-flat modal-close">Close</a></div>');
- footer.appendTo(modal);
- modal.appendTo(container);
- }
- var infoContainer = $('#info-modal>.modal-content>.info-container');
- infoContainer.empty();
- logCollection.appendTo(infoContainer);
- $('#info-modal').modal({dismissible: true});
- $('#info-modal').modal('open');
-}
-
-/**
- * Get the nickname for a test case result.
- *
- * Removes the result prefix and suffix, extracting only the result name.
- *
- * @param testCaseResult The string name of a VtsReportMessage.TestCaseResult.
- * @returns the string nickname of the result.
- */
-function getNickname(testCaseResult) {
- return testCaseResult.replace('TEST_CASE_RESULT_', '')
- .replace('_RESULT', '')
- .trim()
- .toLowerCase();
-}
-
-/**
- * Display test data in the body beneath a test run's metadata.
- * @param container The jquery object in which to insert the test metadata.
- * @param data The json object containing the columns to display.
- * @param lineHeight The height of each list element.
- */
-function displayTestDetails(container, data, lineHeight) {
- var nCol = data.length;
- var width = 's' + (12 / nCol);
- test = container;
- var maxLines = 0;
- data.forEach(function(column, index) {
- if (column.data == undefined || column.name == undefined) {
- return;
- }
- var classes = 'col test-col grey lighten-5 ' + width;
- if (index != nCol - 1) {
- classes += ' bordered';
- }
- if (index == 0) {
- classes += ' left-most';
- }
- if (index == nCol - 1) {
- classes += ' right-most';
- }
- var colContainer = $('<div class="' + classes + '"></div>');
- var col = $('<div class="test-case-container"></div>');
- colContainer.appendTo(container);
- var count = column.data.length;
- var head = $('<h5 class="test-result-label white"></h5>')
- .text(getNickname(column.name))
- .appendTo(colContainer)
- .css('text-transform', 'capitalize');
- $('<div class="indicator right center"></div>')
- .text(count)
- .addClass(column.name)
- .appendTo(head);
- col.appendTo(colContainer);
- var list = $('<ul></ul>').appendTo(col);
- column.data.forEach(function(testCase) {
- $('<li></li>')
- .text(testCase)
- .addClass('test-case')
- .css('font-size', lineHeight - 2)
- .css('line-height', lineHeight + 'px')
- .appendTo(list);
- });
- if (count > maxLines) {
- maxLines = count;
- }
- });
- var containers = container.find('.test-case-container');
- containers.height(maxLines * lineHeight);
-}
diff --git a/src/main/webapp/js/plan_runs.js b/src/main/webapp/js/plan_runs.js
deleted file mode 100644
index 6f11083..0000000
--- a/src/main/webapp/js/plan_runs.js
+++ /dev/null
@@ -1,63 +0,0 @@
-/**
- * Copyright (c) 2017 Google Inc. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you
- * may not use this file except in compliance with the License. You may
- * obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-(function ($, moment) {
-
- /**
- * Display test plan metadata in a vertical popout.
- * @param container The jquery object in which to insert the plan metadata.
- * @param metadataList The list of metadata objects to render on the display.
- */
- function renderCard(container, entry) {
- var card = $('<a class="col s12 m6 l4"></a>');
- var link = (
- '/show_plan_run?plan=' + entry.testPlanRun.testPlanName +
- '&time=' + entry.testPlanRun.startTimestamp);
- card.attr('href', link);
- card.appendTo(container);
- var div = $('<div class="hoverable card release-entry"></div>');
- var startTime = entry.testPlanRun.startTimestamp;
- var endTime = entry.testPlanRun.endTimestamp;
- div.appendTo(card);
- var span = $('<span></span>');
- span.addClass('plan-run-metadata');
- span.appendTo(div);
- $('<b></b>').text(entry.deviceInfo).appendTo(span);
- span.append('<br>');
- $('<b></b>').text('VTS Build: ').appendTo(span);
- span.append(entry.testPlanRun.testBuildId).append('<br>');
- var timeString = (
- moment().renderTime(startTime, false) + ' - ' +
- moment().renderTime(endTime, true) + ' (' +
- moment().renderDuration(endTime - startTime) + ')');
- span.append(timeString);
- var counter = $('<span></span>');
- var color = entry.testPlanRun.failCount > 0 ? 'red' : 'green';
- counter.addClass('counter center ' + color);
- counter.append(
- entry.testPlanRun.passCount + '/' +
- (entry.testPlanRun.passCount + entry.testPlanRun.failCount));
- counter.appendTo(div);
- }
-
- $.fn.showPlanRuns = function(data) {
- var self = $(this);
- data.forEach(function (entry) {
- renderCard(self, entry);
- })
- }
-
-})(jQuery, moment);
diff --git a/src/main/webapp/js/search_header.js b/src/main/webapp/js/search_header.js
deleted file mode 100644
index 4f108c4..0000000
--- a/src/main/webapp/js/search_header.js
+++ /dev/null
@@ -1,251 +0,0 @@
-/**
- * Copyright (c) 2017 Google Inc. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you
- * may not use this file except in compliance with the License. You may
- * obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-(function ($) {
- var _inequalityRegex = '(^)(<|>|<=|>=|=)?[ ]*?[0-9]+$';
- var _inequalityHint = 'e.g. 5, >0, <=10';
-
- function _validate(input, valueSet) {
- var value = input.val();
- if (valueSet.has(value) || !value) {
- input.removeClass('invalid');
- } else {
- input.addClass('invalid');
- }
- }
-
- function _createInput(key, config) {
- var value = config.value;
- var values = config.options.corpus;
- var displayName = config.displayName;
- var width = config.options.width || 's4';
- var div = $('<div class="input-field col"></div>');
- div.addClass(width);
- var input = $('<input class="filter-input"></input>');
- input.attr('type', config.options.type || 'text');
- input.appendTo(div);
- var label = $('<label></label>').text(displayName).appendTo(div);
- if (value) {
- input.attr('value', value);
- label.addClass('active');
- }
- if (config.options.validate == 'inequality') {
- input.addClass('validate');
- input.attr('pattern', _inequalityRegex);
- input.attr('placeholder', _inequalityHint);
- label.addClass('active');
- }
- input.focusout(function() {
- config.value = input.val();
- });
- if (values && values.length > 0) {
- var valueSet = new Set(values);
- input.sizedAutocomplete({
- source: values,
- classes: {
- 'ui-autocomplete': 'card search-bar-menu'
- }
- });
- input.focusout(function() {
- _validate(input, valueSet);
- });
- }
- if (values && values.length > 0 && value) {
- _validate(input, valueSet);
- }
- return div;
- }
-
- function _verifyCheckboxes(checkboxes, refreshObject) {
- var oneChecked = checkboxes.presubmit || checkboxes.postsubmit;
- if (!oneChecked) {
- refreshObject.addClass('disabled');
- } else {
- refreshObject.removeClass('disabled');
- }
- }
-
- function _createRunTypeBoxes(checkboxes, refreshObject) {
- var container = $('<div class="run-type-wrapper col s12"></div>');
- var presubmit = $('<input type="checkbox" id="presubmit"></input>');
- presubmit.appendTo(container);
- if (checkboxes.presubmit) {
- presubmit.prop('checked', true);
- }
- container.append('<label for="presubmit">Presubmit</label>');
- var postsubmit = $('<input type="checkbox" id="postsubmit"></input>');
- postsubmit.appendTo(container);
- if (checkboxes.postsubmit) {
- postsubmit.prop('checked', true);
- }
- container.append('<label for="postsubmit">Postsubmit</label>');
- presubmit.change(function() {
- checkboxes.presubmit = presubmit.prop('checked');
- _verifyCheckboxes(checkboxes, refreshObject);
- });
- postsubmit.change(function() {
- checkboxes.postsubmit = postsubmit.prop('checked');
- _verifyCheckboxes(checkboxes, refreshObject);
- });
- return container;
- }
-
- function _expand(
- container, filters, checkboxes, onRefreshCallback, animate=true) {
- var wrapper = $('<div class="search-wrapper"></div>');
- var col = $('<div class="col s9"></div>');
- col.appendTo(wrapper);
- Object.keys(filters).forEach(function(key) {
- col.append(_createInput(key, filters[key]));
- });
- var refreshCol = $('<div class="col s3 refresh-wrapper"></div>');
- var refresh = $('<a class="btn-floating btn-medium red right waves-effect waves-light"></a>')
- .append($('<i class="medium material-icons">cached</i>'))
- .appendTo(refreshCol);
- refresh.click(onRefreshCallback);
- refreshCol.appendTo(wrapper);
- if (Object.keys(checkboxes).length > 0) {
- col.append(_createRunTypeBoxes(checkboxes, refresh));
- }
- if (animate) {
- wrapper.hide().appendTo(container).slideDown({
- duration: 200,
- easing: "easeOutQuart",
- queue: false
- });
- } else {
- wrapper.appendTo(container);
- }
- container.addClass('expanded')
- }
-
- function _renderHeader(
- container, label, value, filters, checkboxes, expand, onRefreshCallback) {
- var div = $('<div class="row card search-bar"></div>');
- var wrapper = $('<div class="header-wrapper"></div>');
- var header = $('<h5 class="section-header"></h5>');
- $('<b></b>').text(label).appendTo(header);
- $('<span></span>').text(value).appendTo(header);
- header.appendTo(wrapper);
- var iconWrapper = $('<div class="search-icon-wrapper"></div>');
- $('<i class="material-icons">search</i>').appendTo(iconWrapper);
- iconWrapper.appendTo(wrapper);
- wrapper.appendTo(div);
- if (expand) {
- _expand(div, filters, checkboxes, onRefreshCallback, false);
- } else {
- var expanded = false;
- iconWrapper.click(function() {
- if (expanded) return;
- expanded = true;
- _expand(div, filters, checkboxes, onRefreshCallback);
- });
- }
- div.appendTo(container);
- }
-
- function _addFilter(filters, displayName, keyName, options, defaultValue) {
- filters[keyName] = {};
- filters[keyName].displayName = displayName;
- filters[keyName].value = defaultValue;
- filters[keyName].options = options;
- }
-
- function _getOptionString(filters, checkboxes) {
- var args = Object.keys(filters).reduce(function(acc, key) {
- if (filters[key].value) {
- return acc + '&' + key + '=' + encodeURIComponent(filters[key].value);
- }
- return acc;
- }, '');
- if (checkboxes.presubmit != undefined && checkboxes.presubmit) {
- args += '&showPresubmit='
- }
- if (checkboxes.postsubmit != undefined && checkboxes.postsubmit) {
- args += '&showPostsubmit='
- }
- return args;
- }
-
- /**
- * Create a search header element.
- * @param label The header label.
- * @param value The value to display next to the label.
- * @param onRefreshCallback The function to call on refresh.
- */
- $.fn.createSearchHeader = function(label, value, onRefreshCallback) {
- var self = $(this);
- $.widget('custom.sizedAutocomplete', $.ui.autocomplete, {
- _resizeMenu : function() {
- this.menu.element.outerWidth($('.search-bar .filter-input').width());
- }
- });
- var filters = {};
- var checkboxes = {};
- var expandOnRender = false;
- var displayed = false;
- return {
- /**
- * Add a filter to the display.
- * @param displayName The input placeholder/label text.
- * @param keyName The URL key to use for the filter options.
- * @param options A dict of additional options (e.g. width, type).
- * @param defaultValue A default filter value.
- */
- addFilter : function(displayName, keyName, options, defaultValue) {
- if (displayed) return;
- _addFilter(filters, displayName, keyName, options, defaultValue);
- if (defaultValue) expandOnRender = true;
- },
- /**
- * Enable run type checkboxes in the filter options.
- *
- * This will display two checkboxes for selecting pre-/postsubmit runs.
- * @param showPresubmit True if presubmit runs are selected.
- * @param showPostsubmit True if postsubmit runs are selected.
- *
- */
- addRunTypeCheckboxes: function(showPresubmit, showPostsubmit) {
- if (displayed) return;
- checkboxes['presubmit'] = showPresubmit;
- checkboxes['postsubmit'] = showPostsubmit;
- if (!showPostsubmit || showPresubmit) {
- expandOnRender = true;
- }
- },
- /**
- * Display the created search bar.
- *
- * This must be called after filters have been added. After displaying, no
- * modifications to the filter options will take effect.
- */
- display : function() {
- displayed = true;
- _renderHeader(
- self, label, value, filters, checkboxes, expandOnRender,
- onRefreshCallback);
- },
- /**
- * Get the URL arguments string for the current set of filters.
- * @returns a URI-encoded component with the search bar keys and values.
- */
- args : function () {
- return _getOptionString(filters, checkboxes);
- }
- }
- }
-
-})(jQuery);
diff --git a/src/main/webapp/js/test_acknowledgments.js b/src/main/webapp/js/test_acknowledgments.js
deleted file mode 100644
index 810d9d6..0000000
--- a/src/main/webapp/js/test_acknowledgments.js
+++ /dev/null
@@ -1,439 +0,0 @@
-/**
- * Copyright (c) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you
- * may not use this file except in compliance with the License. You may
- * obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-(function($) {
-
- var _isModalOpen = false;
- var _isReadOnly = true;
- var _allTestsSet = new Set();
- var _allBranches = [];
- var _allDevices = [];
-
- var _writableSummary = 'Known test failures are acknowledged below for specific branch and \
- device configurations, and corresponding test breakage alerts will be silenced. Click an \
- entry to edit or see more information about the test failure.'
- var _readOnlySummary = 'Known test failures are acknowledged below for specific branch and \
- device configurations, and corresponding test breakage alerts will be silenced. Click an \
- entry to see more information about the test failure. To add, edit, or remove a test \
- acknowledgment, contact a VTS Dashboard administrator.'
-
- $.widget('custom.sizedAutocomplete', $.ui.autocomplete, {
- options: {
- parent: ''
- },
- _resizeMenu: function() {
- this.menu.element.outerWidth($(this.options.parent).width());
- }
- });
-
- /**
- * Remove an acknowledgment from the list.
- * @param ack (jQuery object) The object for acknowledgment.
- * @param key (String) The value to display next to the label.
- */
- function removeAcknowledgment(ack, key) {
- if (ack.hasClass('disabled')) {
- return;
- }
- ack.addClass('disabled');
- $.ajax({
- url: '/api/test_acknowledgments/' + key,
- type: 'DELETE'
- }).always(function() {
- ack.removeClass('disabled');
- }).then(function() {
- ack.slideUp(150, function() {
- ack.remove();
- });
- });
- }
-
- /**
- * Callback for when a chip is removed from a chiplist.
- * @param text (String) The value stored in the chip.
- * @param allChipsSet (Set) The set of all chip values.
- * @param allIndicator (jQuery object) The object for "All" indicator adjacent to the chips.
- */
- function chipRemoveCallback(text, allChipsSet, allIndicator) {
- allChipsSet.delete(text);
- if (allChipsSet.size == 0) {
- allIndicator.show();
- }
- }
-
- /**
- * Add chips to the chip UI.
- * @param allChipsSet (Set) The set of all chip values.
- * @param container (jQuery object) The object in which to insert the chips.
- * @param chipList (list) The list of chip values to insert.
- * @param allIndicator (jQuery object) The object for "All" indicator adjacent to the chips.
- */
- function addChips(allChipsSet, container, chipList, allIndicator) {
- if (chipList && chipList.length > 0) {
- chipList.forEach(function(text) {
- if (allChipsSet.has(text)) return;
- var chip = $('<span class="chip">' + text + '</span>');
- if (!_isReadOnly) {
- var icon = $('<i class="material-icons">clear</i>').appendTo(chip);
- icon.click(function() {
- chipRemoveCallback(text, allChipsSet, allIndicator);
- });
- }
- chip.appendTo(container);
- allChipsSet.add(text);
- });
- allIndicator.hide();
- }
- }
-
- /**
- * Create a chip input UI.
- * @param container (jQuery object) The object in which to insert the input box.
- * @param placeholder (String) The placeholder text to display in the input.
- * @param allChipsSet (Set) The set of all chip values.
- * @param chipContainer (jQuery object) The object in which to insert new chips from the input.
- * @param allIndicator (jQuery object) The object for "All" indicator adjacent to the chips.
- * @returns The chip input jQuery object.
- */
- function addChipInput(container, placeholder, allChipsSet, chipContainer, allIndicator) {
- var input = $('<input type="text"></input>');
- input.attr('placeholder', placeholder);
- input.keyup(function(e) {
- if (e.keyCode === 13 && input.val().trim()) {
- addChips(allChipsSet, chipContainer, [input.val()], allIndicator);
- input.val('');
- }
- });
- var addButton = $('<i class="material-icons add-button">add</i>');
- addButton.click(function() {
- if (input.val().trim()) {
- addChips(allChipsSet, chipContainer, [input.val()], allIndicator);
- input.val('');
- addButton.hide();
- }
- });
- addButton.hide();
- input.focus(function() {
- addButton.show();
- });
- input.focusout(function() {
- if (!input.val().trim()) {
- addButton.hide();
- }
- });
- var holder = $('<div class="col s12 input-container"></div>').appendTo(container);
- input.appendTo(holder);
- addButton.appendTo(holder);
- return input;
- }
-
- /**
- * Callback to save changes to the acknowledgment.
- * @param ack (jQuery object) The object for acknowledgment.
- * @param modal (jQuery object) The jQueryUI modal object which invoked the callback.
- * @param key (String) The key associated with the acknowledgment.
- * @param test (String) The test name in the acknowledgment.
- * @param branchSet (Set) The set of all branches in the acknowledgment.
- * @param deviceSet (Set) The set of all devoces in the acknowledgment.
- * @param testCaseSet (Set) The set of all test cases in the acknowledgment.
- * @param note (String) The note in the acknowledgment.
- */
- function saveCallback(ack, modal, key, test, branchSet, deviceSet, testCaseSet, note) {
- var allEmpty = true;
- var firstUnemptyInput = null;
- var vals = modal.find('.modal-section>.input-container>input').each(function(_, input) {
- if (!!$(input).val()) {
- allEmpty = false;
- if (!firstUnemptyInput) firstUnemptyInput = $(input);
- }
- });
- if (!allEmpty) {
- firstUnemptyInput.focus();
- return false;
- }
- var branches = Array.from(branchSet);
- branches.sort();
- var devices = Array.from(deviceSet);
- devices.sort();
- var testCaseNames = Array.from(testCaseSet);
- testCaseNames.sort();
- var data = {
- 'key' : key,
- 'testName' : test,
- 'branches' : branches,
- 'devices' : devices,
- 'testCaseNames' : testCaseNames,
- 'note': note
- };
- $.post('/api/test_acknowledgments', JSON.stringify(data)).done(function(newKey) {
- var newAck = createAcknowledgment(newKey, test, branches, devices, testCaseNames, note);
- if (key == null) {
- ack.replaceWith(newAck.hide());
- newAck.slideDown(150);
- } else {
- ack.replaceWith(newAck);
- }
- }).always(function() {
- modal.modal({
- complete: function() { _isModalOpen = false; }
- });
- modal.modal('close');
- });
- }
-
- /**
- * Callback to save changes to the acknowledgment.
- * @param ack (jQuery object) The object for the acknowledgment.
- * @param key (String) The key associated with the acknowledgment.
- * @param test (String) The test name in the acknowledgment.
- * @param branches (list) The list of all branches in the acknowledgment.
- * @param devices (Set) The list of all devoces in the acknowledgment.
- * @param testCases (Set) The list of all test cases in the acknowledgment.
- * @param note (String) The note in the acknowledgment.
- */
- function showModal(ack, key, test, branches, devices, testCases, note) {
- if (_isModalOpen) {
- return;
- }
- _isModalOpen = true;
- var wrapper = $('#modal');
- wrapper.empty();
- wrapper.modal();
- var content = $('<div class="modal-content"><h4>Test Acknowledgment</h4></div>');
- var row = $('<div class="row"></div>').appendTo(content);
- row.append('<div class="col s12"><h5><b>Test: </b>' + test + '</h5></div>');
-
- var branchSet = new Set();
- var branchContainer = $('<div class="col l4 s12 modal-section"></div>').appendTo(row);
- var branchHeader = $('<h5></h5>').appendTo(branchContainer);
- branchHeader.append('<b>Branches:</b>');
- var allBranchesLabel = $('<span> All</span>').appendTo(branchHeader);
- var branchChips = $('<div class="col s12 chips branch-chips"></div>').appendTo(branchContainer);
- addChips(branchSet, branchChips, branches, allBranchesLabel);
- if (!_isReadOnly) {
- var branchInput = addChipInput(
- branchContainer, 'Specify a branch...', branchSet, branchChips, allBranchesLabel);
- branchInput.sizedAutocomplete({
- source: _allBranches,
- classes: {
- 'ui-autocomplete': 'card autocomplete-dropdown'
- },
- parent: branchInput
- });
- }
-
- var deviceSet = new Set();
- var deviceContainer = $('<div class="col l4 s12 modal-section"></div>').appendTo(row);
- var deviceHeader = $('<h5></h5>').appendTo(deviceContainer);
- deviceHeader.append('<b>Devices:</b>');
- var allDevicesLabel = $('<span> All</span>').appendTo(deviceHeader);
- var deviceChips = $('<div class="col s12 chips device-chips"></div>').appendTo(deviceContainer);
- addChips(deviceSet, deviceChips, devices, allDevicesLabel);
- if (!_isReadOnly) {
- var deviceInput = addChipInput(
- deviceContainer, 'Specify a device...', deviceSet, deviceChips, allDevicesLabel);
- deviceInput.sizedAutocomplete({
- source: _allDevices,
- classes: {
- 'ui-autocomplete': 'card autocomplete-dropdown'
- },
- parent: deviceInput
- });
- }
-
- var testCaseSet = new Set();
- var testCaseContainer = $('<div class="col l4 s12 modal-section"></div>').appendTo(row);
- var testCaseHeader = $('<h5></h5>').appendTo(testCaseContainer);
- testCaseHeader.append('<b>Test Cases:</b>');
- var allTestCasesLabel = $('<span> All</span>').appendTo(testCaseHeader);
- var testCaseChips = $('<div class="col s12 chips test-case-chips"></div>').appendTo(
- testCaseContainer);
- addChips(testCaseSet, testCaseChips, testCases, allTestCasesLabel);
- var testCaseInput = null;
- if (!_isReadOnly) {
- testCaseInput = addChipInput(
- testCaseContainer, 'Specify a test case...', testCaseSet, testCaseChips, allTestCasesLabel);
- }
-
- row.append('<div class="col s12"><h5><b>Note:</b></h5></div>');
- var inputField = $('<div class="input-field col s12"></div>').appendTo(row);
- var textArea = $('<textarea placeholder="Type a note..."></textarea>');
- textArea.addClass('materialize-textarea note-field');
- textArea.appendTo(inputField);
- textArea.val(note);
- if (_isReadOnly) {
- textArea.attr('disabled', true);
- }
-
- content.appendTo(wrapper);
- var footer = $('<div class="modal-footer"></div>');
- if (!_isReadOnly) {
- var save = $('<a class="btn">Save</a></div>').appendTo(footer);
- save.click(function() {
- saveCallback(ack, wrapper, key, test, branchSet, deviceSet, testCaseSet, textArea.val());
- });
- }
- var close = $('<a class="btn-flat">Close</a></div>').appendTo(footer);
- close.click(function() {
- wrapper.modal({
- complete: function() { _isModalOpen = false; }
- });
- wrapper.modal('close');
- })
- footer.appendTo(wrapper);
- if (!_isReadOnly) {
- $.get('/api/test_run?test=' + test + '&timestamp=latest').done(function(data) {
- var allTestCases = data.reduce(function(array, column) {
- return array.concat(column.data);
- }, []);
- testCaseInput.sizedAutocomplete({
- source: allTestCases,
- classes: {
- 'ui-autocomplete': 'card autocomplete-dropdown'
- },
- parent: testCaseInput
- });
- }).always(function() {
- wrapper.modal('open');
- });
- } else {
- wrapper.modal('open');
- }
- }
-
- /**
- * Create a test acknowledgment object.
- * @param key (String) The key associated with the acknowledgment.
- * @param test (String) The test name in the acknowledgment.
- * @param branches (list) The list of all branches in the acknowledgment.
- * @param devices (Set) The list of all devoces in the acknowledgment.
- * @param testCases (Set) The list of all test cases in the acknowledgment.
- * @param note (String) The note in the acknowledgment.
- */
- function createAcknowledgment(key, test, branches, devices, testCases, note) {
- var wrapper = $('<div class="col s12 ack-entry"></div>');
- var details = $('<div class="col card hoverable"></div>').appendTo(wrapper);
- details.addClass(_isReadOnly ? 's12' : 's11')
- var testDiv = $('<div class="col s12"><b>' + test + '</b></div>').appendTo(details);
- var infoBtn = $('<span class="info-icon right"></a>').appendTo(testDiv);
- infoBtn.append('<i class="material-icons">info_outline</i>');
- details.click(function() {
- showModal(wrapper, key, test, branches, devices, testCases, note);
- });
- var branchesSummary = 'All';
- if (!!branches && branches.length == 1) {
- branchesSummary = branches[0];
- } else if (!!branches && branches.length > 1) {
- branchesSummary = branches[0];
- branchesSummary += '<span class="count-indicator"> (+' + (branches.length - 1) + ')</span>';
- }
- $('<div class="col l4 s12"><b>Branches: </b>' + branchesSummary + '</div>').appendTo(details);
- var devicesSummary = 'All';
- if (!!devices && devices.length == 1) {
- devicesSummary = devices[0];
- } else if (!!devices && devices.length > 1) {
- devicesSummary = devices[0];
- devicesSummary += '<span class="count-indicator"> (+' + (devices.length - 1) + ')</span>';
- }
- $('<div class="col l4 s12"><b>Devices: </b>' + devicesSummary + '</div>').appendTo(details);
- var testCaseSummary = 'All';
- if (!!testCases && testCases.length == 1) {
- testCaseSummary = testCases[0];
- } else if (!!testCases && testCases.length > 1) {
- testCaseSummary = testCases[0];
- testCaseSummary += '<span class="count-indicator"> (+' + (testCases.length - 1) + ')</span>';
- }
- details.append('<div class="col l4 s12"><b>Test Cases: </b>' + testCaseSummary + '</div>');
-
- if (!_isReadOnly) {
- var btnContainer = $('<div class="col s1 center btn-container"></div>');
-
- var clear = $('<a class="col s12 btn-flat remove-button"></a>');
- clear.append('<i class="material-icons">clear</i>');
- clear.attr('title', 'Remove');
- clear.click(function() { removeAcknowledgment(wrapper, key); });
- clear.appendTo(btnContainer);
-
- btnContainer.appendTo(wrapper);
- }
- return wrapper;
- }
-
- /**
- * Create a test acknowledgments UI.
- * @param allTests (list) The list of all test names.
- * @param allBranches (list) The list of all branches.
- * @param allDevices (list) The list of all device names.
- * @param testAcknowledgments (list) JSON-serialized TestAcknowledgmentEntity object list.
- * @param readOnly (boolean) True if the acknowledgments are read-only, false if mutable.
- */
- $.fn.testAcknowledgments = function(
- allTests, allBranches, allDevices, testAcknowledgments, readOnly) {
- var self = $(this);
- _allTestsSet = new Set(allTests);
- _allBranches = allBranches;
- _allDevices = allDevices;
- _isReadOnly = readOnly;
- var searchRow = $('<div class="search-row"></div>');
- var headerRow = $('<div></div>');
- var acks = $('<div class="acknowledgments"></div>');
-
- if (!_isReadOnly) {
- var inputWrapper = $('<div class="input-field col s8"></div>');
- var input = $('<input type="text"></input>').appendTo(inputWrapper);
- inputWrapper.append('<label>Search for tests to add an acknowledgment</label>');
- inputWrapper.appendTo(searchRow);
- input.sizedAutocomplete({
- source: allTests,
- classes: {
- 'ui-autocomplete': 'card autocomplete-dropdown'
- },
- parent: input
- });
-
- var btnWrapper = $('<div class="col s1"></div>');
- var btn = $('<a class="btn waves-effect waves-light red btn-floating"></a>');
- btn.append('<i class="material-icons">add</a>');
- btn.appendTo(btnWrapper);
- btnWrapper.appendTo(searchRow);
- btn.click(function() {
- if (!_allTestsSet.has(input.val())) return;
- var ack = createAcknowledgment(undefined, input.val());
- ack.hide().prependTo(acks);
- showModal(ack, undefined, input.val());
- });
- searchRow.appendTo(self);
- }
-
- var headerCol = $('<div class="col s12 section-header-col"></div>').appendTo(headerRow);
- if (_isReadOnly) {
- headerCol.append('<p class="acknowledgment-info">' + _readOnlySummary + '</p>');
- } else {
- headerCol.append('<p class="acknowledgment-info">' + _writableSummary + '</p>');
- }
- headerRow.appendTo(self);
-
- testAcknowledgments.forEach(function(ack) {
- var wrapper = createAcknowledgment(
- ack.key, ack.testName, ack.branches, ack.devices, ack.testCaseNames, ack.note);
- wrapper.appendTo(acks);
- });
- acks.appendTo(self);
-
- self.append('<div class="modal modal-fixed-footer acknowledgments-modal" id="modal"></div>');
- };
-
-})(jQuery);
diff --git a/src/main/webapp/js/test_results.js b/src/main/webapp/js/test_results.js
deleted file mode 100644
index 24d4c0b..0000000
--- a/src/main/webapp/js/test_results.js
+++ /dev/null
@@ -1,349 +0,0 @@
-/**
- * Copyright (c) 2017 Google Inc. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you
- * may not use this file except in compliance with the License. You may
- * obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-(function($, moment) {
-
-/**
- * Display the log links in a modal window.
- * @param linkList A list of [name, url] tuples representing log links.
- */
-function showLinks(container, linkList) {
- if (!linkList || linkList.length == 0) return;
-
- var logCollection = $('<ul class="collection"></ul>');
- var entries = linkList.reduce(function(acc, entry) {
- if (!entry || entry.length == 0) return acc;
- var link = '<a href="' + entry[1] + '"';
- link += 'class="collection-item">' + entry[0] + '</li>';
- return acc + link;
- }, '');
- logCollection.html(entries);
-
- if (container.find('#info-modal').length == 0) {
- var modal =
- $('<div id="info-modal" class="modal modal-fixed-footer"></div>');
- var content = $('<div class="modal-content"></div>');
- content.append('<h4>Links</h4>');
- content.append('<div class="info-container"></div>');
- content.appendTo(modal);
- var footer = $('<div class="modal-footer"></div>');
- footer.append('<a class="btn-flat modal-close">Close</a></div>');
- footer.appendTo(modal);
- modal.appendTo(container);
- }
- var infoContainer = $('#info-modal>.modal-content>.info-container');
- infoContainer.empty();
- logCollection.appendTo(infoContainer);
- $('#info-modal').modal({dismissible: true});
- $('#info-modal').modal('open');
-}
-
-/**
- * Get the nickname for a test case result.
- *
- * Removes the result prefix and suffix, extracting only the result name.
- *
- * @param testCaseResult The string name of a VtsReportMessage.TestCaseResult.
- * @returns the string nickname of the result.
- */
-function getNickname(testCaseResult) {
- return testCaseResult.replace('TEST_CASE_RESULT_', '')
- .replace('_RESULT', '')
- .trim()
- .toLowerCase();
-}
-
-/**
- * Get the badge color from ratio value.
- *
- * @param the percentage value.
- * @returns the string of color for the badge.
- */
-function getBadgeColor(ratio) {
- var color = "orange";
- if (ratio <= 20) {
- color = "red";
- } else if (ratio >= 70) {
- color = "green";
- }
- return color;
-}
-
-/**
- * Get the rounded value.
- *
- * @param the percentage value.
- * @returns the rounded value from percentage value.
- */
-function getRoundValue(ratio) {
- return Math.round(ratio * 1000) / 10;
-}
-
-/**
- * Display test data in the body beneath a test run's metadata.
- * @param container The jquery object in which to insert the test metadata.
- * @param data The json object containing the columns to display.
- * @param lineHeight The height of each list element.
- */
-function displayTestDetails(container, data, lineHeight) {
- var nCol = data.length;
- var width = 's' + (12 / nCol);
- test = container;
- var maxLines = 0;
- data.forEach(function(column, index) {
- if (column.data == undefined || column.name == undefined) {
- return;
- }
- var classes = 'col test-col grey lighten-5 ' + width;
- if (index != nCol - 1) {
- classes += ' bordered';
- }
- if (index == 0) {
- classes += ' left-most';
- }
- if (index == nCol - 1) {
- classes += ' right-most';
- }
- var colContainer = $('<div class="' + classes + '"></div>');
- var col = $('<div class="test-case-container"></div>');
- colContainer.appendTo(container);
- var count = column.data.length;
- var head = $('<h5 class="test-result-label white"></h5>')
- .text(getNickname(column.name))
- .appendTo(colContainer)
- .css('text-transform', 'capitalize');
- $('<div class="indicator right center"></div>')
- .text(count)
- .addClass(column.name)
- .appendTo(head);
- col.appendTo(colContainer);
- var list = $('<ul></ul>').appendTo(col);
- column.data.forEach(function(testCase) {
- $('<li></li>')
- .text(testCase)
- .addClass('test-case')
- .css('font-size', lineHeight - 2)
- .css('line-height', lineHeight + 'px')
- .appendTo(list);
- });
- if (count > maxLines) {
- maxLines = count;
- }
- });
- var containers = container.find('.test-case-container');
- containers.height(maxLines * lineHeight);
-}
-
-/**
- * Click handler for displaying test run details.
- * @param e The click event.
- */
-function testRunClick(e) {
- var header = $(this);
- var icon = header.find('.material-icons.expand-arrow');
- var container = header.parent().find('.test-results');
- var test = header.attr('test');
- var time = header.attr('time');
- var url = '/api/test_run?test=' + test + '&timestamp=' + time;
- if (header.parent().hasClass('active')) {
- header.parent().removeClass('active');
- header.removeClass('active');
- icon.removeClass('rotate');
- header.siblings('.collapsible-body').stop(true, false).slideUp({
- duration: 100,
- easing: 'easeOutQuart',
- queue: false,
- complete: function() {
- header.css('height', '');
- }
- });
- } else {
- container.empty();
- header.parent().addClass('active');
- header.addClass('active');
- header.addClass('disabled');
- icon.addClass('rotate');
- $.get(url)
- .done(function(data) {
- displayTestDetails(container, data, 16);
- header.siblings('.collapsible-body').stop(true, false).slideDown({
- duration: 100,
- easing: 'easeOutQuart',
- queue: false,
- complete: function() {
- header.css('height', '');
- }
- });
- })
- .fail(function() {
- icon.removeClass('rotate');
- })
- .always(function() {
- header.removeClass('disabled');
- });
- }
-}
-
-/**
- * Append a clickable indicator link to the container.
- * @param container The jquery object to append the indicator to.
- * @param content The text to display in the indicator.
- * @param classes Additional space-delimited classes to add to the indicator.
- * @param click The click handler to assign to the indicator.
- * @returns The jquery object for the indicator.
- */
-function createClickableIndicator(container, content, classes, click) {
- var link = $('<span></span>');
- link.addClass('indicator badge padded hoverable waves-effect');
- link.addClass(classes);
- link.css('color', 'white');
- link.css('margin-left', '1px');
- link.append(content);
- link.appendTo(container);
- link.click(click);
- return link;
-}
-
-function displayTestMetadata(container, metadataList, showTestNames = false) {
- var popout = $('<ul></ul>');
- popout.attr('data-collapsible', 'expandable');
- popout.addClass('collapsible popout test-runs');
- popout.appendTo(container);
- popout.unbind();
- metadataList.forEach(function(metadata) {
- var li = $('<li class="test-run-container"></li>');
- li.appendTo(popout);
- var div = $('<div></div>');
- var test = metadata.testRun.testName;
- var startTime = metadata.testRun.startTimestamp;
- var endTime = metadata.testRun.endTimestamp;
- div.attr('test', test);
- div.attr('time', startTime);
- div.addClass('collapsible-header test-run');
- div.appendTo(li);
- div.unbind().click(testRunClick);
- var span = $('<span></span>');
- span.addClass('test-run-metadata');
- span.appendTo(div);
- span.click(function() {
- return false;
- });
- if (showTestNames) {
- $('<span class="test-run-label"></span>').text(test).appendTo(span);
- span.append('<br>');
- }
- if (metadata.deviceInfo) {
- $('<b></b>').text(metadata.deviceInfo).appendTo(span);
- span.append('<br>');
- }
- if (metadata.abiInfo) {
- $('<b></b>').text('ABI: ').appendTo(span)
- span.append(metadata.abiInfo).append('<br>');
- }
- $('<b></b>').text('VTS Build: ').appendTo(span)
- span.append(metadata.testRun.testBuildId).append('<br>');
- $('<b></b>').text('Host: ').appendTo(span)
- span.append(metadata.testRun.hostName).append('<br>');
- var timeString =
- (moment().renderTime(startTime, false) + ' - ' +
- moment().renderTime(endTime, true) + ' (' +
- moment().renderDuration(endTime - startTime) + ')');
- span.append(timeString);
- var indicator = $('<span></span>');
- var color = metadata.testRun.failCount > 0 ? 'red' : 'green';
- indicator.addClass('indicator badge ' + color);
- indicator.css('color', 'white');
- indicator.append(
- metadata.testRun.passCount + '/' +
- (metadata.testRun.passCount + metadata.testRun.failCount));
- indicator.appendTo(div);
- if (metadata.testRun.coveredLineCount != undefined &&
- metadata.testRun.totalLineCount != undefined) {
- var url = ('/show_coverage?testName=' + test + '&startTime=' + startTime);
- var covered = metadata.testRun.coveredLineCount;
- var total = metadata.testRun.totalLineCount;
- var covPct = getRoundValue(covered / total);
- var color = getBadgeColor(covPct);
- var coverage =
- ('Coverage: ' + covered + '/' + total + ' (' + covPct + '%)');
- createClickableIndicator(div, coverage, color, function(evt) {
- window.location.href = url;
- return false;
- });
- }
- if (metadata.testRun.coveredApiCount != undefined &&
- metadata.testRun.totalApiCount != undefined) {
- var covered = metadata.testRun.coveredApiCount;
- var total = metadata.testRun.totalApiCount;
- var covPct = getRoundValue(covered / total);
- var color = getBadgeColor(covPct);
- var apiCoverage = ('API Coverage: ' + covered + '/' + total + ' (' + covPct + '%)');
- createClickableIndicator(div, apiCoverage, color, function(evt) {
- $('#apiCoverageModal')
- .data('urlSafeKeyList', metadata.testRun.apiCoverageKeyList);
- $('#apiCoverageModal').modal('open');
- return false;
- });
- }
- if (metadata.testRun.logLinks != undefined) {
- createClickableIndicator(div, 'Links', 'grey lighten-1', function() {
- showLinks(popout, metadata.testRun.logLinks);
- return false;
- });
- }
- if ($('#coverageModalGraph').length) {
- createClickableIndicator(div, 'Graph', 'grey lighten-1', function(evt) {
- $('#coverageModalGraph').data('testname', test);
- $('#coverageModalGraph').modal('open');
- $(evt.target).removeClass('grey');
- $(evt.target).addClass('blue');
- return false;
- });
- }
-
- var expand = $('<i></i>');
- expand.addClass('material-icons expand-arrow')
- expand.text('expand_more');
- expand.appendTo(div);
- var body = $('<div></div>')
- .addClass('collapsible-body test-results row')
- .appendTo(li);
- if (metadata.testDetails != undefined) {
- expand.addClass('rotate');
- li.addClass('active');
- div.addClass('active');
- displayTestDetails(body, metadata.testDetails, 16);
- div.siblings('.collapsible-body').stop(true, false).slideDown({
- duration: 0,
- queue: false,
- complete: function() {
- div.css('height', '');
- }
- });
- }
- });
-}
-
-/**
- * Display test metadata in a vertical popout.
- * @param container The jquery object in which to insert the test metadata.
- * @param metadataList The list of metadata objects to render on the display.
- * @param showTestNames True to label each entry with the test module name.
- */
-$.fn.showTests = function(metadataList, showTestNames = false) {
- displayTestMetadata($(this), metadataList, showTestNames);
-}
-})(jQuery, moment);
diff --git a/src/main/webapp/js/time.js b/src/main/webapp/js/time.js
deleted file mode 100644
index 6178eda..0000000
--- a/src/main/webapp/js/time.js
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * Copyright (c) 2017 Google Inc. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you
- * may not use this file except in compliance with the License. You may
- * obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-(function (moment) {
-
- /**
- * Renders a timestamp in the user timezone.
- * @param timestamp The long timestamp to render (in microseconds).
- * @param showTimezone True if the timezone should be rendered, false otherwise.
- * @returns the string-formatted version of the provided timestamp.
- */
- moment.prototype.renderTime = function (timestamp, showTimezone) {
- var time = moment(timestamp / 1000);
- var format = 'YYYY-M-DD H:mm:ss';
- if (!!showTimezone) {
- format = format + 'ZZ';
- }
- return time.format(format);
- }
-
- /**
- * Renders a date in the user timezone.
- * @param timestamp The long timestamp to render (in microseconds).
- * @param showTimezone True if the timezone should be rendered, false otherwise.
- * @returns the string-formatted version of the provided timestamp.
- */
- moment.prototype.renderDate = function (timestamp, showTimezone) {
- var time = moment(timestamp / 1000);
- var format = 'YYYY-M-DD';
- if (!!showTimezone) {
- format = format + 'ZZ';
- }
- return time.format(format);
- }
-
- /**
- * Renders a duration in the user timezone.
- * @param durationTimestamp The long duration to render (in microseconds).
- * @returns the string-formatted duration of the provided duration timestamp.
- */
- moment.prototype.renderDuration = function (durationTimestamp) {
- var fmt = 's[s]';
- var duration = moment.utc(durationTimestamp / 1000);
- if (duration.hours() > 0) {
- fmt = 'H[h], m[m], ' + fmt;
- } else if (duration.minutes() > 0) {
- fmt = 'm[m], ' + fmt;
- }
- return duration.format(fmt);
- }
-
-})(moment);