RulesLoggerPOC

This commit is contained in:
Dominique Eifländer 2024-10-15 11:59:50 +02:00 committed by Dan Percic
parent 8f541081ae
commit df64a73adc
8 changed files with 50 additions and 11 deletions

View File

@ -24,6 +24,7 @@ import { AuditService } from './services/audit.service';
import { DigitalSignatureService } from './services/digital-signature.service';
import { RulesService } from './services/rules.service';
import { SmtpConfigService } from './services/smtp-config.service';
import { RulesLoggerService } from '@services/rules-logger.service';
const entityRoutes: IqserRoutes = [
{
@ -95,6 +96,19 @@ const dossierTemplateIdRoutes: IqserRoutes = [
};
},
},
{
provide: ENVIRONMENT_INITIALIZER,
multi: true,
useFactory: () => {
const service = inject(RulesLoggerService);
return () => {
setTimeout(() => {
service.connect('/api/rules-logging/rulesocket');
console.log('Rules logger ready');
}, 2000);
};
},
},
],
},
{

View File

@ -85,3 +85,5 @@
<div (click)="revert()" [translate]="translations[type()]['revert-changes']" class="all-caps-label cancel"></div>
</div>
</div>
<redaction-rules-logger></redaction-rules-logger>

View File

@ -24,6 +24,7 @@ import { rulesScreenTranslations } from '../../../translations/rules-screen-tran
import ICodeEditor = monaco.editor.ICodeEditor;
import IModelDeltaDecoration = monaco.editor.IModelDeltaDecoration;
import IStandaloneEditorConstructionOptions = monaco.editor.IStandaloneEditorConstructionOptions;
import { RulesLoggerComponent } from '@components/rules-logger/rules-logger.component';
interface SyntaxError {
line: number;
@ -60,6 +61,7 @@ const RULE_VALIDATION_TIMEOUT = 2000;
NamePipe,
NgForOf,
MatTooltip,
RulesLoggerComponent,
],
})
export default class RulesScreenComponent implements OnInit, ComponentCanDeactivate {

View File

@ -8,3 +8,5 @@
></ngx-monaco-editor>
<ngx-monaco-diff-editor (init)="onDiffEditorInit($event)" *ngIf="showDiffEditor" [options]="editorOptions"></ngx-monaco-diff-editor>
<redaction-rules-logger></redaction-rules-logger>

View File

@ -14,6 +14,7 @@ import ICodeEditor = monaco.editor.ICodeEditor;
import IModelDeltaDecoration = monaco.editor.IModelDeltaDecoration;
import ILineChange = monaco.editor.ILineChange;
import IEditorMouseEvent = monaco.editor.IEditorMouseEvent;
import { RulesLoggerComponent } from '@components/rules-logger/rules-logger.component';
const MIN_WORD_LENGTH = 2;
const lineChangeToDecoration = ({ originalEndLineNumber, originalStartLineNumber }: ILineChange) =>
@ -32,7 +33,7 @@ const notZero = (lineChange: ILineChange) => lineChange.originalEndLineNumber !=
templateUrl: './editor.component.html',
styleUrls: ['./editor.component.scss'],
standalone: true,
imports: [MonacoEditorModule, FormsModule, NgIf],
imports: [MonacoEditorModule, FormsModule, NgIf, RulesLoggerComponent],
})
export class EditorComponent implements OnInit, OnChanges {
@Input() showDiffEditor = false;

View File

@ -0,0 +1,11 @@
import { WebSocketService } from '@services/web-socket.service';
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root',
})
export class RulesLoggerService extends WebSocketService {
get topicPrefix(): string {
return '';
}
}

View File

@ -19,6 +19,8 @@ export class WebSocketService extends RxStomp {
readonly #tenantService = inject(TenantsService);
readonly #destroyRef = inject(DestroyRef);
url: string;
constructor() {
super();
}
@ -46,16 +48,11 @@ export class WebSocketService extends RxStomp {
}
connect(url: string) {
const headers = { Authorization: 'Bearer ' + localStorage.getItem('token') };
console.log(headers);
this.configure({
debug: (msg: string) => this.#logger.debug(msg),
brokerURL: this.#config.API_URL + url,
connectHeaders: headers,
});
this.url = url;
this.configureConnection();
this.connectionState$.pipe(log('[WS] Connection state')).subscribe();
this.webSocketErrors$.pipe(log('[WS] Errors')).subscribe();
this.webSocketErrors$.pipe(log('[WS] Errors')).subscribe(frame => this.configureConnection());
this.stompErrors$
.pipe(
tap(frame => {
@ -69,4 +66,14 @@ export class WebSocketService extends RxStomp {
this.activate();
}
private configureConnection() {
const headers = { Authorization: 'Bearer ' + localStorage.getItem('token') };
console.log(headers);
this.configure({
debug: (msg: string) => this.#logger.debug(msg),
brokerURL: this.#config.API_URL + this.url,
connectHeaders: headers,
});
}
}

View File

@ -1,7 +1,7 @@
{
"ADMIN_CONTACT_NAME": null,
"ADMIN_CONTACT_URL": null,
"API_URL": "https://dan1.iqser.cloud",
"API_URL": "https://dom1.iqser.cloud",
"APP_NAME": "RedactManager",
"IS_DOCUMINE": false,
"RULE_EDITOR_DEV_ONLY": false,
@ -13,7 +13,7 @@
"MAX_RETRIES_ON_SERVER_ERROR": 3,
"OAUTH_CLIENT_ID": "redaction",
"OAUTH_IDP_HINT": null,
"OAUTH_URL": "https://dan1.iqser.cloud/auth",
"OAUTH_URL": "https://dom1.iqser.cloud/auth",
"RECENT_PERIOD_IN_HOURS": 24,
"SELECTION_MODE": "structural",
"MANUAL_BASE_URL": "https://docs.redactmanager.com/preview",