Skip to content

Commit

Permalink
Merge branch 'move-bugreport-modal'
Browse files Browse the repository at this point in the history
  • Loading branch information
julianpoemp committed Nov 18, 2024
2 parents 55c957a + 82dd2d1 commit d98e57e
Show file tree
Hide file tree
Showing 12 changed files with 268 additions and 175 deletions.
37 changes: 18 additions & 19 deletions apps/octra/src/app/core/component/navbar/navbar.component.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';
import { TranslocoService } from '@jsverse/transloco';
import { NgbModalRef, NgbOffcanvas } from '@ng-bootstrap/ng-bootstrap';
import {
AnnotationLevelType,
OctraAnnotationAnyLevel,
OctraAnnotationSegment,
} from '@octra/annotation';
import { AccountRole, ProjectDto } from '@octra/api-types';
import { OctraAPIService } from '@octra/ngx-octra-api';
import { DateTime } from 'luxon';
import { environment } from '../../../../environments/environment';
import { AppInfo } from '../../../app.info';
import { editorComponents } from '../../../editors/components';
import { AboutModalComponent } from '../../modals/about-modal/about-modal.component';
import { ExportFilesModalComponent } from '../../modals/export-files-modal/export-files-modal.component';
import { OctraModalService } from '../../modals/octra-modal.service';
import { StatisticsModalComponent } from '../../modals/statistics-modal/statistics-modal.component';
import { ToolsModalComponent } from '../../modals/tools-modal/tools-modal.component';
import { YesNoModalComponent } from '../../modals/yes-no-modal/yes-no-modal.component';
import {
AudioService,
SettingsService,
Expand All @@ -18,27 +31,13 @@ import {
ConsoleGroupEntry,
ConsoleType,
} from '../../shared/service/bug-report.service';
import { NavbarService } from './navbar.service';
import {
AnnotationLevelType,
OctraAnnotationAnyLevel,
OctraAnnotationSegment,
} from '@octra/annotation';
import { ToolsModalComponent } from '../../modals/tools-modal/tools-modal.component';
import { StatisticsModalComponent } from '../../modals/statistics-modal/statistics-modal.component';
import { BugreportModalComponent } from '../../modals/bugreport-modal/bugreport-modal.component';
import { YesNoModalComponent } from '../../modals/yes-no-modal/yes-no-modal.component';
import { NgbModalRef, NgbOffcanvas } from '@ng-bootstrap/ng-bootstrap';
import { DefaultComponent } from '../default.component';
import { AnnotationStoreService } from '../../store/login-mode/annotation/annotation.store.service';
import { LoginMode } from '../../store';
import { AccountRole, ProjectDto } from '@octra/api-types';
import { AuthenticationStoreService } from '../../store/authentication';
import { OctraAPIService } from '@octra/ngx-octra-api';
import { AboutModalComponent } from '../../modals/about-modal/about-modal.component';
import { DateTime } from 'luxon';
import { ApplicationStoreService } from '../../store/application/application-store.service';
import { AsrStoreService } from '../../store/asr/asr-store-service.service';
import { AuthenticationStoreService } from '../../store/authentication';
import { AnnotationStoreService } from '../../store/login-mode/annotation/annotation.store.service';
import { DefaultComponent } from '../default.component';
import { NavbarService } from './navbar.service';

declare const BUILD: {
version: string;
Expand Down Expand Up @@ -202,7 +201,7 @@ export class NavigationComponent extends DefaultComponent implements OnInit {
this.appStorage.disableUndoRedo();
this.appStoreService.setShortcutsEnabled(false);
this.modalService
.openModal(BugreportModalComponent, BugreportModalComponent.options)
.openBugreportModal()
.then(() => {
this.appStorage.enableUndoRedo();
this.appStoreService.setShortcutsEnabled(true);
Expand Down
7 changes: 3 additions & 4 deletions apps/octra/src/app/core/modals/modals.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Injectable, NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { BugreportModalComponent } from './bugreport-modal/bugreport-modal.component';
import { ErrorModalComponent } from './error-modal/error-modal.component';
import { ExportFilesModalComponent } from './export-files-modal/export-files-modal.component';
import { HelpModalComponent } from './help-modal/help-modal.component';
Expand Down Expand Up @@ -29,8 +28,9 @@ import {
import { HttpClient } from '@angular/common/http';
import { AppSharedModule } from '../../app.shared.module';
import {
BugreportModalComponent,
OctraComponentsModule,
OctraFormGeneratorModule,
OctraFormGeneratorModule
} from '@octra/ngx-components';
import { FormsModule } from '@angular/forms';
import { NamingDragAndDropComponent } from '../tools/naming-drag-and-drop/naming-drag-and-drop.component';
Expand Down Expand Up @@ -65,7 +65,6 @@ export class TranslocoHttpLoader implements TranslocoLoader {

@NgModule({
declarations: [
BugreportModalComponent,
ErrorModalComponent,
ExportFilesModalComponent,
HelpModalComponent,
Expand Down Expand Up @@ -112,9 +111,9 @@ export class TranslocoHttpLoader implements TranslocoLoader {
NgbAccordionCollapse,
NgxJoditComponent,
OctraFormGeneratorModule,
BugreportModalComponent
],
exports: [
BugreportModalComponent,
ErrorModalComponent,
ExportFilesModalComponent,
HelpModalComponent,
Expand Down
79 changes: 72 additions & 7 deletions apps/octra/src/app/core/modals/octra-modal.service.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,41 @@
import { EventEmitter, Injectable } from '@angular/core';
import { EventEmitter, Injectable, OnDestroy } from '@angular/core';
import {
NgbModal,
NgbModalOptions,
NgbModalRef,
} from '@ng-bootstrap/ng-bootstrap';
import { NgbModalWrapper } from './ng-modal-wrapper';
import { Action, Store } from '@ngrx/store';
import { AccountLoginMethod } from '@octra/api-types';
import { Action } from '@ngrx/store';
import { ReAuthenticationModalComponent } from './re-authentication-modal/re-authentication-modal.component';
import { BugreportModalComponent } from '@octra/ngx-components';
import { SubscriptionManager } from '@octra/utilities';
import { AppStorageService } from '../shared/service/appstorage.service';
import { BugReportService } from '../shared/service/bug-report.service';
import { LoginMode, RootState } from '../store';
import { UserActions } from '../store/user/user.actions';
import { ErrorModalComponent } from './error-modal/error-modal.component';
import { FeedbackNoticeModalComponent } from './feedback-notice-modal/feedback-notice-modal.component';
import { NgbModalWrapper } from './ng-modal-wrapper';
import { ReAuthenticationModalComponent } from './re-authentication-modal/re-authentication-modal.component';

@Injectable()
export class OctraModalService {
export class OctraModalService implements OnDestroy {
onModalAction = new EventEmitter<{
name: string;
type: 'open' | 'close';
result?: any;
}>();
private subscrManager = new SubscriptionManager();

constructor(private modalService: NgbModal) {}
constructor(
private modalService: NgbModal,
private bugService: BugReportService,
private appStorage: AppStorageService,
private store: Store<RootState>
) {}

ngOnDestroy(): void {
this.subscrManager.destroy();
}

public openModal<T, R>(modal: T, config: NgbModalOptions, data?: any) {
const modalRef = this.modalService.open(modal, {
Expand Down Expand Up @@ -112,7 +128,7 @@ export class OctraModalService {
});
}

openFeedbackModal() {
openFeedbackNoticeModal() {
const ref = this.openModalRef<FeedbackNoticeModalComponent>(
FeedbackNoticeModalComponent,
FeedbackNoticeModalComponent.options
Expand All @@ -130,4 +146,53 @@ export class OctraModalService {
});
});
}

openBugreportModal() {
this.bugService.getPackage();
const ref = this.openModalRef<BugreportModalComponent>(
BugreportModalComponent,
BugreportModalComponent.options,
{
pkgText: this.bugService.pkgText,
showSenderFields:
this.appStorage.useMode !== LoginMode.ONLINE ||
!this.appStorage.loggedIn,
_profile: {
...((this.appStorage.useMode !== LoginMode.ONLINE
? this.appStorage.snapshot.user
: {
email: this.appStorage.snapshot.authentication?.me.email,
name: `${this.appStorage.snapshot.authentication?.me.first_name} ${this.appStorage.snapshot.authentication?.me.last_name}`,
}) ?? {}),
},
}
);
this.subscrManager.add(
ref.componentInstance.profileChange.subscribe({
next: ({ email, name }) => {
this.store.dispatch(UserActions.setUserProfile({ email, name }));
},
})
);

this.subscrManager.add(
ref.componentInstance.send.subscribe({
next: ({ name, email, message, sendProtocol, screenshots }) => {
console.log('Sending...');
ref.componentInstance.sendStatus = 'sending';
ref.componentInstance.waitForSendResponse(
this.bugService.sendReport(
name,
email,
message,
sendProtocol,
screenshots
)
);
},
})
);

return ref.result;
}
}
Original file line number Diff line number Diff line change
@@ -1,33 +1,26 @@
import { Component, OnInit } from '@angular/core';
import { AppInfo } from '../../../app.info';
import { hasProperty } from '@octra/utilities';
import { AppStorageService } from '../../shared/service/appstorage.service';
import { BugReportService } from '../../shared/service/bug-report.service';
import { OctraModalService } from '../octra-modal.service';
import { YesNoModalComponent } from '../yes-no-modal/yes-no-modal.component';
import { AppInfo } from '../../../app.info';
import { DefaultComponent } from '../../component/default.component';
import { ErrorModalComponent } from '../error-modal/error-modal.component';
import { LoginInvalidModalComponent } from '../login-invalid-modal/login-invalid-modal.component';
import { OctraModalService } from '../octra-modal.service';
import { SupportedFilesModalComponent } from '../supportedfiles-modal/supportedfiles-modal.component';
import { TranscriptionDeleteModalComponent } from '../transcription-delete-modal/transcription-delete-modal.component';
import { TranscriptionStopModalComponent } from '../transcription-stop-modal/transcription-stop-modal.component';
import { ErrorModalComponent } from '../error-modal/error-modal.component';
import { BugreportModalComponent } from '../bugreport-modal/bugreport-modal.component';
import { SupportedFilesModalComponent } from '../supportedfiles-modal/supportedfiles-modal.component';
import { DefaultComponent } from '../../component/default.component';
import { YesNoModalComponent } from '../yes-no-modal/yes-no-modal.component';

@Component({
selector: 'octra-modal',
templateUrl: './octra-modal.component.html',
styleUrls: ['./octra-modal.component.scss'],
})
export class OctraModalComponent extends DefaultComponent implements OnInit {
export class OctraModalComponent extends DefaultComponent {
modals: any = {
error: {
visible: false,
type: ErrorModalComponent,
},
bugreport: {
visible: false,
type: BugreportModalComponent,
},
supportedfiles: {
visible: false,
type: SupportedFilesModalComponent,
Expand All @@ -50,31 +43,16 @@ export class OctraModalComponent extends DefaultComponent implements OnInit {
},
};

public bgdescr = '';
public bgemail = '';
public sendproObj = true;
public bugsent = false;
public data: any;

public get AppInfo(): any {
return AppInfo;
}

constructor(
private modService: OctraModalService,
public bugService: BugReportService,
private appStorage: AppStorageService
) {
constructor(private modService: OctraModalService) {
super();
}

ngOnInit() {
this.bgemail =
this.appStorage.snapshot.authentication.me?.email !== undefined
? this.appStorage.snapshot.authentication.me?.email
: '';
}

openModal(name: string, data?: any): Promise<any> {
if (hasProperty(this.modals, name)) {
if (hasProperty(this.modals, name)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1592,7 +1592,7 @@ export class AnnotationEffects {
rootState.application.options.showFeedbackNotice &&
this.apiService.appProperties?.send_feedback
) {
this.modalsService.openFeedbackModal();
this.modalsService.openFeedbackNoticeModal();
}

// new annotation set
Expand Down Expand Up @@ -1625,7 +1625,7 @@ export class AnnotationEffects {
rootState.application.options.showFeedbackNotice &&
this.apiService.appProperties?.send_feedback
) {
this.modalsService.openFeedbackModal();
this.modalsService.openFeedbackNoticeModal();
}

return of(
Expand Down
5 changes: 3 additions & 2 deletions apps/octra/src/assets/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@
"description": "Bitte teile uns dein Feedback mit. Was können wir besser machen? Hast Du irgendwelche Schwierigkeiten mit der Verwendung von OCTRA?",
"error": "Dein Feedback konnte leider nicht gesendet werden. Bitte sende uns direkt eine E-Mail an {{email}}.",
"give feedback": "Feedback geben",
"send protocol": "Protokoll beifügen (empfohlen)",
"sent": "Dein Feedback wurde erfolgreich gesendet \uD83D\uDE42"
"add protocol": "Protokoll beifügen (empfohlen)",
"sent": "Dein Feedback wurde erfolgreich gesendet \uD83D\uDE42",
"sending": "Bitte warte bis dein Feedback gesendet wurde..."
},
"converters": {
"SRT": {
Expand Down
5 changes: 3 additions & 2 deletions apps/octra/src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@
"description": "Please tell us what you think about OCTRA. What can we do better? Did you find any bugs?",
"error": "Unfortunately your feedback could not be sent to us. Please send us an e-mail to {{email}}.",
"give feedback": "Give feedback",
"send protocol": "Add Protocol (recommended)",
"sent": "Your feedback was successfully reported \uD83D\uDE42"
"add protocol": "Add Protocol (recommended)",
"sent": "Your feedback was successfully reported \uD83D\uDE42",
"sending": "Please wait for octra sending your feedback..."
},
"converters": {
"SRT": {
Expand Down
1 change: 1 addition & 0 deletions libs/ngx-components/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ export * from './lib/components/form-generator/toolconfig-group/toolconfig-group
export * from './lib/obj';
export * from './lib/multi-threading.service';
export * from './lib/components/asr-options/asr-options.component';
export * from './lib/components/bugreport-modal/bugreport-modal.component';
Loading

0 comments on commit d98e57e

Please sign in to comment.