2020-01-27 18:40:18 +00:00
|
|
|
import { Component, Input, ViewChild } from '@angular/core';
|
|
|
|
|
import { Events, MessageBus } from 'protocol';
|
|
|
|
|
import { MatTabGroup } from '@angular/material/tabs';
|
2020-02-04 15:34:34 +00:00
|
|
|
import { DirectiveExplorerComponent } from './directive-explorer/directive-explorer.component';
|
2020-01-27 18:40:18 +00:00
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'ng-devtools-tabs',
|
|
|
|
|
templateUrl: './devtools-tabs.component.html',
|
|
|
|
|
styleUrls: ['./devtools-tabs.component.css'],
|
|
|
|
|
})
|
|
|
|
|
export class DevToolsTabsComponent {
|
2020-01-29 17:10:57 +00:00
|
|
|
@Input() angularVersion: string | undefined = undefined;
|
2020-01-27 18:40:18 +00:00
|
|
|
@ViewChild(MatTabGroup) tabGroup: MatTabGroup;
|
2020-02-06 22:41:19 +00:00
|
|
|
@ViewChild(DirectiveExplorerComponent) directiveExplorer: DirectiveExplorerComponent;
|
2020-01-27 18:40:18 +00:00
|
|
|
|
2020-03-18 00:48:29 +00:00
|
|
|
constructor(private _messageBus: MessageBus<Events>) {}
|
|
|
|
|
|
2020-01-27 18:40:18 +00:00
|
|
|
inspectorRunning = false;
|
|
|
|
|
|
2020-01-29 00:29:23 +00:00
|
|
|
toggleInspector(): void {
|
2020-02-06 22:41:19 +00:00
|
|
|
this.toggleInspectorState();
|
|
|
|
|
this.emitInspectorEvent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
emitInspectorEvent(): void {
|
2020-01-27 18:40:18 +00:00
|
|
|
if (this.inspectorRunning) {
|
2020-03-18 00:48:29 +00:00
|
|
|
this._messageBus.emit('inspectorStart');
|
2020-01-27 18:40:18 +00:00
|
|
|
this.tabGroup.selectedIndex = 0;
|
|
|
|
|
} else {
|
2020-03-18 00:48:29 +00:00
|
|
|
this._messageBus.emit('inspectorEnd');
|
2020-01-27 18:40:18 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-06 22:41:19 +00:00
|
|
|
toggleInspectorState(): void {
|
|
|
|
|
this.inspectorRunning = !this.inspectorRunning;
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-29 00:29:23 +00:00
|
|
|
refresh(): void {
|
2020-02-06 22:41:19 +00:00
|
|
|
this.directiveExplorer.refresh();
|
2020-01-27 18:40:18 +00:00
|
|
|
}
|
|
|
|
|
}
|