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-04-02 23:23:03 +00:00
|
|
|
import { ApplicationEnvironment } from '../application-environment';
|
2020-05-07 03:21:32 +00:00
|
|
|
import { MatSlideToggleChange } from '@angular/material/slide-toggle';
|
2020-05-08 22:12:17 +00:00
|
|
|
import { TabUpdate } from './tab-update';
|
2020-06-02 16:11:15 +00:00
|
|
|
import { ThemeService } from '../theme-service';
|
2020-01-27 18:40:18 +00:00
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'ng-devtools-tabs',
|
|
|
|
|
templateUrl: './devtools-tabs.component.html',
|
2020-03-29 03:28:36 +00:00
|
|
|
styleUrls: ['./devtools-tabs.component.scss'],
|
2020-01-27 18:40:18 +00:00
|
|
|
})
|
|
|
|
|
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-05-08 22:12:17 +00:00
|
|
|
constructor(
|
|
|
|
|
public tabUpdate: TabUpdate,
|
2020-06-02 16:11:15 +00:00
|
|
|
public themeService: ThemeService,
|
2020-05-08 22:12:17 +00:00
|
|
|
private _messageBus: MessageBus<Events>,
|
|
|
|
|
private _applicationEnvironment: ApplicationEnvironment
|
|
|
|
|
) {}
|
2020-04-02 23:23:03 +00:00
|
|
|
|
|
|
|
|
get latestSHA(): string {
|
|
|
|
|
return this._applicationEnvironment.environment.process.env.LATEST_SHA;
|
|
|
|
|
}
|
2020-03-18 00:48:29 +00:00
|
|
|
|
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-04-14 22:27:59 +00:00
|
|
|
this._messageBus.emit('removeHighlightOverlay');
|
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
|
|
|
}
|
2020-05-07 03:21:32 +00:00
|
|
|
|
|
|
|
|
toggleTimingAPI(change: MatSlideToggleChange): void {
|
|
|
|
|
change.checked ? this._messageBus.emit('enableTimingAPI') : this._messageBus.emit('disableTimingAPI');
|
|
|
|
|
}
|
2020-01-27 18:40:18 +00:00
|
|
|
}
|