Skip to content

Commit

Permalink
SONAR-7122 drop web context from js code
Browse files Browse the repository at this point in the history
  • Loading branch information
stas-vilchik committed Feb 19, 2016
1 parent 0c2b2d0 commit 2ee64e5
Show file tree
Hide file tree
Showing 151 changed files with 312 additions and 335 deletions.
14 changes: 7 additions & 7 deletions server/sonar-web/src/main/js/api/ce.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,40 +21,40 @@ import $ from 'jquery';
import { getJSON, post } from '../helpers/request.js';

export function getQueue (data) {
const url = baseUrl + '/api/ce/queue';
const url = '/api/ce/queue';
return $.get(url, data);
}

export function getActivity (data) {
const url = baseUrl + '/api/ce/activity';
const url = '/api/ce/activity';
return $.get(url, data);
}

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)
);
}

export function cancelAllTasks () {
const url = window.baseUrl + '/api/ce/cancel_all';
const url = '/api/ce/cancel_all';
return post(url);
}

export function getTasksForComponent (componentId) {
const url = baseUrl + '/api/ce/component';
const url = '/api/ce/component';
const data = { componentId };
return new Promise((resolve) => $.get(url, data).done(resolve));
}

export function getTypes () {
const url = window.baseUrl + '/api/ce/task_types';
const url = '/api/ce/task_types';
return getJSON(url).then(r => r.taskTypes);
}
24 changes: 12 additions & 12 deletions server/sonar-web/src/main/js/api/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,32 @@ import { getJSON, postJSON, post } from '../helpers/request.js';


export function getComponents (data) {
const url = baseUrl + '/api/components/search';
const url = '/api/components/search';
return getJSON(url, data);
}

export function getProvisioned (data) {
const url = baseUrl + '/api/projects/provisioned';
const url = '/api/projects/provisioned';
return getJSON(url, data);
}

export function getGhosts (data) {
const url = baseUrl + '/api/projects/ghosts';
const url = '/api/projects/ghosts';
return getJSON(url, data);
}

export function deleteComponents (data) {
const url = baseUrl + '/api/projects/bulk_delete';
const url = '/api/projects/bulk_delete';
return post(url, data);
}

export function createProject (data) {
const url = baseUrl + '/api/projects/create';
const url = '/api/projects/create';
return postJSON(url, data);
}

export function getChildren (componentKey, metrics = []) {
const url = baseUrl + '/api/measures/component_tree';
const url = '/api/measures/component_tree';
const data = {
baseComponentKey: componentKey,
metricKeys: metrics.join(','),
Expand All @@ -56,7 +56,7 @@ export function getChildren (componentKey, metrics = []) {
}

export function getFiles (componentKey, metrics = [], additional = {}) {
const url = baseUrl + '/api/measures/component_tree';
const url = '/api/measures/component_tree';
const data = Object.assign({}, additional, {
baseComponentKey: componentKey,
metricKeys: metrics.join(','),
Expand All @@ -66,25 +66,25 @@ export function getFiles (componentKey, metrics = [], additional = {}) {
}

export function getComponent (componentKey, metrics = []) {
const url = 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 = 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 = 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 = 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();
Expand All @@ -93,7 +93,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',
Expand Down
2 changes: 1 addition & 1 deletion server/sonar-web/src/main/js/api/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { getJSON } from '../helpers/request.js';
* @returns {Promise}
*/
export function getEvents (componentKey, categories) {
const url = baseUrl + '/api/events';
const url = '/api/events';
const data = { resource: componentKey };
if (categories) {
data.categories = categories;
Expand Down
2 changes: 1 addition & 1 deletion server/sonar-web/src/main/js/api/issue-filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
6 changes: 3 additions & 3 deletions server/sonar-web/src/main/js/api/issues.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { getJSON } from '../helpers/request.js';


export function getFacets (query, facets) {
const url = 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 };
Expand Down Expand Up @@ -62,14 +62,14 @@ export function getAssignees (query) {


export function getIssuesCount (query) {
const url = baseUrl + '/api/issues/search';
const url = '/api/issues/search';
const data = _.extend({}, query, { ps: 1, facetMode: 'debt' });
return getJSON(url, data).then(r => {
return { issues: r.total, debt: r.debtTotal };
});
}

export function getIssueFilters () {
const url = window.baseUrl + '/api/issue_filters/search';
const url = '/api/issue_filters/search';
return getJSON(url).then(r => r.issueFilters);
}
2 changes: 1 addition & 1 deletion server/sonar-web/src/main/js/api/languages.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
import { getJSON } from '../helpers/request.js';

export function getLanguages () {
const url = baseUrl + '/api/languages/list';
const url = '/api/languages/list';
return getJSON(url).then(r => r.languages);
}
2 changes: 1 addition & 1 deletion server/sonar-web/src/main/js/api/measure-filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
2 changes: 1 addition & 1 deletion server/sonar-web/src/main/js/api/measures.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { getJSON } from '../helpers/request.js';


export function getMeasures (componentKey, metrics) {
const url = baseUrl + '/api/measures/component';
const url = '/api/measures/component';
const data = { componentKey, metricKeys: metrics.join(',') };
return getJSON(url, data).then(r => r.component.measures);
}
2 changes: 1 addition & 1 deletion server/sonar-web/src/main/js/api/metrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import { getJSON } from '../helpers/request.js';

export function getMetrics () {
const url = baseUrl + '/api/metrics/search';
const url = '/api/metrics/search';
const data = { ps: 9999 };
return getJSON(url, data).then(r => r.metrics);
}
6 changes: 3 additions & 3 deletions server/sonar-web/src/main/js/api/nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@
import { getJSON } from '../helpers/request.js';

export function getGlobalNavigation () {
const url = baseUrl + '/api/navigation/global';
const url = '/api/navigation/global';
return getJSON(url);
}

export function getComponentNavigation (componentKey) {
const url = baseUrl + '/api/navigation/component';
const url = '/api/navigation/component';
const data = { componentKey };
return getJSON(url, data);
}

export function getSettingsNavigation () {
const url = baseUrl + '/api/navigation/settings';
const url = '/api/navigation/settings';
return getJSON(url);
}
28 changes: 12 additions & 16 deletions server/sonar-web/src/main/js/api/permissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,13 @@ function request (options) {
return $.ajax(options);
}

function buildUrl (path) {
return window.baseUrl + path;
}

function typeError (method, message) {
throw new TypeError(`permissions#${method}: ${message}`);
}


export function getUsers (data) {
const url = buildUrl('/api/permissions/users');
const url = '/api/permissions/users';
return request({ type: 'GET', url: url, data: data });
}

Expand All @@ -47,7 +43,7 @@ export function grantToUser (permission, user, project) {
return typeError('grantToUser', 'please provide user login');
}

const url = buildUrl('/api/permissions/add_user');
const url = '/api/permissions/add_user';
const data = { permission: permission, login: user };
if (project) {
data.projectId = project;
Expand All @@ -64,7 +60,7 @@ export function revokeFromUser (permission, user, project) {
return typeError('revokeFromUser', 'please provide user login');
}

const url = buildUrl('/api/permissions/remove_user');
const url = '/api/permissions/remove_user';
const data = { permission: permission, login: user };
if (project) {
data.projectId = project;
Expand All @@ -74,7 +70,7 @@ export function revokeFromUser (permission, user, project) {


export function getGroups (data) {
const url = buildUrl('/api/permissions/groups');
const url = '/api/permissions/groups';
return request({ type: 'GET', url: url, data: data });
}

Expand All @@ -87,7 +83,7 @@ export function grantToGroup (permission, group, project) {
return typeError('grantToGroup', 'please provide group name');
}

const url = buildUrl('/api/permissions/add_group');
const url = '/api/permissions/add_group';
const data = { permission: permission, groupName: group };
if (project) {
data.projectId = project;
Expand All @@ -104,7 +100,7 @@ export function revokeFromGroup (permission, group, project) {
return typeError('revokeFromGroup', 'please provide group name');
}

const url = buildUrl('/api/permissions/remove_group');
const url = '/api/permissions/remove_group';
const data = { permission: permission, groupName: group };
if (project) {
data.projectId = project;
Expand All @@ -114,7 +110,7 @@ export function revokeFromGroup (permission, group, project) {


export function getPermissionTemplates (query) {
const url = buildUrl('/api/permissions/search_templates');
const url = '/api/permissions/search_templates';
const data = { };
if (query) {
data.q = query;
Expand All @@ -124,18 +120,18 @@ export function getPermissionTemplates (query) {


export function createPermissionTemplate (options) {
const url = buildUrl('/api/permissions/create_template');
const url = '/api/permissions/create_template';
return request(_.extend({ type: 'POST', url: url }, options));
}

export function updatePermissionTemplate (options) {
const url = buildUrl('/api/permissions/update_template');
const url = '/api/permissions/update_template';
return request(_.extend({ type: 'POST', url: url }, options));
}


export function deletePermissionTemplate (options) {
const url = buildUrl('/api/permissions/delete_template');
const url = '/api/permissions/delete_template';
return request(_.extend({ type: 'POST', url: url }, options));
}

Expand All @@ -145,13 +141,13 @@ export function setDefaultPermissionTemplate (template, qualifier) {
return typeError('setDefaultPermissionTemplate', 'please provide permission template ID');
}

const url = buildUrl('/api/permissions/set_default_template');
const url = '/api/permissions/set_default_template';
const data = { templateId: template, qualifier };
return request({ type: 'POST', url, data });
}


export function applyTemplateToProject(options) {
const url = buildUrl('/api/permissions/apply_template');
const url = '/api/permissions/apply_template';
return request(_.extend({ type: 'POST', url: url }, options));
}
2 changes: 1 addition & 1 deletion server/sonar-web/src/main/js/api/quality-profiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import { checkStatus, parseJSON } from '../helpers/request';

export function createQualityProfile (data) {
const url = window.baseUrl + '/api/qualityprofiles/create';
const url = '/api/qualityprofiles/create';
const options = {
method: 'post',
credentials: 'same-origin',
Expand Down
8 changes: 4 additions & 4 deletions server/sonar-web/src/main/js/api/system.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion server/sonar-web/src/main/js/api/time-machine.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import { getJSON } from '../helpers/request.js';

export function getTimeMachineData (componentKey, metrics) {
const url = baseUrl + '/api/timemachine/index';
const url = '/api/timemachine/index';
const data = { resource: componentKey, metrics };
return getJSON(url, data);
}

0 comments on commit 2ee64e5

Please sign in to comment.