Merge branch 'master' into RED-7550

This commit is contained in:
Nicoleta Panaghiu 2023-09-13 16:33:14 +03:00
commit 284f513526
15 changed files with 841 additions and 660 deletions

View File

@ -3,6 +3,7 @@ variables:
GIT_SUBMODULE_FORCE_HTTPS: 'true'
PROJECT: red-ui
DOCKERFILELOCATION: 'docker/$PROJECT/Dockerfile'
LOCALAZY_RUN: ''
workflow:
rules:
@ -11,4 +12,29 @@ workflow:
include:
- project: 'gitlab/gitlab'
ref: 'main'
file: 'ci-templates/docker_build_nexus.yml'
file: 'ci-templates/docker_build_nexus_v2.yml'
localazy update:
image: node:20.5
cache:
- key:
files:
- yarn.lock
paths:
- .yarn-cache/
script:
- git config user.email "${CI_EMAIL}"
- git config user.name "${CI_USERNAME}"
- git remote add gitlab_origin https://${CI_USERNAME}:${CI_ACCESS_TOKEN}@gitlab.knecon.com/redactmanager/red-ui.git
- cd tools/localazy
- yarn install --cache-folder .yarn-cache
- yarn start
- cd ../..
- git add .
- git commit -m "push back localazy update"
- git push gitlab_origin HEAD:${CI_COMMIT_REF_NAME} -o ci.skip
rules:
- if: $LOCALAZY_RUN
- changes:
- tools/localazy/**/*
- red-ui/src/assets/i18n/**/*

View File

@ -1,10 +1,10 @@
<ng-container *ngIf="componentContext$ | async as ctx">
<div>
<div
[class.error]="file.isError"
[class.initial-processing]="file.isInitialProcessing"
[matTooltip]="file.filename"
[attr.help-mode-key]="'document_in_editor'"
[class.error]="file.isError"
[class.initial-processing]="file.isInitialProcessing || (ctx.ocrByDefault && !file.lastOCRTime)"
[matTooltip]="file.filename"
class="table-item-title"
matTooltipPosition="above"
>

View File

@ -4,6 +4,7 @@ import { FileAttributes } from '@red/domain';
import { FileAttributesService } from '@services/entity-services/file-attributes.service';
import { combineLatest, map, ReplaySubject } from 'rxjs';
import { ContextComponent } from '@iqser/common-ui/lib/utils';
import { DossierTemplatesService } from '@services/dossier-templates/dossier-templates.service';
interface PartialFile {
readonly isError: boolean;
@ -18,6 +19,7 @@ interface PartialFile {
interface FileNameColumnContext {
primaryAttribute: string;
ocrByDefault: boolean;
}
@Component({
@ -27,13 +29,14 @@ interface FileNameColumnContext {
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class FileNameColumnComponent extends ContextComponent<FileNameColumnContext> implements OnInit, OnChanges {
readonly #reloadAttribute = new ReplaySubject<void>(1);
@Input() file: PartialFile;
@Input() dossierTemplateId: string;
readonly #reloadAttribute = new ReplaySubject<void>(1);
constructor(
private readonly _fileAttributeService: FileAttributesService,
private readonly _primaryFileAttributeService: PrimaryFileAttributeService,
private readonly _dossierTemplateService: DossierTemplatesService,
) {
super();
}
@ -42,8 +45,10 @@ export class FileNameColumnComponent extends ContextComponent<FileNameColumnCont
const primaryAttribute$ = combineLatest([this._fileAttributeService.fileAttributesConfig$, this.#reloadAttribute]).pipe(
map(() => this._primaryFileAttributeService.getPrimaryFileAttributeValue(this.file, this.dossierTemplateId)),
);
const ocrByDefault$ = this._dossierTemplateService.get(this.dossierTemplateId).pipe(map(template => template.ocrByDefault));
super._initContext({
primaryAttribute: primaryAttribute$,
ocrByDefault: ocrByDefault$,
});
}

File diff suppressed because it is too large Load Diff

View File

@ -1747,7 +1747,7 @@
"trash-documents": "Documents in Trash",
"unused": "Unused Storage"
},
"copyright-claim-text": "Copyright © 2020 - {currentYear} knecon AG (powered by IQSER)",
"copyright-claim-text": "Copyright © 2020 - {currentYear} knecon",
"copyright-claim-title": "Copyright Claim",
"current-analyzed-pages": "Analyzed Pages in Licensing Period",
"current-volume-analyzed": "Data Volume Analyzed in Licensing Period",
@ -1760,7 +1760,7 @@
},
"title": "License Report {licenseCustomer}"
},
"end-user-license-text": "The use of this product is subject to the terms of the Redaction End User Agreement, unless otherwise specified therein.",
"end-user-license-text": "The use of this product is subject to the terms of the RedactManager End User License Agreement, unless otherwise specified therein.",
"end-user-license-title": "End User License Agreement",
"license-title": "License Title",
"licensed-capacity": "Licensed Capacity",
@ -2533,4 +2533,4 @@
}
},
"yesterday": "Yesterday"
}
}

View File

@ -1747,7 +1747,7 @@
"trash-documents": "Documents in Trash",
"unused": "Unused Storage"
},
"copyright-claim-text": "Copyright © 2020 - {currentYear} knecon AG (powered by IQSER)",
"copyright-claim-text": "Copyright © 2020 - {currentYear} knecon",
"copyright-claim-title": "Copyright Claim",
"current-analyzed-pages": "Analyzed Pages in Licensing Period",
"current-volume-analyzed": "Data Volume Analyzed in Licensing Period",

View File

@ -11,6 +11,7 @@
"nx": "nx",
"start": "nx serve",
"update": "nx migrate latest",
"localazy": "ts-node tools/localazy/src/index.ts",
"migrate": "nx migrate --run-migrations",
"workspace-generator": "nx workspace-generator",
"analyze": "nx build --stats-json && webpack-bundle-analyzer dist/apps/red-ui/stats.json",
@ -75,6 +76,7 @@
"@angular/compiler-cli": "16.2.2",
"@angular/language-service": "16.2.2",
"@bartholomej/ngx-translate-extract": "^8.0.2",
"@localazy/ts-api": "^1.0.0",
"@nx/eslint-plugin": "16.7.4",
"@nx/jest": "16.7.4",
"@nx/linter": "16.7.4",

2
tools/localazy/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
yarn.lock
node_modules/

View File

@ -0,0 +1,15 @@
{
"name": "localazy",
"version": "1.0.0",
"dependencies": {
"@types/node": "^20.5.7"
},
"scripts": {
"start": "ts-node src/index.ts"
},
"devDependencies": {
"@localazy/ts-api": "^1.0.0",
"ts-node": "10.9.1",
"typescript": "5.1.3"
}
}

View File

@ -0,0 +1,2 @@
export const TOKEN: string = process.env.LOCALAZY_TOKEN || '';
export const FILENAME = 'i18n.json';

View File

@ -0,0 +1,63 @@
import { FILENAME, TOKEN } from './constants';
import LocalazyApi from '@localazy/ts-api';
import { Key } from '@localazy/ts-api/dist/models/responses/keys-in-file';
import { get, set } from './utils';
import * as fs from 'fs';
const api = LocalazyApi({
projectToken: TOKEN,
baseUrl: 'https://api.localazy.com',
});
export async function getProjectId(): Promise<string> {
const projects = await api.listProjects();
return projects[0].id;
}
export async function getFileId(projectId: string): Promise<string> {
const files = await api.listFiles({ projectId });
return files.find(file => file.name === FILENAME)!.id;
}
export async function uploadLocal(projectId: string, lang: 'en' | 'de'): Promise<void> {
const langFile = (await import(`./../../../apps/red-ui/src/assets/i18n/redact/${lang}.json`)).default;
await api.import({
projectId,
files: [
{
name: FILENAME,
content: { type: 'json', features: ['plural_icu', 'filter_untranslated'], [lang]: langFile },
},
],
deprecate: 'project',
});
}
export async function downloadLanguage(projectId: string, fileId: string, lang: 'en' | 'de'): Promise<any> {
const response = await api.getFileContents({ projectId, fileId, lang });
return JSON.parse(await response.text());
}
export async function listKeys(projectId: string, fileId: string, lang: 'en' | 'de'): Promise<Key[]> {
const response = await api.listKeysInFileForLanguage({ projectId, fileId, lang });
console.log(`Downloaded ${response.keys.length} keys for ${lang} language`);
return response.keys;
}
export async function updateLocalEn(keys: Key[]): Promise<void> {
const enFile = (await import('./../../../apps/red-ui/src/assets/i18n/redact/en.json')).default;
keys.forEach(({ key, value }) => {
if (get(enFile, key) !== undefined) {
set(enFile, key, value);
}
});
await fs.promises.writeFile('./../../apps/red-ui/src/assets/i18n/redact/en.json', JSON.stringify(enFile, null, 2));
}
export async function updateLocalDe(projectId: string, fileId: string): Promise<void> {
const deFile = await downloadLanguage(projectId, fileId, 'de');
await fs.promises.writeFile('./../../apps/red-ui/src/assets/i18n/redact/de.json', JSON.stringify(deFile, null, 2));
}

View File

@ -0,0 +1,33 @@
import { downloadLanguage, getFileId, getProjectId, listKeys, updateLocalDe, updateLocalEn, uploadLocal } from './functions';
async function execute() {
const projectId = await getProjectId();
const fileId = await getFileId(projectId);
/** Update local en (source) file with potential remotely updated translations. */
const remoteKeys = await listKeys(projectId, fileId, 'en');
await updateLocalEn(remoteKeys);
/** Upload local en (source) file in order to add new keys and deprecate unused keys. */
await uploadLocal(projectId, 'en');
/** Download updated de file. */
await updateLocalDe(projectId, fileId);
}
async function uploadLocals() {
const projectId = await getProjectId();
await uploadLocal(projectId, 'de');
}
async function downloadDe() {
const projectId = await getProjectId();
const fileId = await getFileId(projectId);
console.log({ projectId, fileId });
console.log(await downloadLanguage(projectId, fileId, 'de'));
}
execute().then();
// uploadLocals().then();
// downloadDe().then();

View File

@ -0,0 +1,16 @@
export function get(object: any, path: string[]): any {
return path.reduce((o, k) => (o || {})[k], object);
}
export function set(object: any, path: string[], value: any): void {
path.reduce((o, k, i) => {
if (i === path.length - 1) {
o[k] = value;
} else {
if (o[k] === undefined) {
o[k] = {};
}
}
return o[k];
}, object);
}

View File

@ -0,0 +1,12 @@
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"lib": ["es6", "DOM"],
"outDir": "build",
"strict": true,
"noImplicitAny": true,
"esModuleInterop": true,
"resolveJsonModule": true
}
}

View File

@ -2494,6 +2494,11 @@
resolved "https://registry.yarnpkg.com/@leichtgewicht/ip-codec/-/ip-codec-2.0.4.tgz#b2ac626d6cb9c8718ab459166d4bb405b8ffa78b"
integrity sha512-Hcv+nVC0kZnQ3tD9GVu5xSMR4VVYOteQIr/hwFPVEvPdlXqgGEuRjiheChHgdM+JyqdgNcmzZOX/tnl0JOiI7A==
"@localazy/ts-api@^1.0.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@localazy/ts-api/-/ts-api-1.1.0.tgz#e36edbea775fa950a6dcd54693686ed63fa67218"
integrity sha512-0iLFWRxmKPkuruASye4A6CQoYMDGLqQmPLS76zKhPywwNTc89oIlaWrkl63c2EP70NzHxKu6BnpmJAjqFSeXrg==
"@materia-ui/ngx-monaco-editor@^6.0.0":
version "6.0.0"
resolved "https://registry.yarnpkg.com/@materia-ui/ngx-monaco-editor/-/ngx-monaco-editor-6.0.0.tgz#9ae93666019e9a6d4f787370b4373cbb63a04a38"