Loading src/app/kicker/kicker.component.ts +21 −5 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ import { OptionsFormComponent } from '../options-form/options-form.component'; export class KickerComponent implements OnInit { private readonly http = inject(HttpClient); private readonly _templatesCache = new Map<string, Template[]>(); aggregated: Aggregated; templates: Template[] = []; Loading @@ -30,6 +31,8 @@ export class KickerComponent implements OnInit { .subscribe(value => { this.aggregated = Aggregated.fromJson(value); this.templates = this.aggregated.templates; // Clear cache when templates are loaded this._templatesCache.clear(); console.log(`templates loaded from ${environment.kickermodel.url}:`, this.aggregated); }); } Loading @@ -40,14 +43,27 @@ export class KickerComponent implements OnInit { * @param addNone whether to add a 'none' template entry */ templatesOfKind(kind: string, addNone?: boolean): Template[] { const cacheKey = `${kind}-${addNone || false}`; if (!this._templatesCache.has(cacheKey)) { const templates = this.templates.filter(t => t.kind === kind && this.options.hasExtension(t.extension_id)); if (addNone) { templates.splice(0, 0, new Template('none', 'none...', 'No template selected.')); } return templates; this._templatesCache.set(cacheKey, templates); } return this._templatesCache.get(cacheKey) ?? []; } templatesNotOfKind(kinds: string[]): Template[] { return this.templates.filter(t => kinds.indexOf(t.kind) < 0 && this.options.hasExtension(t.extension_id)); const cacheKey = `not-${kinds.join(',')}`; if (!this._templatesCache.has(cacheKey)) { const templates = this.templates.filter(t => !kinds.includes(t.kind) && this.options.hasExtension(t.extension_id)); this._templatesCache.set(cacheKey, templates); } return this._templatesCache.get(cacheKey) ?? []; } } src/app/variable-editor/variable-editor.component.html +3 −4 Original line number Diff line number Diff line Loading @@ -5,12 +5,11 @@ <div class="col-md-9"> <div [ngClass]="{'input-group-sm input-group': isText || isSelect, 'form-check': isCheckbox}"> <div *ngIf="hasPresets" ngbDropdown class="d-inline-block"> <button ngbDropdownToggle class="btn btn-outline-secondary" type="button" aria-haspopup="true" aria-expanded="false" title="Select a preset value"> <button ngbDropdownToggle class="btn btn-outline-secondary" type="button" title="Select a preset value"> <span class="fas fa-lightbulb"></span> </button> <div ngbDropdownMenu class="dropdown-menu"> <button *ngFor="let preset of presets" ngbDropdownItem href="javascript:null" (click)="aggregated.applyPreset(preset)" <div ngbDropdownMenu> <button *ngFor="let preset of presets" ngbDropdownItem type="button" (click)="aggregated.applyPreset(preset)" [title]="preset.description">{{ preset.name }}</button> </div> </div> Loading src/app/variable-editor/variable-editor.component.ts +3 −2 Original line number Diff line number Diff line Loading @@ -2,12 +2,13 @@ import {Component, Input} from '@angular/core'; import { CommonModule } from '@angular/common'; import { FormsModule } from '@angular/forms'; import { MarkdownModule } from 'ngx-markdown'; import { NgbDropdownModule, NgbTooltipModule } from '@ng-bootstrap/ng-bootstrap'; import {Aggregated, Options, Preset, Variable, VarType} from '../kicker'; @Component({ selector: 'app-variable-editor', standalone: true, imports: [CommonModule, FormsModule, MarkdownModule], imports: [CommonModule, FormsModule, MarkdownModule, NgbDropdownModule, NgbTooltipModule], templateUrl: './variable-editor.component.html', styleUrls: ['./variable-editor.component.css'] }) Loading Loading
src/app/kicker/kicker.component.ts +21 −5 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ import { OptionsFormComponent } from '../options-form/options-form.component'; export class KickerComponent implements OnInit { private readonly http = inject(HttpClient); private readonly _templatesCache = new Map<string, Template[]>(); aggregated: Aggregated; templates: Template[] = []; Loading @@ -30,6 +31,8 @@ export class KickerComponent implements OnInit { .subscribe(value => { this.aggregated = Aggregated.fromJson(value); this.templates = this.aggregated.templates; // Clear cache when templates are loaded this._templatesCache.clear(); console.log(`templates loaded from ${environment.kickermodel.url}:`, this.aggregated); }); } Loading @@ -40,14 +43,27 @@ export class KickerComponent implements OnInit { * @param addNone whether to add a 'none' template entry */ templatesOfKind(kind: string, addNone?: boolean): Template[] { const cacheKey = `${kind}-${addNone || false}`; if (!this._templatesCache.has(cacheKey)) { const templates = this.templates.filter(t => t.kind === kind && this.options.hasExtension(t.extension_id)); if (addNone) { templates.splice(0, 0, new Template('none', 'none...', 'No template selected.')); } return templates; this._templatesCache.set(cacheKey, templates); } return this._templatesCache.get(cacheKey) ?? []; } templatesNotOfKind(kinds: string[]): Template[] { return this.templates.filter(t => kinds.indexOf(t.kind) < 0 && this.options.hasExtension(t.extension_id)); const cacheKey = `not-${kinds.join(',')}`; if (!this._templatesCache.has(cacheKey)) { const templates = this.templates.filter(t => !kinds.includes(t.kind) && this.options.hasExtension(t.extension_id)); this._templatesCache.set(cacheKey, templates); } return this._templatesCache.get(cacheKey) ?? []; } }
src/app/variable-editor/variable-editor.component.html +3 −4 Original line number Diff line number Diff line Loading @@ -5,12 +5,11 @@ <div class="col-md-9"> <div [ngClass]="{'input-group-sm input-group': isText || isSelect, 'form-check': isCheckbox}"> <div *ngIf="hasPresets" ngbDropdown class="d-inline-block"> <button ngbDropdownToggle class="btn btn-outline-secondary" type="button" aria-haspopup="true" aria-expanded="false" title="Select a preset value"> <button ngbDropdownToggle class="btn btn-outline-secondary" type="button" title="Select a preset value"> <span class="fas fa-lightbulb"></span> </button> <div ngbDropdownMenu class="dropdown-menu"> <button *ngFor="let preset of presets" ngbDropdownItem href="javascript:null" (click)="aggregated.applyPreset(preset)" <div ngbDropdownMenu> <button *ngFor="let preset of presets" ngbDropdownItem type="button" (click)="aggregated.applyPreset(preset)" [title]="preset.description">{{ preset.name }}</button> </div> </div> Loading
src/app/variable-editor/variable-editor.component.ts +3 −2 Original line number Diff line number Diff line Loading @@ -2,12 +2,13 @@ import {Component, Input} from '@angular/core'; import { CommonModule } from '@angular/common'; import { FormsModule } from '@angular/forms'; import { MarkdownModule } from 'ngx-markdown'; import { NgbDropdownModule, NgbTooltipModule } from '@ng-bootstrap/ng-bootstrap'; import {Aggregated, Options, Preset, Variable, VarType} from '../kicker'; @Component({ selector: 'app-variable-editor', standalone: true, imports: [CommonModule, FormsModule, MarkdownModule], imports: [CommonModule, FormsModule, MarkdownModule, NgbDropdownModule, NgbTooltipModule], templateUrl: './variable-editor.component.html', styleUrls: ['./variable-editor.component.css'] }) Loading