aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2016-06-15 09:36:50 +0200
committerGitHub <noreply@github.com>2016-06-15 09:36:50 +0200
commit9c53b1dc08d0d07625abd0f77139021384082d28 (patch)
tree0f0175f77d7b82f61d4db763b60229395006f631 /server/sonar-web/src/main/js
parenta115682465bbd4e9c46c86ea03229b4f513a78d5 (diff)
downloadsonarqube-9c53b1dc08d0d07625abd0f77139021384082d28.tar.gz
sonarqube-9c53b1dc08d0d07625abd0f77139021384082d28.zip
SONAR-7717 automatically handle baseUrl (#1039)
Diffstat (limited to 'server/sonar-web/src/main/js')
-rw-r--r--server/sonar-web/src/main/js/api/ce.js10
-rw-r--r--server/sonar-web/src/main/js/api/components.js22
-rw-r--r--server/sonar-web/src/main/js/api/events.js2
-rw-r--r--server/sonar-web/src/main/js/api/favorites.js5
-rw-r--r--server/sonar-web/src/main/js/api/issue-filters.js2
-rw-r--r--server/sonar-web/src/main/js/api/issues.js6
-rw-r--r--server/sonar-web/src/main/js/api/languages.js2
-rw-r--r--server/sonar-web/src/main/js/api/measure-filters.js2
-rw-r--r--server/sonar-web/src/main/js/api/measures.js4
-rw-r--r--server/sonar-web/src/main/js/api/metrics.js2
-rw-r--r--server/sonar-web/src/main/js/api/nav.js6
-rw-r--r--server/sonar-web/src/main/js/api/permissions.js10
-rw-r--r--server/sonar-web/src/main/js/api/quality-gates.js24
-rw-r--r--server/sonar-web/src/main/js/api/quality-profiles.js2
-rw-r--r--server/sonar-web/src/main/js/api/system.js8
-rw-r--r--server/sonar-web/src/main/js/api/time-machine.js2
-rw-r--r--server/sonar-web/src/main/js/api/user-tokens.js6
-rw-r--r--server/sonar-web/src/main/js/api/users.js6
-rw-r--r--server/sonar-web/src/main/js/api/web-api.js4
-rw-r--r--server/sonar-web/src/main/js/helpers/request.js2
20 files changed, 63 insertions, 64 deletions
diff --git a/server/sonar-web/src/main/js/api/ce.js b/server/sonar-web/src/main/js/api/ce.js
index 66c6b3dc8ab..f7ec5e042ba 100644
--- a/server/sonar-web/src/main/js/api/ce.js
+++ b/server/sonar-web/src/main/js/api/ce.js
@@ -31,7 +31,7 @@ export function getActivity (data) {
}
export function getStatus (componentId) {
- const url = window.baseUrl + '/api/ce/activity_status';
+ const url = '/api/ce/activity_status';
const data = {};
if (componentId) {
Object.assign(data, { componentId });
@@ -40,12 +40,12 @@ export function getStatus (componentId) {
}
export function getTask (id) {
- const url = window.baseUrl + '/api/ce/task';
+ const url = '/api/ce/task';
return getJSON(url, { id }).then(r => r.task);
}
export function cancelTask (id) {
- const url = window.baseUrl + '/api/ce/cancel';
+ const url = '/api/ce/cancel';
return post(url, { id }).then(
getTask.bind(null, id),
getTask.bind(null, id)
@@ -53,7 +53,7 @@ export function cancelTask (id) {
}
export function cancelAllTasks () {
- const url = window.baseUrl + '/api/ce/cancel_all';
+ const url = '/api/ce/cancel_all';
return post(url);
}
@@ -64,6 +64,6 @@ export function getTasksForComponent (componentId) {
}
export function getTypes () {
- const url = window.baseUrl + '/api/ce/task_types';
+ const url = '/api/ce/task_types';
return getJSON(url).then(r => r.taskTypes);
}
diff --git a/server/sonar-web/src/main/js/api/components.js b/server/sonar-web/src/main/js/api/components.js
index 934d7a9c1bb..4d36ff7c942 100644
--- a/server/sonar-web/src/main/js/api/components.js
+++ b/server/sonar-web/src/main/js/api/components.js
@@ -20,32 +20,32 @@
import { getJSON, postJSON, post } from '../helpers/request.js';
export function getComponents (data) {
- const url = window.baseUrl + '/api/components/search';
+ const url = '/api/components/search';
return getJSON(url, data);
}
export function getProvisioned (data) {
- const url = window.baseUrl + '/api/projects/provisioned';
+ const url = '/api/projects/provisioned';
return getJSON(url, data);
}
export function getGhosts (data) {
- const url = window.baseUrl + '/api/projects/ghosts';
+ const url = '/api/projects/ghosts';
return getJSON(url, data);
}
export function deleteComponents (data) {
- const url = window.baseUrl + '/api/projects/bulk_delete';
+ const url = '/api/projects/bulk_delete';
return post(url, data);
}
export function createProject (data) {
- const url = window.baseUrl + '/api/projects/create';
+ const url = '/api/projects/create';
return postJSON(url, data);
}
export function getComponentTree (strategy, componentKey, metrics = [], additional = {}) {
- const url = window.baseUrl + '/api/measures/component_tree';
+ const url = '/api/measures/component_tree';
const data = Object.assign({}, additional, {
baseComponentKey: componentKey,
metricKeys: metrics.join(','),
@@ -63,25 +63,25 @@ export function getComponentLeaves (componentKey, metrics, additional) {
}
export function getComponent (componentKey, metrics = []) {
- const url = window.baseUrl + '/api/measures/component';
+ const url = '/api/measures/component';
const data = { componentKey, metricKeys: metrics.join(',') };
return getJSON(url, data).then(r => r.component);
}
export function getTree (baseComponentKey, options = {}) {
- const url = window.baseUrl + '/api/components/tree';
+ const url = '/api/components/tree';
const data = Object.assign({}, options, { baseComponentKey });
return getJSON(url, data);
}
export function getParents ({ id, key }) {
- const url = window.baseUrl + '/api/components/show';
+ const url = '/api/components/show';
const data = id ? { id } : { key };
return getJSON(url, data).then(r => r.ancestors);
}
export function getBreadcrumbs ({ id, key }) {
- const url = window.baseUrl + '/api/components/show';
+ const url = '/api/components/show';
const data = id ? { id } : { key };
return getJSON(url, data).then(r => {
const reversedAncestors = [...r.ancestors].reverse();
@@ -90,7 +90,7 @@ export function getBreadcrumbs ({ id, key }) {
}
export function getProjectsWithInternalId (query) {
- const url = window.baseUrl + '/api/resources/search';
+ const url = '/api/resources/search';
const data = {
f: 's2',
q: 'TRK',
diff --git a/server/sonar-web/src/main/js/api/events.js b/server/sonar-web/src/main/js/api/events.js
index 450a4cd2623..7d9d2da53e0 100644
--- a/server/sonar-web/src/main/js/api/events.js
+++ b/server/sonar-web/src/main/js/api/events.js
@@ -26,7 +26,7 @@ import { getJSON } from '../helpers/request.js';
* @returns {Promise}
*/
export function getEvents (componentKey, categories) {
- const url = window.baseUrl + '/api/events';
+ const url = '/api/events';
const data = { resource: componentKey };
if (categories) {
data.categories = categories;
diff --git a/server/sonar-web/src/main/js/api/favorites.js b/server/sonar-web/src/main/js/api/favorites.js
index c9e61cd2ad4..eff40c309fd 100644
--- a/server/sonar-web/src/main/js/api/favorites.js
+++ b/server/sonar-web/src/main/js/api/favorites.js
@@ -20,13 +20,12 @@
import { post, requestDelete } from '../helpers/request';
export function addFavorite (componentKey) {
- const url = window.baseUrl + '/api/favourites';
+ const url = '/api/favourites';
const data = { key: componentKey };
return post(url, data);
}
export function removeFavorite (componentKey) {
- const url = window.baseUrl +
- '/api/favourites/' + encodeURIComponent(componentKey);
+ const url = '/api/favourites/' + encodeURIComponent(componentKey);
return requestDelete(url);
}
diff --git a/server/sonar-web/src/main/js/api/issue-filters.js b/server/sonar-web/src/main/js/api/issue-filters.js
index 1e8c872dc7d..f2bd4226eab 100644
--- a/server/sonar-web/src/main/js/api/issue-filters.js
+++ b/server/sonar-web/src/main/js/api/issue-filters.js
@@ -20,7 +20,7 @@
import { post } from '../helpers/request.js';
export function toggleIssueFilter (id) {
- const url = window.baseUrl + '/issues/toggle_fav';
+ const url = '/issues/toggle_fav';
const data = { id };
return post(url, data);
}
diff --git a/server/sonar-web/src/main/js/api/issues.js b/server/sonar-web/src/main/js/api/issues.js
index 86ea25a9b30..21146b1bea9 100644
--- a/server/sonar-web/src/main/js/api/issues.js
+++ b/server/sonar-web/src/main/js/api/issues.js
@@ -22,7 +22,7 @@ import _ from 'underscore';
import { getJSON } from '../helpers/request.js';
export function getFacets (query, facets) {
- const url = window.baseUrl + '/api/issues/search';
+ const url = '/api/issues/search';
const data = _.extend({}, query, { facets: facets.join(), ps: 1, additionalFields: '_all' });
return getJSON(url, data).then(r => {
return { facets: r.facets, response: r };
@@ -55,7 +55,7 @@ export function getAssignees (query) {
}
export function getIssuesCount (query) {
- const url = window.baseUrl + '/api/issues/search';
+ const url = '/api/issues/search';
const data = _.extend({}, query, { ps: 1, facetMode: 'effort' });
return getJSON(url, data).then(r => {
return { issues: r.total, debt: r.debtTotal };
@@ -63,6 +63,6 @@ export function getIssuesCount (query) {
}
export function getIssueFilters () {
- const url = window.baseUrl + '/api/issue_filters/search';
+ const url = '/api/issue_filters/search';
return getJSON(url).then(r => r.issueFilters);
}
diff --git a/server/sonar-web/src/main/js/api/languages.js b/server/sonar-web/src/main/js/api/languages.js
index e1176b8527b..4b3a00b764d 100644
--- a/server/sonar-web/src/main/js/api/languages.js
+++ b/server/sonar-web/src/main/js/api/languages.js
@@ -20,6 +20,6 @@
import { getJSON } from '../helpers/request.js';
export function getLanguages () {
- const url = window.baseUrl + '/api/languages/list';
+ const url = '/api/languages/list';
return getJSON(url).then(r => r.languages);
}
diff --git a/server/sonar-web/src/main/js/api/measure-filters.js b/server/sonar-web/src/main/js/api/measure-filters.js
index 67699863d9a..ed64ba09db7 100644
--- a/server/sonar-web/src/main/js/api/measure-filters.js
+++ b/server/sonar-web/src/main/js/api/measure-filters.js
@@ -20,7 +20,7 @@
import { post } from '../helpers/request.js';
export function toggleMeasureFilter (id) {
- const url = window.baseUrl + '/measures/toggle_fav';
+ const url = '/measures/toggle_fav';
const data = { id };
return post(url, data);
}
diff --git a/server/sonar-web/src/main/js/api/measures.js b/server/sonar-web/src/main/js/api/measures.js
index e182dab8174..0b6bd6b4716 100644
--- a/server/sonar-web/src/main/js/api/measures.js
+++ b/server/sonar-web/src/main/js/api/measures.js
@@ -20,13 +20,13 @@
import { getJSON } from '../helpers/request.js';
export function getMeasures (componentKey, metrics) {
- const url = window.baseUrl + '/api/measures/component';
+ const url = '/api/measures/component';
const data = { componentKey, metricKeys: metrics.join(',') };
return getJSON(url, data).then(r => r.component.measures);
}
export function getMeasuresAndMeta (componentKey, metrics, additional = {}) {
- const url = window.baseUrl + '/api/measures/component';
+ const url = '/api/measures/component';
const data = Object.assign({}, additional, {
componentKey,
metricKeys: metrics.join(',')
diff --git a/server/sonar-web/src/main/js/api/metrics.js b/server/sonar-web/src/main/js/api/metrics.js
index 51118918c00..45f2500288c 100644
--- a/server/sonar-web/src/main/js/api/metrics.js
+++ b/server/sonar-web/src/main/js/api/metrics.js
@@ -20,7 +20,7 @@
import { getJSON } from '../helpers/request.js';
export function getMetrics () {
- const url = window.baseUrl + '/api/metrics/search';
+ const url = '/api/metrics/search';
const data = { ps: 9999 };
return getJSON(url, data).then(r => r.metrics);
}
diff --git a/server/sonar-web/src/main/js/api/nav.js b/server/sonar-web/src/main/js/api/nav.js
index 1aeafc17a6f..424c0a68536 100644
--- a/server/sonar-web/src/main/js/api/nav.js
+++ b/server/sonar-web/src/main/js/api/nav.js
@@ -20,17 +20,17 @@
import { getJSON } from '../helpers/request.js';
export function getGlobalNavigation () {
- const url = window.baseUrl + '/api/navigation/global';
+ const url = '/api/navigation/global';
return getJSON(url);
}
export function getComponentNavigation (componentKey) {
- const url = window.baseUrl + '/api/navigation/component';
+ const url = '/api/navigation/component';
const data = { componentKey };
return getJSON(url, data);
}
export function getSettingsNavigation () {
- const url = window.baseUrl + '/api/navigation/settings';
+ const url = '/api/navigation/settings';
return getJSON(url);
}
diff --git a/server/sonar-web/src/main/js/api/permissions.js b/server/sonar-web/src/main/js/api/permissions.js
index d8d0413544b..273c7872735 100644
--- a/server/sonar-web/src/main/js/api/permissions.js
+++ b/server/sonar-web/src/main/js/api/permissions.js
@@ -108,7 +108,7 @@ export function revokeFromGroup (permission, group, project) {
* @returns {Promise}
*/
export function getPermissionTemplates () {
- const url = window.baseUrl + '/api/permissions/search_templates';
+ const url = '/api/permissions/search_templates';
return getJSON(url);
}
@@ -134,7 +134,7 @@ export function deletePermissionTemplate (options) {
* @returns {Promise}
*/
export function setDefaultPermissionTemplate (templateName, qualifier) {
- const url = window.baseUrl + '/api/permissions/set_default_template';
+ const url = '/api/permissions/set_default_template';
const data = { templateName, qualifier };
return post(url, data);
}
@@ -150,15 +150,13 @@ export function bulkApplyTemplateToProject (options) {
}
export function addProjectCreatorToTemplate (templateName, permission) {
- const url = window.baseUrl +
- '/api/permissions/add_project_creator_to_template';
+ const url = '/api/permissions/add_project_creator_to_template';
const data = { templateName, permission };
return post(url, data);
}
export function removeProjectCreatorFromTemplate (templateName, permission) {
- const url = window.baseUrl +
- '/api/permissions/remove_project_creator_from_template';
+ const url = '/api/permissions/remove_project_creator_from_template';
const data = { templateName, permission };
return post(url, data);
}
diff --git a/server/sonar-web/src/main/js/api/quality-gates.js b/server/sonar-web/src/main/js/api/quality-gates.js
index e6567a918c1..a32b0295d1d 100644
--- a/server/sonar-web/src/main/js/api/quality-gates.js
+++ b/server/sonar-web/src/main/js/api/quality-gates.js
@@ -20,13 +20,13 @@
import { getJSON, post, postJSON } from '../helpers/request';
export function fetchQualityGatesAppDetails () {
- const url = window.baseUrl + '/api/qualitygates/app';
+ const url = '/api/qualitygates/app';
return getJSON(url);
}
export function fetchQualityGates () {
- const url = window.baseUrl + '/api/qualitygates/list';
+ const url = '/api/qualitygates/list';
return getJSON(url).then(r => r.qualitygates.map(qualityGate => {
return {
@@ -37,51 +37,51 @@ export function fetchQualityGates () {
}
export function fetchQualityGate (id) {
- const url = window.baseUrl + '/api/qualitygates/show';
+ const url = '/api/qualitygates/show';
return getJSON(url, { id });
}
export function createQualityGate (name) {
- const url = window.baseUrl + '/api/qualitygates/create';
+ const url = '/api/qualitygates/create';
return postJSON(url, { name });
}
export function deleteQualityGate (id) {
- const url = window.baseUrl + '/api/qualitygates/destroy';
+ const url = '/api/qualitygates/destroy';
return post(url, { id });
}
export function renameQualityGate (id, name) {
- const url = window.baseUrl + '/api/qualitygates/rename';
+ const url = '/api/qualitygates/rename';
return post(url, { id, name });
}
export function copyQualityGate (id, name) {
- const url = window.baseUrl + '/api/qualitygates/copy';
+ const url = '/api/qualitygates/copy';
return postJSON(url, { id, name });
}
export function setQualityGateAsDefault (id) {
- const url = window.baseUrl + '/api/qualitygates/set_as_default';
+ const url = '/api/qualitygates/set_as_default';
return post(url, { id });
}
export function unsetQualityGateAsDefault (id) {
- const url = window.baseUrl + '/api/qualitygates/unset_default';
+ const url = '/api/qualitygates/unset_default';
return post(url, { id });
}
export function createCondition (gateId, condition) {
- const url = window.baseUrl + '/api/qualitygates/create_condition';
+ const url = '/api/qualitygates/create_condition';
return postJSON(url, { ...condition, gateId });
}
export function updateCondition (condition) {
- const url = window.baseUrl + '/api/qualitygates/update_condition';
+ const url = '/api/qualitygates/update_condition';
return postJSON(url, { ...condition });
}
export function deleteCondition (id) {
- const url = window.baseUrl + '/api/qualitygates/delete_condition';
+ const url = '/api/qualitygates/delete_condition';
return post(url, { id });
}
diff --git a/server/sonar-web/src/main/js/api/quality-profiles.js b/server/sonar-web/src/main/js/api/quality-profiles.js
index eab3a84200b..c6fbee56978 100644
--- a/server/sonar-web/src/main/js/api/quality-profiles.js
+++ b/server/sonar-web/src/main/js/api/quality-profiles.js
@@ -20,6 +20,7 @@
import { checkStatus, parseJSON } from '../helpers/request';
export function createQualityProfile (data) {
+ // TODO
const url = window.baseUrl + '/api/qualityprofiles/create';
const options = {
method: 'post',
@@ -32,6 +33,7 @@ export function createQualityProfile (data) {
}
export function restoreQualityProfile (data) {
+ // TODO
const url = window.baseUrl + '/api/qualityprofiles/restore';
const options = {
method: 'post',
diff --git a/server/sonar-web/src/main/js/api/system.js b/server/sonar-web/src/main/js/api/system.js
index a280b6f7b73..fcd5d791f9b 100644
--- a/server/sonar-web/src/main/js/api/system.js
+++ b/server/sonar-web/src/main/js/api/system.js
@@ -20,23 +20,23 @@
import { getJSON, post } from '../helpers/request';
export function setLogLevel (level) {
- const url = window.baseUrl + '/api/system/change_log_level';
+ const url = '/api/system/change_log_level';
const data = { level };
return post(url, data);
}
export function getSystemInfo () {
- const url = window.baseUrl + '/api/system/info';
+ const url = '/api/system/info';
return getJSON(url);
}
export function getStatus () {
- const url = window.baseUrl + '/api/system/status';
+ const url = '/api/system/status';
return getJSON(url);
}
export function restart () {
- const url = window.baseUrl + '/api/system/restart';
+ const url = '/api/system/restart';
return post(url);
}
diff --git a/server/sonar-web/src/main/js/api/time-machine.js b/server/sonar-web/src/main/js/api/time-machine.js
index 76af59dfb84..adf44fdbcac 100644
--- a/server/sonar-web/src/main/js/api/time-machine.js
+++ b/server/sonar-web/src/main/js/api/time-machine.js
@@ -20,7 +20,7 @@
import { getJSON } from '../helpers/request.js';
export function getTimeMachineData (componentKey, metrics) {
- const url = window.baseUrl + '/api/timemachine/index';
+ const url = '/api/timemachine/index';
const data = { resource: componentKey, metrics };
return getJSON(url, data);
}
diff --git a/server/sonar-web/src/main/js/api/user-tokens.js b/server/sonar-web/src/main/js/api/user-tokens.js
index 3cd1a71b4c7..493b0cb065e 100644
--- a/server/sonar-web/src/main/js/api/user-tokens.js
+++ b/server/sonar-web/src/main/js/api/user-tokens.js
@@ -25,7 +25,7 @@ import { getJSON, postJSON, post } from '../helpers/request.js';
* @returns {Promise}
*/
export function getTokens (login) {
- const url = window.baseUrl + '/api/user_tokens/search';
+ const url = '/api/user_tokens/search';
const data = { login };
return getJSON(url, data).then(r => r.userTokens);
}
@@ -37,7 +37,7 @@ export function getTokens (login) {
* @returns {Promise}
*/
export function generateToken (userLogin, tokenName) {
- const url = window.baseUrl + '/api/user_tokens/generate';
+ const url = '/api/user_tokens/generate';
const data = { login: userLogin, name: tokenName };
return postJSON(url, data);
}
@@ -49,7 +49,7 @@ export function generateToken (userLogin, tokenName) {
* @returns {Promise}
*/
export function revokeToken (userLogin, tokenName) {
- const url = window.baseUrl + '/api/user_tokens/revoke';
+ const url = '/api/user_tokens/revoke';
const data = { login: userLogin, name: tokenName };
return post(url, data);
}
diff --git a/server/sonar-web/src/main/js/api/users.js b/server/sonar-web/src/main/js/api/users.js
index 0be56fada04..80865674d80 100644
--- a/server/sonar-web/src/main/js/api/users.js
+++ b/server/sonar-web/src/main/js/api/users.js
@@ -20,12 +20,12 @@
import { getJSON, post } from '../helpers/request.js';
export function getCurrentUser () {
- const url = window.baseUrl + '/api/users/current';
+ const url = '/api/users/current';
return getJSON(url);
}
export function changePassword (login, password, previousPassword) {
- const url = window.baseUrl + '/api/users/change_password';
+ const url = '/api/users/change_password';
const data = { login, password };
if (previousPassword != null) {
@@ -36,6 +36,6 @@ export function changePassword (login, password, previousPassword) {
}
export function getIdentityProviders () {
- const url = window.baseUrl + '/api/users/identity_providers';
+ const url = '/api/users/identity_providers';
return getJSON(url);
}
diff --git a/server/sonar-web/src/main/js/api/web-api.js b/server/sonar-web/src/main/js/api/web-api.js
index a790121e2d8..d7c2c734df3 100644
--- a/server/sonar-web/src/main/js/api/web-api.js
+++ b/server/sonar-web/src/main/js/api/web-api.js
@@ -20,7 +20,7 @@
import { getJSON } from '../helpers/request';
export function fetchWebApi (showInternal = true) {
- const url = window.baseUrl + '/api/webservices/list';
+ const url = '/api/webservices/list';
const data = { 'include_internals': showInternal };
return getJSON(url, data).then(r => r.webServices.map(domain => {
@@ -31,7 +31,7 @@ export function fetchWebApi (showInternal = true) {
}
export function fetchResponseExample (domain, action) {
- const url = window.baseUrl + '/api/webservices/response_example';
+ const url = '/api/webservices/response_example';
const data = { controller: domain, action };
return getJSON(url, data);
diff --git a/server/sonar-web/src/main/js/helpers/request.js b/server/sonar-web/src/main/js/helpers/request.js
index a63b07a8420..07b8778a65a 100644
--- a/server/sonar-web/src/main/js/helpers/request.js
+++ b/server/sonar-web/src/main/js/helpers/request.js
@@ -69,7 +69,7 @@ class Request {
options.body = queryString(this.data);
}
}
- return window.fetch(url, options);
+ return window.fetch(window.baseUrl + url, options);
}
setMethod (method) {