Skip to content

Commit 2cc9a9a

Browse files
committed
feat(octra): sending messages to parent window on changes in URL mode
1 parent 300fff7 commit 2cc9a9a

File tree

3 files changed

+84
-16
lines changed

3 files changed

+84
-16
lines changed

apps/octra/src/app/core/store/login-mode/annotation/annotation.effects.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,6 +1218,44 @@ export class AnnotationEffects {
12181218
{ dispatch: false },
12191219
);
12201220

1221+
somethingChanged$ = createEffect(
1222+
() =>
1223+
this.actions$.pipe(
1224+
ofType(
1225+
AnnotationActions.changeCurrentLevelItems.do,
1226+
AnnotationActions.changeCurrentItemById.do,
1227+
AnnotationActions.changeAnnotationLevel.do,
1228+
AnnotationActions.overwriteTranscript.do,
1229+
AnnotationActions.combinePhrases.success,
1230+
AnnotationActions.removeAnnotationLevel.do,
1231+
AnnotationActions.removeCurrentLevelItems.do,
1232+
AnnotationActions.addCurrentLevelItems.do,
1233+
AnnotationActions.addAnnotationLevel.do,
1234+
),
1235+
withLatestFrom(this.store),
1236+
tap(([action, state]) => {
1237+
const currentMode = getModeState(state);
1238+
const annotation = currentMode?.transcript.serialize(
1239+
currentMode.audio.fileName,
1240+
this.audio.audioManager.resource.info.sampleRate,
1241+
this.audio.audioManager.resource.info.duration,
1242+
);
1243+
const converter = new AnnotJSONConverter();
1244+
const result = converter.export(annotation);
1245+
window.parent.postMessage(
1246+
{
1247+
data: {
1248+
annotation: result.file,
1249+
},
1250+
status: 'changed',
1251+
},
1252+
'*',
1253+
);
1254+
}),
1255+
),
1256+
{ dispatch: false },
1257+
);
1258+
12211259
afterAnnotationSent$ = createEffect(() =>
12221260
this.actions$.pipe(
12231261
ofType(AnnotationActions.sendOnlineAnnotation.success),

apps/octra/src/app/editors/2D-editor/transcr-window/transcr-window.component.html

Lines changed: 44 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,17 @@
163163
</span>
164164
}
165165
@if (!easyMode) {
166-
<span>
167-
{{ 'g.save' | transloco }} &
168-
{{ 'segments.previous' | transloco }}
169-
</span>
166+
@if (appStoreService.useMode !== 'url' || routingService.staticQueryParams.bottomNav === true) {
167+
<span>
168+
{{ 'g.save' | transloco }} &
169+
{{ 'segments.previous' | transloco }}
170+
</span>
171+
} @else {
172+
<span>
173+
{{ 'g.apply' | transloco }} &
174+
{{ 'segments.previous' | transloco }}
175+
</span>
176+
}
170177
}
171178
</button>
172179
</div>
@@ -181,10 +188,17 @@
181188
</span>
182189
}
183190
@if (!easyMode) {
184-
<span>
185-
{{ 'g.save' | transloco }} &
186-
{{ 'g.close' | transloco }}
187-
</span>
191+
@if (appStoreService.useMode !== 'url' || routingService.staticQueryParams.bottomNav === true) {
192+
<span>
193+
{{ 'g.save' | transloco }} &
194+
{{ 'g.close' | transloco }}
195+
</span>
196+
} @else {
197+
<span>
198+
{{ 'g.apply' | transloco }} &
199+
{{ 'g.close' | transloco }}
200+
</span>
201+
}
188202
}
189203
</button>
190204
</div>
@@ -201,10 +215,17 @@
201215
</span>
202216
}
203217
@if (!easyMode) {
204-
<span>
205-
{{ 'g.save' | transloco }} &
206-
{{ 'segments.next' | transloco }}
207-
</span>
218+
@if (appStoreService.useMode !== 'url' || routingService.staticQueryParams.bottomNav === true) {
219+
<span>
220+
{{ 'g.save' | transloco }} &
221+
{{ 'segments.next' | transloco }}
222+
</span>
223+
} @else {
224+
<span>
225+
{{ 'g.apply' | transloco }} &
226+
{{ 'segments.next' | transloco }}
227+
</span>
228+
}
208229
}
209230
</button>
210231
</div>
@@ -223,10 +244,17 @@
223244
</span>
224245
}
225246
@if (!easyMode) {
226-
<span>
227-
{{ 'g.save' | transloco }} &
228-
{{ 'g.overview' | transloco }}
229-
</span>
247+
@if (appStoreService.useMode !== 'url' || routingService.staticQueryParams.bottomNav === true) {
248+
<span>
249+
{{ 'g.save' | transloco }} &
250+
{{ 'g.overview' | transloco }}
251+
</span>
252+
} @else {
253+
<span>
254+
{{ 'g.apply' | transloco }} &
255+
{{ 'g.overview' | transloco }}
256+
</span>
257+
}
230258
}
231259
</button>
232260
</div>

apps/octra/src/app/editors/2D-editor/transcr-window/transcr-window.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ import { ApplicationStoreService } from '../../../core/store/application/applica
6666
import { ASRProcessStatus } from '../../../core/store/asr';
6767
import { AsrStoreService } from '../../../core/store/asr/asr-store-service.service';
6868
import { AnnotationStoreService } from '../../../core/store/login-mode/annotation/annotation.store.service';
69+
import { RoutingService } from '../../../core/shared/service/routing.service';
6970

7071
@Component({
7172
selector: 'octra-transcr-window',
@@ -364,6 +365,7 @@ export class TranscrWindowComponent
364365
private alertService: AlertService,
365366
private navbarService: NavbarService,
366367
private activeModal: NgbActiveModal,
368+
protected routingService: RoutingService,
367369
) {
368370
super();
369371

0 commit comments

Comments
 (0)