-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* New page "Search with AQL" * Improve "Search with AQL" page
- Loading branch information
Showing
16 changed files
with
282 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { HttpClient, HttpErrorResponse } from '@angular/common/http' | ||
import { Injectable } from '@angular/core' | ||
import { BehaviorSubject, Observable, throwError } from 'rxjs' | ||
import { catchError, tap } from 'rxjs/operators' | ||
import { AppConfigService } from 'src/app/config/app-config.service' | ||
import { IAqlExecutionResponse } from 'src/app/shared/models/aql/execution/aql-execution-response.interface' | ||
|
||
@Injectable({ | ||
providedIn: 'root', | ||
}) | ||
export class QueryService { | ||
private baseUrl: string | ||
|
||
private projectData: IAqlExecutionResponse = null | ||
private projectDataSubject$ = new BehaviorSubject(this.projectData) | ||
private query: string | ||
|
||
constructor( | ||
private appConfigService: AppConfigService, | ||
private httpClient: HttpClient | ||
) { | ||
this.baseUrl = `${this.appConfigService.config.api.baseUrl}` | ||
} | ||
|
||
setQuery(query: string) { | ||
this.query = query | ||
} | ||
|
||
getData(): Observable<IAqlExecutionResponse> { | ||
return this.httpClient | ||
.post<IAqlExecutionResponse>(`${this.baseUrl}/query/execute`, { | ||
aql: this.query, | ||
}) | ||
.pipe( | ||
tap((res) => { | ||
this.projectData = res | ||
this.projectDataSubject$.next(res) | ||
}), | ||
catchError(this.handleError) | ||
) | ||
} | ||
|
||
handleError(error: HttpErrorResponse): Observable<never> { | ||
return throwError(() => error) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
src/app/modules/search-with-aql/components/search-aql/search.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<div fxLayout="column"> | ||
<section role="region" aria-labelledby="creator-label" fxLayoutGap="20px" class="num-margin-b-60"> | ||
<h2>{{ 'BUILD_QUERY' | translate }}</h2> | ||
<mat-card> | ||
<mat-card-content fxLayout="column" fxFlex="100%"> | ||
<p id="creator-label"> | ||
{{ 'SEARCH_WITH_AQL.BUILD_QUERY_CONTENT' | translate }} | ||
</p> | ||
|
||
<num-button | ||
type="primary" | ||
icon="plus" | ||
class="num-margin-b-40" | ||
(singleClick)="openBuilderDialog()" | ||
data-test="aql-editor__aql-creator__open-builder-button" | ||
>{{ 'BUTTON.OPEN_QUERY_BUILDER' | translate }}</num-button | ||
> | ||
|
||
<div style="height: 300px" class="num-margin-b-40"> | ||
<num-code-editor | ||
class="editor" | ||
style="height: 100%" | ||
[(value)]="aqlQuery" | ||
[formatObservable$]="formatObservable$" | ||
[validationObservable$]="validationObservable$" | ||
(editorInit)="onEditorInit($event)" | ||
></num-code-editor> | ||
</div> | ||
|
||
<div class="button-row num-margin-b-20" fxLayout="row" fxLayoutGap="20px"> | ||
<num-button | ||
type="primary" | ||
icon="align-left" | ||
(singleClick)="format()" | ||
data-test="aql-editor__aql-creator__format-button" | ||
>{{ 'BUTTON.FORMAT_QUERY' | translate }}</num-button | ||
> | ||
|
||
<num-button | ||
type="primary" | ||
icon="align-left" | ||
(singleClick)="validate(true)" | ||
data-test="aql-editor__aql-creator__validate-button" | ||
>{{ 'BUTTON.VALIDATE_QUERY' | translate }}</num-button | ||
> | ||
</div> | ||
|
||
<num-editor-determine-hits | ||
[isButtonDisabled]="!isValidForExecution || isExecutionLoading" | ||
[content]="determineHitsContent" | ||
(clicked)="getData()" | ||
></num-editor-determine-hits> | ||
</mat-card-content> | ||
</mat-card> | ||
</section> | ||
|
||
<section role="region" fxLayout="column" fxFlex="100%"> | ||
<h2 *ngIf="resultSet && !isDataSetLoading">{{ 'SEARCH_WITH_AQL.QUERY_DATA' | translate }}</h2> | ||
|
||
<ng-container *ngIf="!isDataSetLoading; else loading"> | ||
<num-result-table | ||
*ngIf="resultSet" | ||
[resultSet]="resultSet" | ||
[isDataSetLoading]="isDataSetLoading" | ||
[index]="1" | ||
[totalTables]="1" | ||
class="num-margin-b-20" | ||
data-test="manager-data-explorer__table" | ||
></num-result-table> | ||
</ng-container> | ||
|
||
<ng-template #loading> | ||
<mat-card class="mat-elevation-z1"> | ||
<div fxLayout="row" fxLayoutAlign="center center" fxLayoutGap="8px"> | ||
<mat-spinner color="accent" [diameter]="24"></mat-spinner> | ||
<span>{{ 'DATA_EXPLORER.LOADING_RESULT_SET' | translate }}</span> | ||
</div> | ||
</mat-card> | ||
</ng-template> | ||
</section> | ||
</div> |
12 changes: 12 additions & 0 deletions
12
src/app/modules/search-with-aql/components/search-aql/search.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
:host { | ||
width: 100%; | ||
} | ||
|
||
.editor { | ||
border-width: 1px; | ||
border-style: solid; | ||
border-color: grey; | ||
border-radius: 6px; | ||
padding: 20px 20px 20px 3px; | ||
position: relative; | ||
} |
53 changes: 53 additions & 0 deletions
53
src/app/modules/search-with-aql/components/search-aql/search.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { Component, OnDestroy } from '@angular/core' | ||
import { AqlEditorCeatorComponent } from '../../../aqls/components/aql-editor-creator/aql-editor-creator.component' | ||
import { DialogService } from '../../../../core/services/dialog/dialog.service' | ||
import { AqlEditorService } from '../../../../core/services/aql-editor/aql-editor.service' | ||
import { AqlService } from '../../../../core/services/aql/aql.service' | ||
import { ToastMessageService } from '../../../../core/services/toast-message/toast-message.service' | ||
import { QueryService } from '../../../../core/services/query/query.service' | ||
import { RESULT_SET_LOADING_ERROR } from '../../../search/components/manager-data-explorer/constants' | ||
import { IAqlExecutionResponse } from '../../../../shared/models/aql/execution/aql-execution-response.interface' | ||
import { Subscription } from 'rxjs' | ||
|
||
@Component({ | ||
templateUrl: './search.component.html', | ||
styleUrls: ['../../../aqls/components/aql-editor-creator/aql-editor-creator.component.scss'], | ||
}) | ||
export class SearchComponent extends AqlEditorCeatorComponent implements OnDestroy { | ||
constructor( | ||
dialogService: DialogService, | ||
aqlEditorService: AqlEditorService, | ||
aqlService: AqlService, | ||
toastMessageService: ToastMessageService, | ||
private queryService: QueryService | ||
) { | ||
super(dialogService, aqlEditorService, aqlService, toastMessageService) | ||
} | ||
private subscriptions = new Subscription() | ||
|
||
resultSet: IAqlExecutionResponse | ||
isDataSetLoading = false | ||
|
||
ngOnDestroy(): void { | ||
this.subscriptions.unsubscribe() | ||
} | ||
|
||
getData(): void { | ||
this.determineHits() | ||
this.isDataSetLoading = true | ||
this.queryService.setQuery(this.aqlQuery) | ||
this.subscriptions.add( | ||
this.queryService.getData().subscribe({ | ||
next: (result) => { | ||
this.resultSet = result | ||
this.isDataSetLoading = false | ||
}, | ||
error: () => { | ||
this.resultSet = null | ||
this.isDataSetLoading = false | ||
this.toastMessageService.openToast(RESULT_SET_LOADING_ERROR) | ||
}, | ||
}) | ||
) | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/app/modules/search-with-aql/search-with-aql-routing.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { NgModule } from '@angular/core' | ||
import { RouterModule, Routes } from '@angular/router' | ||
import { SearchComponent } from './components/search-aql/search.component' | ||
|
||
const routes: Routes = [ | ||
{ | ||
path: '', | ||
component: SearchComponent, | ||
}, | ||
] | ||
|
||
@NgModule({ | ||
imports: [RouterModule.forChild(routes)], | ||
exports: [RouterModule], | ||
}) | ||
export class SearchWithAqlRoutingModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { NgModule } from '@angular/core' | ||
import { CommonModule } from '@angular/common' | ||
import { SharedModule } from 'src/app/shared/shared.module' | ||
import { LayoutModule } from 'src/app/layout/layout.module' | ||
import { CohortBuilderModule } from '../cohort-builder/cohort-builder.module' | ||
import { SharedProjectsModule } from '../projects/shared-projects.module' | ||
import { CodeEditorModule } from '../code-editor/code-editor.module' | ||
import { SearchComponent } from './components/search-aql/search.component' | ||
import { SearchWithAqlRoutingModule } from './search-with-aql-routing.module' | ||
import { AqlsModule } from '../aqls/aqls.module' | ||
|
||
@NgModule({ | ||
declarations: [SearchComponent], | ||
imports: [ | ||
CohortBuilderModule, | ||
CommonModule, | ||
LayoutModule, | ||
SharedModule, | ||
SharedProjectsModule, | ||
CodeEditorModule, | ||
SearchWithAqlRoutingModule, | ||
AqlsModule, | ||
], | ||
}) | ||
export class SearchWithAqlModule {} |
6 changes: 4 additions & 2 deletions
6
src/app/shared/components/result-table/result-table.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export enum AvailableFeatures { | ||
SearchWithAql, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export interface IFeature { | ||
searchWithAql: boolean | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.