What product/components do you use and which version/fix level are you on?
Cumulocity IoT (backend 1014.0.172 frontend 1011.0.4)
Is your question related to the free trial, or to a production (customer) instance?
Customer license
Hi it’s Luca.
We would like to get rid of the tab “Data Explorer” for specific device type.
I tried to adapt the solution suggested here. I also tried to use the aforementioned solution in combination with this (even though it’s about tab creation).
So far, I’m able to filter out the Data Explorer tab but once it gets removed it’ll never be shown again (even though I land on a device which type should allow to use data explorer)
This is what I have
The Injectable
@Injectable()
export class ExampleTabFactory implements TabFactory {
constructor(public router: Router, public tabService: TabsService, public inventoryService: InventoryService) { }
private findByLabel(tabs, label) {
return tabs.find(tab => tab.label === label);
}
async get() {
const tabs: Tab[] = [];
console.log(this.router.url);
if(this.router.url.match(/device/g)) {
const matcher = this.router.url.match(/(?!device\/)\d+(?=\/dashboard)/);
let id: string;
if(matcher != null) { id = matcher[0]; }
const type = await this.inventoryService.detail(id).then(device => device.data.type);
console.log(type);
this.tabService.items$ = this.tabService.items$.pipe(
map(tabs => type != "dac_rfDetector" ? tabs.filter(tab => tab !== this.findByLabel(tabs, 'Data explorer')) : tabs),
map(tabs => tabs.filter(tab => tab !== this.findByLabel(tabs, 'Location')))
);
}
return tabs;
}
}
In the app.module.ts I added in the providers
{
provide: HOOK_TABS,
useClass: ExampleTabFactory,
multi: true
}
I know I’m messing up a lot of things… I need sort things down
Regards
Luca