зеркало из https://github.com/mozilla/treeherder.git
Bug 1444134 - Consolidate references to SERVICE_DOMAIN (#3319)
* Don't use SERVICE_DOMAIN for references to the front-end code * Change getRootUrl to getApiUrl to better represent what it is for * Convert other usages of SERVICE_DOMAIN to getApiUrl * Convert usages of SERVICE_DOMAIN to getProjectUrl * Convert uses of SERVICE_DOMAIN to getServiceUrl * Convert tests to use ``urlHelper``
This commit is contained in:
Родитель
b221b8ca1e
Коммит
cca48d14df
|
@ -1,12 +1,11 @@
|
|||
import '../../../../ui/js/models/job.js';
|
||||
import { getProjectUrl } from "../../../../ui/helpers/urlHelper";
|
||||
|
||||
describe('ThJobModel', function(){
|
||||
|
||||
var $httpBackend,
|
||||
$timeout,
|
||||
foregroundRepo = "mozilla-central",
|
||||
projectPrefix = '/api/project/',
|
||||
foregroundPrefix = projectPrefix + foregroundRepo,
|
||||
ThJobModel;
|
||||
|
||||
beforeEach(angular.mock.module('treeherder'));
|
||||
|
@ -17,13 +16,13 @@ describe('ThJobModel', function(){
|
|||
jasmine.getJSONFixtures().fixturesPath='base/tests/ui/mock';
|
||||
ThJobModel = $injector.get('ThJobModel');
|
||||
ThJobModel.get_uri = function(){
|
||||
return foregroundPrefix+"/jobs/";
|
||||
return getProjectUrl("/jobs/", foregroundRepo);
|
||||
}
|
||||
}));
|
||||
|
||||
|
||||
describe("get_list", function(){
|
||||
beforeEach(inject(function () {
|
||||
$httpBackend.whenGET(foregroundPrefix + '/jobs/').respond(
|
||||
$httpBackend.whenGET(getProjectUrl('/jobs/', foregroundRepo)).respond(
|
||||
getJSONFixture('job_list/job_1.json')
|
||||
);
|
||||
}));
|
||||
|
@ -37,10 +36,10 @@ describe('ThJobModel', function(){
|
|||
|
||||
describe("pagination", function(){
|
||||
beforeEach(inject(function () {
|
||||
$httpBackend.whenGET(foregroundPrefix + '/jobs/?count=2').respond(
|
||||
$httpBackend.whenGET(getProjectUrl('/jobs/?count=2', foregroundRepo)).respond(
|
||||
getJSONFixture('job_list/pagination/page_1.json')
|
||||
);
|
||||
$httpBackend.whenGET(foregroundPrefix + '/jobs/?count=2&offset=2').respond(
|
||||
$httpBackend.whenGET(getProjectUrl('/jobs/?count=2&offset=2', foregroundRepo)).respond(
|
||||
getJSONFixture('job_list/pagination/page_2.json')
|
||||
);
|
||||
}));
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import { getProjectUrl } from "../../../../ui/helpers/urlHelper";
|
||||
|
||||
describe('ThResultSetStore', function(){
|
||||
|
||||
var $httpBackend,
|
||||
rootScope,
|
||||
model,
|
||||
repoModel,
|
||||
foregroundRepo = "mozilla-inbound",
|
||||
projectPrefix = '/api/project/',
|
||||
foregroundPrefix = projectPrefix + foregroundRepo;
|
||||
foregroundRepo = "mozilla-inbound";
|
||||
|
||||
beforeEach(angular.mock.module('treeherder'));
|
||||
|
||||
|
@ -16,8 +16,6 @@ describe('ThResultSetStore', function(){
|
|||
$httpBackend = $injector.get('$httpBackend');
|
||||
jasmine.getJSONFixtures().fixturesPath='base/tests/ui/mock';
|
||||
|
||||
|
||||
|
||||
$httpBackend.whenGET('https://treestatus.mozilla-releng.net/trees/mozilla-inbound').respond(
|
||||
{
|
||||
"result": {
|
||||
|
@ -30,23 +28,23 @@ describe('ThResultSetStore', function(){
|
|||
|
||||
);
|
||||
|
||||
$httpBackend.whenGET(foregroundPrefix + '/jobs/0/unclassified_failure_count/').respond(
|
||||
$httpBackend.whenGET(getProjectUrl('/jobs/0/unclassified_failure_count/', foregroundRepo)).respond(
|
||||
{
|
||||
"unclassified_failure_count": 1152,
|
||||
"repository": "mozilla-inbound"
|
||||
}
|
||||
);
|
||||
|
||||
$httpBackend.whenGET(foregroundPrefix + '/resultset/?count=10&full=true').respond(
|
||||
$httpBackend.whenGET(getProjectUrl('/resultset/?count=10&full=true', foregroundRepo)).respond(
|
||||
getJSONFixture('push_list.json')
|
||||
);
|
||||
|
||||
|
||||
$httpBackend.whenGET(foregroundPrefix + '/jobs/?count=2000&result_set_id=1&return_type=list').respond(
|
||||
$httpBackend.whenGET(getProjectUrl('/jobs/?count=2000&result_set_id=1&return_type=list', foregroundRepo)).respond(
|
||||
getJSONFixture('job_list/job_1.json')
|
||||
);
|
||||
|
||||
$httpBackend.whenGET(foregroundPrefix + '/jobs/?count=2000&result_set_id=2&return_type=list').respond(
|
||||
$httpBackend.whenGET(getProjectUrl('/jobs/?count=2000&result_set_id=2&return_type=list', foregroundRepo)).respond(
|
||||
getJSONFixture('job_list/job_2.json')
|
||||
);
|
||||
|
||||
|
@ -62,8 +60,6 @@ describe('ThResultSetStore', function(){
|
|||
getJSONFixture('job_group_list.json')
|
||||
);
|
||||
|
||||
|
||||
|
||||
rootScope = $rootScope.$new();
|
||||
rootScope.repoName = foregroundRepo;
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import Push from '../../../../ui/job-view/Push';
|
|||
import PushJobs from '../../../../ui/job-view/PushJobs';
|
||||
import Platform from '../../../../ui/job-view/Platform';
|
||||
import JobButton from '../../../../ui/job-view/JobButton';
|
||||
import { getProjectUrl, getApiUrl } from "../../../../ui/helpers/urlHelper";
|
||||
|
||||
describe('PushList component', () => {
|
||||
let $injector, $httpBackend, pushListEl, pushList;
|
||||
|
@ -12,7 +13,6 @@ describe('PushList component', () => {
|
|||
|
||||
beforeEach(angular.mock.module('treeherder'));
|
||||
beforeEach(inject((_$injector_) => {
|
||||
const projectPrefix = `/api/project/${repoName}/`;
|
||||
$injector = _$injector_;
|
||||
|
||||
// TODO: Once we switch away from angular for fetching data, we may want to
|
||||
|
@ -23,23 +23,23 @@ describe('PushList component', () => {
|
|||
|
||||
jasmine.getJSONFixtures().fixturesPath = 'base/tests/ui/mock';
|
||||
|
||||
$httpBackend.whenGET('/api/repository/').respond(
|
||||
$httpBackend.whenGET(getApiUrl('/repository/')).respond(
|
||||
getJSONFixture('repositories.json')
|
||||
);
|
||||
|
||||
$httpBackend.whenGET(projectPrefix + 'resultset/?count=10&full=true').respond(
|
||||
$httpBackend.whenGET(getProjectUrl('/resultset/?count=10&full=true', repoName)).respond(
|
||||
getJSONFixture('push_list.json')
|
||||
);
|
||||
|
||||
$httpBackend.whenGET(projectPrefix + 'resultset/?count=11&full=true&push_timestamp__lte=1424272126').respond(
|
||||
$httpBackend.whenGET(getProjectUrl('/resultset/?count=11&full=true&push_timestamp__lte=1424272126', repoName)).respond(
|
||||
getJSONFixture('push_list.json')
|
||||
);
|
||||
|
||||
$httpBackend.whenGET(projectPrefix + 'jobs/?count=2000&result_set_id=1&return_type=list').respond(
|
||||
$httpBackend.whenGET(getProjectUrl('/jobs/?count=2000&result_set_id=1&return_type=list', repoName)).respond(
|
||||
getJSONFixture('job_list/job_1.json')
|
||||
);
|
||||
|
||||
$httpBackend.whenGET(projectPrefix + 'jobs/?count=2000&result_set_id=2&return_type=list').respond(
|
||||
$httpBackend.whenGET(getProjectUrl('/jobs/?count=2000&result_set_id=2&return_type=list', repoName)).respond(
|
||||
getJSONFixture('job_list/job_2.json')
|
||||
);
|
||||
|
||||
|
@ -81,7 +81,6 @@ describe('PushList component', () => {
|
|||
describe('PushJobs component', () => {
|
||||
let $injector, pushJobsEl, pushList, ThResultSetStore;
|
||||
const repoName = 'mozilla-inbound';
|
||||
const projectPrefix = `/api/project/${repoName}/`;
|
||||
|
||||
beforeEach(angular.mock.module('treeherder'));
|
||||
beforeEach(inject((_$injector_) => {
|
||||
|
@ -92,16 +91,16 @@ describe('PushJobs component', () => {
|
|||
|
||||
jasmine.getJSONFixtures().fixturesPath = 'base/tests/ui/mock';
|
||||
|
||||
$httpBackend.whenGET('/api/repository/').respond(
|
||||
$httpBackend.whenGET(getApiUrl('/repository/')).respond(
|
||||
getJSONFixture('repositories.json')
|
||||
);
|
||||
$httpBackend.whenGET(projectPrefix + 'resultset/?count=10&full=true').respond(
|
||||
$httpBackend.whenGET(getProjectUrl('/resultset/?count=10&full=true', repoName)).respond(
|
||||
getJSONFixture('push_list.json')
|
||||
);
|
||||
$httpBackend.whenGET(projectPrefix + 'jobs/?count=2000&result_set_id=1&return_type=list').respond(
|
||||
$httpBackend.whenGET(getProjectUrl('/jobs/?count=2000&result_set_id=1&return_type=list', repoName)).respond(
|
||||
getJSONFixture('job_list/job_1.json')
|
||||
);
|
||||
$httpBackend.whenGET(projectPrefix + 'jobs/?count=2000&result_set_id=2&return_type=list').respond(
|
||||
$httpBackend.whenGET(getProjectUrl('/jobs/?count=2000&result_set_id=2&return_type=list', repoName)).respond(
|
||||
getJSONFixture('job_list/job_2.json')
|
||||
);
|
||||
$httpBackend.whenGET('https://treestatus.mozilla-releng.net/trees/mozilla-inbound').respond(
|
||||
|
|
|
@ -4,6 +4,14 @@ import thTaskcluster from "../js/services/taskcluster";
|
|||
import { getUrlParam, getAllUrlParams } from './locationHelper';
|
||||
import { isSHA } from "./revisionHelper";
|
||||
|
||||
export const getServiceUrl = function getServiceUrl(uri) {
|
||||
return `${SERVICE_DOMAIN}${uri}`;
|
||||
};
|
||||
|
||||
export const getApiUrl = function getApiUrl(uri) {
|
||||
return getServiceUrl(`/api${uri}`);
|
||||
};
|
||||
|
||||
export const getBugUrl = function getBugUrl(bug_id) {
|
||||
return `https://bugzilla.mozilla.org/show_bug.cgi?id=${bug_id}`;
|
||||
};
|
||||
|
@ -39,19 +47,17 @@ export const getLogViewerUrl = function getLogViewerUrl(job_id, repoName, line_n
|
|||
// not actually need a repo if they're trying to get a job by ``id``.
|
||||
export const getProjectUrl = function getProjectUrl(uri, repoName) {
|
||||
const repo = repoName || getUrlParam("repo") || 'mozilla-inbound';
|
||||
return `${SERVICE_DOMAIN}/api/project/${repo}${uri}`;
|
||||
|
||||
return getApiUrl(`/project/${repo}${uri}`);
|
||||
};
|
||||
|
||||
export const getProjectJobUrl = function getProjectJobUrl(url, jobId) {
|
||||
return getProjectUrl(`/jobs/${jobId}${url}`);
|
||||
};
|
||||
|
||||
export const getRootUrl = function getRootUrl(uri) {
|
||||
return `${SERVICE_DOMAIN}/api${uri}`;
|
||||
};
|
||||
|
||||
export const linkifyURLs = function linkifyURLs(input) {
|
||||
const urlpattern = /(\b(https?):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gim;
|
||||
|
||||
return input.replace(urlpattern, '<a href="$1" target="_blank" rel="noopener">$1</a>');
|
||||
};
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { userSessionFromAuthResult, renew, loggedOutUser } from './auth-utils';
|
||||
import thTaskcluster from '../services/taskcluster';
|
||||
import { getApiUrl } from "../../helpers/urlHelper";
|
||||
|
||||
export default class AuthService {
|
||||
constructor() {
|
||||
|
@ -7,7 +8,7 @@ export default class AuthService {
|
|||
}
|
||||
|
||||
_fetchUser(userSession) {
|
||||
const loginUrl = `${location.protocol}//${location.host}/api/auth/login/`;
|
||||
const loginUrl = getApiUrl('/auth/login/');
|
||||
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const userResponse = await fetch(loginUrl, {
|
||||
|
|
|
@ -2,7 +2,7 @@ import treeherder from '../treeherder';
|
|||
import AuthService from '../auth/AuthService';
|
||||
import { loggedOutUser } from '../auth/auth-utils';
|
||||
import thTaskcluster from '../services/taskcluster';
|
||||
import { getRootUrl } from '../../helpers/urlHelper';
|
||||
import { getApiUrl } from '../../helpers/urlHelper';
|
||||
|
||||
/**
|
||||
* This component handles logging in to Taskcluster Authentication
|
||||
|
@ -113,7 +113,7 @@ treeherder.component("login", {
|
|||
* the session token. Then updates the UI
|
||||
*/
|
||||
ctrl.logout = function () {
|
||||
$http.get(getRootUrl("/auth/logout/"))
|
||||
$http.get(getApiUrl("/auth/logout/"))
|
||||
.then(function () {
|
||||
ctrl.setLoggedOut();
|
||||
}, function (data) {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import treeherder from '../treeherder';
|
||||
import { getApiUrl } from "../../helpers/urlHelper";
|
||||
|
||||
treeherder.controller('BugFilerCtrl', [
|
||||
'$scope', '$uibModalInstance', '$http', 'summary',
|
||||
|
@ -364,7 +365,7 @@ treeherder.controller('BugFilerCtrl', [
|
|||
});
|
||||
|
||||
return $http({
|
||||
url: "api/bugzilla/create_bug/",
|
||||
url: getApiUrl("/bugzilla/create_bug/"),
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json; charset=utf-8"
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
import perf from '../../perf';
|
||||
import modifyAlertsCtrlTemplate from '../../../partials/perf/modifyalertsctrl.html';
|
||||
import { getApiUrl } from "../../../helpers/urlHelper";
|
||||
|
||||
perf.factory('PhBugs', [
|
||||
'$http', '$httpParamSerializer', '$interpolate', '$rootScope', 'dateFilter',
|
||||
function ($http, $httpParamSerializer, $interpolate, $rootScope, dateFilter) {
|
||||
return {
|
||||
fileBug: function (alertSummary) {
|
||||
$http.get(`${SERVICE_DOMAIN}/api/performance/bug-template/?framework=${alertSummary.framework}`).then(function (response) {
|
||||
$http.get(getApiUrl(`/performance/bug-template/?framework=${alertSummary.framework}`)).then(function (response) {
|
||||
const template = response.data[0];
|
||||
const repo = _.find($rootScope.repos, { name: alertSummary.repository });
|
||||
const compiledText = $interpolate(template.text)({
|
||||
|
|
|
@ -135,7 +135,7 @@ perf.controller('GraphsCtrl', [
|
|||
$scope.tooltipContent = {
|
||||
project: _.find($rootScope.repos,
|
||||
{ name: phSeries.projectName }),
|
||||
revisionUrl: `${SERVICE_DOMAIN}#/jobs?repo=${phSeries.projectName}`,
|
||||
revisionUrl: `/#/jobs?repo=${phSeries.projectName}`,
|
||||
prevResultSetId: prevResultSetId,
|
||||
resultSetId: dataPoint.resultSetId,
|
||||
jobId: dataPoint.jobId,
|
||||
|
|
|
@ -90,7 +90,7 @@ treeherder.filter('escapeHTML', function () {
|
|||
treeherder.filter('getRevisionUrl', function () {
|
||||
return function (revision, projectName) {
|
||||
if (revision) {
|
||||
return `${SERVICE_DOMAIN}/#/jobs?repo=${projectName}&revision=${revision}`;
|
||||
return `/#/jobs?repo=${projectName}&revision=${revision}`;
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import treeherder from '../treeherder';
|
||||
import { getRootUrl } from '../../helpers/urlHelper';
|
||||
import { getApiUrl } from '../../helpers/urlHelper';
|
||||
|
||||
treeherder.factory('ThBugSuggestionsModel', [
|
||||
'$resource', function ($resource) {
|
||||
return $resource(getRootUrl('/project/:project/jobs/:jobId/bug_suggestions/'));
|
||||
return $resource(getApiUrl('/project/:project/jobs/:jobId/bug_suggestions/'));
|
||||
}]);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import angular from 'angular';
|
||||
|
||||
import treeherder from '../treeherder';
|
||||
import { getRootUrl } from '../../helpers/urlHelper';
|
||||
import { getApiUrl } from '../../helpers/urlHelper';
|
||||
|
||||
treeherder.factory('ThBuildPlatformModel', [
|
||||
'$http',
|
||||
|
@ -16,7 +16,7 @@ treeherder.factory('ThBuildPlatformModel', [
|
|||
};
|
||||
|
||||
ThBuildPlatformModel.get_uri = function () {
|
||||
const url = getRootUrl("/buildplatform/");
|
||||
const url = getApiUrl("/buildplatform/");
|
||||
return url;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import angular from 'angular';
|
||||
|
||||
import treeherder from '../treeherder';
|
||||
import { getProjectJobUrl, getRootUrl } from '../../helpers/urlHelper';
|
||||
import { getProjectJobUrl, getApiUrl } from '../../helpers/urlHelper';
|
||||
|
||||
treeherder.factory('ThFailureLinesModel', [
|
||||
'$http', '$q',
|
||||
|
@ -35,7 +35,7 @@ treeherder.factory('ThFailureLinesModel', [
|
|||
};
|
||||
|
||||
ThFailureLinesModel.verify = function (line_id, best_classification) {
|
||||
return $http.put(getRootUrl("/failure-line/" + line_id + "/"),
|
||||
return $http.put(getApiUrl("/failure-line/" + line_id + "/"),
|
||||
{ best_classification: best_classification });
|
||||
};
|
||||
|
||||
|
@ -43,7 +43,7 @@ treeherder.factory('ThFailureLinesModel', [
|
|||
if (!data.length) {
|
||||
return $q.resolve();
|
||||
}
|
||||
return $http.put(getRootUrl("/failure-line/"), data);
|
||||
return $http.put(getApiUrl("/failure-line/"), data);
|
||||
};
|
||||
|
||||
return ThFailureLinesModel;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import treeherder from '../treeherder';
|
||||
import { getRootUrl } from '../../helpers/urlHelper';
|
||||
import { getApiUrl } from '../../helpers/urlHelper';
|
||||
|
||||
treeherder.factory('ThJobDetailModel', [
|
||||
'$http', function ($http) {
|
||||
|
@ -8,7 +8,7 @@ treeherder.factory('ThJobDetailModel', [
|
|||
config = config || {};
|
||||
const timeout = config.timeout || null;
|
||||
|
||||
return $http.get(getRootUrl("/jobdetail/"), {
|
||||
return $http.get(getApiUrl("/jobdetail/"), {
|
||||
params: params,
|
||||
timeout: timeout
|
||||
}).then(function (response) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import angular from 'angular';
|
||||
|
||||
import treeherder from '../treeherder';
|
||||
import { getRootUrl } from '../../helpers/urlHelper';
|
||||
import { getApiUrl } from '../../helpers/urlHelper';
|
||||
|
||||
treeherder.factory('ThJobGroupModel', [
|
||||
'$http',
|
||||
|
@ -16,7 +16,7 @@ treeherder.factory('ThJobGroupModel', [
|
|||
};
|
||||
|
||||
ThJobGroupModel.get_uri = function () {
|
||||
return getRootUrl("/jobgroup/");
|
||||
return getApiUrl("/jobgroup/");
|
||||
};
|
||||
|
||||
ThJobGroupModel.get_list = function (options) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import angular from 'angular';
|
||||
|
||||
import treeherder from '../treeherder';
|
||||
import { getRootUrl } from '../../helpers/urlHelper';
|
||||
import { getApiUrl } from '../../helpers/urlHelper';
|
||||
|
||||
treeherder.factory('ThJobTypeModel', [
|
||||
'$http',
|
||||
|
@ -16,7 +16,7 @@ treeherder.factory('ThJobTypeModel', [
|
|||
};
|
||||
|
||||
ThJobTypeModel.get_uri = function () {
|
||||
const url = getRootUrl("/jobtype/");
|
||||
const url = getApiUrl("/jobtype/");
|
||||
return url;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import angular from 'angular';
|
||||
|
||||
import treeherder from '../treeherder';
|
||||
import { getRootUrl } from '../../helpers/urlHelper';
|
||||
import { getApiUrl } from '../../helpers/urlHelper';
|
||||
|
||||
treeherder.factory('ThMatcherModel', [
|
||||
'$http',
|
||||
|
@ -16,7 +16,7 @@ treeherder.factory('ThMatcherModel', [
|
|||
};
|
||||
|
||||
ThMatcherModel.get_uri = function () {
|
||||
const url = getRootUrl("/matcher/");
|
||||
const url = getApiUrl("/matcher/");
|
||||
return url;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import treeherder from '../treeherder';
|
||||
import { getRootUrl } from '../../helpers/urlHelper';
|
||||
import { getApiUrl } from '../../helpers/urlHelper';
|
||||
|
||||
treeherder.factory('ThOptionCollectionModel', [
|
||||
'$http',
|
||||
function ($http) {
|
||||
const optionCollectionMap = {};
|
||||
const loadPromise = $http.get(
|
||||
getRootUrl("/optioncollectionhash/")).then(
|
||||
getApiUrl("/optioncollectionhash/")).then(
|
||||
function (response) {
|
||||
// return a map of option collection hashes to a string
|
||||
// representation of their contents
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import treeherder from '../../treeherder';
|
||||
import { getApiUrl } from "../../../helpers/urlHelper";
|
||||
|
||||
treeherder.factory('PhAlerts', [
|
||||
'$http', '$httpParamSerializer', '$q', 'ThOptionCollectionModel', 'PhSeries',
|
||||
|
@ -49,7 +50,7 @@ treeherder.factory('PhAlerts', [
|
|||
return endpoint + '?' + $httpParamSerializer(urlParameters);
|
||||
};
|
||||
Alert.prototype.modify = function (modification) {
|
||||
return $http.put(`${SERVICE_DOMAIN}/api/performance/alert/${this.id}/`,
|
||||
return $http.put(getApiUrl(`/performance/alert/${this.id}/`),
|
||||
modification);
|
||||
};
|
||||
_.forEach(phAlertStatusMap, function (status) {
|
||||
|
@ -141,14 +142,14 @@ treeherder.factory('PhAlerts', [
|
|||
};
|
||||
AlertSummary.prototype.updateStatus = function (newStatus) {
|
||||
const alertSummary = this;
|
||||
return $http.put(`${SERVICE_DOMAIN}/api/performance/alertsummary/${this.id}/`,
|
||||
return $http.put(getApiUrl(`/performance/alertsummary/${this.id}/`),
|
||||
{ status: newStatus.id }).then(function () {
|
||||
alertSummary.status = newStatus.id;
|
||||
});
|
||||
};
|
||||
AlertSummary.prototype.update = function () {
|
||||
const alertSummary = this;
|
||||
return $http.get(`${SERVICE_DOMAIN}/api/performance/alertsummary/${this.id}/`).then(
|
||||
return $http.get(getApiUrl(`/performance/alertsummary/${this.id}/`)).then(
|
||||
function (response) {
|
||||
return ThOptionCollectionModel.getMap().then(
|
||||
function (optionCollectionMap) {
|
||||
|
@ -198,7 +199,7 @@ treeherder.factory('PhAlerts', [
|
|||
};
|
||||
AlertSummary.prototype.assignBug = function (taskNumber, issueTrackerId) {
|
||||
const alertSummary = this;
|
||||
return $http.put(`${SERVICE_DOMAIN}/api/performance/alertsummary/${this.id}/`,
|
||||
return $http.put(getApiUrl(`/performance/alertsummary/${this.id}/`),
|
||||
{ bug_number: taskNumber, issue_tracker: issueTrackerId }).then(function () {
|
||||
return alertSummary.update();
|
||||
});
|
||||
|
@ -223,7 +224,7 @@ treeherder.factory('PhAlerts', [
|
|||
const canceller = $q.defer();
|
||||
const promise = ThOptionCollectionModel.getMap().then(
|
||||
function (optionCollectionMap) {
|
||||
return $http.get(`${SERVICE_DOMAIN}/api/performance/alertsummary/${id}/`,
|
||||
return $http.get(getApiUrl(`/performance/alertsummary/${id}/`),
|
||||
{ timeout: canceller.promise }).then(
|
||||
function (response) {
|
||||
return new AlertSummary(response.data,
|
||||
|
@ -251,7 +252,7 @@ treeherder.factory('PhAlerts', [
|
|||
getAlertSummaries: function (options) {
|
||||
let href;
|
||||
if (!options || !options.href) {
|
||||
href = `${SERVICE_DOMAIN}/api/performance/alertsummary/`;
|
||||
href = getApiUrl('/performance/alertsummary/');
|
||||
|
||||
// add filter parameters for status and framework
|
||||
const params = [];
|
||||
|
@ -296,14 +297,14 @@ treeherder.factory('PhAlerts', [
|
|||
});
|
||||
},
|
||||
createAlert: function (data) {
|
||||
return $http.post(`${SERVICE_DOMAIN}/api/performance/alertsummary/`, {
|
||||
return $http.post(getApiUrl('/performance/alertsummary/'), {
|
||||
repository_id: data.project.id,
|
||||
framework_id: data.series.frameworkId,
|
||||
push_id: data.resultSetId,
|
||||
prev_push_id: data.prevResultSetId
|
||||
}).then(function (response) {
|
||||
const newAlertSummaryId = response.data.alert_summary_id;
|
||||
return $http.post(`${SERVICE_DOMAIN}/api/performance/alert/`, {
|
||||
return $http.post(getApiUrl('/performance/alert/'), {
|
||||
summary_id: newAlertSummaryId,
|
||||
signature_id: data.series.id
|
||||
}).then(function () {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import treeherder from '../../treeherder';
|
||||
import { getApiUrl } from "../../../helpers/urlHelper";
|
||||
|
||||
treeherder.factory(
|
||||
'PhFramework', [
|
||||
|
@ -6,7 +7,7 @@ treeherder.factory(
|
|||
function ($http) {
|
||||
return {
|
||||
getFrameworkList: function () {
|
||||
return $http.get(`${SERVICE_DOMAIN}/api/performance/framework/`)
|
||||
return $http.get(getApiUrl('/performance/framework/'))
|
||||
.then(function (response) {
|
||||
return response.data;
|
||||
});
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import treeherder from '../../treeherder';
|
||||
import { getProjectUrl, getApiUrl } from "../../../helpers/urlHelper";
|
||||
|
||||
treeherder.factory('PhSeries', ['$http', 'ThOptionCollectionModel', '$q', function ($http, ThOptionCollectionModel, $q) {
|
||||
|
||||
|
@ -57,7 +58,7 @@ treeherder.factory('PhSeries', ['$http', 'ThOptionCollectionModel', '$q', functi
|
|||
getSeriesList: function (projectName, params) {
|
||||
return ThOptionCollectionModel.getMap().then(function (optionCollectionMap) {
|
||||
return $http.get(
|
||||
`${SERVICE_DOMAIN}/api/project/${projectName}/performance/signatures/`,
|
||||
getProjectUrl('/performance/signatures/', projectName),
|
||||
{ params: params }).then(function (response) {
|
||||
return _.map(response.data, function (signatureProps, signature) {
|
||||
return _getSeriesSummary(projectName, signature,
|
||||
|
@ -69,14 +70,14 @@ treeherder.factory('PhSeries', ['$http', 'ThOptionCollectionModel', '$q', functi
|
|||
},
|
||||
getPlatformList: function (projectName, params) {
|
||||
return $http.get(
|
||||
`${SERVICE_DOMAIN}/api/project/${projectName}/performance/platforms/`,
|
||||
getProjectUrl('/performance/platforms/', projectName),
|
||||
{ params: params }).then(function (response) {
|
||||
return response.data;
|
||||
});
|
||||
},
|
||||
getSeriesData: function (projectName, params) {
|
||||
return $http.get(
|
||||
`${SERVICE_DOMAIN}/api/project/${projectName}/performance/data/`,
|
||||
getProjectUrl('/performance/data/', projectName),
|
||||
{ params: params }).then(function (response) {
|
||||
if (response.data) {
|
||||
return response.data;
|
||||
|
@ -87,7 +88,7 @@ treeherder.factory('PhSeries', ['$http', 'ThOptionCollectionModel', '$q', functi
|
|||
getReplicateData: function (params) {
|
||||
params.value = 'perfherder-data.json';
|
||||
return $http.get(
|
||||
`${SERVICE_DOMAIN}/api/jobdetail/`,
|
||||
getApiUrl('/jobdetail/'),
|
||||
{ params: params }).then(
|
||||
function (response) {
|
||||
if (response.data.results[0]) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import treeherder from '../treeherder';
|
||||
import { getRootUrl } from '../../helpers/urlHelper';
|
||||
import { getApiUrl } from '../../helpers/urlHelper';
|
||||
|
||||
treeherder.factory('ThRepositoryModel', [
|
||||
'$http', '$rootScope', '$interval',
|
||||
|
@ -172,7 +172,7 @@ treeherder.factory('ThRepositoryModel', [
|
|||
};
|
||||
|
||||
const get_uri = function () {
|
||||
return getRootUrl("/repository/");
|
||||
return getApiUrl("/repository/");
|
||||
};
|
||||
|
||||
const get_list = function () {
|
||||
|
|
|
@ -4,7 +4,7 @@ import { Queue, slugid } from 'taskcluster-client-web';
|
|||
|
||||
import treeherder from '../treeherder';
|
||||
import thTaskcluster from '../services/taskcluster';
|
||||
import { getProjectUrl } from '../../helpers/urlHelper';
|
||||
import { getProjectUrl, getServiceUrl } from '../../helpers/urlHelper';
|
||||
|
||||
treeherder.factory('ThResultSetModel', ['$http', '$location',
|
||||
'$q', '$interpolate', 'tcactions',
|
||||
|
@ -124,7 +124,7 @@ treeherder.factory('ThResultSetModel', ['$http', '$location',
|
|||
);
|
||||
},
|
||||
get: function (uri) {
|
||||
return $http.get(SERVICE_DOMAIN + uri);
|
||||
return $http.get(getServiceUrl(uri));
|
||||
},
|
||||
getResultSetJobsUpdates: function (resultSetIdList, repoName, lastModified,
|
||||
locationParams) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import angular from 'angular';
|
||||
|
||||
import treeherder from '../treeherder';
|
||||
import { getProjectJobUrl, getRootUrl } from '../../helpers/urlHelper';
|
||||
import { getProjectJobUrl, getApiUrl } from '../../helpers/urlHelper';
|
||||
|
||||
treeherder.factory('ThTextLogErrorsModel', [
|
||||
'$http', '$q',
|
||||
|
@ -36,7 +36,7 @@ treeherder.factory('ThTextLogErrorsModel', [
|
|||
|
||||
ThTextLogErrorsModel.verify = function (lineId, bestClassification, bugNumber) {
|
||||
return $http.put(
|
||||
getRootUrl(`/text-log-error/${lineId}/`), {
|
||||
getApiUrl(`/text-log-error/${lineId}/`), {
|
||||
best_classification: bestClassification,
|
||||
bug_number: bugNumber
|
||||
});
|
||||
|
@ -46,7 +46,7 @@ treeherder.factory('ThTextLogErrorsModel', [
|
|||
if (!data.length) {
|
||||
return $q.resolve();
|
||||
}
|
||||
return $http.put(getRootUrl("/text-log-error/"), data);
|
||||
return $http.put(getApiUrl("/text-log-error/"), data);
|
||||
};
|
||||
|
||||
return ThTextLogErrorsModel;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import treeherder from '../treeherder';
|
||||
import { getRootUrl } from '../../helpers/urlHelper';
|
||||
import { getApiUrl } from '../../helpers/urlHelper';
|
||||
|
||||
treeherder.factory('ThTextLogStepModel', [
|
||||
'$resource', function ($resource) {
|
||||
return $resource(getRootUrl('/project/:project/jobs/:jobId/text_log_steps/'));
|
||||
return $resource(getApiUrl('/project/:project/jobs/:jobId/text_log_steps/'));
|
||||
}]);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import angular from 'angular';
|
||||
|
||||
import treeherder from '../treeherder';
|
||||
import { getRootUrl } from '../../helpers/urlHelper';
|
||||
import { getApiUrl } from '../../helpers/urlHelper';
|
||||
|
||||
treeherder.factory('ThUserModel', [
|
||||
'$http', 'thNotify', '$q',
|
||||
|
@ -15,7 +15,7 @@ treeherder.factory('ThUserModel', [
|
|||
angular.extend(this, data);
|
||||
};
|
||||
|
||||
ThUserModel.get_uri = function () { return getRootUrl("/user/"); };
|
||||
ThUserModel.get_uri = function () { return getApiUrl("/user/"); };
|
||||
|
||||
ThUserModel.get = function () {
|
||||
// a static method to retrieve a single instance of ThUserModel
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import treeherder from '../treeherder';
|
||||
import { getRootUrl } from '../../helpers/urlHelper';
|
||||
import { getApiUrl } from '../../helpers/urlHelper';
|
||||
|
||||
treeherder.factory('thClassificationTypes', [
|
||||
'$http',
|
||||
|
@ -27,7 +27,7 @@ treeherder.factory('thClassificationTypes', [
|
|||
};
|
||||
|
||||
const load = function () {
|
||||
return $http.get(getRootUrl("/failureclassification/"), { cache: true })
|
||||
return $http.get(getApiUrl("/failureclassification/"), { cache: true })
|
||||
.then(({ data }) => {
|
||||
data.forEach(addClassification);
|
||||
});
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import treeherder from '../../treeherder';
|
||||
import { getApiUrl } from "../../../helpers/urlHelper";
|
||||
|
||||
treeherder.factory('PhCompare', [
|
||||
'$q', '$http', '$httpParamSerializer', 'PhSeries', 'math', 'phTimeRanges',
|
||||
|
@ -214,7 +215,7 @@ treeherder.factory('PhCompare', [
|
|||
if (!newSignature) errors.push('Missing input: newSignature');
|
||||
}
|
||||
|
||||
$http.get(`${SERVICE_DOMAIN}/api/repository/`).then(function (response) {
|
||||
$http.get(getApiUrl('/repository/')).then(function (response) {
|
||||
if (!_.find(response.data, { name: originalProject })) {
|
||||
errors.push("Invalid project, doesn't exist: " + originalProject);
|
||||
}
|
||||
|
|
|
@ -173,10 +173,7 @@ treeherder.controller('PluginCtrl', [
|
|||
series: seriesList.find(s => d.signature_id === s.id),
|
||||
...d
|
||||
})).filter(d => !d.series.parentSignature).map(d => ({
|
||||
url: `${SERVICE_DOMAIN}/perf.html#/graphs?series=` +
|
||||
[$scope.repoName, d.signature_id, 1, d.series.frameworkId] +
|
||||
'&selected=' +
|
||||
[$scope.repoName, d.signature_id, $scope.job.result_set_id, d.id],
|
||||
url: `/perf.html#/graphs?series=${[$scope.repoName, d.signature_id, 1, d.series.frameworkId]}&selected=${[$scope.repoName, d.signature_id, $scope.job.result_set_id, d.id]}`,
|
||||
value: d.value,
|
||||
title: d.series.name
|
||||
}));
|
||||
|
|
|
@ -8,6 +8,7 @@ import createHistory from 'history/createBrowserHistory';
|
|||
import createDebounce from 'redux-debounce';
|
||||
import * as groupsStore from './modules/groups';
|
||||
import { platformMap } from '../../js/constants';
|
||||
import { getServiceUrl, getProjectUrl } from "../../helpers/urlHelper";
|
||||
|
||||
function getGroupText(group) {
|
||||
const symbol = group.symbol.startsWith('tc-') ?
|
||||
|
@ -91,7 +92,7 @@ function filterGroups(filter, groups, options, hideClassified) {
|
|||
async function fetchTests(store, fetchParams) {
|
||||
let fetchStatus = 'No failed tests to show';
|
||||
const { url, filter, options, hideClassified, bugSuggestions } = fetchParams;
|
||||
const response = await fetch(`${SERVICE_DOMAIN}${url}`, fetchParams);
|
||||
const response = await fetch(getServiceUrl(url), fetchParams);
|
||||
const pushResp = await response.json();
|
||||
// Here the json is the job_detail result.
|
||||
// We need to take each entry and query for the errorsummary.log
|
||||
|
@ -198,7 +199,7 @@ async function fetchTests(store, fetchParams) {
|
|||
|
||||
async function fetchOptions(store, fetchParams) {
|
||||
const { url } = fetchParams;
|
||||
const resp = await fetch(`${SERVICE_DOMAIN}${url}`, fetchParams);
|
||||
const resp = await fetch(getServiceUrl(url), fetchParams);
|
||||
const options = await resp.json();
|
||||
store.dispatch({
|
||||
type: groupsStore.types.STORE_OPTIONS,
|
||||
|
@ -212,8 +213,8 @@ async function fetchOptions(store, fetchParams) {
|
|||
}
|
||||
|
||||
async function fetchCounts(store, fetchParams) {
|
||||
const { url } = fetchParams;
|
||||
const resp = await fetch(`${SERVICE_DOMAIN}${url}`, fetchParams);
|
||||
const { url, repoName } = fetchParams;
|
||||
const resp = await fetch(getProjectUrl(url, repoName), fetchParams);
|
||||
const pushStatus = await resp.json();
|
||||
const counts = {
|
||||
success: 0,
|
||||
|
@ -314,7 +315,7 @@ async function fetchBugsSingleTest(store, { test, bugSuggestions, url }) {
|
|||
|
||||
// Do a request for each url in the keys of the testMap. Using them as keys eliminates
|
||||
// duplicate requests since multiple tests can be in the same job.
|
||||
const responses = await Promise.all(Object.keys(testMap).map(url => fetch(`${SERVICE_DOMAIN}${url}`)));
|
||||
const responses = await Promise.all(Object.keys(testMap).map(url => fetch(getServiceUrl(url))));
|
||||
const respData = await Promise.all(responses.map(promise => promise.json()));
|
||||
const updatedBugSuggestions = {
|
||||
...bugSuggestions,
|
||||
|
@ -348,7 +349,7 @@ async function fetchBugs(store, { rowData, url }) {
|
|||
}, {});
|
||||
// Do a request for each url in the keys of the testMap. Using them as keys eliminates
|
||||
// duplicate requests since multiple tests can be in the same job.
|
||||
const responses = await Promise.all(Object.keys(testMap).map(url => fetch(`${SERVICE_DOMAIN}${url}`)));
|
||||
const responses = await Promise.all(Object.keys(testMap).map(url => fetch(getServiceUrl(url))));
|
||||
const respData = await Promise.all(responses.map(promise => promise.json()));
|
||||
const bugSuggestions = respData.reduce((bsAcc, data, idx) => {
|
||||
testMap[stripHost(responses[idx].url)].forEach((test) => {
|
||||
|
|
|
@ -120,7 +120,8 @@ export const actions = {
|
|||
type: types.FETCH_COUNTS,
|
||||
meta: {
|
||||
type: 'api',
|
||||
url: `/api/project/${repoName}/resultset/${pushId}/status/`,
|
||||
url: `/resultset/${pushId}/status/`,
|
||||
repoName,
|
||||
method: 'GET',
|
||||
},
|
||||
}),
|
||||
|
|
Загрузка…
Ссылка в новой задаче