]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/shared/api/orchestrator.service.ts
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / shared / api / orchestrator.service.ts
1 import { HttpClient } from '@angular/common/http';
2 import { Injectable } from '@angular/core';
3
4 import _ from 'lodash';
5 import { Observable } from 'rxjs';
6
7 import { OrchestratorFeature } from '../models/orchestrator.enum';
8 import { OrchestratorStatus } from '../models/orchestrator.interface';
9
10 @Injectable({
11 providedIn: 'root'
12 })
13 export class OrchestratorService {
14 private url = 'ui-api/orchestrator';
15
16 disableMessages = {
17 noOrchestrator: $localize`The feature is disabled because Orchestrator is not available.`,
18 missingFeature: $localize`The Orchestrator backend doesn't support this feature.`
19 };
20
21 constructor(private http: HttpClient) {}
22
23 status(): Observable<OrchestratorStatus> {
24 return this.http.get<OrchestratorStatus>(`${this.url}/status`);
25 }
26
27 hasFeature(status: OrchestratorStatus, features: OrchestratorFeature[]): boolean {
28 return _.every(features, (feature) => _.get(status.features, `${feature}.available`));
29 }
30
31 getTableActionDisableDesc(
32 status: OrchestratorStatus,
33 features: OrchestratorFeature[]
34 ): boolean | string {
35 if (!status) {
36 return false;
37 }
38 if (!status.available) {
39 return this.disableMessages.noOrchestrator;
40 }
41 if (!this.hasFeature(status, features)) {
42 return this.disableMessages.missingFeature;
43 }
44 return false;
45 }
46
47 getName() {
48 return this.http.get(`${this.url}/get_name`);
49 }
50 }