Skip to content

Commit

Permalink
feat(octra): import options can be set in projectconfig.json for each…
Browse files Browse the repository at this point in the history
… converter
  • Loading branch information
julianpoemp committed Dec 12, 2024
1 parent a180700 commit f1addb2
Show file tree
Hide file tree
Showing 39 changed files with 595 additions and 449 deletions.
2 changes: 1 addition & 1 deletion apps/octra/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ import * as fromUser from './core/store/user/user.reducer';
!environment.production
? StoreDevtoolsModule.instrument({
trace: !environment.production,
maxAge: 50,
maxAge: 200,
logOnly: !environment.production,
connectInZone: true,
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { Component, Input, ViewChild } from '@angular/core';
import {
Component,
EventEmitter,
Input,
Output,
ViewChild,
} from '@angular/core';
import { Store } from '@ngrx/store';
import {
AnnotationLevelType,
Converter,
Expand All @@ -18,6 +25,8 @@ import { ImportOptionsModalComponent } from '../../modals/import-options-modal/i
import { OctraModalService } from '../../modals/octra-modal.service';
import { SupportedFilesModalComponent } from '../../modals/supportedfiles-modal/supportedfiles-modal.component';
import { FileProgress } from '../../obj/objects';
import { LoginMode, RootState } from '../../store';
import { LoginModeActions } from '../../store/login-mode';
import { DefaultComponent } from '../default.component';
import { DropZoneComponent } from '../drop-zone';

Expand All @@ -29,6 +38,8 @@ import { DropZoneComponent } from '../drop-zone';
export class OctraDropzoneComponent extends DefaultComponent {
@ViewChild('dropzone', { static: true }) dropzone!: DropZoneComponent;
@Input() height = '250px';
@Output() filesAdded = new EventEmitter<File[]>();

private _audioManager?: AudioManager;

get AppInfo(): AppInfo {
Expand Down Expand Up @@ -63,7 +74,10 @@ export class OctraDropzoneComponent extends DefaultComponent {
return this._status;
}

constructor(private modService: OctraModalService) {
constructor(
private modService: OctraModalService,
private store: Store<RootState>
) {
super();
}

Expand Down Expand Up @@ -359,6 +373,7 @@ export class OctraDropzoneComponent extends DefaultComponent {
this.dropzone.clicklocked = false;
});
}
this.filesAdded.emit(this.dropzone.files);
}

private resetFormatFileProgresses() {
Expand Down Expand Up @@ -389,6 +404,7 @@ export class OctraDropzoneComponent extends DefaultComponent {
this._status = 'invalid';
}
}
this.filesAdded.emit(this.dropzone.files);
}

private decodeArrayBuffer(
Expand Down Expand Up @@ -489,5 +505,21 @@ export class OctraDropzoneComponent extends DefaultComponent {
if (result.action === 'apply') {
fileProgress.options = result.result;
}

const importOptions = {};
importOptions[fileProgress.converter.name] = fileProgress.options;

this.store.dispatch(
LoginModeActions.setImportConverter.do({
mode: LoginMode.LOCAL,
importConverter: fileProgress.converter.name
})
);
this.store.dispatch(
LoginModeActions.changeImportOptions.do({
mode: LoginMode.LOCAL,
importOptions,
})
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ import {
import { AnnotationStoreService } from '../../store/login-mode/annotation/annotation.store.service';
import { ShortcutService } from '../../shared/service/shortcut.service';

declare let validateAnnotation: (transcript: string, guidelines: any) => any;
declare let tidyUpAnnotation: (transcript: string, guidelines: any) => any;

@Component({
selector: 'octra-overview-modal',
templateUrl: './overview-modal.component.html',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ export interface ProjectSettings {
interfaces: boolean;
help_url: string;
};
responsive: {
enabled: boolean;
fixedwidth: number;
};
agreement: {
enabled: boolean;
text: any;
Expand All @@ -33,6 +29,7 @@ export interface ProjectSettings {
sendValidatedTranscriptionOnly?: boolean;
showOverviewIfTranscriptNotValid?: boolean;
theme?: string;
importOptions?: Record<string, any>;
};
guidelines: any;
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
overview: 'g.overview' | transloco,
help: 'g.help' | transloco
}"
[responsive]="responsive"
[responsive]="true"
></octra-fastbar>

<div class="flex">
Expand Down Expand Up @@ -128,9 +128,7 @@
>
<i class="bi bi-x-circle"></i>
@if (!appStorage.easyMode) {
<span
[ngClass]="{ ' d-none d-md-inline': appc.octra.responsive.enabled }"
>
<span class="d-none d-md-inline">
{{ 'g.quit' | transloco }}
</span>
}
Expand All @@ -143,9 +141,7 @@
>
<i class="bi bi-download"></i>
@if (!appStorage.easyMode) {
<span
[ngClass]="{ 'd-none d-md-inline': appc.octra.responsive.enabled }"
>
<span class="d-none d-md-inline">
{{ 'g.export data' | transloco }}</span
>
}
Expand All @@ -157,8 +153,7 @@
type="button"
>
@if (!appStorage.easyMode) {
<span
[ngClass]="{ 'd-none d-md-inline': appc.octra.responsive.enabled }"
<span class="d-none d-md-inline"
>
{{ 'transcription.send' | transloco }}
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,6 @@ export class TranscriptionComponent
return this.settingsService.projectsettings!;
}

get responsive(): boolean {
return this.settingsService.responsive.enabled;
}

private _currentEditor!: ComponentRef<any>;

get currentEditor(): ComponentRef<any> {
Expand Down Expand Up @@ -467,19 +463,9 @@ export class TranscriptionComponent
}
},
});
/*
this.subscribe(
this.transcrService.alertTriggered,(alertConfig) => {
this.alertService.showAlert(
alertConfig.type,
alertConfig.data,
alertConfig.unique,
alertConfig.duration
);
})
);

*/

this.annotationStoreService.overwriteTidyUpAnnotation();

this.navbarServ.interfaces = this.projectsettings.interfaces;
this.shortcutService.registerGeneralShortcutGroup(
Expand Down
4 changes: 2 additions & 2 deletions apps/octra/src/app/core/pages/login/login.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
}
</div>
</div>
@if (compatibleBrowser === true) {
@if (compatibleBrowser !== false) {
<div class="row" id="loginrow">
<div class="col-md-6">
<div
Expand Down Expand Up @@ -127,7 +127,7 @@ <h4>{{ 'login.local mode' | transloco }}</h4>
</div>
</div>
</div>
} @else if(compatibleBrowser === false) {
} @else {
<octra-browser-test></octra-browser-test>
}
</div>
Expand Down
5 changes: 4 additions & 1 deletion apps/octra/src/app/core/shared/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,10 @@ export const isValidAnnotation = (io: TaskInputOutputDto, audiofile: any) => {
);

if (result?.annotjson) {
return result.annotjson;
return {
annotjson: result.annotjson,
converter: converter.name
};
} else if (
converter.name === 'AnnotJSON' &&
/_annot\.json$/g.exec(io.filename) !== null
Expand Down
1 change: 1 addition & 0 deletions apps/octra/src/app/core/shared/octra-database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ export interface IIDBModeOptions {
transcriptID?: string | null;
feedback?: any;
sessionfile?: any;
importConverter?: string;
currentEditor?: string | null;
currentLevel?: number | null;
logging?: boolean | null;
Expand Down
23 changes: 19 additions & 4 deletions apps/octra/src/app/core/shared/service/idb.service.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { Injectable } from '@angular/core';
import { ConsoleEntry, ConsoleGroupEntry } from './bug-report.service';
import { IAnnotJSON, OAnnotJSON } from '@octra/annotation';
import { from, map, Observable, throwError } from 'rxjs';
import { LoginMode } from '../../store';
import {
DefaultModeOptions,
IDBApplicationOptionName,
IIDBApplicationOptions,
IIDBModeOptions,
OctraDatabase,
} from '../octra-database';
import { LoginMode } from '../../store';
import { IAnnotJSON, OAnnotJSON } from '@octra/annotation';
import { from, map, Observable, throwError } from 'rxjs';
import { ConsoleEntry, ConsoleGroupEntry } from './bug-report.service';

@Injectable({
providedIn: 'root',
Expand Down Expand Up @@ -163,6 +163,14 @@ export class IDBService {
);
}

public loadImportOptions(mode: LoginMode): Observable<IIDBModeOptions> {
return this.database.loadDataOfMode<IIDBModeOptions>(
mode,
'importOptions',
undefined
);
}

/**
* save one log item.
*/
Expand All @@ -177,6 +185,13 @@ export class IDBService {
return this.database.saveModeData(mode, 'annotation', annotation, true);
}

/**
* save converter options.
*/
public saveImportOptions(mode: LoginMode, options: Record<string, any>) {
return this.database.saveModeData(mode, 'importOptions', options, true);
}

/**
* clears logging data
*/
Expand Down
19 changes: 0 additions & 19 deletions apps/octra/src/app/core/shared/service/settings.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,6 @@ import { Subscription } from 'rxjs';
export class SettingsService {
private subscrmanager: SubscriptionManager<Subscription>;

get responsive(): {
enabled: boolean;
fixedwidth: number;
} {
if (
this.projectsettings !== undefined &&
this.projectsettings.responsive !== undefined
) {
return this.projectsettings.responsive;
} else {
return this.appSettings?.octra.responsive !== undefined
? this.appSettings?.octra.responsive
: {
enabled: true,
fixedwidth: 1079,
};
}
}

get projectsettings(): ProjectSettings | undefined {
return getModeState(this.appStorage.snapshot)?.projectConfig;
}
Expand Down
54 changes: 20 additions & 34 deletions apps/octra/src/app/core/store/application/application.effects.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { HttpClient, HttpErrorResponse } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { getBrowserLang, TranslocoService } from '@jsverse/transloco';
import { Actions, createEffect, ofType } from '@ngrx/effects';
import { Action, Store } from '@ngrx/store';
import { uniqueHTTPRequest } from '@octra/ngx-utilities';
import { isNumber } from '@octra/utilities';
import { findElements, getAttr } from '@octra/web-media';
import { LocalStorageService, SessionStorageService } from 'ngx-webstorage';
import { ApplicationActions } from '../application/application.actions';
import { LoginModeActions } from '../login-mode';
import {
catchError,
exhaustMap,
Expand All @@ -16,32 +19,29 @@ import {
tap,
withLatestFrom,
} from 'rxjs';
import { HttpClient, HttpErrorResponse } from '@angular/common/http';
import { APIActions } from '../api';
import { getBrowserLang, TranslocoService } from '@jsverse/transloco';
import { uniqueHTTPRequest } from '@octra/ngx-utilities';
import { ConfigurationService } from '../../shared/service/configuration.service';
import { AppConfigSchema } from '../../schemata/appconfig.schema';
import X2JS from 'x2js';
import { environment } from '../../../../environments/environment';
import { AppInfo } from '../../../app.info';
import { ErrorModalComponent } from '../../modals/error-modal/error-modal.component';
import { OctraModalService } from '../../modals/octra-modal.service';
import { AppSettings, ASRSettings } from '../../obj';
import { AppConfigSchema } from '../../schemata/appconfig.schema';
import { isIgnoredAction, isIgnoredConsoleAction } from '../../shared';
import { SettingsService } from '../../shared/service';
import { AppStorageService } from '../../shared/service/appstorage.service';
import {
BugReportService,
ConsoleType,
} from '../../shared/service/bug-report.service';
import { AppSettings, ASRSettings } from '../../obj';
import { ConfigurationService } from '../../shared/service/configuration.service';
import { RoutingService } from '../../shared/service/routing.service';
import { APIActions } from '../api';
import { ApplicationActions } from '../application/application.actions';
import { AuthenticationActions } from '../authentication';
import { IDBActions } from '../idb/idb.actions';
import { AppStorageService } from '../../shared/service/appstorage.service';
import { SettingsService } from '../../shared/service';
import { getModeState, LoginMode, RootState } from '../index';
import { AuthenticationActions } from '../authentication';
import { RoutingService } from '../../shared/service/routing.service';
import { LoginModeActions } from '../login-mode';
import { AnnotationActions } from '../login-mode/annotation/annotation.actions';
import { OctraModalService } from '../../modals/octra-modal.service';
import { ErrorModalComponent } from '../../modals/error-modal/error-modal.component';
import { environment } from '../../../../environments/environment';
import { findElements, getAttr } from '@octra/web-media';
import X2JS from 'x2js';
import { isNumber } from '@octra/utilities';
import { isIgnoredAction, isIgnoredConsoleAction } from '../../shared';

@Injectable({
providedIn: 'root',
Expand Down Expand Up @@ -825,10 +825,6 @@ export class ApplicationEffects {
tap(([a, state]: [Action, RootState]) => {
this.bugService.addEntriesFromDB(this.appStorage.consoleEntries);

if (!this.settingsService.responsive.enabled) {
this.setFixedWidth();
}

// define languages
const languages = state.application.appConfiguration!.octra.languages;
const browserLang =
Expand Down Expand Up @@ -1173,16 +1169,6 @@ export class ApplicationEffects {
}
}

private setFixedWidth() {
// set fixed width
const head = document.head || document.getElementsByTagName('head')[0];
const style = document.createElement('style');
style.type = 'text/css';
style.innerText =
'.container {width:' + this.settingsService.responsive.fixedwidth + 'px}';
head.appendChild(style);
}

private getParameterByName(name: string, url?: string) {
if (!url) {
url = document.location.href;
Expand Down
Loading

0 comments on commit f1addb2

Please sign in to comment.