Skip to content

Commit

Permalink
feat(octra): new query parameter "bottomNav" for URL mode
Browse files Browse the repository at this point in the history
  • Loading branch information
julianpoemp committed Feb 13, 2025
1 parent f831f87 commit 5c8c18c
Show file tree
Hide file tree
Showing 15 changed files with 275 additions and 173 deletions.
2 changes: 1 addition & 1 deletion apps/octra/src/app/app.info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class AppInfo {
static readonly maxAudioFileSize = 3000;

public static readonly queryParamsHandling: NavigationExtras = {
queryParamsHandling: '',
queryParamsHandling: "merge",
preserveFragment: false,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ export class TranscrEditorComponent
@ViewChild('jodit', { static: false }) joditComponent?: NgxJoditComponent;
public focused = false;

public joditOptions: JoditConfig = {};
public joditOptions: JoditConfig = {
};
private guidelines?: OctraGuidelines;

private joditDefaultOptions: JoditConfig = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@ <h4 class="modal-title">
</h4>
</div>
<div class="modal-body">
@if(appStore.useMode !== "url"){
<div [innerHTML]="'modal.transcription.stop.text' | transloco"></div>
} @else if(appStore.useMode === "url") {
<div [innerHTML]="'modal.transcription.stop.url text' | transloco"></div>
}
</div>
<div class="row p-3 g-1">
@if (appStore.useMode !== "url") {
<div class="col-12 col-lg-auto order-3 order-lg-1">
<button
type="button"
Expand All @@ -17,13 +22,28 @@ <h4 class="modal-title">
{{ 'g.quit and release' | transloco }}
</button>
</div>
<div class="col-12 col-lg-auto order-2 order-lg-2">
}
<div
class="col-12 order-2 order-lg-2"
[ngClass]="{
'col-lg-auto': appStore.useMode !== 'url',
'col-lg': appStore.useMode === 'url'
}"
>
<button
type="button"
class="btn btn-raised btn-secondary w-100"
class="btn btn-raised w-100"
[ngClass]="{
'btn-secondary': appStore.useMode !== 'url',
'btn-danger': appStore.useMode === 'url'
}"
(click)="close('QUIT')"
>
@if (appStore.useMode !== "url") {
{{ 'g.quit continue later' | transloco }}
} @else {
{{ 'g.quit discard' | transloco }}
}
</button>
</div>
<div class="col-12 col-lg order-1 order-lg-3">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { Component, ViewChild } from '@angular/core';
import { TranslocoPipe } from '@jsverse/transloco';
import { NgbActiveModal, NgbModalOptions } from '@ng-bootstrap/ng-bootstrap';
import { DefaultComponent } from '../../component/default.component';
import { ApplicationStoreService } from '../../store/application/application-store.service';
import { NgClass } from '@angular/common';

export enum TranscriptionStopModalAnswer {
CONTINUE = 'CONTINUE',
Expand All @@ -13,7 +15,7 @@ export enum TranscriptionStopModalAnswer {
selector: 'octra-transcription-stop-modal',
templateUrl: './transcription-stop-modal.component.html',
styleUrls: ['./transcription-stop-modal.component.scss'],
imports: [TranslocoPipe],
imports: [TranslocoPipe, NgClass],
})
export class TranscriptionStopModalComponent extends DefaultComponent {
@ViewChild('modal', { static: true }) modal: any;
Expand All @@ -24,7 +26,10 @@ export class TranscriptionStopModalComponent extends DefaultComponent {
backdrop: 'static',
};

constructor(private activeModal: NgbActiveModal) {
constructor(
private activeModal: NgbActiveModal,
protected appStore: ApplicationStoreService
) {
super();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@
<i class="bi bi-star-fill"></i>
<i class="bi bi-star-fill"></i>
</button>
} @else { @if (useMode !== 'url') {
} @else { @if (useMode !== 'url' ||
(routingService.staticQueryParams.bottomNav)) {
<button
(click)="abortTranscription()"
type="button"
Expand All @@ -133,7 +134,8 @@
</span>
}
</button>
} @if (useMode === 'local') {
} @if (useMode === 'local' || (useMode === "url" &&
routingService.staticQueryParams.bottomNav) ) {
<button
(click)="navbarServ.doclick('export')"
class="col-md-6 btn btn-primary"
Expand All @@ -159,7 +161,8 @@
}
<i class="bi bi-send-fill"></i>
</button>
} @if (useMode === 'url' && !routingService.staticQueryParams.readonly) {
} @if (useMode === 'url') {
@if(!routingService.staticQueryParams.readonly && routingService.staticQueryParams.embedded) {
<button
(click)="onSaveTranscriptionButtonClicked()"
class="btn btn-primary"
Expand All @@ -168,7 +171,7 @@
<i class="bi bi-floppy-fill"></i>
<span> {{ 'g.save' | transloco }} </span>
</button>
} }
} } }
</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ export class TranscriptionComponent
}

abortTranscription = () => {
if (this.appStorage.useMode === LoginMode.ONLINE) {
if ([LoginMode.ONLINE, LoginMode.URL].includes(this.appStorage.useMode)) {
this.modService
.openModal(
TranscriptionStopModalComponent,
Expand Down
4 changes: 4 additions & 0 deletions apps/octra/src/app/core/shared/service/routing.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export class RoutingService {
private sessionStorage: SessionStorageService
) {}

clear() {
this._staticQueryParams = {};
}

public removeStaticParam(name: string) {
if (Object.keys(this._staticQueryParams).includes(name)) {
this.staticQueryParams[name] = undefined;
Expand Down
18 changes: 12 additions & 6 deletions apps/octra/src/app/core/store/application/application.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ 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 { DateTime } from 'luxon';
import { LocalStorageService, SessionStorageService } from 'ngx-webstorage';
import {
catchError,
Expand Down Expand Up @@ -42,7 +43,6 @@ import { IDBActions } from '../idb/idb.actions';
import { getModeState, LoginMode, RootState } from '../index';
import { LoginModeActions } from '../login-mode';
import { AnnotationActions } from '../login-mode/annotation/annotation.actions';
import { DateTime } from 'luxon';

@Injectable({
providedIn: 'root',
Expand All @@ -53,9 +53,9 @@ export class ApplicationEffects {
ofType(ApplicationActions.initApplication.do),
exhaustMap(() => {
AppInfo.BUILD = (window as any).BUILD ?? AppInfo.BUILD;
AppInfo.BUILD.timestamp = DateTime.fromISO(AppInfo.BUILD.timestamp).toLocaleString(
DateTime.DATETIME_SHORT_WITH_SECONDS
);
AppInfo.BUILD.timestamp = DateTime.fromISO(
AppInfo.BUILD.timestamp
).toLocaleString(DateTime.DATETIME_SHORT_WITH_SECONDS);
this.appStorage.saveCurrentPageAsLastPage();

const queryParams = {
Expand All @@ -66,6 +66,7 @@ export class ApplicationEffects {
transcript: this.getParameterByName('transcript'),
readonly: this.getParameterByName('readonly'),
embedded: this.getParameterByName('embedded'),
bottomNav: this.getParameterByName('bottomNav'),
};

this.routerService.addStaticParams(queryParams);
Expand Down Expand Up @@ -679,7 +680,7 @@ export class ApplicationEffects {
clearSession: false,
})
);
} else {
} else if (!this.routerService.staticQueryParams.audio_url) {
this.store.dispatch(
ApplicationActions.redirectToLastPage.do({
mode: state.application.mode!,
Expand Down Expand Up @@ -866,6 +867,7 @@ export class ApplicationEffects {
}
}

console.log('CHECK AUDIO_URL PARAM');
if (this.routerService.staticQueryParams?.audio_url) {
this.store.dispatch(
AuthenticationActions.loginURL.do({
Expand Down Expand Up @@ -913,11 +915,15 @@ export class ApplicationEffects {
subject.next(LoginModeActions.clearSessionStorage.success());
subject.complete();

this.routerService.clear();
this.routerService
.navigate(
'after logout success',
['/login'],
AppInfo.queryParamsHandling
{
queryParams: {},
},
'replace'
)
.catch((error) => {
console.error(error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export const reducer = createReducer(
IDBActions.loadOptions.success,
(state: ApplicationState, { applicationOptions }) => ({
...state,
mode: applicationOptions.useMode ?? undefined,
mode: applicationOptions.useMode ?? state.mode,
language: applicationOptions.language ?? 'en',
options: {
...state.options,
Expand Down
4 changes: 2 additions & 2 deletions apps/octra/src/app/core/store/idb/idb-effects.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export class IDBEffects {
projectID: action.demoOptions?.project?.id ?? '1234',
taskID: action.demoOptions?.transcriptID ?? '38295',
mode: this.routingService.staticQueryParams.audio_url
? LoginMode.URL
? undefined
: state.application.mode!,
})
);
Expand Down Expand Up @@ -201,7 +201,7 @@ export class IDBEffects {
return forkJoin([
this.idbService.loadAnnotation(LoginMode.ONLINE),
this.idbService.loadAnnotation(LoginMode.LOCAL),
this.idbService.loadAnnotation(LoginMode.DEMO),
this.idbService.loadAnnotation(LoginMode.DEMO)
]).pipe(
withLatestFrom(this.store),
map(
Expand Down
Loading

0 comments on commit 5c8c18c

Please sign in to comment.