Skip to content

Commit

Permalink
LSC 2022 (#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
silvanheller authored Aug 10, 2022
1 parent 3fcf716 commit 0337861
Show file tree
Hide file tree
Showing 44 changed files with 636 additions and 435 deletions.
26 changes: 0 additions & 26 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"src/assets",
"src/favicon.ico",
"src/config.json",
"src/evaluation.json",
{
"glob": "**/*",
"input": "node_modules/leaflet/dist/images/",
Expand Down Expand Up @@ -77,31 +76,6 @@
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "vitrivr-ng:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"karmaConfig": "./karma.conf.js",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"scripts": [],
"styles": [
"src/vitrivr-theme.css"
],
"assets": [
"src/assets",
"src/favicon.ico",
"src/config.json",
"src/evaluation.json"
]
}
},
"lint": {
"builder": "@angular-eslint/builder:lint",
"options": {
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 19 additions & 13 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,45 +9,48 @@

<span class="spacer-xlarge"></span>

<a *ngIf="!(_config | GetConfigVariablePipe:competitionHost)" mat-icon-button matTooltip="Gallery view"
<a *ngIf="!(config | GetConfigVariablePipe:competitionHost)" mat-icon-button matTooltip="Gallery view"
routerLink="/gallery"
routerLinkActive="active" skipLocationChange="true">
<mat-icon>grid_on</mat-icon>
</a>

<span class="spacer-medium"></span>

<a mat-icon-button matTooltip="Mini-gallery view" routerLink="/mini-gallery" routerLinkActive="active"
skipLocationChange="true" (click)="setActiveView(0)" [color]="_active_view === 0 ? 'accent' : ''">
<a mat-icon-button matTooltip="Mini gallery view" routerLink="/mini-gallery" routerLinkActive="active"
skipLocationChange="true" (click)="setActiveView(0)" [color]="activeView === 0 ? 'accent' : ''">
<mat-icon>view_comfy</mat-icon>
</a>

<span class="spacer-medium"></span>

<a mat-icon-button matTooltip="List view" routerLink="/list" routerLinkActive="active" skipLocationChange="true"
(click)="setActiveView(1)" [color]="_active_view === 1 ? 'accent' : ''">
(click)="setActiveView(1)" [color]="activeView === 1 ? 'accent' : ''">
<mat-icon>list</mat-icon>
</a>

<span class="spacer-medium"></span>

<a mat-icon-button matTooltip="Temporal Scoring view" routerLink="/temporal-list" routerLinkActive="active"
skipLocationChange="true" (click)="setActiveView(2)" [color]="_active_view === 2 ? 'accent' : ''">
<mat-icon>filter_list</mat-icon>
skipLocationChange="true" (click)="setActiveView(2)" [color]="activeView === 2 ? 'accent' : ''">
<mat-icon>access_time</mat-icon>
<mat-icon>trending_flat</mat-icon>
</a>

<span class="spacer-xlarge"></span>

<button (click)="showHistory()" mat-icon-button matTooltip="Show query history.">
<mat-icon>history</mat-icon>
</button>
<ng-container *ngIf="(config|GetConfigVariablePipe:queryHistory)>0">
<button (click)="showHistory()" mat-icon-button matTooltip="Show query history.">
<mat-icon>history</mat-icon>
</button>
</ng-container>

<button (click)="settingssidenav.toggle()" mat-icon-button [matBadge]="settingsbadge"
<button (click)="settingssidenav.toggle()" mat-icon-button [matBadge]="settingsBadge"
matTooltip="Toggle query refinement sidebar">
<mat-icon>storage</mat-icon>
</button>

<ng-container *ngIf="('' | competitionEnabledPipe |async)">
<ng-container *ngIf="config|GetConfigVariablePipe:textualInput">
<span class="spacer-flex"></span>

<div *ngIf="textualSubmissionOpen">
Expand All @@ -60,16 +63,19 @@
<mat-icon style="transform: translate(-12px, 12px);">{{ textualSubmissionOpen ? 'close' : 'near_me'}}</mat-icon>
</button>
</ng-container>

<span class="spacer-flex"></span>

<app-dres-timer></app-dres-timer>

<span class="spacer-medium"></span>

<app-api-status>
<mat-icon>av timer</mat-icon>
</app-api-status>
</mat-toolbar>

<div>
<mat-progress-bar *ngIf="_loadBool" [attr.color]="'accent'" mode="query"></mat-progress-bar>
<mat-progress-bar *ngIf="loading" [attr.color]="'accent'" mode="query"></mat-progress-bar>
</div>

<mat-sidenav-container fullscreen style="margin-top:75px;">
Expand Down
64 changes: 27 additions & 37 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import {AfterViewInit, ChangeDetectionStrategy, Component, OnInit} from '@angular/core';
import {AfterViewInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit} from '@angular/core';
import {QueryService} from './core/queries/query.service';
import {Config} from './shared/model/config/config.model';
import {Observable} from 'rxjs';
import {filter, map} from 'rxjs/operators';
import {MatBottomSheet} from '@angular/material/bottom-sheet';
import {HistoryComponent} from './results/history.component';
import {DistinctElementLookupService} from './core/lookup/distinct-element-lookup.service';
Expand All @@ -20,58 +18,51 @@ enum View { GALLERY, LIST, TEMPORAL}
changeDetection: ChangeDetectionStrategy.OnPush
})
export class AppComponent implements OnInit, AfterViewInit {
settingsbadge = '';

_config: Config;
_loadBool = false
textualSubmissionOpen = false;
/** Variable to safe currently selected view */
public _active_view: View;
competitionHost = ((c: Config) => c._config.competition.host);
/** Observable that return the loading state of the QueryService. */
private readonly _loading: Observable<boolean>;
settingsBadge = ''
config: Config
loading = false
textualSubmissionOpen = false
activeView: View = View.GALLERY
competitionHost = ((c: Config) => c._config.competition.host)
textualInput = ((c: Config) => c._config.competition.textualInput)
queryHistory = ((c: Config) => c._config.query.history);


/**
* Default constructor. Subscribe for PING messages at the CineastWebSocketFactoryService.
*/
constructor(_queryService: QueryService,
constructor(private _queryService: QueryService,
private _configService: AppConfig,
private _bottomSheet: MatBottomSheet,
private _distinctLookupService: DistinctElementLookupService,
private _notificationService: NotificationService
private _notificationService: NotificationService,
private _cdr: ChangeDetectorRef
) {
_queryService.observable.subscribe(msg => {
if (['STARTED', 'ENDED', 'ERROR'].indexOf(msg) > -1) {
this._loadBool = _queryService.running
}
})
this._loading = _queryService.observable.pipe(
filter(msg => ['STARTED', 'ENDED', 'ERROR'].indexOf(msg) > -1),
map(() => {
return _queryService.running;
})
);
_configService.configAsObservable.subscribe(c => this._config = c)
this._active_view = View.GALLERY;
}

ngOnInit(): void {
const config = this._configService.config;
/* Initialize stuff which might take 1s+ on the Cineast-Side*/
this.initLookup(config, this._distinctLookupService);
this._configService.configAsObservable.subscribe(_config => this.initLookup(_config, this._distinctLookupService));
this._configService.configAsObservable.subscribe(c => {
this.config = c
this.initLookup(c, this._distinctLookupService)
})
this._queryService.observable.subscribe(msg => {
if (['STARTED', 'ENDED', 'ERROR'].indexOf(msg) > -1) {
this.loading = this._queryService.running
}
})

}

public initLookup(config: Config, distinctLookupService: DistinctElementLookupService) {
if (config._config.query.options.boolean) {
config._config.query.boolean.forEach(v => {
const type = <number><unknown>InputType[v[1]];
if (type === InputType.DYNAMICOPTIONS.valueOf()) {
const table: string = v[3];
const column: string = v[4];
distinctLookupService.getDistinct(table, column).subscribe()
distinctLookupService.getDistinct(v.table, v.col).subscribe()
}
});
})
}
}

Expand All @@ -85,12 +76,11 @@ export class AppComponent implements OnInit, AfterViewInit {
}

ngAfterViewInit(): void {
this._notificationService.getDresStatusBadgeObservable().subscribe(el => this.settingsbadge = el)
this._notificationService.getDresStatusBadgeObservable().subscribe(el => this.settingsBadge = el)
}

/** Change the active view to the given one */
public setActiveView(view: View) {
this._active_view = view;
this.activeView = view;
}

}
4 changes: 3 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import {AppConfig} from './app.config';
import {SegmentdetailsModule} from './segmentdetails/segmentdetails.module';
import {PipesModule} from './shared/pipes/pipes.module';
import {CollectionModule} from "./collection/collection.module";
import {DresTimerComponent} from "./toolbar/dres-timer.component";
import {TextualSubmissionComponent} from "./toolbar/textual-submission/textual-submission.component";

/**
* Method used to laod the application config
Expand Down Expand Up @@ -46,7 +48,7 @@ export function initializeConfig(appConfig: AppConfig) {
MatBadgeModule,
PipesModule
],
declarations: [AppComponent, PingComponent],
declarations: [AppComponent, PingComponent, DresTimerComponent, TextualSubmissionComponent],
providers: [AppConfig, {provide: APP_INITIALIZER, useFactory: initializeConfig, deps: [AppConfig], multi: true}],
bootstrap: [AppComponent]
})
Expand Down
3 changes: 1 addition & 2 deletions src/app/core/api/web-socket-factory.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class WebSocketFactoryService extends BehaviorSubject<WebSocketSubject<Me
constructor(@Inject(AppConfig) private _configService: AppConfig, private _snackbar: MatSnackBar) {
super(null);
this._configService.configAsObservable.pipe(
filter(c => c.cineastEndpointWs != null),
filter(c => c.cineastEndpointWs != null),
).subscribe(c => this.connect(c))
}

Expand Down Expand Up @@ -74,7 +74,6 @@ export class WebSocketFactoryService extends BehaviorSubject<WebSocketSubject<Me
* endpoint config has changed.
*/
private connect(c: Config) {

/* Check if connection has changed. */
if (this._config && this._config.cineastEndpointWs === c.cineastEndpointWs) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/basics/resolver.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class ResolverService {
*/
public static iiifUrlToObject(object: MediaObjectDescriptor, rawPath?: boolean, height?: number, width?: number): string {
// @ts-ignore
const metadata = object._metadata
const metadata = object.metadata
if (!metadata) {
return null
}
Expand Down
16 changes: 16 additions & 0 deletions src/app/core/competition/collabordinator.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export class CollabordinatorService extends Subject<CollabordinatorMessage> {

/** The current instance of the loaded Config. */
private _config: Config;
private off: boolean = true;

/**
* Constructor for the CollabordinatorService.
Expand All @@ -44,6 +45,9 @@ export class CollabordinatorService extends Subject<CollabordinatorMessage> {
* @param id List of ids to add.
*/
public add(tag: Tag, ...id: string[]) {
if(this.off){
return
}
if (this._webSocket) {
this._webSocket.next({action: 'ADD', key: `vitrivr~${tag.name.toLowerCase()}`, attribute: id})
} else {
Expand All @@ -58,6 +62,9 @@ export class CollabordinatorService extends Subject<CollabordinatorMessage> {
* @param id List of ids to remove.
*/
public remove(tag: Tag, ...id: string[]) {
if(this.off){
return
}
if (this._webSocket) {
this._webSocket.next({action: 'REMOVE', key: `vitrivr~${tag.name.toLowerCase()}`, attribute: id})
} else {
Expand All @@ -69,6 +76,9 @@ export class CollabordinatorService extends Subject<CollabordinatorMessage> {
* Sends a signal to the Collabordinator endpoint that tells it to clear the list.
*/
public clear(tag: Tag) {
if(this.off){
return
}
if (this._webSocket) {
this._webSocket.next({action: 'CLEAR', key: `vitrivr~${tag.name.toLowerCase()}`, attribute: []})
} else {
Expand All @@ -86,6 +96,12 @@ export class CollabordinatorService extends Subject<CollabordinatorMessage> {
if (this._webSocket) {
this._webSocket.complete();
}
if(this._config._config.competition.collabordinator===null){
console.debug("collabordinator not enabled in config")
this.off = true
return
}
this.off = false
this._webSocket = webSocket<CollabordinatorMessage>(this._config._config.competition.collabordinator);
this._online.next(true)
this._webSocket.subscribe(
Expand Down
Loading

0 comments on commit 0337861

Please sign in to comment.