Skip to content

Commit

Permalink
fix: http proxy tabs should not be gone when alarms tab is visited
Browse files Browse the repository at this point in the history
  • Loading branch information
reey committed Dec 12, 2024
1 parent 2338b54 commit 339ed9b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
8 changes: 4 additions & 4 deletions frontend/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@
"builder": "@c8y/devkit:dev-server",
"configurations": {
"production": {
"browserTarget": "frontend:build:production"
"buildTarget": "frontend:build:production"
},
"development": {
"browserTarget": "frontend:build:development"
"buildTarget": "frontend:build:development"
}
},
"defaultConfiguration": "development"
Expand Down Expand Up @@ -133,10 +133,10 @@
"builder": "@c8y/devkit:deploy",
"configurations": {
"production": {
"browserTarget": "frontend:build:production"
"buildTarget": "frontend:build:production"
},
"development": {
"browserTarget": "frontend:build:development"
"buildTarget": "frontend:build:development"
}
},
"defaultConfiguration": "production"
Expand Down
28 changes: 18 additions & 10 deletions frontend/src/app/cloud-http-proxy/cloud-http-proxy-tab.factory.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { Injectable } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { IManagedObject } from '@c8y/client';
import { ExtensionFactory, Tab, ViewContext } from '@c8y/ngx-components';
import {
ContextRouteService,
ExtensionFactory,
Tab,
ViewContext,
} from '@c8y/ngx-components';
import { Observable } from 'rxjs';
import { filter, map } from 'rxjs/operators';
import { CloudHttpProxyAvailabilityService } from './cloud-http-proxy-available';
Expand All @@ -19,25 +24,27 @@ export class CloudHttpProxyTabFactory implements ExtensionFactory<Tab> {
static secureRemoteAccessConnectPrefix = 'https:';
private canActivate$: Observable<boolean>;

constructor(private proxyAvailability: CloudHttpProxyAvailabilityService) {
constructor(
private proxyAvailability: CloudHttpProxyAvailabilityService,
private context: ContextRouteService
) {
this.canActivate$ = this.proxyAvailability.canActivate();
}

get(
activatedRoute?: ActivatedRoute | undefined
): Tab | Tab[] | Observable<Tab | Tab[]> | Promise<Tab | Tab[]> {
const context: ViewContext | undefined =
activatedRoute?.snapshot.data?.['context'] ||
activatedRoute?.parent?.snapshot.data?.['context'];
const data = this.context.getContextData(activatedRoute as ActivatedRoute);
if (!data) {
return [];
}

const { context, contextData } = data;
if (context !== ViewContext.Device) {
return [];
}

const device: IManagedObject | undefined =
activatedRoute?.snapshot.data?.['contextData'] ||
activatedRoute?.parent?.snapshot.data?.['contextData'];

const device: IManagedObject = contextData as IManagedObject;
if (!device || !device['c8y_RemoteAccessList']) {
return [];
}
Expand Down Expand Up @@ -96,7 +103,8 @@ export class CloudHttpProxyTabFactory implements ExtensionFactory<Tab> {
return tabs;
}
return [this.getDefaultTab(name, prefix, device, secure, id)];
}).flat();
})
.flat();
}

private getCustomPathTabs(
Expand Down

0 comments on commit 339ed9b

Please sign in to comment.