選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

measures.ts 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2021 SonarSource SA
  4. * mailto:info AT sonarsource DOT com
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with this program; if not, write to the Free Software Foundation,
  18. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. import { getJSON } from 'sonar-ui-common/helpers/request';
  21. import throwGlobalError from '../app/utils/throwGlobalError';
  22. import { BranchParameters } from '../types/branch-like';
  23. import {
  24. MeasuresAndMetaWithMetrics,
  25. MeasuresAndMetaWithPeriod,
  26. MeasuresForProjects
  27. } from '../types/measures';
  28. const COMPONENT_URL = '/api/measures/component';
  29. export function getMeasures(
  30. data: { component: string; metricKeys: string } & BranchParameters
  31. ): Promise<T.Measure[]> {
  32. return getJSON(COMPONENT_URL, data).then(r => r.component.measures, throwGlobalError);
  33. }
  34. export function getMeasuresWithMetrics(
  35. component: string,
  36. metrics: string[],
  37. branchParameters?: BranchParameters
  38. ): Promise<MeasuresAndMetaWithMetrics> {
  39. return getJSON(COMPONENT_URL, {
  40. additionalFields: 'metrics',
  41. component,
  42. metricKeys: metrics.join(','),
  43. ...branchParameters
  44. }).catch(throwGlobalError);
  45. }
  46. export function getMeasuresWithPeriod(
  47. component: string,
  48. metrics: string[],
  49. branchParameters?: BranchParameters
  50. ): Promise<MeasuresAndMetaWithPeriod> {
  51. return getJSON(COMPONENT_URL, {
  52. additionalFields: 'period',
  53. component,
  54. metricKeys: metrics.join(','),
  55. ...branchParameters
  56. }).catch(throwGlobalError);
  57. }
  58. export function getMeasuresWithPeriodAndMetrics(
  59. component: string,
  60. metrics: string[],
  61. branchParameters?: BranchParameters
  62. ): Promise<MeasuresAndMetaWithPeriod & MeasuresAndMetaWithMetrics> {
  63. return getJSON(COMPONENT_URL, {
  64. additionalFields: 'period,metrics',
  65. component,
  66. metricKeys: metrics.join(','),
  67. ...branchParameters
  68. }).catch(throwGlobalError);
  69. }
  70. export function getMeasuresForProjects(
  71. projectKeys: string[],
  72. metricKeys: string[]
  73. ): Promise<MeasuresForProjects[]> {
  74. return getJSON('/api/measures/search', {
  75. projectKeys: projectKeys.join(),
  76. metricKeys: metricKeys.join()
  77. }).then(r => r.measures);
  78. }