Merge pull request #14 from mozilla/plugin-arch

Plugin arch
This commit is contained in:
Mauro Doglio 2013-09-19 03:43:32 -07:00
Родитель 853afb9eed 39ab0d78a7
Коммит c683b7c1be
20 изменённых файлов: 812 добавлений и 197 удалений

Просмотреть файл

@ -2,65 +2,5 @@ treeherder-ui
=============
Local Development: Running the web server
-----------------------------------------
-----------------------
You can run the webserver locally. For now, static data is loaded for testing
and development.
### Requirements
* [node.js](http://nodejs.org/download/)
### Execution
cd webapp
./scripts/web-server.js
### Endpoints
Once the server is running, you can nav to:
* [Jobs list](http://localhost:8000/app/index.html?tree=Try#/jobs)
* [Log Viewer](http://localhost:8000/app/logviewer.html)
Running the unit tests
----------------------
-----------------------
The unit tests run with [Karma](http://karma-runner.github.io/0.8/config/configuration-file.html).
### Requirements
* [node.js](http://nodejs.org/download/)
* karma: ``sudo npm install -g karma``
### Execution
cd webapp
./scripts/test.sh
Configuration
-------------
-------------
You can either run the treeherder service locally, or use a remote server.
This setting is specified in this file:
webapp/app/js/config/local.conf.js
A sample copy of this file is located here:
webapp/app/js/config/sample.local.conf.js
Copy the sample file to ``local.conf.js`` and make your custom settings.
Please visit our ``readthedocs`` page at:
https://treeherder-ui.readthedocs.org/en/latest/index.html

153
docs/ui/Makefile Normal file
Просмотреть файл

@ -0,0 +1,153 @@
# Makefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = _build
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
# the i18n builder cannot share the environment and doctrees with the others
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " singlehtml to make a single large HTML file"
@echo " pickle to make pickle files"
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " qthelp to make HTML files and a qthelp project"
@echo " devhelp to make HTML files and a Devhelp project"
@echo " epub to make an epub"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " latexpdf to make LaTeX files and run them through pdflatex"
@echo " text to make text files"
@echo " man to make manual pages"
@echo " texinfo to make Texinfo files"
@echo " info to make Texinfo files and run them through makeinfo"
@echo " gettext to make PO message catalogs"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
clean:
-rm -rf $(BUILDDIR)/*
html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
singlehtml:
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
pickle:
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@echo
@echo "Build finished; now you can process the pickle files."
json:
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
@echo
@echo "Build finished; now you can process the JSON files."
htmlhelp:
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in $(BUILDDIR)/htmlhelp."
qthelp:
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/treeherder.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/treeherder.qhc"
devhelp:
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo
@echo "Build finished."
@echo "To view the help file:"
@echo "# mkdir -p $$HOME/.local/share/devhelp/treeherder"
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/treeherder"
@echo "# devhelp"
epub:
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
@echo
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
latex:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
@echo "Run \`make' in that directory to run these through (pdf)latex" \
"(use \`make latexpdf' here to do that automatically)."
latexpdf:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through pdflatex..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
text:
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
@echo
@echo "Build finished. The text files are in $(BUILDDIR)/text."
man:
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
@echo
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
texinfo:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
@echo "Run \`make' in that directory to run these through makeinfo" \
"(use \`make info' here to do that automatically)."
info:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo "Running Texinfo files through makeinfo..."
make -C $(BUILDDIR)/texinfo info
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
gettext:
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
@echo
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
changes:
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
@echo "The overview file is in $(BUILDDIR)/changes."
linkcheck:
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt."
doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."

243
docs/ui/conf.py Normal file
Просмотреть файл

@ -0,0 +1,243 @@
# -*- coding: utf-8 -*-
#
# treeherder documentation build configuration file, created by
# sphinx-quickstart on Tue Mar 12 11:11:48 2013.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys, os
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.insert(0, os.path.abspath('.'))
# -- General configuration -----------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.coverage',
'sphinx.ext.viewcode', 'sphinxcontrib.httpdomain']
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix of source filenames.
source_suffix = '.rst'
# The encoding of source files.
#source_encoding = 'utf-8-sig'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'Treeherder'
copyright = u'2013, Mozilla'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = 'prototype'
# The full version, including alpha/beta/rc tags.
release = 'prototype'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['_build']
# The reST default role (used for this markup: `text`) to use for all documents.
#default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
# -- Options for HTML output ---------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'default'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
#html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = None
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {}
# If false, no module index is generated.
#html_domain_indices = True
# If false, no index is generated.
#html_use_index = True
# If true, the index is split into individual pages for each letter.
#html_split_index = False
# If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
#html_show_sphinx = True
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
#html_show_copyright = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
#html_use_opensearch = ''
# This is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = None
# Output file base name for HTML help builder.
htmlhelp_basename = 'treeherderdoc'
# -- Options for LaTeX output --------------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#'preamble': '',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'treeherder.tex', u'Treeherder Documentation',
u'Mozilla', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False
# If true, show page references after internal links.
#latex_show_pagerefs = False
# If true, show URL addresses after external links.
#latex_show_urls = False
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# If false, no module index is generated.
#latex_domain_indices = True
# -- Options for manual page output --------------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'Treeherder', u'Treeherder Documentation',
[u'Mozilla'], 1)
]
# If true, show URL addresses after external links.
#man_show_urls = False
# -- Options for Texinfo output ------------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'treeherder', u'Treeherder Documentation',
u'Mozilla', 'Treeherder', 'One line description of project.',
'Miscellaneous'),
]
# Documents to append as an appendix to all manuals.
#texinfo_appendices = []
# If false, no module index is generated.
#texinfo_domain_indices = True
# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'

23
docs/ui/index.rst Normal file
Просмотреть файл

@ -0,0 +1,23 @@
.. treeherder documentation master file, created by
sphinx-quickstart on Tue Mar 12 11:11:48 2013.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to Treeherder's UI documentation!
=========================================
Contents:
.. toctree::
:maxdepth: 2
installation
plugin
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

59
docs/ui/installation.rst Normal file
Просмотреть файл

@ -0,0 +1,59 @@
Installation
============
You can run the webserver locally. For now, static data is loaded for testing
and development.
Requirements
------------
* node.js: http://nodejs.org/download/
Execution::
cd webapp
./scripts/web-server.js
Endpoints
---------
Once the server is running, you can nav to:
* Jobs list: http://localhost:8000/app/index.html?tree=Try#/jobs
* Log Viewer: http://localhost:8000/app/logviewer.html
Running the unit tests
======================
The unit tests run with Karma: http://karma-runner.github.io/0.8/config/configuration-file.html
Requirements
------------
* [node.js](http://nodejs.org/download/)
* karma: ``sudo npm install -g karma``
Execution::
cd webapp
./scripts/test.sh
Configuration
=============
You can either run the treeherder service locally, or use a remote server.
This setting is specified in this file:
``webapp/app/js/config/local.conf.js``
A sample copy of this file is located here:
``webapp/app/js/config/sample.local.conf.js``
Copy the sample file to ``local.conf.js`` and make your custom settings.

98
docs/ui/plugin.rst Normal file
Просмотреть файл

@ -0,0 +1,98 @@
Writing a Plugin
================
When a job is selected, a bottom tabbed panel is activated which shows details
of that job. You can add your own tab to that panel in the form of a
``plugin``.
The existing ``Jobs Detail`` tab is, itself, a plugin. So it is a good example
to follow. See ``webapp/app/plugins/jobdetail``.
To create a new plugin the following steps are required:
* Create your plugin folder
* Create a ``controller`` in your plugin folder
* Create a ``partial`` HTML file in your plugin folder
* Register the ``controller``
* Register the ``partial``
Create your plugin folder
-------------------------
Your folder can have whatever name you choose, but it should reside beneath
``app/plugins``. For example: ``app/plugins/jobfoo``.
Create a controller
-------------------
The most basic of controllers would look like this::
"use strict";
treeherder.controller('JobFooPluginCtrl',
function JobFooPluginCtrl($scope) {
$scope.$watch('selectedJob', function(newValue, oldValue) {
// preferred way to get access to the selected job
if (newValue) {
$scope.job = newValue;
}
}, true);
}
);
This controller just watches the value of ``selectedJob`` to see when it gets
a value. ``selectedJob`` is set by the ui when a job is... well... selected.
Create a partial
----------------
The ``partial`` is the portion of HTML that will be displayed in your plugin's
tab. A very simple partial would look like this::
<div ng-controller="JobFooPluginCtrl">
<p>I pitty the foo that don't like job_guid: {{ job.job_guid }}</p>
</div>
Register the controller
-----------------------
Due to a limitation of jqlite, you must register your ``controller.js`` in
the main application's ``index.html`` file. You can see at the end of the file
that many ``.js`` files are registered. Simply add yours to the list::
<script src="plugins/jobfoo/controller.js"></script>
Register the partial
--------------------
The plugins controller needs to be told to use your plugin. So edit the file:
``app/plugins/controller.js`` and add an entry to the ``tabs`` array with the
information about your plugin::
$scope.tabs = [
{
title: "Jobs Detail",
content: "plugins/jobdetail/main.html",
active: true
},
{
title: "Jobs Foo",
content: "plugins/jobfoo/main.html"
}
];
It may be obvious, but ``title`` is the title of the tab to display. And
``content`` is the path to your partial.
Profit
------
That's it! Reload your page, and you should now have a tab to your plugin!
Rejoice in the profit!

3
docs/ui/requirements.txt Normal file
Просмотреть файл

@ -0,0 +1,3 @@
# requirements specific to the docs, used by readthedocs.org
Sphinx==1.1.3
sphinxcontrib-httpdomain==1.1.7

Просмотреть файл

@ -10,6 +10,7 @@ module.exports = function (config) {
'app/vendor/*.js',
'app/js/**/*.js',
'app/js/controllers/**/*.js',
'app/plugins/**/*.js',
'test/vendor/angular/angular-mocks.js',
'test/vendor/jquery-2.0.3.js',
'test/vendor/jasmine-jquery.js',

Просмотреть файл

@ -97,65 +97,7 @@ describe('JobsCtrl', function(){
var pushCtrl = createPushCtrl(jobScope.result_sets[2]);
var job = pushScope.job_results[0].groups[0].jobs[0];
pushScope.viewJob(job);
$httpBackend.flush();
expect(pushScope.selectedJob).toBe(job);
});
it('should set the visibleFields in the job when calling viewJob()', function() {
var pushCtrl = createPushCtrl(jobScope.result_sets[2]);
var job = pushScope.job_results[0].groups[0].jobs[0];
pushScope.viewJob(job);
$httpBackend.flush();
expect(pushScope.selectedJob.visibleFields).toEqual({
'Reason' : 'scheduler',
'State' : 'finished',
'Result' : 'success',
'Type Name' : 'mochitest-5',
'Type Desc' : 'fill me',
'Who' : 'sendchange-unittest',
'Job GUID' : '19e993f5b0a717185083fb9eacb2d422b36d6bd1',
'Machine Name' : 'tegra-363',
'Machine Platform Arch' : 'ARMv7',
'Machine Platform OS' : 'android',
'Build Platform' : '2.2',
'Build Arch' : 'ARMv7',
'Build OS' : 'android'
});
});
it('should set jobArtifact when calling viewJob()', function() {
var pushCtrl = createPushCtrl(jobScope.result_sets[2]);
var job = pushScope.job_results[0].groups[0].jobs[0];
pushScope.viewJob(job);
$httpBackend.flush();
// toEqual does a deep equality check, but $resource call adds a few
// things to the object that don't show on the json stringify output.
// so much compare each field separately.
expect(pushScope.selectedJob.jobArtifact.name).toEqual("Unknown Builder Job Artifact");
expect(pushScope.selectedJob.jobArtifact.active_status).toEqual("active");
expect(pushScope.selectedJob.jobArtifact.blob).toEqual({
"errors": [ ],
"tinderbox_printlines": [
"mochitest-plain<br/>895/0/128"
],
"logurl": "http://ftp.mozilla.org/pub/mozilla.org/mobile/tinderbox-builds/mozilla-inbound-android-armv6/1377289258/mozilla-inbound_tegra_android-armv6_test-mochitest-5-bm10-tests1-tegra-build1958.txt.gz"
});
expect(pushScope.selectedJob.jobArtifact.type).toEqual("json");
expect(pushScope.selectedJob.jobArtifact.id).toEqual(519);
expect(pushScope.selectedJob.jobArtifact.job_id).toEqual(260);
});
it('should set lvArtifact when calling viewJob()', function() {
var pushCtrl = createPushCtrl(jobScope.result_sets[2]);
var job = pushScope.job_results[0].groups[0].jobs[0];
pushScope.viewJob(job);
$httpBackend.flush();
expect(pushScope.selectedJob.lvArtifact).toEqual({
resource_uri : '/api/project/mozilla-inbound/artifact/520/',
type : 'json',
id : 520,
name : 'Structured Log'
});
});
});

Просмотреть файл

@ -0,0 +1,99 @@
'use strict';
/* jasmine specs for controllers go here */
describe('JobDetailPluginCtrl', function(){
var $httpBackend, createJobDetailPluginCtrl, jobDetailPluginScope;
beforeEach(module('treeherder'));
beforeEach(inject(function ($injector, $rootScope, $controller) {
$httpBackend = $injector.get('$httpBackend');
jasmine.getJSONFixtures().fixturesPath='base/test/mock';
$httpBackend.whenGET('http://local.treeherder.mozilla.org/api/project/mozilla-inbound/resultset/').respond(
getJSONFixture('resultset_list.json')
);
$httpBackend.whenGET('http://local.treeherder.mozilla.org/api/project/mozilla-inbound/resultset/2/').respond(
getJSONFixture('resultset_2.json')
);
$httpBackend.whenGET('http://local.treeherder.mozilla.org/api/project/mozilla-inbound/jobs/260/').respond(
getJSONFixture('job_260.json')
);
$httpBackend.whenGET('http://local.treeherder.mozilla.org/api/project/mozilla-inbound/artifact/519/').respond(
getJSONFixture('artifact_519.json')
);
$httpBackend.whenGET('http://local.treeherder.mozilla.org/api/project/mozilla-inbound/artifact/519').respond(
getJSONFixture('artifact_519.json')
);
jobDetailPluginScope = $rootScope.$new();
createJobDetailPluginCtrl = function() {
var ctrl = $controller('JobDetailPluginCtrl', {'$scope': jobDetailPluginScope});
jobDetailPluginScope.selectedJob = getJSONFixture('resultset_3.json').platforms[0].groups[0].jobs[0];
jobDetailPluginScope.$apply();
$httpBackend.flush();
return ctrl;
};
}));
/*
Tests JobDetailCtrl
*/
it('should set the visibleFields in the job when calling viewJob()', function() {
createJobDetailPluginCtrl();
expect(jobDetailPluginScope.visibleFields).toEqual({
'Reason' : 'scheduler',
'State' : 'finished',
'Result' : 'success',
'Type Name' : 'mochitest-5',
'Type Desc' : 'fill me',
'Who' : 'sendchange-unittest',
'Job GUID' : '19e993f5b0a717185083fb9eacb2d422b36d6bd1',
'Machine Name' : 'tegra-363',
'Machine Platform Arch' : 'ARMv7',
'Machine Platform OS' : 'android',
'Build Platform' : '2.2',
'Build Arch' : 'ARMv7',
'Build OS' : 'android'
});
});
it('should set jobArtifact when calling viewJob()', function() {
createJobDetailPluginCtrl();
// toEqual does a deep equality check, but $resource call adds a few
// things to the object that don't show on the json stringify output.
// so much compare each field separately.
expect(jobDetailPluginScope.jobArtifact.name).toEqual("Unknown Builder Job Artifact");
expect(jobDetailPluginScope.jobArtifact.active_status).toEqual("active");
expect(jobDetailPluginScope.jobArtifact.blob).toEqual({
"errors": [ ],
"tinderbox_printlines": [
"mochitest-plain<br/>895/0/128"
],
"logurl": "http://ftp.mozilla.org/pub/mozilla.org/mobile/tinderbox-builds/mozilla-inbound-android-armv6/1377289258/mozilla-inbound_tegra_android-armv6_test-mochitest-5-bm10-tests1-tegra-build1958.txt.gz"
});
expect(jobDetailPluginScope.jobArtifact.type).toEqual("json");
expect(jobDetailPluginScope.jobArtifact.id).toEqual(519);
expect(jobDetailPluginScope.jobArtifact.job_id).toEqual(260);
});
it('should set lvArtifact when calling viewJob()', function() {
createJobDetailPluginCtrl();
expect(jobDetailPluginScope.lvArtifact).toEqual({
resource_uri : '/api/project/mozilla-inbound/artifact/520/',
type : 'json',
id : 520,
name : 'Structured Log'
});
});
});

Просмотреть файл

@ -1,5 +1,6 @@
body{
padding-top: 60px;
padding-bottom: 500px;
}
.pushactions span.dropdown:hover ul.dropdown-menu{

Просмотреть файл

@ -70,40 +70,17 @@
ng-show="selectedJob">
<div class="navbar-inner">
<div class="container-fluid">
<button type="button"
class="close pull-right"
aria-hidden="true"
ng-click="clearJob()">&times;</button>
<div class="span7">
<dl class="dl-horizontal">
<span ng-repeat="(label, value) in selectedJob.visibleFields">
<dt class="label label-info">{{label}}</dt>
<dd class="">{{value}}</dd>
</span>
</dl>
<div ng-show="selectedJob.lvArtifact"
class="btn">
<a target="_blank" href="{{ selectedJob.lvUrl }}">View Structured Log</a>
</div>
<div ng-hide="selectedJob.lvArtifact">
<em>Processing Structured Log</em>
</div>
<div ng-repeat="joblog in selectedJob.logs">
<a target="_blank" href="{{ joblog.url }}">Raw Log: {{ joblog.url }}</a>
</div>
</div>
<ul class="span7" >
<li ng-repeat="line in selectedJob.jobArtifact.blob.tinderbox_printlines">
<div ng-bind-html-unsafe="line"></div>
</li>
</ul>
<button type="button"
class="close pull-right"
aria-hidden="true"
ng-click="clearJob()">&times;</button>
<div ng-include src="'plugins/pluginpanel.html'"></div>
</div>
</div>
</div>
<!-- modal window -->
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
@ -134,6 +111,9 @@
<script src="js/controllers/jobs.js"></script>
<script src="js/controllers/machines.js"></script>
<script src="js/controllers/timeline.js"></script>
<script src="plugins/controller.js"></script>
<script src="plugins/jobdetail/controller.js"></script>
<script src="plugins/jobfoo/controller.js"></script>
<script src="js/filters.js"></script>
</body>
</html>

Просмотреть файл

@ -45,55 +45,14 @@ treeherder.controller('PushCtrl',
thResults, thUrl, thServiceDomain) {
// whether or not revision list for a push is collapsed
$scope.isCollapsedRevisions = true;
$scope.isCollapsedResults = true;
// get the jobs list for the current resultset
thResults.getResults($scope.push, $scope);
$scope.viewJob = function(job) {
// view the job details in the lower job-details section
// set the selected job
$rootScope.selectedJob = job;
// fields that will show in the job detail panel
job.visibleFields = {
"Reason": job.reason,
"State": job.state,
"Result": job.result,
"Type Name": job.job_type_name,
"Type Desc": job.job_type_description,
"Who": job.who,
"Job GUID": job.job_guid,
"Machine Name": job.machine_name,
"Machine Platform Arch": job.machine_platform_architecture,
"Machine Platform OS": job.machine_platform_os,
"Build Platform": job.build_platform,
"Build Arch": job.build_architecture,
"Build OS": job.build_os
};
$http.get(thServiceDomain + job.resource_uri).
success(function(data) {
job.logs = data.logs;
data.artifacts.forEach(function(artifact) {
if (artifact.name.contains("Job Artifact")) {
// we don't return the blobs with job, just
// resource_uris to them. For the Job Artifact,
// we want that blob, so we need to fetch the
// detail to get the blob which has the
// tinderbox_printlines, etc.
job.jobArtifact = $resource(
thServiceDomain + artifact.resource_uri).get();
} else if (artifact.name === "Structured Log") {
// for the structured log, we don't need the blob
// here, we have everything we need in the artifact
// as is, so just save it.
job.lvArtifact=artifact;
job.lvUrl = thUrl.getLogViewerUrl(artifact.id);
}
});
});
};
$scope.viewLog = function(job_uri) {

Просмотреть файл

@ -1,6 +0,0 @@
<a class="btn-mini {{ resjob|typeClass }} {{ resjob.status|statusClass }}"
popover="{{ resjob.status }}"
popover-trigger="mouseenter">
<i class="icon-fire" ng-show="resjob.status=='fail' || resjob.status=='orange'"></i>
{{ resjob.symbol }}
</a>

19
ui/plugins/controller.js Normal file
Просмотреть файл

@ -0,0 +1,19 @@
"use strict";
treeherder.controller('PluginCtrl',
function PluginCtrl($scope, $rootScope) {
$scope.tabs = [
{
title: "Jobs Detail",
content: "plugins/jobdetail/main.html",
active: true
},
{
title: "Jobs Foo",
content: "plugins/jobfoo/main.html"
}
];
}
);

Просмотреть файл

@ -0,0 +1,53 @@
"use strict";
treeherder.controller('JobDetailPluginCtrl',
function JobDetailPluginCtrl($scope, $resource, $http,
thServiceDomain, thUrl) {
$scope.$watch('selectedJob', function(newValue, oldValue) {
// preferred way to get access to the selected job
if (newValue) {
$scope.job = newValue;
// fields that will show in the job detail panel
$scope.visibleFields = {
"Reason": $scope.job.reason,
"State": $scope.job.state,
"Result": $scope.job.result,
"Type Name": $scope.job.job_type_name,
"Type Desc": $scope.job.job_type_description,
"Who": $scope.job.who,
"Job GUID": $scope.job.job_guid,
"Machine Name": $scope.job.machine_name,
"Machine Platform Arch": $scope.job.machine_platform_architecture,
"Machine Platform OS": $scope.job.machine_platform_os,
"Build Platform": $scope.job.build_platform,
"Build Arch": $scope.job.build_architecture,
"Build OS": $scope.job.build_os
};
$http.get(thServiceDomain + $scope.job.resource_uri).
success(function(data) {
$scope.logs = data.logs;
data.artifacts.forEach(function(artifact) {
if (artifact.name.contains("Job Artifact")) {
// we don't return the blobs with job, just
// resource_uris to them. For the Job Artifact,
// we want that blob, so we need to fetch the
// detail to get the blob which has the
// tinderbox_printlines, etc.
$scope.jobArtifact = $resource(
thServiceDomain + artifact.resource_uri).get();
} else if (artifact.name === "Structured Log") {
// for the structured log, we don't need the blob
// here, we have everything we need in the artifact
// as is, so just save it.
$scope.lvArtifact=artifact;
$scope.lvUrl = thUrl.getLogViewerUrl(artifact.id);
}
});
});
}
}, true);
}
);

Просмотреть файл

@ -0,0 +1,25 @@
<div ng-controller="JobDetailPluginCtrl">
<div class="span7">
<dl class="dl-horizontal">
<span ng-repeat="(label, value) in visibleFields">
<dt class="label label-info">{{label}}</dt>
<dd class="">{{value}}</dd>
</span>
</dl>
<div ng-show="lvArtifact"
class="btn">
<a target="_blank" href="{{ lvUrl }}">View Structured Log</a>
</div>
<div ng-hide="lvArtifact">
<em>Processing Structured Log</em>
</div>
<div ng-repeat="joblog in logs">
<a target="_blank" href="{{ joblog.url }}">Raw Log: {{ joblog.url }}</a>
</div>
</div>
<ul class="span7" >
<li ng-repeat="line in jobArtifact.blob.tinderbox_printlines">
<div ng-bind-html-unsafe="line"></div>
</li>
</ul>
</div>

Просмотреть файл

@ -0,0 +1,13 @@
"use strict";
treeherder.controller('JobFooPluginCtrl',
function JobFooPluginCtrl($scope) {
$scope.$watch('selectedJob', function(newValue, oldValue) {
// preferred way to get access to the selected job
if (newValue) {
$scope.job = newValue;
}
}, true);
}
);

Просмотреть файл

@ -0,0 +1,3 @@
<div ng-controller="JobFooPluginCtrl">
<p>I pitty the foo that don't like job_guid: {{ job.job_guid }}</p>
</div>

Просмотреть файл

@ -0,0 +1,7 @@
<div ng-controller="PluginCtrl">
<tabset class="tabs-below">
<tab ng-repeat="tab in tabs" heading="{{ tab.title }}" active="tab.active" disabled="tab.disabled">
<ng-include src="tab.content"></ng-include>
</tab>
</tabset>
</div>