Skip to content

Commit

Permalink
caching status if backend deployed
Browse files Browse the repository at this point in the history
  • Loading branch information
ck-c8y committed Mar 13, 2024
1 parent 09d312b commit 4d521b4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
8 changes: 5 additions & 3 deletions analytics-service/c8y_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@


class C8YAgent:
PATH_CEP_DIAGNOSTICS = "/service/cep/diagnostics/apamaCtrlStatus"
PATH_CEP_RESTART = "/service/cep/restart"
def __init__(self):
self._logger = logging.getLogger("C8YAgent")
self._logger.setLevel(logging.DEBUG)
Expand All @@ -43,7 +45,7 @@ def restart_cep(self, request_headers):
try:
self._logger.info(f"Restarting CEP ...")
self.c8yapp.get_tenant_instance(headers=request_headers).put(
resource="/service/cep/restart", json={}
resource=self.PATH_CEP_RESTART, json={}
)
except Exception as e:
self._logger.error(f"Exception:", exc_info=True)
Expand All @@ -57,7 +59,7 @@ def get_cep_operationobject_id(self, request_headers):
self._logger.info(f"Retrieving id of operation object for CEP ...")

response = self.c8yapp.get_tenant_instance(headers=request_headers).get(
resource=f"/service/cep/diagnostics/apamaCtrlStatus")
resource=self.PATH_CEP_DIAGNOSTICS)
try:
app_id = response["microservice_application_id"]
microservice_name = response["microservice_name"]
Expand Down Expand Up @@ -96,7 +98,7 @@ def get_cep_ctrl_status(self, request_headers):
self._logger.info(f"Retrieving CEP control status ...")

response = self.c8yapp.get_tenant_instance(headers=request_headers).get(
resource=f"/service/cep/diagnostics/apamaCtrlStatus")
resource=self.PATH_CEP_DIAGNOSTICS)
return response
except Exception as e:
self._logger.error(f"Exception:", exc_info=True)
Expand Down
15 changes: 6 additions & 9 deletions analytics-ui/src/shared/analytics-tab.factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@
import { Injectable } from '@angular/core';
import { TabFactory, Tab } from '@c8y/ngx-components';
import { Router } from '@angular/router';
import { ApplicationService } from '@c8y/client';
import { Observable, from, map, merge, mergeAll, of, toArray } from 'rxjs';
import { APPLICATION_ANALYTICS_BUILDER_SERVICE } from './analytics.model';
import { AnalyticsService } from './analytics.service';
@Injectable()
export class AnalyticsTabFactory implements TabFactory {
constructor(
private router: Router,
private applicationService: ApplicationService
private analyticsService: AnalyticsService
) {}

get(): Observable<Tab[]> {
Expand All @@ -50,20 +49,18 @@ export class AnalyticsTabFactory implements TabFactory {
orientation: 'horizontal'
} as Tab);
repositoryTab$ = from(
this.applicationService.isAvailable(
APPLICATION_ANALYTICS_BUILDER_SERVICE
)
this.analyticsService.isBackendDeployed()
).pipe(
map((value) => {
if (value.data) {
map((result) => {
if (result) {
return {
path: 'sag-ps-pkg-analytics-extension/repository',
priority: 920,
label: 'Repositories',
icon: 'test',
orientation: 'horizontal'
} as Tab;
} else return {} as Tab;
}
})
);
tabs.push({
Expand Down

0 comments on commit 4d521b4

Please sign in to comment.