allocation.js 707 B

1234567891011121314151617181920212223242526
  1. import axios from 'axios';
  2. import { useLocation } from 'react-router';
  3. const env = process.env;
  4. class AllocationService {
  5. BASE_URL = process.env.BASE_URL || 'http://localhost:9090/allocation';
  6. async fetchAllocation(win, aggregate, options) {
  7. const url = process.env.BASE_URL ?? "";
  8. const baseUrl = `${url}${this.BASE_PATH}`;
  9. const { accumulate, filters, } = options;
  10. const params = {
  11. window: win,
  12. aggregate: aggregate,
  13. step: '1d',
  14. };
  15. if (typeof accumulate === 'boolean') {
  16. params.accumulate = accumulate;
  17. }
  18. const result = await axios.get(`${baseUrl}/compute`, { params });
  19. return result.data;
  20. }
  21. }
  22. export default new AllocationService();