Skip to content

Commit

Permalink
Add events
Browse files Browse the repository at this point in the history
  • Loading branch information
dxvladislavvolkov committed Aug 7, 2024
1 parent 6226efe commit 6c01233
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 4 deletions.
26 changes: 24 additions & 2 deletions src/app/left-menu/editor/editor.component.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
/* eslint-disable @typescript-eslint/no-magic-numbers */
import { Component, Input } from '@angular/core';
import { SafeHtml } from '@angular/platform-browser';
import { Router } from '@angular/router';

import { MetadataRepositoryService } from '../../meta-repository.service';
import { NamesService } from '../../names.service';
import { MetaItem } from '../../types/meta-item';
import { AnalyticsEventsService } from '../../analytics-events.service';

@Component({
selector: 'app-editor',
Expand All @@ -17,7 +19,10 @@ export class EditorComponent {
@Input() searchText = '';

constructor(private names: NamesService,
private metaRepository: MetadataRepositoryService) { }
private metaRepository: MetadataRepositoryService,
private analyticsEventsService: AnalyticsEventsService,
private router: Router
) { }

private isValueCanBePixels() {
return this.item.Key.endsWith('border-radius');
Expand All @@ -31,7 +36,18 @@ export class EditorComponent {
return this.names.getHighlightedForLeftMenuName(text, this.searchText);
}

valueTextChanged(e: { value: string }, key: string): void {
getSettingsName(): string {
const routeParts = this.router.url.split('/').filter(part => part !== '');

Check failure on line 40 in src/app/left-menu/editor/editor.component.ts

View workflow job for this annotation

GitHub Actions / test

Expected parentheses around arrow function argument

Check failure on line 40 in src/app/left-menu/editor/editor.component.ts

View workflow job for this annotation

GitHub Actions / test

Expected parentheses around arrow function argument
return routeParts[routeParts.length - 1];
}

valueTextChanged(e: { value: string, component: any }, key: string): void {
this.analyticsEventsService.trackEvent(
'TB: settings menu',
`TB change property of ${this.getSettingsName()}`,
key,
e.value
)

Check failure on line 50 in src/app/left-menu/editor/editor.component.ts

View workflow job for this annotation

GitHub Actions / test

Missing semicolon

Check failure on line 50 in src/app/left-menu/editor/editor.component.ts

View workflow job for this annotation

GitHub Actions / test

Missing semicolon
if(this.isValueCanBePixels() && this.isPositiveNumber(e.value)) {
e.value = e.value + 'px';
}
Expand All @@ -40,6 +56,12 @@ export class EditorComponent {
}

valueChanged(e: any, key: string): void {
this.analyticsEventsService.trackEvent(
'TB: settings menu',
`TB change property of ${this.getSettingsName()}`,
key,
e.value
)

Check failure on line 64 in src/app/left-menu/editor/editor.component.ts

View workflow job for this annotation

GitHub Actions / test

Missing semicolon

Check failure on line 64 in src/app/left-menu/editor/editor.component.ts

View workflow job for this annotation

GitHub Actions / test

Missing semicolon
this.metaRepository.updateSingleVariable(e, key);
}
}
2 changes: 1 addition & 1 deletion src/app/left-menu/main/left-menu.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
class="menu-item"
[routerLink]="['/advanced', theme, colorScheme, menuItem.route]"
routerLinkActive="active-link"
(click)="menuClosed = true;"
(click)="selectComponent(menuItem.route)"
>
{{ menuItem.name }}
</div>
Expand Down
20 changes: 19 additions & 1 deletion src/app/left-menu/main/left-menu.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { NamesService } from '../../names.service';
import { LeftMenuItem } from '../../types/left-menu-item';
import { MetaItem } from '../../types/meta-item';
import { LeftMenuAlias } from '../left-menu.aliases';
import { AnalyticsEventsService } from '../../analytics-events.service';
import { SafeHtml } from '@angular/platform-browser';

const BASE_THEMING_NAME = 'Basic Settings';
Expand Down Expand Up @@ -39,14 +40,22 @@ export class LeftMenuComponent implements OnDestroy, OnInit {
formControl: new UntypedFormControl('')
});

constructor(private route: ActivatedRoute, private metaRepository: MetadataRepositoryService, private names: NamesService) {
constructor(private route: ActivatedRoute,
private metaRepository: MetadataRepositoryService,
private names: NamesService,
private analyticsEventsService: AnalyticsEventsService
) {
this.route.params.subscribe((params) => {
this.widget = params['group'];
this.changeWidget(this.widget);
});
}

openMenu(): void {
this.analyticsEventsService.trackEvent(
'TB: settings menu',
`TB open settings menu`,

Check failure on line 57 in src/app/left-menu/main/left-menu.component.ts

View workflow job for this annotation

GitHub Actions / test

Strings must use singlequote

Check failure on line 57 in src/app/left-menu/main/left-menu.component.ts

View workflow job for this annotation

GitHub Actions / test

Unexpected trailing comma

Check failure on line 57 in src/app/left-menu/main/left-menu.component.ts

View workflow job for this annotation

GitHub Actions / test

Strings must use singlequote

Check failure on line 57 in src/app/left-menu/main/left-menu.component.ts

View workflow job for this annotation

GitHub Actions / test

Unexpected trailing comma
);
this.menuClosed = false;
}

Expand All @@ -64,6 +73,15 @@ export class LeftMenuComponent implements OnDestroy, OnInit {
e.stopPropagation();
}

selectComponent(componentName: string): void {
this.analyticsEventsService.trackEvent(
'TB: settings menu',
`TB select subgroup`,

Check failure on line 79 in src/app/left-menu/main/left-menu.component.ts

View workflow job for this annotation

GitHub Actions / test

Strings must use singlequote

Check failure on line 79 in src/app/left-menu/main/left-menu.component.ts

View workflow job for this annotation

GitHub Actions / test

Strings must use singlequote
componentName
);
this.menuClosed = true;
}

menuSearch(): void {
const keyword = this.names.getRealName(this.searchKeyword.toLowerCase());

Expand Down

0 comments on commit 6c01233

Please sign in to comment.