PreferencesService.ts 698 B

12345678910111213141516171819202122232425
  1. import { UserPreferencesDTO } from 'app/types';
  2. import { backendSrv } from './backend_srv';
  3. export class PreferencesService {
  4. constructor(private resourceUri: string) {}
  5. /**
  6. * Overrides all preferences
  7. */
  8. update(preferences: UserPreferencesDTO): Promise<any> {
  9. return backendSrv.put(`/api/${this.resourceUri}/preferences`, preferences);
  10. }
  11. /**
  12. * Updates only provided preferences
  13. */
  14. patch(preferences: Partial<UserPreferencesDTO>): Promise<any> {
  15. return backendSrv.patch(`/api/${this.resourceUri}/preferences`, preferences);
  16. }
  17. load(): Promise<UserPreferencesDTO> {
  18. return backendSrv.get<UserPreferencesDTO>(`/api/${this.resourceUri}/preferences`);
  19. }
  20. }