Merge branch 'master' into VM/DM-358

This commit is contained in:
Valentin Mihai 2023-09-08 15:51:00 +03:00
commit 1dad9f4b40
9 changed files with 103 additions and 29 deletions

View File

@ -6,12 +6,21 @@
<ngx-monaco-editor (init)="onCodeEditorInit($event)" [(ngModel)]="codeEditorText" [options]="editorOptions"></ngx-monaco-editor>
<div *ngIf="changed && permissionsService.canEditRules() && !isLeaving" class="changes-box">
<iqser-icon-button
(action)="save()"
[label]="'rules-screen.save-changes' | translate"
[type]="iconButtonTypes.primary"
icon="iqser:check"
></iqser-icon-button>
<div (click)="goToErrors()" *ngIf="numberOfErrors()" class="errors">
<span>
<mat-icon [svgIcon]="'iqser:alert-circle'" class="icon"></mat-icon>
<span [translateParams]="{ errors: numberOfErrors() }" [translate]="'rules-screen.errors-found'"></span>
</span>
<mat-icon [svgIcon]="'iqser:expand'" class="icon face-up"></mat-icon>
</div>
<div class="actions">
<iqser-icon-button
(action)="save()"
[label]="'rules-screen.save-changes' | translate"
[type]="iconButtonTypes.primary"
icon="iqser:check"
></iqser-icon-button>
<div (click)="revert()" [translate]="'rules-screen.revert-changes'" class="all-caps-label cancel"></div>
<div (click)="revert()" [translate]="'rules-screen.revert-changes'" class="all-caps-label cancel"></div>
</div>
</div>

View File

@ -23,3 +23,45 @@ ngx-monaco-editor {
font-style: italic;
}
}
.changes-box {
flex-direction: column;
justify-content: center;
align-items: start;
gap: 10px;
> div {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
width: 100%;
}
.errors {
cursor: pointer;
.icon {
scale: 0.7;
}
:first-child {
display: flex;
align-items: center;
gap: 0.5em;
font-weight: 500;
/* TODO: Update this to --iqser-error when added */
color: var(--iqser-red-1);
}
.face-up {
transform: rotate(90deg);
}
margin-right: 0;
}
.actions {
gap: 24px;
}
}

View File

@ -1,4 +1,4 @@
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, OnInit, signal, ViewChild } from '@angular/core';
import { PermissionsService } from '@services/permissions.service';
import { IconButtonTypes, LoadingService, Toaster } from '@iqser/common-ui';
import { saveAs } from 'file-saver';
@ -25,6 +25,7 @@ interface SyntaxError {
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class RulesScreenComponent implements OnInit, ComponentCanDeactivate {
readonly numberOfErrors = signal<number>(0);
readonly iconButtonTypes = IconButtonTypes;
readonly editorOptions: IStandaloneEditorConstructionOptions = {
theme: 'vs',
@ -90,8 +91,13 @@ export class RulesScreenComponent implements OnInit, ComponentCanDeactivate {
this._decorations = this._codeEditor.deltaDecorations(this._decorations, newDecorations);
}
goToErrors() {
this._codeEditor.trigger('keyboard', 'editor.action.marker.next', null);
}
async save(): Promise<void> {
this._loadingService.start();
this.numberOfErrors.set(0);
await firstValueFrom(
this._rulesService.uploadRules({
rules: this._codeEditor.getModel().getValue(),
@ -180,6 +186,7 @@ export class RulesScreenComponent implements OnInit, ComponentCanDeactivate {
},
});
});
this.numberOfErrors.set(markers.length);
this._errorGlyphs = this._codeEditor.deltaDecorations(this._errorGlyphs, glyphs);
(window as any).monaco.editor.setModelMarkers(model, model.id, markers);
}

View File

@ -7,11 +7,20 @@ import { PendingChangesGuard } from '@guards/can-deactivate.guard';
import { TranslateModule } from '@ngx-translate/core';
import { IconButtonComponent } from '@iqser/common-ui';
import { FormsModule } from '@angular/forms';
import { MatIconModule } from '@angular/material/icon';
const routes = [{ path: '', component: RulesScreenComponent, canDeactivate: [PendingChangesGuard] }];
@NgModule({
declarations: [RulesScreenComponent],
imports: [RouterModule.forChild(routes), CommonModule, MonacoEditorModule, TranslateModule, IconButtonComponent, FormsModule],
imports: [
RouterModule.forChild(routes),
CommonModule,
MonacoEditorModule,
TranslateModule,
IconButtonComponent,
FormsModule,
MatIconModule,
],
})
export class RulesModule {}

View File

@ -1,9 +1,9 @@
{
"ADMIN_CONTACT_NAME": null,
"ADMIN_CONTACT_URL": null,
"API_URL": "https://frontend2.iqser.cloud",
"API_URL": "https://dan.iqser.cloud",
"APP_NAME": "RedactManager",
"IS_DOCUMINE": true,
"IS_DOCUMINE": false,
"RULE_EDITOR_DEV_ONLY": false,
"AUTO_READ_TIME": 3,
"BACKEND_APP_VERSION": "4.4.40",
@ -13,13 +13,13 @@
"MAX_RETRIES_ON_SERVER_ERROR": 3,
"OAUTH_CLIENT_ID": "redaction",
"OAUTH_IDP_HINT": null,
"OAUTH_URL": "https://frontend2.iqser.cloud/auth",
"OAUTH_URL": "https://dan.iqser.cloud/auth",
"RECENT_PERIOD_IN_HOURS": 24,
"SELECTION_MODE": "structural",
"MANUAL_BASE_URL": "https://docs.redactmanager.com/preview",
"ANNOTATIONS_THRESHOLD": 1000,
"THEME": "scm",
"BASE_TRANSLATIONS_DIRECTORY": "/assets/i18n/scm/",
"THEME": "redact",
"BASE_TRANSLATIONS_DIRECTORY": "/assets/i18n/redact/",
"AVAILABLE_NOTIFICATIONS_DAYS": 30,
"AVAILABLE_OLD_NOTIFICATIONS_MINUTES": 60,
"NOTIFICATIONS_THRESHOLD": 1000,

View File

@ -1237,7 +1237,8 @@
"reason": "",
"redacted-text": "",
"section": "",
"type": ""
"type": "",
"unchanged": ""
},
"title": ""
}
@ -2209,16 +2210,17 @@
"title": ""
},
"rules-screen": {
"title": "",
"warning-text": "",
"error": {
"generic": "Es ist ein Fehler aufgetreten ... Die Regeln konnten nicht aktualisiert werden!"
},
"errors-found": "",
"revert-changes": "Anmeldedaten speichern",
"save-changes": "Änderungen speichern",
"success": {
"generic": "Die Regeln wurden aktualisiert!"
}
},
"title": "",
"warning-text": ""
},
"search-screen": {
"cols": {

View File

@ -1237,7 +1237,8 @@
"reason": "Reason",
"redacted-text": "Redacted text",
"section": "Paragraph / Location",
"type": "Type"
"type": "Type",
"unchanged": ""
},
"title": "Edit {type, select, image{Image} hint{Hint} other{Redaction}}"
}
@ -2209,16 +2210,17 @@
"title": "Structured Component Management"
},
"rules-screen": {
"title": "Rule Editor",
"warning-text": "Warning: experimental feature!",
"error": {
"generic": "Something went wrong... Rules update failed!"
},
"errors-found": "{errors, plural, one{An error} other{{errors} errors}} found in rules",
"revert-changes": "Revert",
"save-changes": "Save Changes",
"success": {
"generic": "Rules updated!"
}
},
"title": "Rule Editor",
"warning-text": "Warning: experimental feature!"
},
"search-screen": {
"cols": {

View File

@ -1237,7 +1237,8 @@
"reason": "",
"redacted-text": "",
"section": "",
"type": ""
"type": "",
"unchanged": ""
},
"title": ""
}
@ -2209,16 +2210,17 @@
"title": ""
},
"rules-screen": {
"title": "",
"warning-text": "",
"error": {
"generic": "Es ist ein Fehler aufgetreten ... Die Regeln konnten nicht aktualisiert werden!"
},
"errors-found": "",
"revert-changes": "Anmeldedaten speichern",
"save-changes": "Änderungen speichern",
"success": {
"generic": "Die Regeln wurden aktualisiert!"
}
},
"title": "",
"warning-text": ""
},
"search-screen": {
"cols": {

View File

@ -2210,16 +2210,17 @@
"title": "Component View"
},
"rules-screen": {
"title": "Rule Editor",
"warning-text": "Warning: experimental feature!",
"error": {
"generic": "Something went wrong... Rules update failed!"
},
"errors-found": "",
"revert-changes": "Revert",
"save-changes": "Save Changes",
"success": {
"generic": "Rules updated!"
}
},
"title": "Rule Editor",
"warning-text": "Warning: experimental feature!"
},
"search-screen": {
"cols": {