Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/plugin filter editor #48

Merged
merged 31 commits into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
01bf1bb
add plugin filter editor
infacc Jun 19, 2023
e55a407
show plugin editor when no tab link is provided
infacc Jul 3, 2023
8b1fe43
hide mat-card if filter is empty
infacc Jul 4, 2023
5616886
refactor: improve filter editor usability
infacc Jul 11, 2023
76d7744
refactor: avoid ViewChild decorator in filter editor
infacc Jul 12, 2023
4e2edb3
simplify isLeaf check
infacc Jul 12, 2023
38879c2
rectify warning message
infacc Jul 12, 2023
e71700b
refactor: simplify filter setup
infacc Jul 12, 2023
d81143a
Merge branch 'feature/plugin-filter-editor' of github.com:UST-QuAntiL…
infacc Jul 12, 2023
fae56c0
handle filter deletion by parent
infacc Jul 13, 2023
4ceb6d4
catch JSON paring errors
infacc Jul 13, 2023
183ced2
separate ternary operator to improve readability
infacc Jul 13, 2023
a1fe552
add inverted indication for and/or filters
infacc Jul 13, 2023
05d026b
remove index property
infacc Jul 17, 2023
f62ff31
store info whether filter is empty in property
infacc Jul 17, 2023
334189a
refactor: separate input and output objects
infacc Jul 18, 2023
c0ee392
check for empty filter
infacc Jul 18, 2023
51171f8
fix bug: keep input focus when typing
infacc Jul 18, 2023
fff9496
fix bug: use JSON editor input on tab change
infacc Jul 18, 2023
be07ea4
add active warning for filters with multiple attributes
infacc Jul 18, 2023
9622400
set filter string via template expression
infacc Jul 18, 2023
ec041cf
refactor: simplify type check for filter keys
infacc Jul 18, 2023
62344c6
Merge branch 'main' into feature/plugin-filter-editor
infacc Jul 18, 2023
b8b6cf6
rename HTML class to avoid confusion
infacc Jul 18, 2023
16dd6a5
use deep copies to emit filters
infacc Jul 19, 2023
8ea5eea
remove filter string from template form
infacc Jul 20, 2023
af7ad6b
add reload filter button
infacc Jul 20, 2023
37526f4
remove unused location interface
infacc Jul 20, 2023
6a33202
add JSON validator to filter string textarea input
infacc Jul 20, 2023
f5423d5
rename revert filter button
infacc Jul 21, 2023
eb4ebca
hide button from screen readers
infacc Jul 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
<div class="filter-editor mat-elevation-z0">
<h3 class="editor-description">Filter Editor</h3>
<mat-slide-toggle [(ngModel)]="showEditor">
Editor Mode {{ showEditor ? '(UI)' : '(JSON)' }}
</mat-slide-toggle>
<div class="editor-header">
<mat-slide-toggle [(ngModel)]="showEditor">
Editor Mode {{ showEditor ? '(UI)' : '(JSON)' }}
</mat-slide-toggle>
<button mat-raised-button type="button" (click)="ngOnInit()">
<mat-icon>refresh</mat-icon>
infacc marked this conversation as resolved.
Show resolved Hide resolved
Reload Filter
infacc marked this conversation as resolved.
Show resolved Hide resolved
</button>
</div>
<qhana-plugin-filter-node *ngIf="filterObject && showEditor" [filterIn]="filterObject" (filterOut)="updateFilter($event)" (delete)="deleteFilter()"></qhana-plugin-filter-node>
<ng-container *ngIf="!showEditor">
<mat-form-field class="form-field">
Expand All @@ -13,6 +19,7 @@ <h3 class="editor-description">Filter Editor</h3>
<button mat-raised-button class="copy-button" type="button" (click)="copyFilterString()">
<mat-icon>content_copy</mat-icon>
</button>
<mat-error *ngIf="filterControl.hasError('invalidJSON')">Invalid JSON</mat-error>
</mat-form-field>
<details>
<summary>Filter String Info</summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,9 @@
padding-bottom: 0px

.editor-description
margin: 0
margin: 0

.editor-header
display: flex
justify-content: space-between
align-items: center
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { FormControl, Validators } from '@angular/forms';
import { AbstractControl, FormControl, Validators, ValidatorFn } from '@angular/forms';
import { ApiLink } from 'src/app/services/api-data-types';
import { PluginRegistryBaseService } from 'src/app/services/registry.service';
import { TemplateTabApiObject } from 'src/app/services/templates.service';

export function isJSONValidator(): ValidatorFn {
return (control: AbstractControl): { [key: string]: any } | null => {
try {
JSON.parse(control.value);
return null;
} catch (e) {
return { invalidJSON: true };
}
};
}

@Component({
selector: 'qhana-plugin-filter-editor',
templateUrl: './plugin-filter-editor.component.html',
Expand All @@ -14,7 +25,8 @@ export class PluginFilterEditorComponent implements OnInit {
@Output() filterEmitter: EventEmitter<string> = new EventEmitter<string>();

filterString: string = "{}";
filterControl = new FormControl(this.filterString, [Validators.required, Validators.minLength(2)]); // TODO: Add validator for JSON
// TODO: Add JSON validator for filter strings
filterControl = new FormControl(this.filterString, [isJSONValidator()]);

filterObject: any = {};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ export function isInSetValidator(validValues: any[]): Validators {
};
}

export interface Location {
value: string;
description: string;
}


@Component({
selector: 'qhana-template-details',
templateUrl: './template-details.component.html',
Expand Down