TD-837,TD-833: Remove until destroy. Update monaco editor (#308)

This commit is contained in:
Rinat Arsaev 2024-01-12 16:11:32 +07:00 committed by GitHub
parent f617d1c292
commit e3d491326e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
104 changed files with 496 additions and 1135 deletions

View File

@ -28,8 +28,8 @@
"src/assets", "src/assets",
{ {
"glob": "**/*", "glob": "**/*",
"input": "./node_modules/monaco-editor/min/vs", "input": "node_modules/monaco-editor",
"output": "libs/vs" "output": "/assets/monaco/"
} }
], ],
"styles": ["src/app/styles/styles.scss"], "styles": ["src/app/styles/styles.scss"],
@ -39,7 +39,6 @@
"short-uuid", "short-uuid",
"js-sha256", "js-sha256",
"jwt-decode", "jwt-decode",
"css-element-queries",
"base64-js", "base64-js",
"@vality/deanonimus-proto", "@vality/deanonimus-proto",
"@vality/domain-proto", "@vality/domain-proto",
@ -128,8 +127,8 @@
"src/assets", "src/assets",
{ {
"glob": "**/*", "glob": "**/*",
"input": "./node_modules/monaco-editor/min/vs", "input": "node_modules/monaco-editor",
"output": "libs/vs" "output": "/assets/monaco/"
} }
], ],
"styles": ["src/app/styles/styles.scss"], "styles": ["src/app/styles/styles.scss"],

71
package-lock.json generated
View File

@ -20,25 +20,24 @@
"@angular/platform-server": "17.0.8", "@angular/platform-server": "17.0.8",
"@angular/router": "17.0.8", "@angular/router": "17.0.8",
"@ngneat/input-mask": "6.0.0", "@ngneat/input-mask": "6.0.0",
"@ngneat/until-destroy": "9.2.2",
"@s-libs/ng-core": "17.0.0", "@s-libs/ng-core": "17.0.0",
"@vality/deanonimus-proto": "2.0.1-2a02d87.0", "@vality/deanonimus-proto": "2.0.1-2a02d87.0",
"@vality/domain-proto": "2.0.1-23211ff.0", "@vality/domain-proto": "2.0.1-23211ff.0",
"@vality/fistful-proto": "2.0.1-3b9a0a7.0", "@vality/fistful-proto": "2.0.1-3b9a0a7.0",
"@vality/machinegun-proto": "1.0.0", "@vality/machinegun-proto": "1.0.0",
"@vality/magista-proto": "2.0.2-4383410.0", "@vality/magista-proto": "2.0.2-4383410.0",
"@vality/ng-core": "17.0.0", "@vality/ng-core": "17.1.1-pr-57-8d24d61.0",
"@vality/payout-manager-proto": "2.0.1-eb4091a.0", "@vality/payout-manager-proto": "2.0.1-eb4091a.0",
"@vality/repairer-proto": "2.0.2-07b73e9.0", "@vality/repairer-proto": "2.0.2-07b73e9.0",
"@vality/thrift-ts": "2.4.1-8ad5123.0", "@vality/thrift-ts": "2.4.1-8ad5123.0",
"@vality/woody": "0.1.3", "@vality/woody": "0.1.3",
"css-element-queries": "1.2.3",
"date-fns": "2.30.0", "date-fns": "2.30.0",
"inputmask": "5.0.7", "inputmask": "5.0.7",
"keycloak-angular": "^15.0.0", "keycloak-angular": "^15.0.0",
"keycloak-js": "^18.0.1", "keycloak-js": "^20.0.5",
"lodash-es": "^4.17.21", "lodash-es": "^4.17.21",
"monaco-editor": "0.21.2", "monaco-editor": "^0.44.0",
"ngx-monaco-editor-v2": "^17.0.1",
"papaparse": "^5.4.1", "papaparse": "^5.4.1",
"rxjs": "7.8.1", "rxjs": "7.8.1",
"short-uuid": "4.2.2", "short-uuid": "4.2.2",
@ -5000,18 +4999,6 @@
"inputmask": "^5.0.7" "inputmask": "^5.0.7"
} }
}, },
"node_modules/@ngneat/until-destroy": {
"version": "9.2.2",
"resolved": "https://registry.npmjs.org/@ngneat/until-destroy/-/until-destroy-9.2.2.tgz",
"integrity": "sha512-pD5idTgUdF0XZMuaV1n0BZTnE2BvxymutoXhwfZbO3uxjh63wS6Pzzzwv+pkXalKhuSwdf6uA1gRx7DOvlj/Kw==",
"dependencies": {
"tslib": "^2.3.0"
},
"peerDependencies": {
"@angular/core": ">=13",
"rxjs": "^6.4.0 || ^7.0.0"
}
},
"node_modules/@ngtools/webpack": { "node_modules/@ngtools/webpack": {
"version": "17.0.8", "version": "17.0.8",
"resolved": "https://registry.npmjs.org/@ngtools/webpack/-/webpack-17.0.8.tgz", "resolved": "https://registry.npmjs.org/@ngtools/webpack/-/webpack-17.0.8.tgz",
@ -6536,9 +6523,9 @@
"integrity": "sha512-kAiKSTvof+jFuNkQKyAsc2s+Br2NXPWAyKuD0f7mQIk9HrP8uHsKJya5KxdOdng97JYe0MSUlx7seQxWmCgYfA==" "integrity": "sha512-kAiKSTvof+jFuNkQKyAsc2s+Br2NXPWAyKuD0f7mQIk9HrP8uHsKJya5KxdOdng97JYe0MSUlx7seQxWmCgYfA=="
}, },
"node_modules/@vality/ng-core": { "node_modules/@vality/ng-core": {
"version": "17.0.0", "version": "17.1.1-pr-57-8d24d61.0",
"resolved": "https://registry.npmjs.org/@vality/ng-core/-/ng-core-17.0.0.tgz", "resolved": "https://registry.npmjs.org/@vality/ng-core/-/ng-core-17.1.1-pr-57-8d24d61.0.tgz",
"integrity": "sha512-07oxorY6xtLxUve+1GGsHTWRsz8jkzisFOeuZA4FfKkwCHQhW7x/LUQM9xQoUkon5ZKMBV8A7SvwNW7rwXO1UA==", "integrity": "sha512-6nRi75ML8LhDObD9iUUtk+6pQ3rpgyDttvK3Bp30Fs3wWP3Ypk2Z9gD+40G0RPpbunR7c27vtJ0po0Oe4IyyiA==",
"dependencies": { "dependencies": {
"@angular/material-date-fns-adapter": "^17.0.0", "@angular/material-date-fns-adapter": "^17.0.0",
"@ng-matero/extensions": "^17.0.0", "@ng-matero/extensions": "^17.0.0",
@ -6548,7 +6535,7 @@
"@s-libs/rxjs-core": "^17.0.0", "@s-libs/rxjs-core": "^17.0.0",
"dinero.js": "^2.0.0-alpha.14", "dinero.js": "^2.0.0-alpha.14",
"fuse.js": "^7.0.0", "fuse.js": "^7.0.0",
"ng-let": "^16.0.1", "short-uuid": "^4.2.2",
"tslib": "^2.3.0" "tslib": "^2.3.0"
}, },
"peerDependencies": { "peerDependencies": {
@ -9276,11 +9263,6 @@
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
"dev": true "dev": true
}, },
"node_modules/css-element-queries": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/css-element-queries/-/css-element-queries-1.2.3.tgz",
"integrity": "sha512-QK9uovYmKTsV2GXWQiMOByVNrLn2qz6m3P7vWpOR4IdD6I3iXoDw5qtgJEN3Xq7gIbdHVKvzHjdAtcl+4Arc4Q=="
},
"node_modules/css-loader": { "node_modules/css-loader": {
"version": "6.8.1", "version": "6.8.1",
"resolved": "https://registry.npmjs.org/css-loader/-/css-loader-6.8.1.tgz", "resolved": "https://registry.npmjs.org/css-loader/-/css-loader-6.8.1.tgz",
@ -13494,9 +13476,9 @@
} }
}, },
"node_modules/keycloak-js": { "node_modules/keycloak-js": {
"version": "18.0.1", "version": "20.0.5",
"resolved": "https://registry.npmjs.org/keycloak-js/-/keycloak-js-18.0.1.tgz", "resolved": "https://registry.npmjs.org/keycloak-js/-/keycloak-js-20.0.5.tgz",
"integrity": "sha512-IRXToYpbIrkyfLeNNJly2OjUCf11ncx2Sdsg257NVDwjOYE923osu47w8pfxEVWpTaS14/Y2QjbTHciuBK0RBQ==", "integrity": "sha512-7+M5Uni4oNlAmbjM/lDJzFHu2+PGqU6/bvmTBuQssE1fJ7ZyNeCRHgFoaVfFpIU3m6aAFwPUko4lVcn4kPXP5Q==",
"dependencies": { "dependencies": {
"base64-js": "^1.5.1", "base64-js": "^1.5.1",
"js-sha256": "^0.9.0" "js-sha256": "^0.9.0"
@ -14372,9 +14354,9 @@
} }
}, },
"node_modules/monaco-editor": { "node_modules/monaco-editor": {
"version": "0.21.2", "version": "0.44.0",
"resolved": "https://registry.npmjs.org/monaco-editor/-/monaco-editor-0.21.2.tgz", "resolved": "https://registry.npmjs.org/monaco-editor/-/monaco-editor-0.44.0.tgz",
"integrity": "sha512-jS51RLuzMaoJpYbu7F6TPuWpnWTLD4kjRW0+AZzcryvbxrTwhNy1KC9yboyKpgMTahpUbDUsuQULoo0GV1EPqg==" "integrity": "sha512-5SmjNStN6bSuSE5WPT2ZV+iYn1/yI9sd4Igtk23ChvqB7kDk9lZbB9F5frsuvpB+2njdIeGGFf2G4gbE6rCC9Q=="
}, },
"node_modules/mrmime": { "node_modules/mrmime": {
"version": "1.0.1", "version": "1.0.1",
@ -14493,18 +14475,6 @@
"integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==", "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==",
"dev": true "dev": true
}, },
"node_modules/ng-let": {
"version": "16.0.1",
"resolved": "https://registry.npmjs.org/ng-let/-/ng-let-16.0.1.tgz",
"integrity": "sha512-xS213D2J+WRBVVB2CQnTtKxaEMFt/gjtVhhklfmfqbXOXGQJXmPonI9m4n9Sp+gp/NcmMRMn21pmeKAjcLsPzA==",
"dependencies": {
"tslib": "^2.3.1"
},
"peerDependencies": {
"@angular/common": ">15.0.0",
"@angular/core": ">15.0.0"
}
},
"node_modules/ngx-color": { "node_modules/ngx-color": {
"version": "9.0.0", "version": "9.0.0",
"resolved": "https://registry.npmjs.org/ngx-color/-/ngx-color-9.0.0.tgz", "resolved": "https://registry.npmjs.org/ngx-color/-/ngx-color-9.0.0.tgz",
@ -14519,6 +14489,19 @@
"@angular/core": ">=16.0.0-0" "@angular/core": ">=16.0.0-0"
} }
}, },
"node_modules/ngx-monaco-editor-v2": {
"version": "17.0.1",
"resolved": "https://registry.npmjs.org/ngx-monaco-editor-v2/-/ngx-monaco-editor-v2-17.0.1.tgz",
"integrity": "sha512-GP+Ni6zKFQjF/ve5ZQtfE9eRLKL4GxMvdmDTrla1x6F5pSIcYGCcjZ4gQ1/AHMa5dgarfs+Et+1bBtAOJtI6KA==",
"dependencies": {
"tslib": "^2.1.0"
},
"peerDependencies": {
"@angular/common": "^17.0.3",
"@angular/core": "^17.0.3",
"monaco-editor": "^0.44.0"
}
},
"node_modules/nice-napi": { "node_modules/nice-napi": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/nice-napi/-/nice-napi-1.0.2.tgz", "resolved": "https://registry.npmjs.org/nice-napi/-/nice-napi-1.0.2.tgz",

View File

@ -28,25 +28,24 @@
"@angular/platform-server": "17.0.8", "@angular/platform-server": "17.0.8",
"@angular/router": "17.0.8", "@angular/router": "17.0.8",
"@ngneat/input-mask": "6.0.0", "@ngneat/input-mask": "6.0.0",
"@ngneat/until-destroy": "9.2.2",
"@s-libs/ng-core": "17.0.0", "@s-libs/ng-core": "17.0.0",
"@vality/deanonimus-proto": "2.0.1-2a02d87.0", "@vality/deanonimus-proto": "2.0.1-2a02d87.0",
"@vality/domain-proto": "2.0.1-23211ff.0", "@vality/domain-proto": "2.0.1-23211ff.0",
"@vality/fistful-proto": "2.0.1-3b9a0a7.0", "@vality/fistful-proto": "2.0.1-3b9a0a7.0",
"@vality/machinegun-proto": "1.0.0", "@vality/machinegun-proto": "1.0.0",
"@vality/magista-proto": "2.0.2-4383410.0", "@vality/magista-proto": "2.0.2-4383410.0",
"@vality/ng-core": "17.0.0", "@vality/ng-core": "17.1.1-pr-57-8d24d61.0",
"@vality/payout-manager-proto": "2.0.1-eb4091a.0", "@vality/payout-manager-proto": "2.0.1-eb4091a.0",
"@vality/repairer-proto": "2.0.2-07b73e9.0", "@vality/repairer-proto": "2.0.2-07b73e9.0",
"@vality/thrift-ts": "2.4.1-8ad5123.0", "@vality/thrift-ts": "2.4.1-8ad5123.0",
"@vality/woody": "0.1.3", "@vality/woody": "0.1.3",
"css-element-queries": "1.2.3",
"date-fns": "2.30.0", "date-fns": "2.30.0",
"inputmask": "5.0.7", "inputmask": "5.0.7",
"keycloak-angular": "^15.0.0", "keycloak-angular": "^15.0.0",
"keycloak-js": "^18.0.1", "keycloak-js": "^20.0.5",
"lodash-es": "^4.17.21", "lodash-es": "^4.17.21",
"monaco-editor": "0.21.2", "monaco-editor": "^0.44.0",
"ngx-monaco-editor-v2": "^17.0.1",
"papaparse": "^5.4.1", "papaparse": "^5.4.1",
"rxjs": "7.8.1", "rxjs": "7.8.1",
"short-uuid": "4.2.2", "short-uuid": "4.2.2",

View File

@ -1,5 +1,5 @@
import { Injectable } from '@angular/core'; import { Injectable, DestroyRef } from '@angular/core';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { Domain, DomainObject, Reference } from '@vality/domain-proto/domain'; import { Domain, DomainObject, Reference } from '@vality/domain-proto/domain';
import { Commit, Snapshot, Version } from '@vality/domain-proto/domain_config'; import { Commit, Snapshot, Version } from '@vality/domain-proto/domain_config';
import { NotifyLogService } from '@vality/ng-core'; import { NotifyLogService } from '@vality/ng-core';
@ -12,7 +12,6 @@ import { DomainSecretService } from '../../../shared/services';
import { handleError } from '../../../shared/services/notification-error'; import { handleError } from '../../../shared/services/notification-error';
import { RepositoryService } from '../index'; import { RepositoryService } from '../index';
@UntilDestroy()
@Injectable({ @Injectable({
providedIn: 'root', providedIn: 'root',
}) })
@ -30,7 +29,7 @@ export class DomainStoreService {
.Checkout({ head: {} }) .Checkout({ head: {} })
.pipe(progressTo(this.progress$), handleError(this.log.error)), .pipe(progressTo(this.progress$), handleError(this.log.error)),
), ),
untilDestroyed(this), takeUntilDestroyed(this.destroyRef),
shareReplay(1), shareReplay(1),
); );
private reload$ = new ReplaySubject<void>(1); private reload$ = new ReplaySubject<void>(1);
@ -40,6 +39,7 @@ export class DomainStoreService {
private repositoryService: RepositoryService, private repositoryService: RepositoryService,
private domainSecretService: DomainSecretService, private domainSecretService: DomainSecretService,
private log: NotifyLogService, private log: NotifyLogService,
private destroyRef: DestroyRef,
) {} ) {}
forceReload(): void { forceReload(): void {

View File

@ -3,7 +3,7 @@
<mat-sidenav-container autosize class="container"> <mat-sidenav-container autosize class="container">
<mat-sidenav fixedInViewport="true" fixedTopGap="64" mode="side" opened role="navigation"> <mat-sidenav fixedInViewport="true" fixedTopGap="64" mode="side" opened role="navigation">
<mat-nav-list> <mat-nav-list>
<ng-container *ngFor="let group of menuItems; let i = index"> <ng-container *ngFor="let group of menuItemsGroups$ | async; let i = index">
<mat-divider *ngIf="i !== 0"></mat-divider> <mat-divider *ngIf="i !== 0"></mat-divider>
<mat-list-item <mat-list-item
*ngFor="let item of group" *ngFor="let item of group"

View File

@ -1,9 +1,13 @@
import { Component, OnInit } from '@angular/core'; import { Component } from '@angular/core';
import { KeycloakService } from 'keycloak-angular'; import { KeycloakService } from 'keycloak-angular';
import sortBy from 'lodash-es/sortBy'; import sortBy from 'lodash-es/sortBy';
import { from, Observable } from 'rxjs';
import { shareReplay, map } from 'rxjs/operators';
import { AppAuthGuardService } from '@cc/app/shared/services'; import { AppAuthGuardService } from '@cc/app/shared/services';
import { environment } from '../environments/environment';
import { ROUTING_CONFIG as CLAIMS_ROUTING_CONFIG } from './sections/claims/routing-config'; import { ROUTING_CONFIG as CLAIMS_ROUTING_CONFIG } from './sections/claims/routing-config';
import { ROUTING_CONFIG as DEPOSITS_ROUTING_CONFIG } from './sections/deposits/routing-config'; import { ROUTING_CONFIG as DEPOSITS_ROUTING_CONFIG } from './sections/deposits/routing-config';
import { ROUTING_CONFIG as DOMAIN_ROUTING_CONFIG } from './sections/domain/routing-config'; import { ROUTING_CONFIG as DOMAIN_ROUTING_CONFIG } from './sections/domain/routing-config';
@ -23,22 +27,37 @@ import { SidenavInfoService } from './shared/components/sidenav-info';
templateUrl: './app.component.html', templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'], styleUrls: ['./app.component.scss'],
}) })
export class AppComponent implements OnInit { export class AppComponent {
menuItems: { name: string; route: string }[][] = []; menuItemsGroups$: Observable<{ name: string; route: string }[][]> = from(
this.keycloakService.loadUserProfile(),
).pipe(
map(() => this.getMenuItemsGroups()),
shareReplay({ refCount: true, bufferSize: 1 }),
);
constructor( constructor(
private keycloakService: KeycloakService, private keycloakService: KeycloakService,
private appAuthGuardService: AppAuthGuardService, private appAuthGuardService: AppAuthGuardService,
public sidenavInfoService: SidenavInfoService, public sidenavInfoService: SidenavInfoService,
) {} ) {
this.registerConsoleUtils();
}
ngOnInit() { private registerConsoleUtils() {
void this.keycloakService.loadUserProfile().then(() => { Object.assign(window as never as object, {
this.menuItems = this.getMenuItems(); ccSwitchLogging: () => {
environment.logging = { requests: !environment.logging.requests };
// eslint-disable-next-line no-console
console.log(`Logging ${environment.logging.requests ? 'enabled' : 'disabled'}`);
},
ccGetMyRoles: () => {
// eslint-disable-next-line no-console
console.log(this.keycloakService.getUserRoles(true).sort().join('\n'));
},
}); });
} }
private getMenuItems() { private getMenuItemsGroups() {
const menuItems = [ const menuItems = [
[ [
{ {

View File

@ -14,6 +14,7 @@ import { BrowserModule, DomSanitizer } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { InputMaskModule } from '@ngneat/input-mask'; import { InputMaskModule } from '@ngneat/input-mask';
import { QUERY_PARAMS_SERIALIZERS } from '@vality/ng-core'; import { QUERY_PARAMS_SERIALIZERS } from '@vality/ng-core';
import { MonacoEditorModule } from 'ngx-monaco-editor-v2';
import { KeycloakTokenInfoModule } from '@cc/app/shared/services'; import { KeycloakTokenInfoModule } from '@cc/app/shared/services';
@ -71,6 +72,7 @@ export let AppInjector: Injector;
SectionsModule, SectionsModule,
SidenavInfoComponent, SidenavInfoComponent,
ToolbarComponent, ToolbarComponent,
MonacoEditorModule.forRoot(),
// TODO: hack for metadata datetime 😡 // TODO: hack for metadata datetime 😡
MatDatepickerModule, MatDatepickerModule,
// TODO: hack for cash field 😡 // TODO: hack for cash field 😡

View File

@ -5,7 +5,7 @@ import { MatIconModule } from '@angular/material/icon';
import { MatMenuModule } from '@angular/material/menu'; import { MatMenuModule } from '@angular/material/menu';
import { MatToolbarModule } from '@angular/material/toolbar'; import { MatToolbarModule } from '@angular/material/toolbar';
import { KeycloakService } from 'keycloak-angular'; import { KeycloakService } from 'keycloak-angular';
import { of, switchMap } from 'rxjs'; import { from } from 'rxjs';
import { map, shareReplay } from 'rxjs/operators'; import { map, shareReplay } from 'rxjs/operators';
@Component({ @Component({
@ -16,8 +16,7 @@ import { map, shareReplay } from 'rxjs/operators';
styleUrl: './toolbar.component.scss', styleUrl: './toolbar.component.scss',
}) })
export class ToolbarComponent { export class ToolbarComponent {
username$ = of().pipe( username$ = from(this.keycloakService.loadUserProfile()).pipe(
switchMap(() => this.keycloakService.loadUserProfile()),
map(() => this.keycloakService.getUsername()), map(() => this.keycloakService.getUsername()),
shareReplay({ refCount: true, bufferSize: 1 }), shareReplay({ refCount: true, bufferSize: 1 }),
); );

View File

@ -1,6 +1,6 @@
import { Component, OnInit, Inject } from '@angular/core'; import { Component, OnInit, Inject, DestroyRef } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { NonNullableFormBuilder } from '@angular/forms'; import { NonNullableFormBuilder } from '@angular/forms';
import { untilDestroyed, UntilDestroy } from '@ngneat/until-destroy';
import { ChargebackSearchQuery, StatChargeback } from '@vality/magista-proto/magista'; import { ChargebackSearchQuery, StatChargeback } from '@vality/magista-proto/magista';
import { import {
DateRange, DateRange,
@ -32,7 +32,6 @@ import { DATE_RANGE_DAYS } from '../../tokens';
import { CreateChargebacksByFileDialogComponent } from './components/create-chargebacks-by-file-dialog/create-chargebacks-by-file-dialog.component'; import { CreateChargebacksByFileDialogComponent } from './components/create-chargebacks-by-file-dialog/create-chargebacks-by-file-dialog.component';
import { FetchChargebacksService } from './fetch-chargebacks.service'; import { FetchChargebacksService } from './fetch-chargebacks.service';
@UntilDestroy()
@Component({ @Component({
selector: 'cc-chargebacks', selector: 'cc-chargebacks',
templateUrl: './chargebacks.component.html', templateUrl: './chargebacks.component.html',
@ -67,6 +66,7 @@ export class ChargebacksComponent implements OnInit {
private fetchChargebacksService: FetchChargebacksService, private fetchChargebacksService: FetchChargebacksService,
private dialog: DialogService, private dialog: DialogService,
@Inject(DATE_RANGE_DAYS) private dateRangeDays: number, @Inject(DATE_RANGE_DAYS) private dateRangeDays: number,
private destroyRef: DestroyRef,
) {} ) {}
ngOnInit() { ngOnInit() {
@ -74,7 +74,7 @@ export class ChargebacksComponent implements OnInit {
merge({}, this.qp.params.filters, clean({ dateRange: this.qp.params.dateRange })), merge({}, this.qp.params.filters, clean({ dateRange: this.qp.params.dateRange })),
); );
this.filtersForm.valueChanges this.filtersForm.valueChanges
.pipe(startWith(null), debounceTime(500), untilDestroyed(this)) .pipe(startWith(null), debounceTime(500), takeUntilDestroyed(this.destroyRef))
.subscribe(() => { .subscribe(() => {
this.load(); this.load();
}); });
@ -120,7 +120,7 @@ export class ChargebacksComponent implements OnInit {
.afterClosed() .afterClosed()
.pipe( .pipe(
filter((res) => res.status === DialogResponseStatus.Success), filter((res) => res.status === DialogResponseStatus.Success),
untilDestroyed(this), takeUntilDestroyed(this.destroyRef),
) )
.subscribe((res) => { .subscribe((res) => {
this.filtersForm.reset({ this.filtersForm.reset({
@ -136,7 +136,7 @@ export class ChargebacksComponent implements OnInit {
.afterClosed() .afterClosed()
.pipe( .pipe(
filter((res) => res.status === DialogResponseStatus.Success), filter((res) => res.status === DialogResponseStatus.Success),
untilDestroyed(this), takeUntilDestroyed(this.destroyRef),
) )
.subscribe(() => { .subscribe(() => {
this.load(); this.load();

View File

@ -1,6 +1,6 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit, DestroyRef } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { FormControl } from '@angular/forms'; import { FormControl } from '@angular/forms';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { InvoicePaymentChargeback } from '@vality/domain-proto/domain'; import { InvoicePaymentChargeback } from '@vality/domain-proto/domain';
import { InvoicePaymentChargebackParams } from '@vality/domain-proto/payment_processing'; import { InvoicePaymentChargebackParams } from '@vality/domain-proto/payment_processing';
import { import {
@ -29,7 +29,6 @@ interface ChargebackParams {
params: InvoicePaymentChargebackParams; params: InvoicePaymentChargebackParams;
} }
@UntilDestroy()
@Component({ @Component({
selector: 'cc-create-chargebacks-by-file-dialog', selector: 'cc-create-chargebacks-by-file-dialog',
templateUrl: './create-chargebacks-by-file-dialog.component.html', templateUrl: './create-chargebacks-by-file-dialog.component.html',
@ -141,12 +140,13 @@ export class CreateChargebacksByFileDialogComponent
private invoicingService: InvoicingService, private invoicingService: InvoicingService,
private log: NotifyLogService, private log: NotifyLogService,
private amountCurrencyService: AmountCurrencyService, private amountCurrencyService: AmountCurrencyService,
private destroyRef: DestroyRef,
) { ) {
super(); super();
} }
ngOnInit() { ngOnInit() {
this.chargebacks$.pipe(untilDestroyed(this)).subscribe((c) => { this.chargebacks$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((c) => {
this.selectedChargebacks = c || []; this.selectedChargebacks = c || [];
}); });
} }
@ -159,7 +159,7 @@ export class CreateChargebacksByFileDialogComponent
), ),
this.progress$, this.progress$,
) )
.pipe(untilDestroyed(this)) .pipe(takeUntilDestroyed(this.destroyRef))
.subscribe({ .subscribe({
next: (res) => { next: (res) => {
this.successfullyChargebacks.push( this.successfullyChargebacks.push(

View File

@ -1,13 +1,12 @@
import { Component } from '@angular/core'; import { Component, DestroyRef } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { DialogResponseStatus, DialogService } from '@vality/ng-core'; import { DialogResponseStatus, DialogService } from '@vality/ng-core';
import { BehaviorSubject, combineLatest, defer, merge, Observable, Subject, switchMap } from 'rxjs'; import { BehaviorSubject, combineLatest, defer, merge, Observable, Subject, switchMap } from 'rxjs';
import { first, map, shareReplay } from 'rxjs/operators'; import { first, map, shareReplay } from 'rxjs/operators';
import { ClaimManagementService } from '@cc/app/api/claim-management'; import { ClaimManagementService } from '@cc/app/api/claim-management';
import { PartyManagementService } from '@cc/app/api/payment-processing'; import { PartyManagementService } from '@cc/app/api/payment-processing';
import { NotificationService } from '@cc/app/shared/services/notification';
import { getUnionKey, inProgressFrom, progressTo } from '@cc/utils'; import { getUnionKey, inProgressFrom, progressTo } from '@cc/utils';
import { NotificationErrorService, handleError } from '../../shared/services/notification-error'; import { NotificationErrorService, handleError } from '../../shared/services/notification-error';
@ -17,7 +16,6 @@ import { ChangeStatusDialogComponent } from './components/change-status-dialog/c
import { AllowedClaimStatusesService } from './services/allowed-claim-statuses.service'; import { AllowedClaimStatusesService } from './services/allowed-claim-statuses.service';
import { CLAIM_STATUS_COLOR } from './types/claim-status-color'; import { CLAIM_STATUS_COLOR } from './types/claim-status-color';
@UntilDestroy()
@Component({ @Component({
selector: 'cc-claim', selector: 'cc-claim',
templateUrl: './claim.component.html', templateUrl: './claim.component.html',
@ -62,10 +60,10 @@ export class ClaimComponent {
private route: ActivatedRoute, private route: ActivatedRoute,
private claimManagementService: ClaimManagementService, private claimManagementService: ClaimManagementService,
private partyManagementService: PartyManagementService, private partyManagementService: PartyManagementService,
private notificationService: NotificationService,
private allowedClaimStatusesService: AllowedClaimStatusesService, private allowedClaimStatusesService: AllowedClaimStatusesService,
private dialogService: DialogService, private dialogService: DialogService,
private notificationErrorService: NotificationErrorService, private notificationErrorService: NotificationErrorService,
private destroyRef: DestroyRef,
) {} ) {}
reloadClaim() { reloadClaim() {
@ -81,7 +79,7 @@ export class ClaimComponent {
.open(AddModificationDialogComponent, { party, claim }) .open(AddModificationDialogComponent, { party, claim })
.afterClosed(), .afterClosed(),
), ),
untilDestroyed(this), takeUntilDestroyed(this.destroyRef),
) )
.subscribe((result) => { .subscribe((result) => {
if (result.status === DialogResponseStatus.Success) { if (result.status === DialogResponseStatus.Success) {
@ -99,7 +97,7 @@ export class ClaimComponent {
.open(ChangeStatusDialogComponent, { partyID: party.id, claim }) .open(ChangeStatusDialogComponent, { partyID: party.id, claim })
.afterClosed(), .afterClosed(),
), ),
untilDestroyed(this), takeUntilDestroyed(this.destroyRef),
) )
.subscribe((result) => { .subscribe((result) => {
if (result.status === DialogResponseStatus.Success) { if (result.status === DialogResponseStatus.Success) {

View File

@ -1,6 +1,6 @@
import { Component } from '@angular/core'; import { Component, DestroyRef } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { Validators, FormBuilder } from '@angular/forms'; import { Validators, FormBuilder } from '@angular/forms';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { Claim, ModificationUnit } from '@vality/domain-proto/claim_management'; import { Claim, ModificationUnit } from '@vality/domain-proto/claim_management';
import { Party } from '@vality/domain-proto/domain'; import { Party } from '@vality/domain-proto/domain';
import { ModificationChange, Modification } from '@vality/domain-proto/internal/claim_management'; import { ModificationChange, Modification } from '@vality/domain-proto/internal/claim_management';
@ -13,7 +13,6 @@ import { inProgressFrom, progressTo } from '@cc/utils';
import { NotificationErrorService } from '../../../../shared/services/notification-error'; import { NotificationErrorService } from '../../../../shared/services/notification-error';
@UntilDestroy()
@Component({ @Component({
selector: 'cc-add-modification-dialog', selector: 'cc-add-modification-dialog',
templateUrl: './add-modification-dialog.component.html', templateUrl: './add-modification-dialog.component.html',
@ -41,6 +40,7 @@ export class AddModificationDialogComponent extends DialogSuperclass<
private claimManagementService: ClaimManagementService, private claimManagementService: ClaimManagementService,
private notificationService: NotificationService, private notificationService: NotificationService,
private notificationErrorService: NotificationErrorService, private notificationErrorService: NotificationErrorService,
private destroyRef: DestroyRef,
) { ) {
super(); super();
} }
@ -49,7 +49,7 @@ export class AddModificationDialogComponent extends DialogSuperclass<
const { party, claim } = this.dialogData; const { party, claim } = this.dialogData;
this.claimManagementService this.claimManagementService
.UpdateClaim(party.id, claim.id, claim.revision, [this.control.value]) .UpdateClaim(party.id, claim.id, claim.revision, [this.control.value])
.pipe(progressTo(this.progress$), untilDestroyed(this)) .pipe(progressTo(this.progress$), takeUntilDestroyed(this.destroyRef))
.subscribe({ .subscribe({
next: () => { next: () => {
this.notificationService.success('Modification added successfully'); this.notificationService.success('Modification added successfully');
@ -69,7 +69,7 @@ export class AddModificationDialogComponent extends DialogSuperclass<
modificationUnit.modification_id, modificationUnit.modification_id,
this.control.value, this.control.value,
) )
.pipe(progressTo(this.progress$), untilDestroyed(this)) .pipe(progressTo(this.progress$), takeUntilDestroyed(this.destroyRef))
.subscribe({ .subscribe({
next: () => { next: () => {
this.notificationService.success('Modification updated successfully'); this.notificationService.success('Modification updated successfully');

View File

@ -1,6 +1,6 @@
import { Component } from '@angular/core'; import { Component, DestroyRef } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { Validators, FormBuilder } from '@angular/forms'; import { Validators, FormBuilder } from '@angular/forms';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { Claim, ClaimStatus } from '@vality/domain-proto/claim_management'; import { Claim, ClaimStatus } from '@vality/domain-proto/claim_management';
import { DialogResponseStatus, DialogSuperclass } from '@vality/ng-core'; import { DialogResponseStatus, DialogSuperclass } from '@vality/ng-core';
import { BehaviorSubject, Observable } from 'rxjs'; import { BehaviorSubject, Observable } from 'rxjs';
@ -12,7 +12,6 @@ import { getUnionKey, inProgressFrom, progressTo } from '@cc/utils';
import { NotificationErrorService } from '../../../../shared/services/notification-error'; import { NotificationErrorService } from '../../../../shared/services/notification-error';
@UntilDestroy()
@Component({ @Component({
selector: 'cc-change-status-dialog', selector: 'cc-change-status-dialog',
templateUrl: './change-status-dialog.component.html', templateUrl: './change-status-dialog.component.html',
@ -39,6 +38,7 @@ export class ChangeStatusDialogComponent extends DialogSuperclass<
private notificationService: NotificationService, private notificationService: NotificationService,
private allowedClaimStatusesService: AllowedClaimStatusesService, private allowedClaimStatusesService: AllowedClaimStatusesService,
private notificationErrorService: NotificationErrorService, private notificationErrorService: NotificationErrorService,
private destroyRef: DestroyRef,
) { ) {
super(); super();
} }
@ -65,7 +65,7 @@ export class ChangeStatusDialogComponent extends DialogSuperclass<
result$ = this.claimManagementService.RequestClaimChanges(...params); result$ = this.claimManagementService.RequestClaimChanges(...params);
break; break;
} }
result$.pipe(progressTo(this.progress$), untilDestroyed(this)).subscribe({ result$.pipe(progressTo(this.progress$), takeUntilDestroyed(this.destroyRef)).subscribe({
next: () => { next: () => {
this.dialogRef.close({ status: DialogResponseStatus.Success }); this.dialogRef.close({ status: DialogResponseStatus.Success });
this.notificationService.success('Status successfully changed'); this.notificationService.success('Status successfully changed');

View File

@ -1,5 +1,12 @@
import { Component, EventEmitter, Input, Output, booleanAttribute } from '@angular/core'; import {
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; Component,
EventEmitter,
Input,
Output,
booleanAttribute,
DestroyRef,
} from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { Claim, ModificationUnit } from '@vality/domain-proto/claim_management'; import { Claim, ModificationUnit } from '@vality/domain-proto/claim_management';
import { DialogResponseStatus, DialogService, ConfirmDialogComponent } from '@vality/ng-core'; import { DialogResponseStatus, DialogService, ConfirmDialogComponent } from '@vality/ng-core';
import isEmpty from 'lodash-es/isEmpty'; import isEmpty from 'lodash-es/isEmpty';
@ -18,7 +25,6 @@ import { getUnionValue } from '@cc/utils/get-union-key';
import { NotificationErrorService } from '../../../../shared/services/notification-error'; import { NotificationErrorService } from '../../../../shared/services/notification-error';
import { AddModificationDialogComponent } from '../add-modification-dialog/add-modification-dialog.component'; import { AddModificationDialogComponent } from '../add-modification-dialog/add-modification-dialog.component';
@UntilDestroy()
@Component({ @Component({
selector: 'cc-modification-unit-timeline-item', selector: 'cc-modification-unit-timeline-item',
templateUrl: './modification-unit-timeline-item.component.html', templateUrl: './modification-unit-timeline-item.component.html',
@ -48,6 +54,7 @@ export class ModificationUnitTimelineItemComponent {
private notificationService: NotificationService, private notificationService: NotificationService,
private domainMetadataViewExtensionsService: DomainMetadataViewExtensionsService, private domainMetadataViewExtensionsService: DomainMetadataViewExtensionsService,
private notificationErrorService: NotificationErrorService, private notificationErrorService: NotificationErrorService,
private destroyRef: DestroyRef,
) {} ) {}
get name() { get name() {
@ -72,7 +79,7 @@ export class ModificationUnitTimelineItemComponent {
}) })
.afterClosed(), .afterClosed(),
), ),
untilDestroyed(this), takeUntilDestroyed(this.destroyRef),
) )
.subscribe((result) => { .subscribe((result) => {
if (result.status === DialogResponseStatus.Success) { if (result.status === DialogResponseStatus.Success) {
@ -97,7 +104,7 @@ export class ModificationUnitTimelineItemComponent {
), ),
), ),
progressTo(this.progress$), progressTo(this.progress$),
untilDestroyed(this), takeUntilDestroyed(this.destroyRef),
) )
.subscribe({ .subscribe({
next: () => { next: () => {

View File

@ -1,6 +1,6 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit, DestroyRef } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { NonNullableFormBuilder } from '@angular/forms'; import { NonNullableFormBuilder } from '@angular/forms';
import { untilDestroyed, UntilDestroy } from '@ngneat/until-destroy';
import { PartyID } from '@vality/domain-proto/domain'; import { PartyID } from '@vality/domain-proto/domain';
import { DialogService, LoadOptions, QueryParamsService, clean } from '@vality/ng-core'; import { DialogService, LoadOptions, QueryParamsService, clean } from '@vality/ng-core';
import { debounceTime } from 'rxjs'; import { debounceTime } from 'rxjs';
@ -11,7 +11,6 @@ import { CLAIM_STATUSES } from '../../api/claim-management';
import { CreateClaimDialogComponent } from './components/create-claim-dialog/create-claim-dialog.component'; import { CreateClaimDialogComponent } from './components/create-claim-dialog/create-claim-dialog.component';
import { FetchClaimsService } from './fetch-claims.service'; import { FetchClaimsService } from './fetch-claims.service';
@UntilDestroy()
@Component({ @Component({
templateUrl: './claims.component.html', templateUrl: './claims.component.html',
}) })
@ -34,12 +33,13 @@ export class ClaimsComponent implements OnInit {
private dialogService: DialogService, private dialogService: DialogService,
private fb: NonNullableFormBuilder, private fb: NonNullableFormBuilder,
private qp: QueryParamsService<ClaimsComponent['filtersForm']['value']>, private qp: QueryParamsService<ClaimsComponent['filtersForm']['value']>,
private destroyRef: DestroyRef,
) {} ) {}
ngOnInit(): void { ngOnInit(): void {
this.filtersForm.patchValue(this.qp.params); this.filtersForm.patchValue(this.qp.params);
this.filtersForm.valueChanges this.filtersForm.valueChanges
.pipe(startWith(null), debounceTime(500), untilDestroyed(this)) .pipe(startWith(null), debounceTime(500), takeUntilDestroyed(this.destroyRef))
.subscribe(() => { .subscribe(() => {
this.load(); this.load();
}); });

View File

@ -1,7 +1,7 @@
import { Component } from '@angular/core'; import { Component, DestroyRef } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { FormControl, Validators } from '@angular/forms'; import { FormControl, Validators } from '@angular/forms';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { untilDestroyed, UntilDestroy } from '@ngneat/until-destroy';
import { DialogSuperclass } from '@vality/ng-core'; import { DialogSuperclass } from '@vality/ng-core';
import { BehaviorSubject } from 'rxjs'; import { BehaviorSubject } from 'rxjs';
@ -10,7 +10,6 @@ import { NotificationService } from '@cc/app/shared/services/notification';
import { NotificationErrorService } from '@cc/app/shared/services/notification-error'; import { NotificationErrorService } from '@cc/app/shared/services/notification-error';
import { progressTo } from '@cc/utils'; import { progressTo } from '@cc/utils';
@UntilDestroy()
@Component({ @Component({
selector: 'cc-create-claim-dialog', selector: 'cc-create-claim-dialog',
templateUrl: './create-claim-dialog.component.html', templateUrl: './create-claim-dialog.component.html',
@ -27,6 +26,7 @@ export class CreateClaimDialogComponent extends DialogSuperclass<
private notificationService: NotificationService, private notificationService: NotificationService,
private notificationErrorService: NotificationErrorService, private notificationErrorService: NotificationErrorService,
private router: Router, private router: Router,
private destroyRef: DestroyRef,
) { ) {
super(); super();
} }
@ -34,7 +34,7 @@ export class CreateClaimDialogComponent extends DialogSuperclass<
create() { create() {
this.claimService this.claimService
.CreateClaim(this.control.value, []) .CreateClaim(this.control.value, [])
.pipe(progressTo(this.progress$), untilDestroyed(this)) .pipe(progressTo(this.progress$), takeUntilDestroyed(this.destroyRef))
.subscribe({ .subscribe({
next: (claim) => { next: (claim) => {
this.notificationService.success('Claim successfully created'); this.notificationService.success('Claim successfully created');

View File

@ -1,11 +1,9 @@
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core'; import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { UntilDestroy } from '@ngneat/until-destroy';
import { pluck, take } from 'rxjs/operators'; import { pluck, take } from 'rxjs/operators';
import { ReceiveDepositService } from './services/receive-deposit/receive-deposit.service'; import { ReceiveDepositService } from './services/receive-deposit/receive-deposit.service';
@UntilDestroy()
@Component({ @Component({
templateUrl: 'deposit-details.component.html', templateUrl: 'deposit-details.component.html',
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,

View File

@ -1,6 +1,6 @@
import { ChangeDetectionStrategy, Component } from '@angular/core'; import { ChangeDetectionStrategy, Component, DestroyRef } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { Validators, NonNullableFormBuilder } from '@angular/forms'; import { Validators, NonNullableFormBuilder } from '@angular/forms';
import { untilDestroyed, UntilDestroy } from '@ngneat/until-destroy';
import { Revert } from '@vality/fistful-proto/internal/deposit_revert'; import { Revert } from '@vality/fistful-proto/internal/deposit_revert';
import { DialogSuperclass, NotifyLogService, toMinor, clean } from '@vality/ng-core'; import { DialogSuperclass, NotifyLogService, toMinor, clean } from '@vality/ng-core';
import { BehaviorSubject } from 'rxjs'; import { BehaviorSubject } from 'rxjs';
@ -11,7 +11,6 @@ import { UserInfoBasedIdGeneratorService } from '../../../../shared/services';
import { CreateRevertDialogConfig } from './types/create-revert-dialog-config'; import { CreateRevertDialogConfig } from './types/create-revert-dialog-config';
@UntilDestroy()
@Component({ @Component({
templateUrl: 'create-revert-dialog.component.html', templateUrl: 'create-revert-dialog.component.html',
styleUrls: ['create-revert-dialog.component.scss'], styleUrls: ['create-revert-dialog.component.scss'],
@ -35,6 +34,7 @@ export class CreateRevertDialogComponent extends DialogSuperclass<
private depositManagementService: ManagementService, private depositManagementService: ManagementService,
private idGenerator: UserInfoBasedIdGeneratorService, private idGenerator: UserInfoBasedIdGeneratorService,
private log: NotifyLogService, private log: NotifyLogService,
private destroyRef: DestroyRef,
) { ) {
super(); super();
} }
@ -60,7 +60,7 @@ export class CreateRevertDialogComponent extends DialogSuperclass<
true, true,
), ),
) )
.pipe(untilDestroyed(this)) .pipe(takeUntilDestroyed(this.destroyRef))
.subscribe({ .subscribe({
next: (revert) => { next: (revert) => {
this.log.successOperation('create', 'revert'); this.log.successOperation('create', 'revert');

View File

@ -1,13 +1,12 @@
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core'; import { ChangeDetectionStrategy, Component, OnInit, DestroyRef } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { UntypedFormGroup } from '@angular/forms'; import { UntypedFormGroup } from '@angular/forms';
import { MatSnackBar } from '@angular/material/snack-bar'; import { MatSnackBar } from '@angular/material/snack-bar';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { StatDeposit } from '@vality/fistful-proto/fistful_stat'; import { StatDeposit } from '@vality/fistful-proto/fistful_stat';
import { DialogSuperclass } from '@vality/ng-core'; import { DialogSuperclass } from '@vality/ng-core';
import { CreateDepositService } from './services/create-deposit/create-deposit.service'; import { CreateDepositService } from './services/create-deposit/create-deposit.service';
@UntilDestroy()
@Component({ @Component({
templateUrl: 'create-deposit-dialog.component.html', templateUrl: 'create-deposit-dialog.component.html',
styleUrls: ['create-deposit-dialog.component.scss'], styleUrls: ['create-deposit-dialog.component.scss'],
@ -28,6 +27,7 @@ export class CreateDepositDialogComponent
constructor( constructor(
private createDepositService: CreateDepositService, private createDepositService: CreateDepositService,
private snackBar: MatSnackBar, private snackBar: MatSnackBar,
private destroyRef: DestroyRef,
) { ) {
super(); super();
} }
@ -39,17 +39,17 @@ export class CreateDepositDialogComponent
this.closeWithSuccess(deposit); this.closeWithSuccess(deposit);
this.form.enable(); this.form.enable();
}); });
this.error$.pipe(untilDestroyed(this)).subscribe(() => { this.error$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {
this.snackBar.open('An error occurred while deposit create', 'OK'); this.snackBar.open('An error occurred while deposit create', 'OK');
this.closeWithError(); this.closeWithError();
this.form.enable(); this.form.enable();
}); });
this.pollingError$.pipe(untilDestroyed(this)).subscribe(() => { this.pollingError$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {
this.snackBar.open('An error occurred while deposit polling', 'OK'); this.snackBar.open('An error occurred while deposit polling', 'OK');
this.closeWithError(); this.closeWithError();
this.form.enable(); this.form.enable();
}); });
this.pollingTimeout$.pipe(untilDestroyed(this)).subscribe(() => { this.pollingTimeout$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {
this.snackBar.open('Polling timeout error', 'OK'); this.snackBar.open('Polling timeout error', 'OK');
this.closeWithError(); this.closeWithError();
this.form.enable(); this.form.enable();

View File

@ -1,7 +1,7 @@
import { ChangeDetectionStrategy, Component, OnInit, Inject } from '@angular/core'; import { ChangeDetectionStrategy, Component, OnInit, Inject, DestroyRef } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { FormBuilder } from '@angular/forms'; import { FormBuilder } from '@angular/forms';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { StatDeposit, RevertStatus } from '@vality/fistful-proto/fistful_stat'; import { StatDeposit, RevertStatus } from '@vality/fistful-proto/fistful_stat';
import { import {
Column, Column,
@ -34,7 +34,6 @@ const REVERT_STATUS: { [N in RevertStatus]: string } = {
2: 'full', 2: 'full',
}; };
@UntilDestroy()
@Component({ @Component({
templateUrl: 'deposits.component.html', templateUrl: 'deposits.component.html',
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
@ -125,6 +124,7 @@ export class DepositsComponent implements OnInit {
@Inject(DATE_RANGE_DAYS) private dateRangeDays: number, @Inject(DATE_RANGE_DAYS) private dateRangeDays: number,
@Inject(DEBOUNCE_TIME_MS) private debounceTimeMs: number, @Inject(DEBOUNCE_TIME_MS) private debounceTimeMs: number,
private qp: QueryParamsService<object>, private qp: QueryParamsService<object>,
private destroyRef: DestroyRef,
) {} ) {}
ngOnInit() { ngOnInit() {
@ -133,7 +133,7 @@ export class DepositsComponent implements OnInit {
.pipe( .pipe(
startWith(this.filtersForm.value), startWith(this.filtersForm.value),
debounceTime(this.debounceTimeMs), debounceTime(this.debounceTimeMs),
untilDestroyed(this), takeUntilDestroyed(this.destroyRef),
) )
.subscribe(() => { .subscribe(() => {
this.update(); this.update();
@ -146,7 +146,7 @@ export class DepositsComponent implements OnInit {
.afterClosed() .afterClosed()
.pipe( .pipe(
filter((res) => res.status === DialogResponseStatus.Success), filter((res) => res.status === DialogResponseStatus.Success),
untilDestroyed(this), takeUntilDestroyed(this.destroyRef),
) )
.subscribe(() => { .subscribe(() => {
this.update(); this.update();

View File

@ -1,9 +1,7 @@
import { Component } from '@angular/core'; import { Component } from '@angular/core';
import { UntilDestroy } from '@ngneat/until-destroy';
import { DomainStoreService } from '@cc/app/api/domain-config'; import { DomainStoreService } from '@cc/app/api/domain-config';
@UntilDestroy()
@Component({ @Component({
templateUrl: './domain-info.component.html', templateUrl: './domain-info.component.html',
styleUrls: ['./domain-info.component.scss'], styleUrls: ['./domain-info.component.scss'],

View File

@ -10,8 +10,6 @@ import { MatSnackBarModule } from '@angular/material/snack-bar';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
import { PipesModule, ActionsModule } from '@vality/ng-core'; import { PipesModule, ActionsModule } from '@vality/ng-core';
import { MonacoEditorModule } from '@cc/components/monaco-editor';
import { ThriftPipesModule, PageLayoutModule } from '../../../shared'; import { ThriftPipesModule, PageLayoutModule } from '../../../shared';
import { DomainThriftViewerComponent } from '../../../shared/components/thrift-api-crud'; import { DomainThriftViewerComponent } from '../../../shared/components/thrift-api-crud';
import { ThriftViewerModule } from '../../../shared/components/thrift-viewer'; import { ThriftViewerModule } from '../../../shared/components/thrift-viewer';
@ -31,7 +29,6 @@ import { DomainObjectsTableComponent } from './domain-objects-table';
MatButtonModule, MatButtonModule,
MatInputModule, MatInputModule,
MatProgressSpinnerModule, MatProgressSpinnerModule,
MonacoEditorModule,
ThriftViewerModule, ThriftViewerModule,
PipesModule, PipesModule,
RouterModule, RouterModule,

View File

@ -3,7 +3,6 @@ import { Component, OnInit } from '@angular/core';
import { FormControl, ReactiveFormsModule } from '@angular/forms'; import { FormControl, ReactiveFormsModule } from '@angular/forms';
import { MatButtonModule } from '@angular/material/button'; import { MatButtonModule } from '@angular/material/button';
import { Sort } from '@angular/material/sort'; import { Sort } from '@angular/material/sort';
import { UntilDestroy } from '@ngneat/until-destroy';
import { Reference, DomainObject } from '@vality/domain-proto/domain'; import { Reference, DomainObject } from '@vality/domain-proto/domain';
import { import {
QueryParamsService, QueryParamsService,
@ -35,7 +34,6 @@ interface DomainObjectData {
obj: DomainObject; obj: DomainObject;
} }
@UntilDestroy()
@Component({ @Component({
standalone: true, standalone: true,
selector: 'cc-domain-objects-table', selector: 'cc-domain-objects-table',
@ -81,22 +79,22 @@ export class DomainObjectsTableComponent implements OnInit {
}, },
{ {
field: 'name', field: 'name',
formatter: (d: DomainObjectData) => getDomainObjectDetails(d.obj).label || d.type, formatter: (d: DomainObjectData) => getDomainObjectDetails(d.obj).label,
sortable: true, sortable: true,
click: (d) => { click: (d) => {
this.details(d); this.details(d);
}, },
}, },
{
field: 'description',
formatter: (d: DomainObjectData) => getDomainObjectDetails(d.obj).description,
sortable: true,
},
{ {
field: 'type', field: 'type',
sortable: true, sortable: true,
formatter: (d) => startCase(d.type), formatter: (d) => startCase(d.type),
}, },
// {
// field: 'data',
// formatter: (d) => inlineJson(getUnionValue(d.obj)?.data, Infinity),
// sortable: true,
// },
createOperationColumn([ createOperationColumn([
{ {
label: 'Details', label: 'Details',

View File

@ -1,6 +1,6 @@
import { Component } from '@angular/core'; import { Component, DestroyRef } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { FormControl, Validators } from '@angular/forms'; import { FormControl, Validators } from '@angular/forms';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { DomainObject } from '@vality/domain-proto/domain'; import { DomainObject } from '@vality/domain-proto/domain';
import { NotifyLogService } from '@vality/ng-core'; import { NotifyLogService } from '@vality/ng-core';
import { BehaviorSubject } from 'rxjs'; import { BehaviorSubject } from 'rxjs';
@ -15,7 +15,6 @@ import { NotificationService } from '../../../shared/services/notification';
import { DomainNavigateService } from '../services/domain-navigate.service'; import { DomainNavigateService } from '../services/domain-navigate.service';
import { MetadataService } from '../services/metadata.service'; import { MetadataService } from '../services/metadata.service';
@UntilDestroy()
@Component({ @Component({
templateUrl: './domain-obj-creation.component.html', templateUrl: './domain-obj-creation.component.html',
styleUrls: ['../editor-container.scss'], styleUrls: ['../editor-container.scss'],
@ -37,6 +36,7 @@ export class DomainObjCreationComponent {
private log: NotifyLogService, private log: NotifyLogService,
private domainNavigateService: DomainNavigateService, private domainNavigateService: DomainNavigateService,
private metadataService: MetadataService, private metadataService: MetadataService,
private destroyRef: DestroyRef,
) {} ) {}
reviewChanges() { reviewChanges() {
@ -51,7 +51,7 @@ export class DomainObjCreationComponent {
this.metadataService.getDomainFieldByFieldName(getUnionKey(this.control.value)), this.metadataService.getDomainFieldByFieldName(getUnionKey(this.control.value)),
), ),
progressTo(this.progress$), progressTo(this.progress$),
untilDestroyed(this), takeUntilDestroyed(this.destroyRef),
) )
.subscribe({ .subscribe({
next: ([, field]) => { next: ([, field]) => {

View File

@ -10,7 +10,6 @@ import { RouterModule } from '@angular/router';
import { ActionsModule } from '@vality/ng-core'; import { ActionsModule } from '@vality/ng-core';
import { ThriftEditorModule } from '@cc/app/shared/components/thrift-editor'; import { ThriftEditorModule } from '@cc/app/shared/components/thrift-editor';
import { MonacoEditorModule } from '@cc/components/monaco-editor';
import { PageLayoutModule } from '../../../shared'; import { PageLayoutModule } from '../../../shared';
import { ThriftViewerModule } from '../../../shared/components/thrift-viewer'; import { ThriftViewerModule } from '../../../shared/components/thrift-viewer';
@ -26,7 +25,6 @@ import { DomainObjCreationComponent } from './domain-obj-creation.component';
MatCardModule, MatCardModule,
MatButtonModule, MatButtonModule,
MatIconModule, MatIconModule,
MonacoEditorModule,
MatDialogModule, MatDialogModule,
ReactiveFormsModule, ReactiveFormsModule,
ThriftEditorModule, ThriftEditorModule,

View File

@ -1,37 +0,0 @@
import {
CancellationToken,
CodeLens,
CodeLensList,
CodeLensProvider,
ITextModel,
ProviderResult,
} from '@cc/components/monaco-editor';
export class DomainObjCodeLensProvider implements CodeLensProvider {
get language() {
return 'json';
}
provideCodeLenses(model: ITextModel): ProviderResult<CodeLensList> {
const range = monaco.Range.fromPositions(model.getPositionAt(5), model.getPositionAt(8));
return {
lenses: [
{
range,
id: 'First Line',
command: {
id: null,
title: 'DomainRef',
},
},
],
// eslint-disable-next-line @typescript-eslint/no-empty-function
dispose: () => {},
};
}
resolveCodeLens?(
model: ITextModel,
codeLens: CodeLens,
token: CancellationToken,
): ProviderResult<CodeLens>;
}

View File

@ -1,33 +0,0 @@
import {
CompletionList,
CompletionProvider,
ITextModel,
Position,
ProviderResult,
} from '@cc/components/monaco-editor';
export class DomainObjCompletionProvider implements CompletionProvider {
get language() {
return 'json';
}
provideCompletionItems(model: ITextModel, position: Position): ProviderResult<CompletionList> {
const word = model.getWordUntilPosition(position);
const range = {
startLineNumber: position.lineNumber,
endLineNumber: position.lineNumber,
startColumn: word.startColumn,
endColumn: word.endColumn,
};
return {
suggestions: [
{
label: 'test',
kind: monaco.languages.CompletionItemKind.Text,
insertText: 'Test value',
range,
},
],
};
}
}

View File

@ -6,8 +6,6 @@
<mat-card> <mat-card>
<mat-card-content class="content"> <mat-card-content class="content">
<cc-thrift-editor <cc-thrift-editor
[codeLensProviders]="codeLensProviders"
[completionProviders]="completionProviders"
[defaultValue]="object$ | async" [defaultValue]="object$ | async"
[extensions]="extensions$ | async" [extensions]="extensions$ | async"
[formControl]="control" [formControl]="control"

View File

@ -1,21 +1,15 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit, DestroyRef } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { FormControl } from '@angular/forms'; import { FormControl } from '@angular/forms';
import { Router, ActivatedRoute } from '@angular/router'; import { Router, ActivatedRoute } from '@angular/router';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { from } from 'rxjs'; import { from } from 'rxjs';
import { first } from 'rxjs/operators'; import { first } from 'rxjs/operators';
import { CodeLensProvider, CompletionProvider } from '@cc/components/monaco-editor';
import { DomainMetadataFormExtensionsService } from '../../../shared/services'; import { DomainMetadataFormExtensionsService } from '../../../shared/services';
import { DomainNavigateService } from '../services/domain-navigate.service'; import { DomainNavigateService } from '../services/domain-navigate.service';
import { DomainObjModificationService } from '../services/domain-obj-modification.service'; import { DomainObjModificationService } from '../services/domain-obj-modification.service';
import { ModifiedDomainObjectService } from '../services/modified-domain-object.service'; import { ModifiedDomainObjectService } from '../services/modified-domain-object.service';
import { DomainObjCodeLensProvider } from './domain-obj-code-lens-provider';
import { DomainObjCompletionProvider } from './domain-obj-completion-provider';
@UntilDestroy()
@Component({ @Component({
templateUrl: './domain-obj-modification.component.html', templateUrl: './domain-obj-modification.component.html',
styleUrls: ['../editor-container.scss'], styleUrls: ['../editor-container.scss'],
@ -25,8 +19,6 @@ export class DomainObjModificationComponent implements OnInit {
control = new FormControl(); control = new FormControl();
progress$ = this.domainObjModService.progress$; progress$ = this.domainObjModService.progress$;
codeLensProviders: CodeLensProvider[] = [new DomainObjCodeLensProvider()];
completionProviders: CompletionProvider[] = [new DomainObjCompletionProvider()];
metadata$ = from(import('@vality/domain-proto/metadata.json').then((m) => m.default)); metadata$ = from(import('@vality/domain-proto/metadata.json').then((m) => m.default));
object$ = this.domainObjModService.object$; object$ = this.domainObjModService.object$;
type$ = this.domainObjModService.type$; type$ = this.domainObjModService.type$;
@ -39,10 +31,13 @@ export class DomainObjModificationComponent implements OnInit {
private modifiedDomainObjectService: ModifiedDomainObjectService, private modifiedDomainObjectService: ModifiedDomainObjectService,
private domainMetadataFormExtensionsService: DomainMetadataFormExtensionsService, private domainMetadataFormExtensionsService: DomainMetadataFormExtensionsService,
private domainNavigateService: DomainNavigateService, private domainNavigateService: DomainNavigateService,
private destroyRef: DestroyRef,
) {} ) {}
ngOnInit() { ngOnInit() {
this.domainObjModService.object$.pipe(first(), untilDestroyed(this)).subscribe((object) => { this.domainObjModService.object$
.pipe(first(), takeUntilDestroyed(this.destroyRef))
.subscribe((object) => {
if ( if (
this.modifiedDomainObjectService.domainObject && this.modifiedDomainObjectService.domainObject &&
this.route.snapshot.queryParams.ref === this.modifiedDomainObjectService.ref this.route.snapshot.queryParams.ref === this.modifiedDomainObjectService.ref

View File

@ -10,7 +10,6 @@ import { RouterModule } from '@angular/router';
import { ActionsModule } from '@vality/ng-core'; import { ActionsModule } from '@vality/ng-core';
import { ThriftEditorModule } from '@cc/app/shared/components/thrift-editor'; import { ThriftEditorModule } from '@cc/app/shared/components/thrift-editor';
import { MonacoEditorModule } from '@cc/components/monaco-editor';
import { PageLayoutModule } from '../../../shared'; import { PageLayoutModule } from '../../../shared';
@ -26,7 +25,6 @@ import { DomainObjModificationComponent } from './domain-obj-modification.compon
MatCardModule, MatCardModule,
MatButtonModule, MatButtonModule,
MatIconModule, MatIconModule,
MonacoEditorModule,
MatDialogModule, MatDialogModule,
ReactiveFormsModule, ReactiveFormsModule,
ThriftEditorModule, ThriftEditorModule,

View File

@ -1,6 +1,6 @@
import { Component } from '@angular/core'; import { Component, DestroyRef } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { Router, ActivatedRoute } from '@angular/router'; import { Router, ActivatedRoute } from '@angular/router';
import { untilDestroyed, UntilDestroy } from '@ngneat/until-destroy';
import { switchMap } from 'rxjs'; import { switchMap } from 'rxjs';
import { first, withLatestFrom } from 'rxjs/operators'; import { first, withLatestFrom } from 'rxjs/operators';
@ -14,7 +14,6 @@ import { DomainNavigateService } from '../services/domain-navigate.service';
import { DomainObjModificationService } from '../services/domain-obj-modification.service'; import { DomainObjModificationService } from '../services/domain-obj-modification.service';
import { ModifiedDomainObjectService } from '../services/modified-domain-object.service'; import { ModifiedDomainObjectService } from '../services/modified-domain-object.service';
@UntilDestroy()
@Component({ @Component({
templateUrl: './domain-obj-review.component.html', templateUrl: './domain-obj-review.component.html',
styleUrls: ['../editor-container.scss'], styleUrls: ['../editor-container.scss'],
@ -36,6 +35,7 @@ export class DomainObjReviewComponent {
private notificationErrorService: NotificationErrorService, private notificationErrorService: NotificationErrorService,
private domainNavigateService: DomainNavigateService, private domainNavigateService: DomainNavigateService,
private domainSecretService: DomainSecretService, private domainSecretService: DomainSecretService,
private destroyRef: DestroyRef,
) { ) {
if (!modifiedDomainObjectService.domainObject) { if (!modifiedDomainObjectService.domainObject) {
this.back(); this.back();
@ -62,7 +62,7 @@ export class DomainObjReviewComponent {
}), }),
), ),
withLatestFrom(this.type$), withLatestFrom(this.type$),
untilDestroyed(this), takeUntilDestroyed(this.destroyRef),
) )
.subscribe({ .subscribe({
next: ([, type]) => { next: ([, type]) => {

View File

@ -9,8 +9,6 @@ import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
import { ActionsModule } from '@vality/ng-core'; import { ActionsModule } from '@vality/ng-core';
import { MonacoEditorModule } from '@cc/components/monaco-editor';
import { PageLayoutModule } from '../../../shared'; import { PageLayoutModule } from '../../../shared';
import { ThriftEditorModule } from '../../../shared/components/thrift-editor'; import { ThriftEditorModule } from '../../../shared/components/thrift-editor';
import { ThriftViewerModule } from '../../../shared/components/thrift-viewer'; import { ThriftViewerModule } from '../../../shared/components/thrift-viewer';
@ -26,7 +24,6 @@ import { DomainObjReviewComponent } from './domain-obj-review.component';
MatCardModule, MatCardModule,
MatButtonModule, MatButtonModule,
MatCheckboxModule, MatCheckboxModule,
MonacoEditorModule,
MatIconModule, MatIconModule,
ThriftEditorModule, ThriftEditorModule,
MatProgressSpinnerModule, MatProgressSpinnerModule,

View File

@ -1,9 +0,0 @@
import * as short from 'short-uuid';
import { MonacoFile } from '@cc/components/monaco-editor';
export const toMonacoFile = (content: string): MonacoFile => ({
uri: `${short().uuid()}.json`,
language: 'json',
content,
});

View File

@ -1,6 +1,6 @@
import { Component } from '@angular/core'; import { Component, DestroyRef } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { FormControl } from '@angular/forms'; import { FormControl } from '@angular/forms';
import { untilDestroyed, UntilDestroy } from '@ngneat/until-destroy';
import { InvoicePaymentChargeback } from '@vality/domain-proto/domain'; import { InvoicePaymentChargeback } from '@vality/domain-proto/domain';
import { InvoicePaymentChargebackParams } from '@vality/domain-proto/payment_processing'; import { InvoicePaymentChargebackParams } from '@vality/domain-proto/payment_processing';
import { DialogSuperclass } from '@vality/ng-core'; import { DialogSuperclass } from '@vality/ng-core';
@ -12,7 +12,6 @@ import { DomainMetadataFormExtensionsService } from '@cc/app/shared/services';
import { NotificationService } from '@cc/app/shared/services/notification'; import { NotificationService } from '@cc/app/shared/services/notification';
import { NotificationErrorService } from '@cc/app/shared/services/notification-error'; import { NotificationErrorService } from '@cc/app/shared/services/notification-error';
@UntilDestroy()
@Component({ @Component({
selector: 'cc-create-chargeback-dialog', selector: 'cc-create-chargeback-dialog',
templateUrl: './create-chargeback-dialog.component.html', templateUrl: './create-chargeback-dialog.component.html',
@ -31,6 +30,7 @@ export class CreateChargebackDialogComponent extends DialogSuperclass<
private domainMetadataFormExtensionsService: DomainMetadataFormExtensionsService, private domainMetadataFormExtensionsService: DomainMetadataFormExtensionsService,
private notificationErrorService: NotificationErrorService, private notificationErrorService: NotificationErrorService,
private notificationService: NotificationService, private notificationService: NotificationService,
private destroyRef: DestroyRef,
) { ) {
super(); super();
} }
@ -42,7 +42,7 @@ export class CreateChargebackDialogComponent extends DialogSuperclass<
this.dialogData.paymentID, this.dialogData.paymentID,
this.form.value as InvoicePaymentChargebackParams, this.form.value as InvoicePaymentChargebackParams,
) )
.pipe(untilDestroyed(this)) .pipe(takeUntilDestroyed(this.destroyRef))
.subscribe({ .subscribe({
next: (res) => { next: (res) => {
this.notificationService.success('Chargeback created'); this.notificationService.success('Chargeback created');

View File

@ -1,6 +1,6 @@
import { ChangeDetectionStrategy, Component } from '@angular/core'; import { ChangeDetectionStrategy, Component, DestroyRef } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { untilDestroyed, UntilDestroy } from '@ngneat/until-destroy';
import { ThriftAstMetadata } from '@vality/domain-proto'; import { ThriftAstMetadata } from '@vality/domain-proto';
import { DialogService, DialogResponseStatus } from '@vality/ng-core'; import { DialogService, DialogResponseStatus } from '@vality/ng-core';
import { Subject, merge, defer, from } from 'rxjs'; import { Subject, merge, defer, from } from 'rxjs';
@ -11,7 +11,6 @@ import { InvoicingService } from '@cc/app/api/payment-processing';
import { CreateChargebackDialogComponent } from './create-chargeback-dialog/create-chargeback-dialog.component'; import { CreateChargebackDialogComponent } from './create-chargeback-dialog/create-chargeback-dialog.component';
import { PaymentDetailsService } from './payment-details.service'; import { PaymentDetailsService } from './payment-details.service';
@UntilDestroy()
@Component({ @Component({
templateUrl: 'payment-details.component.html', templateUrl: 'payment-details.component.html',
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
@ -44,6 +43,7 @@ export class PaymentDetailsComponent {
private route: ActivatedRoute, private route: ActivatedRoute,
private invoicingService: InvoicingService, private invoicingService: InvoicingService,
private dialogService: DialogService, private dialogService: DialogService,
private destroyRef: DestroyRef,
) {} ) {}
createChargeback() { createChargeback() {
@ -53,7 +53,7 @@ export class PaymentDetailsComponent {
this.route.snapshot.params as Record<'invoiceID' | 'paymentID', string>, this.route.snapshot.params as Record<'invoiceID' | 'paymentID', string>,
) )
.afterClosed() .afterClosed()
.pipe(untilDestroyed(this)) .pipe(takeUntilDestroyed(this.destroyRef))
.subscribe(({ status }) => { .subscribe(({ status }) => {
if (status === DialogResponseStatus.Success) { if (status === DialogResponseStatus.Success) {
this.updateChargebacks$.next(); this.updateChargebacks$.next();

View File

@ -1,6 +1,6 @@
import { Component } from '@angular/core'; import { Component, DestroyRef } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { FormControl } from '@angular/forms'; import { FormControl } from '@angular/forms';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { InvoicePaymentAdjustmentParams } from '@vality/domain-proto/payment_processing'; import { InvoicePaymentAdjustmentParams } from '@vality/domain-proto/payment_processing';
import { StatPayment } from '@vality/magista-proto/magista'; import { StatPayment } from '@vality/magista-proto/magista';
import { import {
@ -16,7 +16,6 @@ import { DomainMetadataFormExtensionsService } from '@cc/app/shared/services';
import { InvoicingService } from '../../../../api/payment-processing'; import { InvoicingService } from '../../../../api/payment-processing';
@UntilDestroy()
@Component({ @Component({
selector: 'cc-create-payment-adjustment', selector: 'cc-create-payment-adjustment',
templateUrl: './create-payment-adjustment.component.html', templateUrl: './create-payment-adjustment.component.html',
@ -36,6 +35,7 @@ export class CreatePaymentAdjustmentComponent extends DialogSuperclass<
private invoicingService: InvoicingService, private invoicingService: InvoicingService,
private log: NotifyLogService, private log: NotifyLogService,
private domainMetadataFormExtensionsService: DomainMetadataFormExtensionsService, private domainMetadataFormExtensionsService: DomainMetadataFormExtensionsService,
private destroyRef: DestroyRef,
) { ) {
super(); super();
} }
@ -56,7 +56,7 @@ export class CreatePaymentAdjustmentComponent extends DialogSuperclass<
this.progress$, this.progress$,
payments, payments,
) )
.pipe(untilDestroyed(this)) .pipe(takeUntilDestroyed(this.destroyRef))
.subscribe((res) => { .subscribe((res) => {
const [result, errors] = splitResultsErrors(res); const [result, errors] = splitResultsErrors(res);
if (errors.length) { if (errors.length) {

View File

@ -1,6 +1,6 @@
import { Component, OnInit, Inject } from '@angular/core'; import { Component, OnInit, Inject, DestroyRef } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { NonNullableFormBuilder } from '@angular/forms'; import { NonNullableFormBuilder } from '@angular/forms';
import { untilDestroyed, UntilDestroy } from '@ngneat/until-destroy';
import { ThriftAstMetadata } from '@vality/fistful-proto'; import { ThriftAstMetadata } from '@vality/fistful-proto';
import { PaymentSearchQuery, StatPayment } from '@vality/magista-proto/magista'; import { PaymentSearchQuery, StatPayment } from '@vality/magista-proto/magista';
import { import {
@ -28,7 +28,6 @@ import { DATE_RANGE_DAYS } from '../../tokens';
import { CreatePaymentAdjustmentComponent } from './components/create-payment-adjustment/create-payment-adjustment.component'; import { CreatePaymentAdjustmentComponent } from './components/create-payment-adjustment/create-payment-adjustment.component';
import { FetchPaymentsService } from './services/fetch-payments.service'; import { FetchPaymentsService } from './services/fetch-payments.service';
@UntilDestroy()
@Component({ @Component({
templateUrl: 'payments.component.html', templateUrl: 'payments.component.html',
}) })
@ -82,6 +81,7 @@ export class PaymentsComponent implements OnInit {
private dialogService: DialogService, private dialogService: DialogService,
private fb: NonNullableFormBuilder, private fb: NonNullableFormBuilder,
@Inject(DATE_RANGE_DAYS) private dateRangeDays: number, @Inject(DATE_RANGE_DAYS) private dateRangeDays: number,
private destroyRef: DestroyRef,
) {} ) {}
ngOnInit() { ngOnInit() {
@ -92,7 +92,7 @@ export class PaymentsComponent implements OnInit {
const otherFiltersParams: Partial<PaymentSearchQuery> = this.qp.params.otherFilters || {}; const otherFiltersParams: Partial<PaymentSearchQuery> = this.qp.params.otherFilters || {};
this.otherFiltersControl.patchValue(lodashMerge({}, otherFilters, otherFiltersParams)); this.otherFiltersControl.patchValue(lodashMerge({}, otherFilters, otherFiltersParams));
merge(this.filtersForm.valueChanges, this.otherFiltersControl.valueChanges) merge(this.filtersForm.valueChanges, this.otherFiltersControl.valueChanges)
.pipe(startWith(null), debounceTime(500), untilDestroyed(this)) .pipe(startWith(null), debounceTime(500), takeUntilDestroyed(this.destroyRef))
.subscribe(() => { .subscribe(() => {
this.load(); this.load();
}); });

View File

@ -1,6 +1,6 @@
import { Component } from '@angular/core'; import { Component, DestroyRef } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { FormControl } from '@angular/forms'; import { FormControl } from '@angular/forms';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { DialogResponseStatus, DialogSuperclass } from '@vality/ng-core'; import { DialogResponseStatus, DialogSuperclass } from '@vality/ng-core';
import { PayoutID } from '@vality/payout-manager-proto/payout_manager'; import { PayoutID } from '@vality/payout-manager-proto/payout_manager';
import { BehaviorSubject } from 'rxjs'; import { BehaviorSubject } from 'rxjs';
@ -11,7 +11,6 @@ import { progressTo } from '@cc/utils/operators';
import { NotificationErrorService } from '../../../../../shared/services/notification-error'; import { NotificationErrorService } from '../../../../../shared/services/notification-error';
@UntilDestroy()
@Component({ @Component({
selector: 'cc-cancel-payout-dialog', selector: 'cc-cancel-payout-dialog',
templateUrl: './cancel-payout-dialog.component.html', templateUrl: './cancel-payout-dialog.component.html',
@ -27,6 +26,7 @@ export class CancelPayoutDialogComponent extends DialogSuperclass<
private payoutManagementService: PayoutManagementService, private payoutManagementService: PayoutManagementService,
private notificationService: NotificationService, private notificationService: NotificationService,
private notificationErrorService: NotificationErrorService, private notificationErrorService: NotificationErrorService,
private destroyRef: DestroyRef,
) { ) {
super(); super();
} }
@ -34,7 +34,7 @@ export class CancelPayoutDialogComponent extends DialogSuperclass<
accept() { accept() {
this.payoutManagementService this.payoutManagementService
.CancelPayout(this.dialogData.id, this.detailsControl.value) .CancelPayout(this.dialogData.id, this.detailsControl.value)
.pipe(progressTo(this.progress$), untilDestroyed(this)) .pipe(progressTo(this.progress$), takeUntilDestroyed(this.destroyRef))
.subscribe({ .subscribe({
next: () => { next: () => {
this.dialogRef.close({ status: DialogResponseStatus.Success }); this.dialogRef.close({ status: DialogResponseStatus.Success });

View File

@ -1,6 +1,6 @@
import { ChangeDetectionStrategy, Component } from '@angular/core'; import { ChangeDetectionStrategy, Component, DestroyRef } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { FormBuilder } from '@angular/forms'; import { FormBuilder } from '@angular/forms';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { DialogResponseStatus, DialogSuperclass } from '@vality/ng-core'; import { DialogResponseStatus, DialogSuperclass } from '@vality/ng-core';
import { PayoutParams } from '@vality/payout-manager-proto/payout_manager'; import { PayoutParams } from '@vality/payout-manager-proto/payout_manager';
import isNil from 'lodash-es/isNil'; import isNil from 'lodash-es/isNil';
@ -22,7 +22,6 @@ interface CreatePayoutDialogForm {
payoutToolId?: string; payoutToolId?: string;
} }
@UntilDestroy()
@Component({ @Component({
selector: 'cc-create-payout-dialog', selector: 'cc-create-payout-dialog',
templateUrl: './create-payout-dialog.component.html', templateUrl: './create-payout-dialog.component.html',
@ -43,6 +42,7 @@ export class CreatePayoutDialogComponent extends DialogSuperclass<CreatePayoutDi
private payoutManagementService: PayoutManagementService, private payoutManagementService: PayoutManagementService,
private notificationService: NotificationService, private notificationService: NotificationService,
private notificationErrorService: NotificationErrorService, private notificationErrorService: NotificationErrorService,
private destroyRef: DestroyRef,
) { ) {
super(); super();
} }
@ -66,7 +66,7 @@ export class CreatePayoutDialogComponent extends DialogSuperclass<CreatePayoutDi
isNil, isNil,
) as PayoutParams, ) as PayoutParams,
) )
.pipe(untilDestroyed(this), progressTo(this.progress$)) .pipe(takeUntilDestroyed(this.destroyRef), progressTo(this.progress$))
.subscribe({ .subscribe({
next: () => { next: () => {
this.notificationService.success('Payout created successfully'); this.notificationService.success('Payout created successfully');

View File

@ -1,6 +1,6 @@
import { Component, OnInit, Inject } from '@angular/core'; import { Component, OnInit, Inject, DestroyRef } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { FormBuilder } from '@angular/forms'; import { FormBuilder } from '@angular/forms';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { Party, Shop, ShopID, PartyID } from '@vality/domain-proto/domain'; import { Party, Shop, ShopID, PartyID } from '@vality/domain-proto/domain';
import { magista } from '@vality/magista-proto'; import { magista } from '@vality/magista-proto';
import { StatPayout } from '@vality/magista-proto/magista'; import { StatPayout } from '@vality/magista-proto/magista';
@ -40,7 +40,6 @@ interface PayoutsSearchForm {
payoutToolType: magista.PayoutToolType; payoutToolType: magista.PayoutToolType;
} }
@UntilDestroy()
@Component({ @Component({
selector: 'cc-payouts', selector: 'cc-payouts',
templateUrl: './payouts.component.html', templateUrl: './payouts.component.html',
@ -112,6 +111,7 @@ export class PayoutsComponent implements OnInit {
@Inject(DATE_RANGE_DAYS) private dateRangeDays: number, @Inject(DATE_RANGE_DAYS) private dateRangeDays: number,
private payoutActionsService: PayoutActionsService, private payoutActionsService: PayoutActionsService,
private fb: FormBuilder, private fb: FormBuilder,
private destroyRef: DestroyRef,
) {} ) {}
ngOnInit() { ngOnInit() {
@ -119,10 +119,10 @@ export class PayoutsComponent implements OnInit {
getValueChanges(this.filtersForm) getValueChanges(this.filtersForm)
.pipe( .pipe(
filter(() => this.filtersForm.valid), filter(() => this.filtersForm.valid),
untilDestroyed(this), takeUntilDestroyed(this.destroyRef),
) )
.subscribe((value) => void this.qp.set(clean(value))); .subscribe((value) => void this.qp.set(clean(value)));
this.qp.params$.pipe(untilDestroyed(this)).subscribe(() => this.search()); this.qp.params$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => this.search());
} }
more() { more() {

View File

@ -1,5 +1,5 @@
import { Injectable } from '@angular/core'; import { Injectable, DestroyRef } from '@angular/core';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { PayoutID, PayoutStatus } from '@vality/magista-proto/magista'; import { PayoutID, PayoutStatus } from '@vality/magista-proto/magista';
import { DialogResponseStatus, DialogService, ConfirmDialogComponent } from '@vality/ng-core'; import { DialogResponseStatus, DialogService, ConfirmDialogComponent } from '@vality/ng-core';
import { switchMap } from 'rxjs'; import { switchMap } from 'rxjs';
@ -10,13 +10,13 @@ import { NotificationErrorService } from '@cc/app/shared/services/notification-e
import { CancelPayoutDialogComponent } from '../payouts/components/cancel-payout-dialog/cancel-payout-dialog.component'; import { CancelPayoutDialogComponent } from '../payouts/components/cancel-payout-dialog/cancel-payout-dialog.component';
@UntilDestroy()
@Injectable() @Injectable()
export class PayoutActionsService { export class PayoutActionsService {
constructor( constructor(
private payoutManagementService: PayoutManagementService, private payoutManagementService: PayoutManagementService,
private dialogService: DialogService, private dialogService: DialogService,
private notificationErrorService: NotificationErrorService, private notificationErrorService: NotificationErrorService,
private destroyRef: DestroyRef,
) {} ) {}
canBeConfirmed(status: keyof PayoutStatus) { canBeConfirmed(status: keyof PayoutStatus) {
@ -38,7 +38,7 @@ export class PayoutActionsService {
.pipe( .pipe(
filter(({ status }) => status === DialogResponseStatus.Success), filter(({ status }) => status === DialogResponseStatus.Success),
switchMap(() => this.payoutManagementService.ConfirmPayout(id)), switchMap(() => this.payoutManagementService.ConfirmPayout(id)),
untilDestroyed(this), takeUntilDestroyed(this.destroyRef),
) )
.subscribe({ .subscribe({
error: this.notificationErrorService.error, error: this.notificationErrorService.error,

View File

@ -1,6 +1,6 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit, DestroyRef } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { Validators, FormControl } from '@angular/forms'; import { Validators, FormControl } from '@angular/forms';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { DialogResponseStatus, DialogSuperclass } from '@vality/ng-core'; import { DialogResponseStatus, DialogSuperclass } from '@vality/ng-core';
import { import {
RepairInvoicesRequest, RepairInvoicesRequest,
@ -27,7 +27,6 @@ enum Namespace {
Withdrawal, Withdrawal,
} }
@UntilDestroy()
@Component({ @Component({
templateUrl: './repair-by-scenario-dialog.component.html', templateUrl: './repair-by-scenario-dialog.component.html',
}) })
@ -61,13 +60,14 @@ export class RepairByScenarioDialogComponent
private notificationErrorService: NotificationErrorService, private notificationErrorService: NotificationErrorService,
private notificationService: NotificationService, private notificationService: NotificationService,
private domainMetadataFormExtensionsService: DomainMetadataFormExtensionsService, private domainMetadataFormExtensionsService: DomainMetadataFormExtensionsService,
private destroyRef: DestroyRef,
) { ) {
super(); super();
} }
ngOnInit() { ngOnInit() {
getFormValueChanges(this.nsControl) getFormValueChanges(this.nsControl)
.pipe(untilDestroyed(this)) .pipe(takeUntilDestroyed(this.destroyRef))
.subscribe(() => { .subscribe(() => {
this.form.setValue( this.form.setValue(
this.dialogData.machines.map(({ id }) => ({ id, scenario: {} })), this.dialogData.machines.map(({ id }) => ({ id, scenario: {} })),
@ -84,7 +84,7 @@ export class RepairByScenarioDialogComponent
? this.repairManagementService.RepairInvoices(value as RepairInvoicesRequest) ? this.repairManagementService.RepairInvoices(value as RepairInvoicesRequest)
: this.repairManagementService.RepairWithdrawals(value as RepairWithdrawalsRequest) : this.repairManagementService.RepairWithdrawals(value as RepairWithdrawalsRequest)
) )
.pipe(progressTo(this.progress$), untilDestroyed(this)) .pipe(progressTo(this.progress$), takeUntilDestroyed(this.destroyRef))
.subscribe({ .subscribe({
next: () => { next: () => {
this.notificationService.success(); this.notificationService.success();

View File

@ -1,6 +1,6 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit, DestroyRef } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { FormBuilder } from '@angular/forms'; import { FormBuilder } from '@angular/forms';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { import {
DialogResponseStatus, DialogResponseStatus,
DialogService, DialogService,
@ -37,7 +37,6 @@ interface Filters {
error_message: string; error_message: string;
} }
@UntilDestroy()
@Component({ @Component({
selector: 'cc-repairing', selector: 'cc-repairing',
templateUrl: './repairing.component.html', templateUrl: './repairing.component.html',
@ -96,6 +95,7 @@ export class RepairingComponent implements OnInit {
private notificationService: NotificationService, private notificationService: NotificationService,
private log: NotifyLogService, private log: NotifyLogService,
private domainStoreService: DomainStoreService, private domainStoreService: DomainStoreService,
private destroyRef: DestroyRef,
) {} ) {}
ngOnInit() { ngOnInit() {
@ -103,7 +103,7 @@ export class RepairingComponent implements OnInit {
this.filters.valueChanges this.filters.valueChanges
.pipe( .pipe(
map(() => clean(this.filters.value)), map(() => clean(this.filters.value)),
untilDestroyed(this), takeUntilDestroyed(this.destroyRef),
) )
.subscribe((v: Filters) => this.qp.set(v)); .subscribe((v: Filters) => this.qp.set(v));
this.qp.params$ this.qp.params$
@ -124,7 +124,7 @@ export class RepairingComponent implements OnInit {
: null, : null,
}), }),
), ),
untilDestroyed(this), takeUntilDestroyed(this.destroyRef),
) )
.subscribe((params) => this.machinesService.search(params)); .subscribe((params) => this.machinesService.search(params));
} }
@ -151,7 +151,7 @@ export class RepairingComponent implements OnInit {
this.selected$.value.map(({ id, ns }) => ({ id, ns })), this.selected$.value.map(({ id, ns }) => ({ id, ns })),
), ),
), ),
untilDestroyed(this), takeUntilDestroyed(this.destroyRef),
) )
.subscribe({ .subscribe({
next: () => { next: () => {
@ -165,7 +165,7 @@ export class RepairingComponent implements OnInit {
this.dialogService this.dialogService
.open(RepairByScenarioDialogComponent, { machines: this.selected$.value }) .open(RepairByScenarioDialogComponent, { machines: this.selected$.value })
.afterClosed() .afterClosed()
.pipe(untilDestroyed(this)) .pipe(takeUntilDestroyed(this.destroyRef))
.subscribe(); .subscribe();
} }
} }

View File

@ -1,12 +1,11 @@
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core'; import { ChangeDetectionStrategy, Component, OnInit, DestroyRef } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { UntypedFormBuilder } from '@angular/forms'; import { UntypedFormBuilder } from '@angular/forms';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { DialogSuperclass } from '@vality/ng-core'; import { DialogSuperclass } from '@vality/ng-core';
import { map } from 'rxjs/operators'; import { map } from 'rxjs/operators';
import { RoutingRulesService } from '../services/routing-rules'; import { RoutingRulesService } from '../services/routing-rules';
@UntilDestroy()
@Component({ @Component({
selector: 'cc-change-delegate-ruleset-dialog', selector: 'cc-change-delegate-ruleset-dialog',
templateUrl: 'change-delegate-ruleset-dialog.component.html', templateUrl: 'change-delegate-ruleset-dialog.component.html',
@ -29,6 +28,7 @@ export class ChangeDelegateRulesetDialogComponent
constructor( constructor(
private fb: UntypedFormBuilder, private fb: UntypedFormBuilder,
private routingRulesService: RoutingRulesService, private routingRulesService: RoutingRulesService,
private destroyRef: DestroyRef,
) { ) {
super(); super();
} }
@ -38,7 +38,7 @@ export class ChangeDelegateRulesetDialogComponent
.getRuleset(this.dialogData.mainRulesetRefID) .getRuleset(this.dialogData.mainRulesetRefID)
.pipe( .pipe(
map((r) => r?.data?.decisions?.delegates?.[this.dialogData?.delegateIdx]), map((r) => r?.data?.decisions?.delegates?.[this.dialogData?.delegateIdx]),
untilDestroyed(this), takeUntilDestroyed(this.destroyRef),
) )
.subscribe((delegate) => { .subscribe((delegate) => {
this.form.patchValue({ this.form.patchValue({
@ -56,7 +56,7 @@ export class ChangeDelegateRulesetDialogComponent
newDelegateRulesetRefID: this.form.value.rulesetRefId, newDelegateRulesetRefID: this.form.value.rulesetRefId,
description: this.form.value.description, description: this.form.value.description,
}) })
.pipe(untilDestroyed(this)) .pipe(takeUntilDestroyed(this.destroyRef))
.subscribe(() => this.dialogRef.close()); .subscribe(() => this.dialogRef.close());
} }
} }

View File

@ -1,5 +1,5 @@
import { ChangeDetectionStrategy, Component } from '@angular/core'; import { ChangeDetectionStrategy, Component, DestroyRef } from '@angular/core';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { DialogSuperclass } from '@vality/ng-core'; import { DialogSuperclass } from '@vality/ng-core';
import { BehaviorSubject } from 'rxjs'; import { BehaviorSubject } from 'rxjs';
@ -9,7 +9,6 @@ import { RoutingRulesService } from '../services/routing-rules';
import { TargetRuleset } from '../target-ruleset-form'; import { TargetRuleset } from '../target-ruleset-form';
import { RoutingRulesType } from '../types/routing-rules-type'; import { RoutingRulesType } from '../types/routing-rules-type';
@UntilDestroy()
@Component({ @Component({
templateUrl: 'change-target-dialog.component.html', templateUrl: 'change-target-dialog.component.html',
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
@ -25,11 +24,12 @@ export class ChangeTargetDialogComponent extends DialogSuperclass<
constructor( constructor(
private routingRulesService: RoutingRulesService, private routingRulesService: RoutingRulesService,
private notificationErrorService: NotificationErrorService, private notificationErrorService: NotificationErrorService,
private destroyRef: DestroyRef,
) { ) {
super(); super();
this.routingRulesService this.routingRulesService
.getRuleset(this.dialogData?.mainRulesetRefID) .getRuleset(this.dialogData?.mainRulesetRefID)
.pipe(untilDestroyed(this)) .pipe(takeUntilDestroyed(this.destroyRef))
.subscribe((ruleset) => { .subscribe((ruleset) => {
this.initValue = { this.initValue = {
mainRulesetRefID: ruleset.ref.id, mainRulesetRefID: ruleset.ref.id,
@ -50,7 +50,7 @@ export class ChangeTargetDialogComponent extends DialogSuperclass<
mainDelegateDescription, mainDelegateDescription,
delegateIdx, delegateIdx,
}) })
.pipe(untilDestroyed(this)) .pipe(takeUntilDestroyed(this.destroyRef))
.subscribe(() => this.dialogRef.close(), this.notificationErrorService.error); .subscribe(() => this.dialogRef.close(), this.notificationErrorService.error);
} }
} }

View File

@ -1,6 +1,6 @@
import { ChangeDetectionStrategy, Component } from '@angular/core'; import { ChangeDetectionStrategy, Component, DestroyRef } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { UntypedFormBuilder } from '@angular/forms'; import { UntypedFormBuilder } from '@angular/forms';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { DialogSuperclass } from '@vality/ng-core'; import { DialogSuperclass } from '@vality/ng-core';
import { BehaviorSubject } from 'rxjs'; import { BehaviorSubject } from 'rxjs';
@ -10,7 +10,6 @@ import { NotificationErrorService } from '@cc/app/shared/services/notification-e
import { RoutingRulesService } from '../../services/routing-rules'; import { RoutingRulesService } from '../../services/routing-rules';
import { TargetRuleset } from '../../target-ruleset-form'; import { TargetRuleset } from '../../target-ruleset-form';
@UntilDestroy()
@Component({ @Component({
templateUrl: 'attach-new-ruleset-dialog.component.html', templateUrl: 'attach-new-ruleset-dialog.component.html',
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
@ -33,6 +32,7 @@ export class AttachNewRulesetDialogComponent extends DialogSuperclass<
private fb: UntypedFormBuilder, private fb: UntypedFormBuilder,
private routingRulesService: RoutingRulesService, private routingRulesService: RoutingRulesService,
private notificationErrorService: NotificationErrorService, private notificationErrorService: NotificationErrorService,
private destroyRef: DestroyRef,
) { ) {
super(); super();
} }
@ -46,7 +46,7 @@ export class AttachNewRulesetDialogComponent extends DialogSuperclass<
mainDelegateDescription, mainDelegateDescription,
ruleset: this.form.value.ruleset, ruleset: this.form.value.ruleset,
}) })
.pipe(untilDestroyed(this)) .pipe(takeUntilDestroyed(this.destroyRef))
.subscribe({ .subscribe({
next: () => this.dialogRef.close(), next: () => this.dialogRef.close(),
error: (err) => this.notificationErrorService.error(err), error: (err) => this.notificationErrorService.error(err),

View File

@ -1,6 +1,6 @@
import { ChangeDetectionStrategy, Component } from '@angular/core'; import { ChangeDetectionStrategy, Component, DestroyRef } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { ActivatedRoute, Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { DialogService } from '@vality/ng-core'; import { DialogService } from '@vality/ng-core';
import { first, map } from 'rxjs/operators'; import { first, map } from 'rxjs/operators';
@ -14,7 +14,6 @@ import { RoutingRulesService } from '../services/routing-rules';
import { AttachNewRulesetDialogComponent } from './attach-new-ruleset-dialog'; import { AttachNewRulesetDialogComponent } from './attach-new-ruleset-dialog';
import { PartyDelegateRulesetsService } from './party-delegate-rulesets.service'; import { PartyDelegateRulesetsService } from './party-delegate-rulesets.service';
@UntilDestroy()
@Component({ @Component({
selector: 'cc-party-delegate-rulesets', selector: 'cc-party-delegate-rulesets',
templateUrl: 'party-delegate-rulesets.component.html', templateUrl: 'party-delegate-rulesets.component.html',
@ -63,6 +62,7 @@ export class PartyDelegateRulesetsComponent {
private domainStoreService: DomainStoreService, private domainStoreService: DomainStoreService,
private notificationErrorService: NotificationErrorService, private notificationErrorService: NotificationErrorService,
private route: ActivatedRoute, private route: ActivatedRoute,
private destroyRef: DestroyRef,
) {} ) {}
attachNewRuleset() { attachNewRuleset() {
@ -72,14 +72,17 @@ export class PartyDelegateRulesetsComponent {
type: this.route.snapshot.params.type, type: this.route.snapshot.params.type,
}) })
.afterClosed() .afterClosed()
.pipe(handleError(this.notificationErrorService.error), untilDestroyed(this)) .pipe(
handleError(this.notificationErrorService.error),
takeUntilDestroyed(this.destroyRef),
)
.subscribe(); .subscribe();
} }
navigateToPartyRuleset(parentRefId: number, delegateIdx: number) { navigateToPartyRuleset(parentRefId: number, delegateIdx: number) {
this.routingRulesService this.routingRulesService
.getRuleset(parentRefId) .getRuleset(parentRefId)
.pipe(first(), untilDestroyed(this)) .pipe(first(), takeUntilDestroyed(this.destroyRef))
.subscribe((parent) => { .subscribe((parent) => {
void this.router.navigate([ void this.router.navigate([
'party', 'party',

View File

@ -1,6 +1,6 @@
import { Component } from '@angular/core'; import { Component, DestroyRef } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { FormBuilder } from '@angular/forms'; import { FormBuilder } from '@angular/forms';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { Shop } from '@vality/domain-proto/domain'; import { Shop } from '@vality/domain-proto/domain';
import { StatWallet } from '@vality/fistful-proto/fistful_stat'; import { StatWallet } from '@vality/fistful-proto/fistful_stat';
import { DialogResponseStatus, DialogSuperclass } from '@vality/ng-core'; import { DialogResponseStatus, DialogSuperclass } from '@vality/ng-core';
@ -10,7 +10,6 @@ import { NotificationErrorService } from '@cc/app/shared/services/notification-e
import { RoutingRulesService } from '../../services/routing-rules'; import { RoutingRulesService } from '../../services/routing-rules';
import { RoutingRulesType } from '../../types/routing-rules-type'; import { RoutingRulesType } from '../../types/routing-rules-type';
@UntilDestroy()
@Component({ @Component({
templateUrl: 'add-party-routing-rule-dialog.component.html', templateUrl: 'add-party-routing-rule-dialog.component.html',
}) })
@ -29,6 +28,7 @@ export class AddPartyRoutingRuleDialogComponent extends DialogSuperclass<
private fb: FormBuilder, private fb: FormBuilder,
private routingRulesService: RoutingRulesService, private routingRulesService: RoutingRulesService,
private notificationErrorService: NotificationErrorService, private notificationErrorService: NotificationErrorService,
private destroyRef: DestroyRef,
) { ) {
super(); super();
} }
@ -51,7 +51,7 @@ export class AddPartyRoutingRuleDialogComponent extends DialogSuperclass<
walletID, walletID,
}) })
) )
.pipe(untilDestroyed(this)) .pipe(takeUntilDestroyed(this.destroyRef))
.subscribe({ .subscribe({
next: () => this.dialogRef.close({ status: DialogResponseStatus.Success }), next: () => this.dialogRef.close({ status: DialogResponseStatus.Success }),
error: this.notificationErrorService.error, error: this.notificationErrorService.error,

View File

@ -1,12 +1,11 @@
import { Component } from '@angular/core'; import { Component, DestroyRef } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { UntypedFormBuilder } from '@angular/forms'; import { UntypedFormBuilder } from '@angular/forms';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { DialogSuperclass } from '@vality/ng-core'; import { DialogSuperclass } from '@vality/ng-core';
import { NotificationErrorService } from '../../../../shared/services/notification-error'; import { NotificationErrorService } from '../../../../shared/services/notification-error';
import { RoutingRulesService } from '../../services/routing-rules'; import { RoutingRulesService } from '../../services/routing-rules';
@UntilDestroy()
@Component({ @Component({
selector: 'cc-initialize-routing-rules-dialog', selector: 'cc-initialize-routing-rules-dialog',
templateUrl: 'initialize-routing-rules-dialog.component.html', templateUrl: 'initialize-routing-rules-dialog.component.html',
@ -25,6 +24,7 @@ export class InitializeRoutingRulesDialogComponent extends DialogSuperclass<
private fb: UntypedFormBuilder, private fb: UntypedFormBuilder,
private routingRulesService: RoutingRulesService, private routingRulesService: RoutingRulesService,
private notificationErrorService: NotificationErrorService, private notificationErrorService: NotificationErrorService,
private destroyRef: DestroyRef,
) { ) {
super(); super();
} }
@ -39,7 +39,7 @@ export class InitializeRoutingRulesDialogComponent extends DialogSuperclass<
description, description,
delegateDescription, delegateDescription,
}) })
.pipe(untilDestroyed(this)) .pipe(takeUntilDestroyed(this.destroyRef))
.subscribe(() => this.dialogRef.close(), this.notificationErrorService.error); .subscribe(() => this.dialogRef.close(), this.notificationErrorService.error);
} }
} }

View File

@ -1,6 +1,6 @@
import { Component } from '@angular/core'; import { Component, DestroyRef } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { ActivatedRoute, Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { DialogService, DialogResponseStatus } from '@vality/ng-core'; import { DialogService, DialogResponseStatus } from '@vality/ng-core';
import { combineLatest, Observable } from 'rxjs'; import { combineLatest, Observable } from 'rxjs';
import { filter, map, pluck, shareReplay, startWith, switchMap, take } from 'rxjs/operators'; import { filter, map, pluck, shareReplay, startWith, switchMap, take } from 'rxjs/operators';
@ -13,7 +13,6 @@ import { AddPartyRoutingRuleDialogComponent } from './add-party-routing-rule-dia
import { InitializeRoutingRulesDialogComponent } from './initialize-routing-rules-dialog'; import { InitializeRoutingRulesDialogComponent } from './initialize-routing-rules-dialog';
import { PartyRoutingRulesetService } from './party-routing-ruleset.service'; import { PartyRoutingRulesetService } from './party-routing-ruleset.service';
@UntilDestroy()
@Component({ @Component({
selector: 'cc-party-routing-ruleset', selector: 'cc-party-routing-ruleset',
templateUrl: 'party-routing-ruleset.component.html', templateUrl: 'party-routing-ruleset.component.html',
@ -61,7 +60,7 @@ export class PartyRoutingRulesetComponent {
}; };
}), }),
), ),
untilDestroyed(this), takeUntilDestroyed(this.destroyRef),
shareReplay(1), shareReplay(1),
); );
walletsData$ = combineLatest([ walletsData$ = combineLatest([
@ -88,7 +87,7 @@ export class PartyRoutingRulesetComponent {
}; };
}), }),
), ),
untilDestroyed(this), takeUntilDestroyed(this.destroyRef),
shareReplay(1), shareReplay(1),
); );
@ -98,6 +97,7 @@ export class PartyRoutingRulesetComponent {
private router: Router, private router: Router,
private route: ActivatedRoute, private route: ActivatedRoute,
private domainStoreService: DomainStoreService, private domainStoreService: DomainStoreService,
private destroyRef: DestroyRef,
) {} ) {}
initialize() { initialize() {
@ -112,7 +112,7 @@ export class PartyRoutingRulesetComponent {
.open(InitializeRoutingRulesDialogComponent, { partyID, refID }) .open(InitializeRoutingRulesDialogComponent, { partyID, refID })
.afterClosed(), .afterClosed(),
), ),
untilDestroyed(this), takeUntilDestroyed(this.destroyRef),
) )
.subscribe({ .subscribe({
next: () => { next: () => {
@ -142,7 +142,7 @@ export class PartyRoutingRulesetComponent {
}) })
.afterClosed(), .afterClosed(),
), ),
untilDestroyed(this), takeUntilDestroyed(this.destroyRef),
) )
.subscribe({ .subscribe({
next: (res) => { next: (res) => {
@ -155,7 +155,7 @@ export class PartyRoutingRulesetComponent {
navigateToDelegate(parentRefId: number, delegateIdx: number) { navigateToDelegate(parentRefId: number, delegateIdx: number) {
this.partyRoutingRulesetService.partyRuleset$ this.partyRoutingRulesetService.partyRuleset$
.pipe(take(1), untilDestroyed(this)) .pipe(take(1), takeUntilDestroyed(this.destroyRef))
.subscribe((ruleset) => .subscribe((ruleset) =>
this.router.navigate([ this.router.navigate([
'party', 'party',

View File

@ -1,6 +1,6 @@
import { Injectable } from '@angular/core'; import { Injectable, DestroyRef } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { combineLatest, defer, Observable } from 'rxjs'; import { combineLatest, defer, Observable } from 'rxjs';
import { map, pluck, shareReplay, switchMap } from 'rxjs/operators'; import { map, pluck, shareReplay, switchMap } from 'rxjs/operators';
@ -9,18 +9,17 @@ import { PartyManagementService } from '@cc/app/api/payment-processing';
import { RoutingRulesService } from '../services/routing-rules'; import { RoutingRulesService } from '../services/routing-rules';
@UntilDestroy()
@Injectable() @Injectable()
export class PartyRoutingRulesetService { export class PartyRoutingRulesetService {
partyID$ = this.route.params.pipe( partyID$ = this.route.params.pipe(
pluck('partyID'), pluck('partyID'),
untilDestroyed(this), takeUntilDestroyed(this.destroyRef),
shareReplay(1), shareReplay(1),
) as Observable<string>; ) as Observable<string>;
refID$ = this.route.params.pipe( refID$ = this.route.params.pipe(
pluck('partyRefID'), pluck('partyRefID'),
map((r) => +r), map((r) => +r),
untilDestroyed(this), takeUntilDestroyed(this.destroyRef),
shareReplay(1), shareReplay(1),
); );
@ -35,19 +34,19 @@ export class PartyRoutingRulesetService {
}), }),
), ),
pluck('data', 'wallets'), pluck('data', 'wallets'),
untilDestroyed(this), takeUntilDestroyed(this.destroyRef),
shareReplay(1), shareReplay(1),
); );
partyRuleset$ = combineLatest([this.routingRulesService.rulesets$, this.refID$]).pipe( partyRuleset$ = combineLatest([this.routingRulesService.rulesets$, this.refID$]).pipe(
map(([rules, refID]) => rules.find((r) => r?.ref?.id === refID)), map(([rules, refID]) => rules.find((r) => r?.ref?.id === refID)),
untilDestroyed(this), takeUntilDestroyed(this.destroyRef),
shareReplay(1), shareReplay(1),
); );
private party$ = this.partyID$.pipe( private party$ = this.partyID$.pipe(
switchMap((partyID) => this.partyManagementService.Get(partyID)), switchMap((partyID) => this.partyManagementService.Get(partyID)),
untilDestroyed(this), takeUntilDestroyed(this.destroyRef),
shareReplay(1), shareReplay(1),
); );
@ -56,6 +55,7 @@ export class PartyRoutingRulesetService {
private partyManagementService: PartyManagementService, private partyManagementService: PartyManagementService,
private routingRulesService: RoutingRulesService, private routingRulesService: RoutingRulesService,
private fistfulStatistics: FistfulStatisticsService, private fistfulStatistics: FistfulStatisticsService,
private destroyRef: DestroyRef,
) {} ) {}
reload() { reload() {

View File

@ -6,9 +6,10 @@ import {
Output, Output,
OnChanges, OnChanges,
booleanAttribute, booleanAttribute,
DestroyRef,
} from '@angular/core'; } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { import {
DialogResponseStatus, DialogResponseStatus,
DialogService, DialogService,
@ -30,7 +31,6 @@ type DelegateId = {
delegateIdx: number; delegateIdx: number;
}; };
@UntilDestroy()
@Component({ @Component({
selector: 'cc-routing-rules-list', selector: 'cc-routing-rules-list',
templateUrl: 'routing-rules-list.component.html', templateUrl: 'routing-rules-list.component.html',
@ -55,6 +55,7 @@ export class RoutingRulesListComponent<
private log: NotifyLogService, private log: NotifyLogService,
private routingRulesService: RoutingRulesService, private routingRulesService: RoutingRulesService,
private route: ActivatedRoute, private route: ActivatedRoute,
private destroyRef: DestroyRef,
) {} ) {}
ngOnChanges(changes: ComponentChanges<RoutingRulesListComponent<T>>) { ngOnChanges(changes: ComponentChanges<RoutingRulesListComponent<T>>) {
@ -119,7 +120,7 @@ export class RoutingRulesListComponent<
delegateIdx: delegateId.delegateIdx, delegateIdx: delegateId.delegateIdx,
}) })
.afterClosed() .afterClosed()
.pipe(handleError(this.log.error), untilDestroyed(this)) .pipe(handleError(this.log.error), takeUntilDestroyed(this.destroyRef))
.subscribe(); .subscribe();
} }
@ -131,7 +132,7 @@ export class RoutingRulesListComponent<
type: this.route.snapshot.params.type, type: this.route.snapshot.params.type,
}) })
.afterClosed() .afterClosed()
.pipe(untilDestroyed(this)) .pipe(takeUntilDestroyed(this.destroyRef))
.subscribe({ error: this.log.error }); .subscribe({ error: this.log.error });
} }
@ -147,7 +148,7 @@ export class RoutingRulesListComponent<
delegateIdx: delegateId.delegateIdx, delegateIdx: delegateId.delegateIdx,
}), }),
), ),
untilDestroyed(this), takeUntilDestroyed(this.destroyRef),
) )
.subscribe({ error: this.log.error }); .subscribe({ error: this.log.error });
} }
@ -164,7 +165,7 @@ export class RoutingRulesListComponent<
delegateIdx: delegateId.delegateIdx, delegateIdx: delegateId.delegateIdx,
}), }),
), ),
untilDestroyed(this), takeUntilDestroyed(this.destroyRef),
) )
.subscribe({ error: this.log.error }); .subscribe({ error: this.log.error });
} }

View File

@ -1,6 +1,6 @@
import { Component } from '@angular/core'; import { Component, DestroyRef } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { RoutingCandidate, Predicate } from '@vality/domain-proto/domain'; import { RoutingCandidate, Predicate } from '@vality/domain-proto/domain';
import { import {
DialogResponseStatus, DialogResponseStatus,
@ -30,7 +30,6 @@ import { RoutingRulesService } from '../services/routing-rules';
import { ChangeCandidatesPrioritiesDialogComponent } from './components/change-candidates-priorities-dialog/change-candidates-priorities-dialog.component'; import { ChangeCandidatesPrioritiesDialogComponent } from './components/change-candidates-priorities-dialog/change-candidates-priorities-dialog.component';
import { RoutingRulesetService } from './routing-ruleset.service'; import { RoutingRulesetService } from './routing-ruleset.service';
@UntilDestroy()
@Component({ @Component({
templateUrl: 'routing-ruleset.component.html', templateUrl: 'routing-ruleset.component.html',
providers: [RoutingRulesetService], providers: [RoutingRulesetService],
@ -54,7 +53,7 @@ export class RoutingRulesetComponent {
formatter: (d) => this.getCandidateIdx(d).pipe(map((idx) => `#${idx + 1}`)), formatter: (d) => this.getCandidateIdx(d).pipe(map((idx) => `#${idx + 1}`)),
click: (d) => { click: (d) => {
combineLatest([this.getCandidateIdx(d), this.routingRulesetService.shopRuleset$]) combineLatest([this.getCandidateIdx(d), this.routingRulesetService.shopRuleset$])
.pipe(untilDestroyed(this)) .pipe(takeUntilDestroyed(this.destroyRef))
.subscribe(([idx, ruleset]) => { .subscribe(([idx, ruleset]) => {
this.sidenavInfoService.toggle(CandidateCardComponent, { this.sidenavInfoService.toggle(CandidateCardComponent, {
idx, idx,
@ -110,7 +109,7 @@ export class RoutingRulesetComponent {
label: 'Edit', label: 'Edit',
click: (d) => { click: (d) => {
this.getCandidateIdx(d) this.getCandidateIdx(d)
.pipe(untilDestroyed(this)) .pipe(takeUntilDestroyed(this.destroyRef))
.subscribe((idx) => { .subscribe((idx) => {
this.editShopRule(idx); this.editShopRule(idx);
}); });
@ -120,7 +119,7 @@ export class RoutingRulesetComponent {
label: 'Duplicate', label: 'Duplicate',
click: (d) => { click: (d) => {
this.getCandidateIdx(d) this.getCandidateIdx(d)
.pipe(untilDestroyed(this)) .pipe(takeUntilDestroyed(this.destroyRef))
.subscribe((idx) => { .subscribe((idx) => {
void this.duplicateShopRule(idx); void this.duplicateShopRule(idx);
}); });
@ -130,7 +129,7 @@ export class RoutingRulesetComponent {
label: 'Remove', label: 'Remove',
click: (d) => { click: (d) => {
this.getCandidateIdx(d) this.getCandidateIdx(d)
.pipe(untilDestroyed(this)) .pipe(takeUntilDestroyed(this.destroyRef))
.subscribe((idx) => { .subscribe((idx) => {
void this.removeShopRule(idx); void this.removeShopRule(idx);
}); });
@ -147,6 +146,7 @@ export class RoutingRulesetComponent {
private log: NotifyLogService, private log: NotifyLogService,
private route: ActivatedRoute, private route: ActivatedRoute,
private sidenavInfoService: SidenavInfoService, private sidenavInfoService: SidenavInfoService,
private destroyRef: DestroyRef,
) {} ) {}
addShopRule() { addShopRule() {
@ -163,7 +163,7 @@ export class RoutingRulesetComponent {
.afterClosed(), .afterClosed(),
), ),
) )
.pipe(untilDestroyed(this)) .pipe(takeUntilDestroyed(this.destroyRef))
.subscribe({ .subscribe({
next: (res) => { next: (res) => {
if (res.status === DialogResponseStatus.Success) { if (res.status === DialogResponseStatus.Success) {
@ -195,7 +195,7 @@ export class RoutingRulesetComponent {
.afterClosed(), .afterClosed(),
), ),
) )
.pipe(untilDestroyed(this)) .pipe(takeUntilDestroyed(this.destroyRef))
.subscribe({ .subscribe({
next: (res) => { next: (res) => {
if (res.status === DialogResponseStatus.Success) { if (res.status === DialogResponseStatus.Success) {
@ -227,7 +227,7 @@ export class RoutingRulesetComponent {
.afterClosed(), .afterClosed(),
), ),
) )
.pipe(untilDestroyed(this)) .pipe(takeUntilDestroyed(this.destroyRef))
.subscribe({ .subscribe({
next: (res) => { next: (res) => {
if (res.status === DialogResponseStatus.Success) { if (res.status === DialogResponseStatus.Success) {

View File

@ -1,6 +1,6 @@
import { Injectable } from '@angular/core'; import { Injectable, DestroyRef } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { untilDestroyed, UntilDestroy } from '@ngneat/until-destroy';
import { import {
DialogService, DialogService,
ConfirmDialogComponent, ConfirmDialogComponent,
@ -14,7 +14,6 @@ import { PartyManagementService } from '@cc/app/api/payment-processing';
import { RoutingRulesService as RoutingRulesDamselService } from '../services/routing-rules'; import { RoutingRulesService as RoutingRulesDamselService } from '../services/routing-rules';
@UntilDestroy()
@Injectable() @Injectable()
export class RoutingRulesetService { export class RoutingRulesetService {
partyID$: Observable<string> = this.route.params.pipe( partyID$: Observable<string> = this.route.params.pipe(
@ -57,6 +56,7 @@ export class RoutingRulesetService {
private partyManagementService: PartyManagementService, private partyManagementService: PartyManagementService,
private log: NotifyLogService, private log: NotifyLogService,
private dialog: DialogService, private dialog: DialogService,
private destroyRef: DestroyRef,
) {} ) {}
removeShopRule(candidateIdx: number) { removeShopRule(candidateIdx: number) {
@ -73,7 +73,7 @@ export class RoutingRulesetService {
candidateIdx, candidateIdx,
}), }),
), ),
untilDestroyed(this), takeUntilDestroyed(this.destroyRef),
) )
.subscribe({ .subscribe({
next: () => { next: () => {

View File

@ -5,9 +5,10 @@ import {
Input, Input,
OnChanges, OnChanges,
Output, Output,
DestroyRef,
} from '@angular/core'; } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { UntypedFormBuilder } from '@angular/forms'; import { UntypedFormBuilder } from '@angular/forms';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { PaymentInstitutionObject } from '@vality/domain-proto/domain'; import { PaymentInstitutionObject } from '@vality/domain-proto/domain';
import { ComponentChanges } from '@vality/ng-core'; import { ComponentChanges } from '@vality/ng-core';
import sortBy from 'lodash-es/sortBy'; import sortBy from 'lodash-es/sortBy';
@ -22,7 +23,6 @@ import { getPoliciesIdByType } from '../utils/get-policies-id-by-type';
import { Target } from './types/target'; import { Target } from './types/target';
import { TargetRuleset } from './types/target-ruleset'; import { TargetRuleset } from './types/target-ruleset';
@UntilDestroy()
@Component({ @Component({
selector: 'cc-target-ruleset-form', selector: 'cc-target-ruleset-form',
templateUrl: 'target-ruleset-form.component.html', templateUrl: 'target-ruleset-form.component.html',
@ -59,9 +59,10 @@ export class TargetRulesetFormComponent implements OnChanges {
private fb: UntypedFormBuilder, private fb: UntypedFormBuilder,
private domainStoreService: DomainStoreService, private domainStoreService: DomainStoreService,
private routingRulesService: RoutingRulesService, private routingRulesService: RoutingRulesService,
private destroyRef: DestroyRef,
) { ) {
this.form.controls.target.valueChanges this.form.controls.target.valueChanges
.pipe(startWith(this.form.value.target), untilDestroyed(this)) .pipe(startWith(this.form.value.target), takeUntilDestroyed(this.destroyRef))
.subscribe((target) => { .subscribe((target) => {
switch (target) { switch (target) {
case Target.Manual: case Target.Manual:
@ -98,14 +99,14 @@ export class TargetRulesetFormComponent implements OnChanges {
mainDelegateDescription, mainDelegateDescription,
}), }),
), ),
untilDestroyed(this), takeUntilDestroyed(this.destroyRef),
) )
.subscribe((value) => this.valueChanges.emit(value)); .subscribe((value) => this.valueChanges.emit(value));
this.form.statusChanges this.form.statusChanges
.pipe( .pipe(
startWith(this.form.valid), startWith(this.form.valid),
map(() => this.form.valid), map(() => this.form.valid),
untilDestroyed(this), takeUntilDestroyed(this.destroyRef),
) )
.subscribe((valid) => this.valid.emit(valid)); .subscribe((valid) => this.valid.emit(valid));
} }

View File

@ -1,5 +1,4 @@
import { Component } from '@angular/core'; import { Component } from '@angular/core';
import { UntilDestroy } from '@ngneat/until-destroy';
import { SearchShopHit } from '@vality/deanonimus-proto/deanonimus'; import { SearchShopHit } from '@vality/deanonimus-proto/deanonimus';
import { Column, progressTo, NotifyLogService } from '@vality/ng-core'; import { Column, progressTo, NotifyLogService } from '@vality/ng-core';
import { BehaviorSubject, defer, of, combineLatest, Subject, Observable } from 'rxjs'; import { BehaviorSubject, defer, of, combineLatest, Subject, Observable } from 'rxjs';
@ -8,7 +7,6 @@ import { switchMap, shareReplay, catchError, map } from 'rxjs/operators';
import { DeanonimusService } from '../../api/deanonimus'; import { DeanonimusService } from '../../api/deanonimus';
import { ShopParty } from '../../shared/components/shops-table'; import { ShopParty } from '../../shared/components/shops-table';
@UntilDestroy()
@Component({ @Component({
selector: 'cc-shops', selector: 'cc-shops',
templateUrl: './shops.component.html', templateUrl: './shops.component.html',

View File

@ -1,7 +1,7 @@
import { Component } from '@angular/core'; import { Component, DestroyRef } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { Sort } from '@angular/material/sort'; import { Sort } from '@angular/material/sort';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { untilDestroyed, UntilDestroy } from '@ngneat/until-destroy';
import { TerminalObject } from '@vality/domain-proto/domain'; import { TerminalObject } from '@vality/domain-proto/domain';
import { Column } from '@vality/ng-core'; import { Column } from '@vality/ng-core';
import { of } from 'rxjs'; import { of } from 'rxjs';
@ -14,7 +14,6 @@ import { DomainObjectCardComponent } from '../../shared/components/thrift-api-cr
import { getTerminalShopWalletDelegates } from './utils/get-terminal-shop-wallet-delegates'; import { getTerminalShopWalletDelegates } from './utils/get-terminal-shop-wallet-delegates';
@UntilDestroy()
@Component({ @Component({
selector: 'cc-terminals', selector: 'cc-terminals',
templateUrl: './terminals.component.html', templateUrl: './terminals.component.html',
@ -40,7 +39,7 @@ export class TerminalsComponent {
sortable: true, sortable: true,
click: (d) => { click: (d) => {
this.getProvider(d) this.getProvider(d)
.pipe(take(1), untilDestroyed(this)) .pipe(take(1), takeUntilDestroyed(this.destroyRef))
.subscribe((provider) => { .subscribe((provider) => {
if (!provider) { if (!provider) {
return; return;
@ -68,6 +67,7 @@ export class TerminalsComponent {
private domainStoreService: DomainStoreService, private domainStoreService: DomainStoreService,
private router: Router, private router: Router,
private sidenavInfoService: SidenavInfoService, private sidenavInfoService: SidenavInfoService,
private destroyRef: DestroyRef,
) {} ) {}
update() { update() {

View File

@ -1,6 +1,6 @@
import { Component, OnInit, Inject, ViewChild } from '@angular/core'; import { Component, OnInit, Inject, ViewChild, DestroyRef } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { FormBuilder, FormControl } from '@angular/forms'; import { FormBuilder, FormControl } from '@angular/forms';
import { untilDestroyed, UntilDestroy } from '@ngneat/until-destroy';
import { SearchWalletHit } from '@vality/deanonimus-proto/internal/deanonimus'; import { SearchWalletHit } from '@vality/deanonimus-proto/internal/deanonimus';
import { AccountBalance } from '@vality/fistful-proto/internal/account'; import { AccountBalance } from '@vality/fistful-proto/internal/account';
import { StatWallet } from '@vality/fistful-proto/internal/fistful_stat'; import { StatWallet } from '@vality/fistful-proto/internal/fistful_stat';
@ -28,7 +28,6 @@ import { DEBOUNCE_TIME_MS } from '../../tokens';
import { FetchWalletsTextService } from './fetch-wallets-text.service'; import { FetchWalletsTextService } from './fetch-wallets-text.service';
import { FetchWalletsService } from './fetch-wallets.service'; import { FetchWalletsService } from './fetch-wallets.service';
@UntilDestroy()
@Component({ @Component({
selector: 'cc-wallets', selector: 'cc-wallets',
templateUrl: './wallets.component.html', templateUrl: './wallets.component.html',
@ -114,6 +113,7 @@ export class WalletsComponent implements OnInit {
private walletManagementService: ManagementService, private walletManagementService: ManagementService,
private log: NotifyLogService, private log: NotifyLogService,
@Inject(DEBOUNCE_TIME_MS) private debounceTimeMs: number, @Inject(DEBOUNCE_TIME_MS) private debounceTimeMs: number,
private destroyRef: DestroyRef,
) {} ) {}
ngOnInit() { ngOnInit() {
@ -123,12 +123,12 @@ export class WalletsComponent implements OnInit {
this.isFilterControl.setValue(Number(isFilter)); this.isFilterControl.setValue(Number(isFilter));
} }
getValueChanges(this.isFilterControl) getValueChanges(this.isFilterControl)
.pipe(untilDestroyed(this)) .pipe(takeUntilDestroyed(this.destroyRef))
.subscribe((value) => { .subscribe((value) => {
void this.typeQp.set({ isFilter: !!value }); void this.typeQp.set({ isFilter: !!value });
}); });
getValueChanges(this.filtersForm) getValueChanges(this.filtersForm)
.pipe(debounceTime(this.debounceTimeMs), untilDestroyed(this)) .pipe(debounceTime(this.debounceTimeMs), takeUntilDestroyed(this.destroyRef))
.subscribe((value) => { .subscribe((value) => {
void this.qp.set(clean(value)); void this.qp.set(clean(value));
this.filterSearch(); this.filterSearch();

View File

@ -1,6 +1,6 @@
import { Component } from '@angular/core'; import { Component, DestroyRef } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { Validators, FormControl } from '@angular/forms'; import { Validators, FormControl } from '@angular/forms';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { ChangeRequest } from '@vality/fistful-proto/deposit_adjustment'; import { ChangeRequest } from '@vality/fistful-proto/deposit_adjustment';
import { StatWithdrawal } from '@vality/fistful-proto/fistful_stat'; import { StatWithdrawal } from '@vality/fistful-proto/fistful_stat';
import { ExternalID } from '@vality/fistful-proto/withdrawal_adjustment'; import { ExternalID } from '@vality/fistful-proto/withdrawal_adjustment';
@ -11,7 +11,6 @@ import * as short from 'short-uuid';
import { ManagementService } from '@cc/app/api/withdrawal'; import { ManagementService } from '@cc/app/api/withdrawal';
import { MetadataFormExtension } from '@cc/app/shared/components/metadata-form'; import { MetadataFormExtension } from '@cc/app/shared/components/metadata-form';
@UntilDestroy()
@Component({ @Component({
templateUrl: './create-adjustment-dialog.component.html', templateUrl: './create-adjustment-dialog.component.html',
}) })
@ -41,6 +40,7 @@ export class CreateAdjustmentDialogComponent extends DialogSuperclass<
constructor( constructor(
private managementService: ManagementService, private managementService: ManagementService,
private log: NotifyLogService, private log: NotifyLogService,
private destroyRef: DestroyRef,
) { ) {
super(); super();
} }
@ -56,7 +56,7 @@ export class CreateAdjustmentDialogComponent extends DialogSuperclass<
), ),
this.progress$, this.progress$,
) )
.pipe(untilDestroyed(this)) .pipe(takeUntilDestroyed(this.destroyRef))
.subscribe((res) => { .subscribe((res) => {
const withError = res.filter((e) => e.hasError); const withError = res.filter((e) => e.hasError);
if (withError.length) { if (withError.length) {

View File

@ -1,6 +1,6 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit, DestroyRef } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { FormBuilder } from '@angular/forms'; import { FormBuilder } from '@angular/forms';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { PartyID } from '@vality/domain-proto/domain'; import { PartyID } from '@vality/domain-proto/domain';
import { StatWithdrawal } from '@vality/fistful-proto/fistful_stat'; import { StatWithdrawal } from '@vality/fistful-proto/fistful_stat';
import { import {
@ -36,7 +36,6 @@ interface WithdrawalsForm {
walletId: WithdrawalParams['wallet_id']; walletId: WithdrawalParams['wallet_id'];
} }
@UntilDestroy()
@Component({ @Component({
selector: 'cc-withdrawals', selector: 'cc-withdrawals',
templateUrl: './withdrawals.component.html', templateUrl: './withdrawals.component.html',
@ -104,13 +103,14 @@ export class WithdrawalsComponent implements OnInit {
private qp: QueryParamsService<Partial<WithdrawalsForm>>, private qp: QueryParamsService<Partial<WithdrawalsForm>>,
private amountCurrencyService: AmountCurrencyService, private amountCurrencyService: AmountCurrencyService,
private dialogService: DialogService, private dialogService: DialogService,
private destroyRef: DestroyRef,
) {} ) {}
ngOnInit() { ngOnInit() {
this.filtersForm.valueChanges this.filtersForm.valueChanges
.pipe(untilDestroyed(this)) .pipe(takeUntilDestroyed(this.destroyRef))
.subscribe((v) => void this.qp.set(clean(v))); .subscribe((v) => void this.qp.set(clean(v)));
this.qp.params$.pipe(untilDestroyed(this)).subscribe(() => this.update()); this.qp.params$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => this.update());
} }
update(options?: UpdateOptions) { update(options?: UpdateOptions) {

View File

@ -1,10 +1,10 @@
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { Component, OnInit } from '@angular/core'; import { Component, OnInit, DestroyRef } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { ReactiveFormsModule, FormControl, Validators } from '@angular/forms'; import { ReactiveFormsModule, FormControl, Validators } from '@angular/forms';
import { MatButtonModule } from '@angular/material/button'; import { MatButtonModule } from '@angular/material/button';
import { MatFormFieldModule } from '@angular/material/form-field'; import { MatFormFieldModule } from '@angular/material/form-field';
import { MatSelectModule } from '@angular/material/select'; import { MatSelectModule } from '@angular/material/select';
import { untilDestroyed, UntilDestroy } from '@ngneat/until-destroy';
import { StatChargeback } from '@vality/magista-proto/internal/magista'; import { StatChargeback } from '@vality/magista-proto/internal/magista';
import { import {
DialogSuperclass, DialogSuperclass,
@ -35,7 +35,6 @@ const CHANGE_STATUS_METHODS = {
[Action.Cancel]: 'CancelChargeback', [Action.Cancel]: 'CancelChargeback',
} as const; } as const;
@UntilDestroy()
@Component({ @Component({
standalone: true, standalone: true,
templateUrl: './change-chargebacks-status-dialog.component.html', templateUrl: './change-chargebacks-status-dialog.component.html',
@ -75,12 +74,13 @@ export class ChangeChargebacksStatusDialogComponent
private invoicingService: InvoicingService, private invoicingService: InvoicingService,
private log: NotifyLogService, private log: NotifyLogService,
private domainMetadataFormExtensionsService: DomainMetadataFormExtensionsService, private domainMetadataFormExtensionsService: DomainMetadataFormExtensionsService,
private destroyRef: DestroyRef,
) { ) {
super(); super();
} }
ngOnInit() { ngOnInit() {
this.actionControl.valueChanges.pipe(untilDestroyed(this)).subscribe(() => { this.actionControl.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {
this.control.reset(); this.control.reset();
}); });
} }
@ -97,7 +97,7 @@ export class ChangeChargebacksStatusDialogComponent
), ),
this.progress$, this.progress$,
) )
.pipe(untilDestroyed(this)) .pipe(takeUntilDestroyed(this.destroyRef))
.subscribe({ .subscribe({
next: (res) => { next: (res) => {
const withErrors = res.filter((r) => r.hasError); const withErrors = res.filter((r) => r.hasError);

View File

@ -1,6 +1,5 @@
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { Component, Input } from '@angular/core'; import { Component, Input } from '@angular/core';
import { UntilDestroy } from '@ngneat/until-destroy';
import { InvoicePaymentChargeback } from '@vality/domain-proto/payment_processing'; import { InvoicePaymentChargeback } from '@vality/domain-proto/payment_processing';
import { DialogService, Column, TableModule, createOperationColumn } from '@vality/ng-core'; import { DialogService, Column, TableModule, createOperationColumn } from '@vality/ng-core';
import startCase from 'lodash-es/startCase'; import startCase from 'lodash-es/startCase';
@ -11,7 +10,6 @@ import { DetailsDialogComponent } from '@cc/app/shared/components/details-dialog
import { getUnionKey } from '../../../../utils'; import { getUnionKey } from '../../../../utils';
import { ChangeChargebacksStatusDialogComponent } from '../change-chargebacks-status-dialog'; import { ChangeChargebacksStatusDialogComponent } from '../change-chargebacks-status-dialog';
@UntilDestroy()
@Component({ @Component({
standalone: true, standalone: true,
selector: 'cc-chargebacks', selector: 'cc-chargebacks',

View File

@ -1,8 +1,8 @@
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { Component } from '@angular/core'; import { Component, DestroyRef } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { ReactiveFormsModule, FormControl } from '@angular/forms'; import { ReactiveFormsModule, FormControl } from '@angular/forms';
import { MatButtonModule } from '@angular/material/button'; import { MatButtonModule } from '@angular/material/button';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { ID } from '@vality/machinegun-proto/internal/base'; import { ID } from '@vality/machinegun-proto/internal/base';
import { import {
DialogSuperclass, DialogSuperclass,
@ -31,7 +31,6 @@ const TYPE_NS_MAP: Record<Type, Namespace[]> = {
[Type.Withdrawal]: [Namespace.Withdrawal, Namespace.WithdrawalSession], [Type.Withdrawal]: [Namespace.Withdrawal, Namespace.WithdrawalSession],
}; };
@UntilDestroy()
@Component({ @Component({
standalone: true, standalone: true,
templateUrl: './fail-machines-dialog.component.html', templateUrl: './fail-machines-dialog.component.html',
@ -58,6 +57,7 @@ export class FailMachinesDialogComponent extends DialogSuperclass<
constructor( constructor(
private automatonService: AutomatonService, private automatonService: AutomatonService,
private log: NotifyLogService, private log: NotifyLogService,
private destroyRef: DestroyRef,
) { ) {
super(); super();
} }
@ -88,7 +88,7 @@ export class FailMachinesDialogComponent extends DialogSuperclass<
this.progress$, this.progress$,
ids, ids,
) )
.pipe(untilDestroyed(this)) .pipe(takeUntilDestroyed(this.destroyRef))
.subscribe((res) => { .subscribe((res) => {
const [result, errors] = splitResultsErrors(res); const [result, errors] = splitResultsErrors(res);
if (errors.length) { if (errors.length) {

View File

@ -1,5 +1,5 @@
import { Component, Input, AfterViewInit, booleanAttribute } from '@angular/core'; import { Component, Input, AfterViewInit, booleanAttribute, DestroyRef } from '@angular/core';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { PartyID } from '@vality/domain-proto/domain'; import { PartyID } from '@vality/domain-proto/domain';
import { import {
Option, Option,
@ -12,7 +12,6 @@ import { catchError, debounceTime, map, switchMap, tap, startWith } from 'rxjs/o
import { DeanonimusService } from '@cc/app/api/deanonimus'; import { DeanonimusService } from '@cc/app/api/deanonimus';
@UntilDestroy()
@Component({ @Component({
selector: 'cc-merchant-field', selector: 'cc-merchant-field',
templateUrl: 'merchant-field.component.html', templateUrl: 'merchant-field.component.html',
@ -32,6 +31,7 @@ export class MerchantFieldComponent
constructor( constructor(
private deanonimusService: DeanonimusService, private deanonimusService: DeanonimusService,
private log: NotifyLogService, private log: NotifyLogService,
private destroyRef: DestroyRef,
) { ) {
super(); super();
} }
@ -46,7 +46,7 @@ export class MerchantFieldComponent
}), }),
debounceTime(600), debounceTime(600),
switchMap((term) => this.searchOptions(term)), switchMap((term) => this.searchOptions(term)),
untilDestroyed(this), takeUntilDestroyed(this.destroyRef),
) )
.subscribe((options) => { .subscribe((options) => {
this.options$.next(options); this.options$.next(options);

View File

@ -1,4 +1,5 @@
import { Component, Input, OnInit } from '@angular/core'; import { Component, Input, OnInit, DestroyRef } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { import {
ValidationErrors, ValidationErrors,
Validator, Validator,
@ -6,7 +7,6 @@ import {
FormControl, FormControl,
AbstractControl, AbstractControl,
} from '@angular/forms'; } from '@angular/forms';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { FormComponentSuperclass } from '@s-libs/ng-core'; import { FormComponentSuperclass } from '@s-libs/ng-core';
import { MapType, SetType, ListType } from '@vality/thrift-ts'; import { MapType, SetType, ListType } from '@vality/thrift-ts';
import { merge } from 'rxjs'; import { merge } from 'rxjs';
@ -26,7 +26,6 @@ function updateFormArray<V>(formArray: FormArray<AbstractControl<V>>, values: V[
type ComplexType<T, K = never> = T[] | Map<K, T> | Set<T>; type ComplexType<T, K = never> = T[] | Map<K, T> | Set<T>;
@UntilDestroy()
@Component({ @Component({
selector: 'cc-complex-form', selector: 'cc-complex-form',
templateUrl: './complex-form.component.html', templateUrl: './complex-form.component.html',
@ -57,9 +56,13 @@ export class ComplexFormComponent<V, K = never>
} }
} }
constructor(private destroyRef: DestroyRef) {
super();
}
ngOnInit() { ngOnInit() {
merge(this.valueControls.valueChanges, this.keyControls.valueChanges) merge(this.valueControls.valueChanges, this.keyControls.valueChanges)
.pipe(untilDestroyed(this)) .pipe(takeUntilDestroyed(this.destroyRef))
.subscribe(() => { .subscribe(() => {
const values = this.valueControls.value; const values = this.valueControls.value;
switch (this.data.type.name) { switch (this.data.type.name) {

View File

@ -1,6 +1,6 @@
import { Component, Input, OnChanges, OnInit } from '@angular/core'; import { Component, Input, OnChanges, OnInit, DestroyRef } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { Validator, ValidationErrors, FormControl, Validators } from '@angular/forms'; import { Validator, ValidationErrors, FormControl, Validators } from '@angular/forms';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { FormComponentSuperclass } from '@s-libs/ng-core'; import { FormComponentSuperclass } from '@s-libs/ng-core';
import { ComponentChanges, createControlProviders } from '@vality/ng-core'; import { ComponentChanges, createControlProviders } from '@vality/ng-core';
import { ThriftType } from '@vality/thrift-ts'; import { ThriftType } from '@vality/thrift-ts';
@ -17,7 +17,6 @@ import {
getFirstDeterminedExtensionsResult, getFirstDeterminedExtensionsResult,
} from '../../types/metadata-form-extension'; } from '../../types/metadata-form-extension';
@UntilDestroy()
@Component({ @Component({
selector: 'cc-extension-field', selector: 'cc-extension-field',
templateUrl: './extension-field.component.html', templateUrl: './extension-field.component.html',
@ -62,11 +61,15 @@ export class ExtensionFieldComponent<T>
shareReplay({ refCount: true, bufferSize: 1 }), shareReplay({ refCount: true, bufferSize: 1 }),
); );
constructor(private destroyRef: DestroyRef) {
super();
}
ngOnInit() { ngOnInit() {
this.control.valueChanges this.control.valueChanges
.pipe( .pipe(
switchMap(() => this.converter$), switchMap(() => this.converter$),
untilDestroyed(this), takeUntilDestroyed(this.destroyRef),
) )
.subscribe((converter) => { .subscribe((converter) => {
this.emitOutgoingValue(converter.internalToOutput(this.control.value) as never); this.emitOutgoingValue(converter.internalToOutput(this.control.value) as never);
@ -74,7 +77,9 @@ export class ExtensionFieldComponent<T>
} }
handleIncomingValue(value: T) { handleIncomingValue(value: T) {
this.converter$.pipe(first(), untilDestroyed(this)).subscribe((converter) => { this.converter$
.pipe(first(), takeUntilDestroyed(this.destroyRef))
.subscribe((converter) => {
this.control.setValue(converter.outputToInternal(value) as never); this.control.setValue(converter.outputToInternal(value) as never);
}); });
} }
@ -97,7 +102,7 @@ export class ExtensionFieldComponent<T>
this.generate$ this.generate$
.pipe( .pipe(
switchMap((generate) => generate()), switchMap((generate) => generate()),
untilDestroyed(this), takeUntilDestroyed(this.destroyRef),
) )
.subscribe((value) => this.control.setValue(value as T)); .subscribe((value) => this.control.setValue(value as T));
event.stopPropagation(); event.stopPropagation();

View File

@ -1,5 +1,5 @@
import { Component, Input, OnChanges } from '@angular/core'; import { Component, Input, OnChanges, DestroyRef } from '@angular/core';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { import {
ComponentChanges, ComponentChanges,
Option, Option,
@ -19,7 +19,6 @@ import {
import { MetadataFormData, getAliases } from '../../types/metadata-form-data'; import { MetadataFormData, getAliases } from '../../types/metadata-form-data';
import { getFirstDeterminedExtensionsResult } from '../../types/metadata-form-extension'; import { getFirstDeterminedExtensionsResult } from '../../types/metadata-form-extension';
@UntilDestroy()
@Component({ @Component({
selector: 'cc-primitive-field', selector: 'cc-primitive-field',
templateUrl: './primitive-field.component.html', templateUrl: './primitive-field.component.html',
@ -85,6 +84,10 @@ export class PrimitiveFieldComponent<T> extends FormControlSuperclass<T> impleme
private data$ = new ReplaySubject<MetadataFormData<ThriftType>>(1); private data$ = new ReplaySubject<MetadataFormData<ThriftType>>(1);
private extensions$ = new ReplaySubject<MetadataFormExtension[]>(1); private extensions$ = new ReplaySubject<MetadataFormExtension[]>(1);
constructor(private destroyRef: DestroyRef) {
super();
}
ngOnChanges(changes: ComponentChanges<PrimitiveFieldComponent<T>>) { ngOnChanges(changes: ComponentChanges<PrimitiveFieldComponent<T>>) {
super.ngOnChanges(changes); super.ngOnChanges(changes);
if (changes.data) { if (changes.data) {
@ -99,7 +102,7 @@ export class PrimitiveFieldComponent<T> extends FormControlSuperclass<T> impleme
this.generate$ this.generate$
.pipe( .pipe(
switchMap((generate) => generate()), switchMap((generate) => generate()),
untilDestroyed(this), takeUntilDestroyed(this.destroyRef),
) )
.subscribe((value) => this.control.setValue(value as T)); .subscribe((value) => this.control.setValue(value as T));
event.stopPropagation(); event.stopPropagation();

View File

@ -1,6 +1,6 @@
import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core'; import { Component, Input, OnChanges, OnInit, SimpleChanges, DestroyRef } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { ValidationErrors, Validators, FormBuilder, FormGroup } from '@angular/forms'; import { ValidationErrors, Validators, FormBuilder, FormGroup } from '@angular/forms';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import isNil from 'lodash-es/isNil'; import isNil from 'lodash-es/isNil';
import omitBy from 'lodash-es/omitBy'; import omitBy from 'lodash-es/omitBy';
import { merge } from 'rxjs'; import { merge } from 'rxjs';
@ -11,7 +11,6 @@ import { createControlProviders, ValidatedControlSuperclass } from '@cc/utils';
import { MetadataFormData } from '../../types/metadata-form-data'; import { MetadataFormData } from '../../types/metadata-form-data';
import { MetadataFormExtension } from '../../types/metadata-form-extension'; import { MetadataFormExtension } from '../../types/metadata-form-extension';
@UntilDestroy()
@Component({ @Component({
selector: 'cc-struct-form', selector: 'cc-struct-form',
templateUrl: './struct-form.component.html', templateUrl: './struct-form.component.html',
@ -35,13 +34,16 @@ export class StructFormComponent<T extends { [N in string]: unknown }>
); );
} }
constructor(private fb: FormBuilder) { constructor(
private fb: FormBuilder,
private destroyRef: DestroyRef,
) {
super(); super();
} }
ngOnInit() { ngOnInit() {
merge(this.control.valueChanges, this.labelControl.valueChanges) merge(this.control.valueChanges, this.labelControl.valueChanges)
.pipe(delay(0), untilDestroyed(this)) .pipe(delay(0), takeUntilDestroyed(this.destroyRef))
.subscribe(() => { .subscribe(() => {
this.emitOutgoingValue( this.emitOutgoingValue(
this.control.value && this.labelControl.value this.control.value && this.labelControl.value

View File

@ -1,6 +1,6 @@
import { Component, Input, OnInit } from '@angular/core'; import { Component, Input, OnInit, DestroyRef } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { ValidationErrors, Validator, FormControl } from '@angular/forms'; import { ValidationErrors, Validator, FormControl } from '@angular/forms';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { FormComponentSuperclass } from '@s-libs/ng-core'; import { FormComponentSuperclass } from '@s-libs/ng-core';
import { Field } from '@vality/thrift-ts'; import { Field } from '@vality/thrift-ts';
import { merge } from 'rxjs'; import { merge } from 'rxjs';
@ -12,7 +12,6 @@ import { MetadataFormData } from '../../types/metadata-form-data';
import { MetadataFormExtension } from '../../types/metadata-form-extension'; import { MetadataFormExtension } from '../../types/metadata-form-extension';
import { getDefaultValue } from '../../utils/get-default-value'; import { getDefaultValue } from '../../utils/get-default-value';
@UntilDestroy()
@Component({ @Component({
selector: 'cc-union-field', selector: 'cc-union-field',
templateUrl: './union-field.component.html', templateUrl: './union-field.component.html',
@ -28,6 +27,10 @@ export class UnionFieldComponent<T extends { [N in string]: unknown }>
fieldControl = new FormControl() as FormControl<Field>; fieldControl = new FormControl() as FormControl<Field>;
internalControl = new FormControl() as FormControl<T[keyof T]>; internalControl = new FormControl() as FormControl<T[keyof T]>;
constructor(private destroyRef: DestroyRef) {
super();
}
ngOnInit() { ngOnInit() {
merge(this.fieldControl.valueChanges, this.internalControl.valueChanges) merge(this.fieldControl.valueChanges, this.internalControl.valueChanges)
.pipe( .pipe(
@ -37,12 +40,12 @@ export class UnionFieldComponent<T extends { [N in string]: unknown }>
}), }),
distinctUntilChanged(), distinctUntilChanged(),
delay(0), delay(0),
untilDestroyed(this), takeUntilDestroyed(this.destroyRef),
) )
.subscribe((value) => { .subscribe((value) => {
this.emitOutgoingValue(value); this.emitOutgoingValue(value);
}); });
this.fieldControl.valueChanges.pipe(untilDestroyed(this)).subscribe(() => { this.fieldControl.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {
this.cleanInternal(true); this.cleanInternal(true);
}); });
} }

View File

@ -1,5 +1,4 @@
import { Component, Input, OnInit, booleanAttribute } from '@angular/core'; import { Component, Input, OnInit, booleanAttribute } from '@angular/core';
import { UntilDestroy } from '@ngneat/until-destroy';
import { PayoutTool } from '@vality/domain-proto/domain'; import { PayoutTool } from '@vality/domain-proto/domain';
import { PartyID, ShopID } from '@vality/domain-proto/payment_processing'; import { PartyID, ShopID } from '@vality/domain-proto/payment_processing';
import { createControlProviders, FormControlSuperclass, Option } from '@vality/ng-core'; import { createControlProviders, FormControlSuperclass, Option } from '@vality/ng-core';
@ -10,7 +9,6 @@ import { PartyManagementService } from '@cc/app/api/payment-processing';
import { handleError, NotificationErrorService } from '../../services/notification-error'; import { handleError, NotificationErrorService } from '../../services/notification-error';
@UntilDestroy()
@Component({ @Component({
selector: 'cc-payout-tool-field', selector: 'cc-payout-tool-field',
templateUrl: 'payout-tool-field.component.html', templateUrl: 'payout-tool-field.component.html',

View File

@ -5,8 +5,9 @@ import {
OnChanges, OnChanges,
OnInit, OnInit,
booleanAttribute, booleanAttribute,
DestroyRef,
} from '@angular/core'; } from '@angular/core';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { Shop } from '@vality/domain-proto/domain'; import { Shop } from '@vality/domain-proto/domain';
import { PartyID, ShopID } from '@vality/domain-proto/payment_processing'; import { PartyID, ShopID } from '@vality/domain-proto/payment_processing';
import { import {
@ -21,7 +22,6 @@ import { filter, map, share, switchMap } from 'rxjs/operators';
import { PartyManagementService } from '@cc/app/api/payment-processing'; import { PartyManagementService } from '@cc/app/api/payment-processing';
@UntilDestroy()
@Component({ @Component({
selector: 'cc-shop-field', selector: 'cc-shop-field',
templateUrl: './shop-field.component.html', templateUrl: './shop-field.component.html',
@ -53,7 +53,10 @@ export class ShopFieldComponent<M extends boolean = boolean>
private partyId$ = new BehaviorSubject<PartyID>(null); private partyId$ = new BehaviorSubject<PartyID>(null);
constructor(private partyManagementService: PartyManagementService) { constructor(
private partyManagementService: PartyManagementService,
private destroyRef: DestroyRef,
) {
super(); super();
} }
@ -79,7 +82,7 @@ export class ShopFieldComponent<M extends boolean = boolean>
? !this.control.value.every((v) => shops.some((s) => s.id === v)) ? !this.control.value.every((v) => shops.some((s) => s.id === v))
: !shops.some((s) => s.id === this.control.value)), : !shops.some((s) => s.id === this.control.value)),
), ),
untilDestroyed(this), takeUntilDestroyed(this.destroyRef),
) )
.subscribe(() => { .subscribe(() => {
this.control.setValue(null); this.control.setValue(null);

View File

@ -3,7 +3,6 @@ import { Component, Output, EventEmitter, Input, booleanAttribute, OnChanges } f
import { MatCardModule } from '@angular/material/card'; import { MatCardModule } from '@angular/material/card';
import { Sort } from '@angular/material/sort'; import { Sort } from '@angular/material/sort';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { UntilDestroy } from '@ngneat/until-destroy';
import { Shop, Party } from '@vality/domain-proto/domain'; import { Shop, Party } from '@vality/domain-proto/domain';
import { import {
InputFieldModule, InputFieldModule,
@ -38,7 +37,6 @@ export interface ShopParty {
}; };
} }
@UntilDestroy()
@Component({ @Component({
selector: 'cc-shops-table', selector: 'cc-shops-table',
standalone: true, standalone: true,

View File

@ -1,14 +1,13 @@
import { Component } from '@angular/core'; import { Component, DestroyRef } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { FormBuilder, ReactiveFormsModule } from '@angular/forms'; import { FormBuilder, ReactiveFormsModule } from '@angular/forms';
import { MatButtonModule } from '@angular/material/button'; import { MatButtonModule } from '@angular/material/button';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { DialogSuperclass, DialogModule, DEFAULT_DIALOG_CONFIG } from '@vality/ng-core'; import { DialogSuperclass, DialogModule, DEFAULT_DIALOG_CONFIG } from '@vality/ng-core';
import { ValueType } from '@vality/thrift-ts'; import { ValueType } from '@vality/thrift-ts';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { DomainThriftFormComponent } from '../domain-thrift-form'; import { DomainThriftFormComponent } from '../domain-thrift-form';
@UntilDestroy()
@Component({ @Component({
standalone: true, standalone: true,
templateUrl: 'domain-thrift-form-dialog.component.html', templateUrl: 'domain-thrift-form-dialog.component.html',
@ -37,14 +36,17 @@ export class DomainThriftFormDialogComponent<T = unknown, R = unknown> extends D
); );
} }
constructor(private fb: FormBuilder) { constructor(
private fb: FormBuilder,
private destroyRef: DestroyRef,
) {
super(); super();
} }
upsert() { upsert() {
this.dialogData this.dialogData
.action(this.control.value) .action(this.control.value)
.pipe(untilDestroyed(this)) .pipe(takeUntilDestroyed(this.destroyRef))
.subscribe({ .subscribe({
next: (result) => { next: (result) => {
this.closeWithSuccess({ object: this.control.value, result }); this.closeWithSuccess({ object: this.control.value, result });

View File

@ -1,6 +1,6 @@
import { formatDate } from '@angular/common'; import { formatDate } from '@angular/common';
import { Injectable } from '@angular/core'; import { Injectable, DestroyRef } from '@angular/core';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { ThriftAstMetadata } from '@vality/domain-proto'; import { ThriftAstMetadata } from '@vality/domain-proto';
import { DomainObject } from '@vality/domain-proto/domain'; import { DomainObject } from '@vality/domain-proto/domain';
import { Rational, Timestamp } from '@vality/domain-proto/internal/base'; import { Rational, Timestamp } from '@vality/domain-proto/internal/base';
@ -16,10 +16,8 @@ import { isTypeWithAliases, MetadataFormData } from '@cc/app/shared/components/m
import { getUnionValue } from '../../../../../../../../utils'; import { getUnionValue } from '../../../../../../../../utils';
import { SidenavInfoService } from '../../../../../sidenav-info'; import { SidenavInfoService } from '../../../../../sidenav-info';
import { getDomainObjectDetails } from '../../../utils';
import { getObjectLabel } from './utils/get-object-label';
@UntilDestroy()
@Injectable({ @Injectable({
providedIn: 'root', providedIn: 'root',
}) })
@ -47,13 +45,14 @@ export class DomainMetadataViewExtensionsService {
}), }),
}, },
]), ]),
untilDestroyed(this), takeUntilDestroyed(this.destroyRef),
shareReplay(1), shareReplay(1),
); );
constructor( constructor(
private domainStoreService: DomainStoreService, private domainStoreService: DomainStoreService,
private sidenavInfoService: SidenavInfoService, private sidenavInfoService: SidenavInfoService,
private destroyRef: DestroyRef,
) {} ) {}
createDomainObjectExtensions(metadata: ThriftAstMetadata[]): MetadataViewExtension[] { createDomainObjectExtensions(metadata: ThriftAstMetadata[]): MetadataViewExtension[] {
@ -74,9 +73,14 @@ export class DomainMetadataViewExtensionsService {
determinant: (data) => of(isTypeWithAliases(data, refType, 'domain')), determinant: (data) => of(isTypeWithAliases(data, refType, 'domain')),
extension: (_, value) => extension: (_, value) =>
this.domainStoreService.getObjectsRefs(objectKey).pipe( this.domainStoreService.getObjectsRefs(objectKey).pipe(
map((objs) => objs.find(([, o]) => isEqual(o[objectKey].ref, value))), map((refObjs) => refObjs.find(([, o]) => isEqual(o[objectKey].ref, value))),
map(([ref, obj]) => ({ map((refObj) => {
value: getObjectLabel(getUnionValue(obj), objectKey), if (!refObj) {
return undefined;
}
const [ref, obj] = refObj;
return {
value: getDomainObjectDetails(obj).label,
tooltip: getUnionValue(ref), tooltip: getUnionValue(ref),
click: () => { click: () => {
this.sidenavInfoService.toggle( this.sidenavInfoService.toggle(
@ -86,7 +90,8 @@ export class DomainMetadataViewExtensionsService {
{ ref }, { ref },
); );
}, },
})), };
}),
), ),
}; };
}); });

View File

@ -1,8 +0,0 @@
import { DomainObject } from '@vality/domain-proto/domain';
import { getDomainObjectValueDetailsFn } from '../../../../utils';
export function getObjectLabel(o: DomainObject[keyof DomainObject], objectKey: keyof DomainObject) {
const details = getDomainObjectValueDetailsFn(objectKey)(o);
return details.label ?? String(details.id);
}

View File

@ -1,5 +1,6 @@
import { DomainObject } from '@vality/domain-proto/domain'; import { DomainObject } from '@vality/domain-proto/domain';
import { inlineJson } from '@vality/ng-core'; import { inlineJson } from '@vality/ng-core';
import startCase from 'lodash-es/startCase';
import { PickByValue, ValuesType } from 'utility-types'; import { PickByValue, ValuesType } from 'utility-types';
import { getUnionKey, getUnionValue } from '../../../../../../utils'; import { getUnionKey, getUnionValue } from '../../../../../../utils';
@ -7,13 +8,15 @@ import { getUnionKey, getUnionValue } from '../../../../../../utils';
export interface DomainObjectDetails { export interface DomainObjectDetails {
id: number | string; id: number | string;
label: string; label: string;
description: string;
type: string;
} }
type GetDomainObjectDetails<TObject extends ValuesType<DomainObject> = ValuesType<DomainObject>> = < type GetDomainObjectDetails<TObject extends ValuesType<DomainObject> = ValuesType<DomainObject>> = <
T extends TObject, T extends TObject,
>( >(
o: T, o: T,
) => DomainObjectDetails; ) => Partial<Omit<DomainObjectDetails, 'type'>>;
type DomainRefDataObjects = PickByValue< type DomainRefDataObjects = PickByValue<
DomainObject, DomainObject,
@ -27,9 +30,9 @@ const defaultGetDomainObjectDetails: GetDomainObjectDetails<ValuesType<DomainRef
) => ({ ) => ({
id: o.ref.id, id: o.ref.id,
label: label:
('name' in o.data ? o.data.name : undefined) ?? ('name' in o.data ? o.data.name : undefined) ||
('id' in o.data ? String(o.data.id ?? '') : undefined) ?? ('id' in o.data ? String(o.data.id ?? undefined) : undefined),
'', description: 'description' in o.data ? o.data.description : undefined,
}); });
type DomainNoRefDataObjects = Omit<DomainObject, keyof DomainRefDataObjects>; type DomainNoRefDataObjects = Omit<DomainObject, keyof DomainRefDataObjects>;
@ -37,12 +40,34 @@ const GET_DOMAIN_OBJECTS_DETAILS: {
[N in keyof DomainNoRefDataObjects]-?: GetDomainObjectDetails<DomainNoRefDataObjects[N]>; [N in keyof DomainNoRefDataObjects]-?: GetDomainObjectDetails<DomainNoRefDataObjects[N]>;
} = { } = {
/* eslint-disable @typescript-eslint/naming-convention */ /* eslint-disable @typescript-eslint/naming-convention */
currency: (o) => ({ id: o.ref.symbolic_code, label: o.data.name }), currency: (o) => ({
payment_method: (o) => ({ id: inlineJson(o.ref.id, Infinity), label: o.data.name }), id: o.ref.symbolic_code,
globals: (o) => ({ id: inlineJson(o.ref), label: inlineJson(o.data) }), label: o.data.name,
identity_provider: (o) => ({ id: o.ref.id, label: inlineJson(o.data) }), description: `Exponent: ${o.data.exponent}`,
dummy_link: (o) => ({ id: o.ref.id, label: o.data.link.id }), }),
limit_config: (o) => ({ id: o.ref.id, label: o.data.description }), payment_method: (o) => ({
id: inlineJson(o.ref.id, Infinity),
label: o.data.name,
description: o.data.description,
}),
globals: (o) => ({
id: inlineJson(o.ref),
label: startCase(getUnionKey(o.data)),
description: inlineJson(o.data),
}),
identity_provider: (o) => ({
id: o.ref.id,
label: startCase(getUnionKey(o.data)),
description: inlineJson(o.data),
}),
dummy_link: (o) => ({
id: o.ref.id,
label: o.data.link.id,
}),
limit_config: (o) => ({
id: o.ref.id,
label: o.data.description,
}),
/* eslint-enable @typescript-eslint/naming-convention */ /* eslint-enable @typescript-eslint/naming-convention */
}; };
@ -52,7 +77,13 @@ export function getDomainObjectValueDetailsFn(key: keyof DomainObject): GetDomai
export function getDomainObjectDetails(o: DomainObject): DomainObjectDetails { export function getDomainObjectDetails(o: DomainObject): DomainObjectDetails {
if (!o) { if (!o) {
return { id: null, label: 'Unknown' }; return { id: null, label: '', description: '', type: '' };
} }
return getDomainObjectValueDetailsFn(getUnionKey(o))(getUnionValue(o)); const result = getDomainObjectValueDetailsFn(getUnionKey(o))(getUnionValue(o));
return {
id: result.id,
label: result.label || result.description || String(result.id) || startCase(getUnionKey(o)),
description: result.label ? result.description : '',
type: startCase(getUnionKey(o)),
};
} }

View File

@ -16,12 +16,11 @@
[namespace]="namespace" [namespace]="namespace"
[type]="type" [type]="type"
></cc-metadata-form> ></cc-metadata-form>
<cc-monaco-editor <ngx-monaco-editor
*ngIf="kind === 'editor'" *ngIf="kind === 'editor'"
[codeLensProviders]="codeLensProviders" [ngModel]="content$ | async"
[completionProviders]="completionProviders" [options]="{ language: 'json' }"
[file]="file$ | async"
class="monaco-editor" class="monaco-editor"
(fileChange)="fileChange($event)" (ngModelChange)="contentChange($event)"
></cc-monaco-editor> ></ngx-monaco-editor>
</div> </div>

View File

@ -5,8 +5,6 @@ import { DialogService, DialogResponseStatus, ConfirmDialogComponent } from '@va
import { merge, defer, of, Subject } from 'rxjs'; import { merge, defer, of, Subject } from 'rxjs';
import { map, filter, shareReplay } from 'rxjs/operators'; import { map, filter, shareReplay } from 'rxjs/operators';
import { toMonacoFile } from '@cc/app/sections/domain/utils';
import { MonacoFile, CodeLensProvider, CompletionProvider } from '@cc/components/monaco-editor';
import { ValidatedFormControlSuperclass, createControlProviders } from '@cc/utils'; import { ValidatedFormControlSuperclass, createControlProviders } from '@cc/utils';
import { objectToJSON } from '@cc/utils/thrift-instance'; import { objectToJSON } from '@cc/utils/thrift-instance';
@ -33,17 +31,14 @@ export class ThriftEditorComponent<T> extends ValidatedFormControlSuperclass<T>
@Input() type: string; @Input() type: string;
@Input() extensions: MetadataFormExtension[]; @Input() extensions: MetadataFormExtension[];
@Input() codeLensProviders: CodeLensProvider[];
@Input() completionProviders: CompletionProvider[];
@Output() changeKind = new EventEmitter<EditorKind>(); @Output() changeKind = new EventEmitter<EditorKind>();
file$ = merge( content$ = merge(
this.control.valueChanges.pipe(filter(() => this.kind !== EditorKind.Editor)), this.control.valueChanges.pipe(filter(() => this.kind !== EditorKind.Editor)),
defer(() => of(this.control.value)), defer(() => of(this.control.value)),
defer(() => this.updateFile$), defer(() => this.updateFile$),
).pipe( ).pipe(
map((value) => toMonacoFile(this.createMonacoContent(value))), map((value) => this.createMonacoContent(value)),
shareReplay({ refCount: true, bufferSize: 1 }), shareReplay({ refCount: true, bufferSize: 1 }),
); );
@ -61,11 +56,11 @@ export class ThriftEditorComponent<T> extends ValidatedFormControlSuperclass<T>
return super.validate(); return super.validate();
} }
fileChange($event: MonacoFile) { contentChange(str: string) {
try { try {
this.editorError = null; this.editorError = null;
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const parsed = JSON.parse($event.content); const parsed = JSON.parse(str);
this.control.setValue(parsed as T); this.control.setValue(parsed as T);
} catch (err) { } catch (err) {
console.warn(err); console.warn(err);

View File

@ -1,12 +1,12 @@
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { ReactiveFormsModule } from '@angular/forms'; import { ReactiveFormsModule, FormsModule } from '@angular/forms';
import { MatButtonModule } from '@angular/material/button'; import { MatButtonModule } from '@angular/material/button';
import { MatButtonToggleModule } from '@angular/material/button-toggle'; import { MatButtonToggleModule } from '@angular/material/button-toggle';
import { MatIconModule } from '@angular/material/icon'; import { MatIconModule } from '@angular/material/icon';
import { MonacoEditorModule } from 'ngx-monaco-editor-v2';
import { MetadataFormModule } from '@cc/app/shared/components/metadata-form'; import { MetadataFormModule } from '@cc/app/shared/components/metadata-form';
import { MonacoEditorModule } from '@cc/components/monaco-editor';
import { ThriftEditorComponent } from './thrift-editor.component'; import { ThriftEditorComponent } from './thrift-editor.component';
@ -21,6 +21,7 @@ import { ThriftEditorComponent } from './thrift-editor.component';
MatButtonToggleModule, MatButtonToggleModule,
MatButtonModule, MatButtonModule,
MatIconModule, MatIconModule,
FormsModule,
], ],
}) })
export class ThriftEditorModule {} export class ThriftEditorModule {}

View File

@ -6,13 +6,13 @@
</div> </div>
<ng-template #loaded> <ng-template #loaded>
<div class="wrapper"> <div class="wrapper">
<cc-monaco-diff-editor <ngx-monaco-diff-editor
*ngIf="isDiff; else standard" *ngIf="isDiff; else standard"
[modified]="comparedFile$ | async" [modifiedModel]="comparedFile$ | async"
[options]="{ renderSideBySide: true, readOnly: true }" [options]="{ renderSideBySide: true, readOnly: true }"
[original]="valueFile$ | async" [originalModel]="valueFile$ | async"
class="monaco-editor" class="monaco-editor"
></cc-monaco-diff-editor> ></ngx-monaco-diff-editor>
<ng-template #standard> <ng-template #standard>
<cc-json-viewer <cc-json-viewer
*ngIf="kind === 'component'" *ngIf="kind === 'component'"
@ -22,13 +22,13 @@
[type]="type" [type]="type"
[value]="value" [value]="value"
></cc-json-viewer> ></cc-json-viewer>
<cc-monaco-editor <ngx-monaco-editor
*ngIf="kind === 'editor'" *ngIf="kind === 'editor'"
[file]="valueFile$ | async" [ngModel]="(valueFile$ | async).code"
[options]="{ readOnly: true }" [options]="{ readOnly: true, language: (valueFile$ | async).language }"
class="monaco-editor" class="monaco-editor"
> >
</cc-monaco-editor> </ngx-monaco-editor>
<div class="actions"> <div class="actions">
<button color="primary" mat-icon-button (click)="toggleKind()"> <button color="primary" mat-icon-button (click)="toggleKind()">
<mat-icon *ngIf="kind === 'component'">code_blocks</mat-icon> <mat-icon *ngIf="kind === 'component'">code_blocks</mat-icon>

View File

@ -1,22 +1,18 @@
import { Component, Input, OnChanges, Output, EventEmitter, booleanAttribute } from '@angular/core'; import { Component, Input, OnChanges, Output, EventEmitter, booleanAttribute } from '@angular/core';
import { UntilDestroy } from '@ngneat/until-destroy';
import { ThriftAstMetadata } from '@vality/domain-proto'; import { ThriftAstMetadata } from '@vality/domain-proto';
import { ComponentChanges } from '@vality/ng-core'; import { ComponentChanges } from '@vality/ng-core';
import { ValueType } from '@vality/thrift-ts'; import { ValueType } from '@vality/thrift-ts';
import { DiffEditorModel } from 'ngx-monaco-editor-v2';
import { ReplaySubject } from 'rxjs'; import { ReplaySubject } from 'rxjs';
import { MetadataViewExtension } from '@cc/app/shared/components/json-viewer'; import { MetadataViewExtension } from '@cc/app/shared/components/json-viewer';
import { objectToJSON } from '@cc/utils/thrift-instance'; import { objectToJSON } from '@cc/utils/thrift-instance';
import { MonacoFile } from '../../../../components/monaco-editor';
import { toMonacoFile } from '../../../sections/domain/utils';
export enum ViewerKind { export enum ViewerKind {
Editor = 'editor', Editor = 'editor',
Component = 'component', Component = 'component',
} }
@UntilDestroy()
@Component({ @Component({
selector: 'cc-thrift-viewer', selector: 'cc-thrift-viewer',
templateUrl: './thrift-viewer.component.html', templateUrl: './thrift-viewer.component.html',
@ -35,8 +31,8 @@ export class ThriftViewerComponent<T> implements OnChanges {
@Output() changeKind = new EventEmitter<ViewerKind>(); @Output() changeKind = new EventEmitter<ViewerKind>();
valueFile$ = new ReplaySubject<MonacoFile>(1); valueFile$ = new ReplaySubject<DiffEditorModel>(1);
comparedFile$ = new ReplaySubject<MonacoFile>(1); comparedFile$ = new ReplaySubject<DiffEditorModel>(1);
get isDiff() { get isDiff() {
return !!this.compared; return !!this.compared;
@ -44,12 +40,16 @@ export class ThriftViewerComponent<T> implements OnChanges {
ngOnChanges(changes: ComponentChanges<ThriftViewerComponent<T>>) { ngOnChanges(changes: ComponentChanges<ThriftViewerComponent<T>>) {
if (changes.value) { if (changes.value) {
this.valueFile$.next(toMonacoFile(JSON.stringify(objectToJSON(this.value), null, 2))); this.valueFile$.next({
code: JSON.stringify(objectToJSON(this.value), null, 2),
language: 'json',
});
} }
if (changes.compared) { if (changes.compared) {
this.comparedFile$.next( this.comparedFile$.next({
toMonacoFile(JSON.stringify(objectToJSON(this.compared), null, 2)), code: JSON.stringify(objectToJSON(this.compared), null, 2),
); language: 'json',
});
} }
} }

View File

@ -1,13 +1,13 @@
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { ReactiveFormsModule } from '@angular/forms'; import { ReactiveFormsModule, FormsModule } from '@angular/forms';
import { MatButtonModule } from '@angular/material/button'; import { MatButtonModule } from '@angular/material/button';
import { MatButtonToggleModule } from '@angular/material/button-toggle'; import { MatButtonToggleModule } from '@angular/material/button-toggle';
import { MatIconModule } from '@angular/material/icon'; import { MatIconModule } from '@angular/material/icon';
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner'; import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { MonacoEditorModule } from 'ngx-monaco-editor-v2';
import { MetadataFormModule } from '@cc/app/shared/components/metadata-form'; import { MetadataFormModule } from '@cc/app/shared/components/metadata-form';
import { MonacoEditorModule } from '@cc/components/monaco-editor';
import { JsonViewerModule } from '../json-viewer'; import { JsonViewerModule } from '../json-viewer';
@ -26,6 +26,7 @@ import { ThriftViewerComponent } from './thrift-viewer.component';
MatIconModule, MatIconModule,
JsonViewerModule, JsonViewerModule,
MatProgressSpinnerModule, MatProgressSpinnerModule,
FormsModule,
], ],
}) })
export class ThriftViewerModule {} export class ThriftViewerModule {}

View File

@ -1,11 +1,10 @@
import { Injectable } from '@angular/core'; import { Injectable, DestroyRef } from '@angular/core';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { BehaviorSubject, NEVER, ReplaySubject, Subject } from 'rxjs'; import { BehaviorSubject, NEVER, ReplaySubject, Subject } from 'rxjs';
import { catchError, switchMap, shareReplay, tap } from 'rxjs/operators'; import { catchError, switchMap, shareReplay, tap } from 'rxjs/operators';
import { ManagementService } from '@cc/app/api/wallet'; import { ManagementService } from '@cc/app/api/wallet';
@UntilDestroy()
@Injectable() @Injectable()
export class ReceiveWalletService { export class ReceiveWalletService {
private receiveWallet$ = new ReplaySubject<string>(); private receiveWallet$ = new ReplaySubject<string>();
@ -26,7 +25,7 @@ export class ReceiveWalletService {
), ),
), ),
tap(() => this.loading$.next(false)), tap(() => this.loading$.next(false)),
untilDestroyed(this), takeUntilDestroyed(this.destroyRef),
shareReplay(1), shareReplay(1),
); );
@ -35,7 +34,10 @@ export class ReceiveWalletService {
// eslint-disable-next-line @typescript-eslint/member-ordering // eslint-disable-next-line @typescript-eslint/member-ordering
hasError$ = this.error$.asObservable(); hasError$ = this.error$.asObservable();
constructor(private walletManagementService: ManagementService) {} constructor(
private walletManagementService: ManagementService,
private destroyRef: DestroyRef,
) {}
receiveWallet(id: string): void { receiveWallet(id: string): void {
this.receiveWallet$.next(id); this.receiveWallet$.next(id);

View File

@ -1,6 +1,13 @@
import { formatCurrency, getCurrencySymbol } from '@angular/common'; import { formatCurrency, getCurrencySymbol } from '@angular/common';
import { Pipe, Inject, LOCALE_ID, DEFAULT_CURRENCY_CODE, PipeTransform } from '@angular/core'; import {
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; Pipe,
Inject,
LOCALE_ID,
DEFAULT_CURRENCY_CODE,
PipeTransform,
DestroyRef,
} from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { CurrencyObject } from '@vality/domain-proto/domain'; import { CurrencyObject } from '@vality/domain-proto/domain';
import isNil from 'lodash-es/isNil'; import isNil from 'lodash-es/isNil';
import { ReplaySubject, combineLatest } from 'rxjs'; import { ReplaySubject, combineLatest } from 'rxjs';
@ -10,7 +17,6 @@ import { DomainStoreService } from '@cc/app/api/domain-config';
import { toMajor } from '../../../utils'; import { toMajor } from '../../../utils';
@UntilDestroy()
@Pipe({ @Pipe({
standalone: true, standalone: true,
pure: false, pure: false,
@ -29,6 +35,7 @@ export class AmountCurrencyPipe implements PipeTransform {
@Inject(LOCALE_ID) private _locale: string, @Inject(LOCALE_ID) private _locale: string,
@Inject(DEFAULT_CURRENCY_CODE) private _defaultCurrencyCode: string = 'USD', @Inject(DEFAULT_CURRENCY_CODE) private _defaultCurrencyCode: string = 'USD',
private domainStoreService: DomainStoreService, private domainStoreService: DomainStoreService,
private destroyRef: DestroyRef,
) {} ) {}
init() { init() {
@ -61,7 +68,7 @@ export class AmountCurrencyPipe implements PipeTransform {
format === 'short' ? '0.0-2' : undefined, format === 'short' ? '0.0-2' : undefined,
); );
}), }),
untilDestroyed(this), takeUntilDestroyed(this.destroyRef),
) )
.subscribe((value) => { .subscribe((value) => {
this.latestValue = value; this.latestValue = value;

View File

@ -1,5 +1,4 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { UntilDestroy } from '@ngneat/until-destroy';
import jwtDecode from 'jwt-decode'; import jwtDecode from 'jwt-decode';
import { KeycloakService } from 'keycloak-angular'; import { KeycloakService } from 'keycloak-angular';
import { Observable, defer, switchMap, of } from 'rxjs'; import { Observable, defer, switchMap, of } from 'rxjs';
@ -7,7 +6,6 @@ import { map, shareReplay } from 'rxjs/operators';
import { KeycloakToken } from './types/keycloak-token'; import { KeycloakToken } from './types/keycloak-token';
@UntilDestroy()
@Injectable({ providedIn: 'root' }) @Injectable({ providedIn: 'root' })
export class KeycloakTokenInfoService { export class KeycloakTokenInfoService {
info$: Observable<KeycloakToken> = defer(() => this.token$).pipe( info$: Observable<KeycloakToken> = defer(() => this.token$).pipe(

View File

@ -3,6 +3,9 @@ import { MatSnackBar } from '@angular/material/snack-bar';
const DEFAULT_DURATION_MS = 3000; const DEFAULT_DURATION_MS = 3000;
/**
* @deprecated
*/
@Injectable({ providedIn: 'root' }) @Injectable({ providedIn: 'root' })
export class NotificationService { export class NotificationService {
constructor(private snackBar: MatSnackBar) {} constructor(private snackBar: MatSnackBar) {}

View File

@ -1,4 +1,5 @@
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { DestroyRef, inject } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { EMPTY, merge, Observable, of, Subject } from 'rxjs'; import { EMPTY, merge, Observable, of, Subject } from 'rxjs';
import { import {
debounceTime, debounceTime,
@ -27,7 +28,6 @@ import { SHARE_REPLAY_CONF } from './utils/share-replay-conf';
/** /**
* @deprecated * @deprecated
*/ */
@UntilDestroy()
export abstract class PartialFetcher<R, P> { export abstract class PartialFetcher<R, P> {
readonly fetchResultChanges$: Observable<{ readonly fetchResultChanges$: Observable<{
result: R[]; result: R[];
@ -42,6 +42,7 @@ export abstract class PartialFetcher<R, P> {
readonly errors$: Observable<unknown>; readonly errors$: Observable<unknown>;
private action$ = new Subject<FetchAction<P>>(); private action$ = new Subject<FetchAction<P>>();
private destroyRef = inject(DestroyRef);
// TODO: make a dependency for DI // TODO: make a dependency for DI
constructor( constructor(
@ -93,7 +94,7 @@ export abstract class PartialFetcher<R, P> {
this.errors$, this.errors$,
this.fetchResultChanges$, this.fetchResultChanges$,
) )
.pipe(untilDestroyed(this)) .pipe(takeUntilDestroyed(this.destroyRef))
.subscribe(); .subscribe();
} }

View File

@ -7,10 +7,11 @@ import {
LOCALE_ID, LOCALE_ID,
OnInit, OnInit,
booleanAttribute, booleanAttribute,
DestroyRef,
} from '@angular/core'; } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { Validator, ValidationErrors, FormControl } from '@angular/forms'; import { Validator, ValidationErrors, FormControl } from '@angular/forms';
import { createMask } from '@ngneat/input-mask'; import { createMask } from '@ngneat/input-mask';
import { untilDestroyed, UntilDestroy } from '@ngneat/until-destroy';
import { FormComponentSuperclass } from '@s-libs/ng-core'; import { FormComponentSuperclass } from '@s-libs/ng-core';
import sortBy from 'lodash-es/sortBy'; import sortBy from 'lodash-es/sortBy';
import { combineLatest } from 'rxjs'; import { combineLatest } from 'rxjs';
@ -27,7 +28,6 @@ export interface Cash {
const GROUP_SEPARATOR = ' '; const GROUP_SEPARATOR = ' ';
@UntilDestroy()
@Component({ @Component({
selector: 'cc-cash-field', selector: 'cc-cash-field',
templateUrl: './cash-field.component.html', templateUrl: './cash-field.component.html',
@ -77,6 +77,7 @@ export class CashFieldComponent extends FormComponentSuperclass<Cash> implements
injector: Injector, injector: Injector,
@Inject(LOCALE_ID) private _locale: string, @Inject(LOCALE_ID) private _locale: string,
private domainStoreService: DomainStoreService, private domainStoreService: DomainStoreService,
private destroyRef: DestroyRef,
) { ) {
super(injector); super(injector);
} }
@ -88,7 +89,7 @@ export class CashFieldComponent extends FormComponentSuperclass<Cash> implements
]) ])
.pipe( .pipe(
switchMap(([currencyCode]) => this.getCurrencyByCode(currencyCode)), switchMap(([currencyCode]) => this.getCurrencyByCode(currencyCode)),
untilDestroyed(this), takeUntilDestroyed(this.destroyRef),
) )
.subscribe((currency) => { .subscribe((currency) => {
const amountStr = this.amountControl.value; const amountStr = this.amountControl.value;

View File

@ -1,76 +0,0 @@
import {
Directive,
ElementRef,
EventEmitter,
Input,
OnChanges,
OnDestroy,
OnInit,
Output,
SimpleChanges,
} from '@angular/core';
import { ComponentChanges } from '@vality/ng-core';
import isNil from 'lodash-es/isNil';
import { AbstractMonacoService } from './abstract-monaco.service';
import {
CodeLensProvider,
CompletionProvider,
IDisposable,
IEditor,
IDiffEditorOptions,
MonacoFile,
} from './model';
@Directive()
export abstract class AbstractMonacoDirective implements OnInit, OnChanges, OnDestroy {
@Input() options: IDiffEditorOptions;
@Input() set codeLensProviders(providers: CodeLensProvider[]) {
if (!isNil(providers) && providers.length > 0) {
this.monacoEditorService.addCodeLensProvider(providers);
}
}
@Input() set completionProviders(providers: CompletionProvider[]) {
if (!isNil(providers) && providers.length > 0) {
this.monacoEditorService.addCompletionProvider(providers);
}
}
@Output() fileChange = new EventEmitter<MonacoFile>();
@Output() ready = new EventEmitter<IEditor>();
@Output() codeLensProviderRegistered = new EventEmitter<IDisposable[]>();
@Output() completionProviderRegistered = new EventEmitter<IDisposable[]>();
constructor(
protected monacoEditorService: AbstractMonacoService,
protected editorRef: ElementRef,
) {}
ngOnChanges(changes: ComponentChanges<AbstractMonacoDirective>) {
this.childOnChanges(changes);
if (!isNil(changes.options?.currentValue)) {
this.monacoEditorService.updateOptions(changes.options.currentValue);
}
}
ngOnInit() {
this.monacoEditorService
.init(this.editorRef, this.options)
.subscribe(() => this.ready.emit(this.monacoEditorService.editor));
this.monacoEditorService.fileChange.subscribe((file) => this.fileChange.emit(file));
this.monacoEditorService
.codeLensProviderRegistered()
.subscribe((disposable) => this.codeLensProviderRegistered.emit(disposable));
this.monacoEditorService
.completionProviderRegistered()
.subscribe((disposable) => this.completionProviderRegistered.emit(disposable));
}
ngOnDestroy() {
this.monacoEditorService.destroy();
}
abstract childOnChanges(changes: SimpleChanges);
}

View File

@ -1,169 +0,0 @@
import { ElementRef, NgZone } from '@angular/core';
import { ResizeSensor } from 'css-element-queries';
import { Observable, Subject } from 'rxjs';
import { map, take, takeUntil, tap, first } from 'rxjs/operators';
import { BOOTSTRAP$ } from './bootstrap';
import { fromDisposable } from './from-disposable';
import {
CodeLensProvider,
CompletionProvider,
IDisposable,
IEditorOptions,
ITextModel,
MonacoFile,
} from './model';
import { CodeLensService } from './providers/code-lens.service';
import { CompletionService } from './providers/completion.service';
export abstract class AbstractMonacoService {
protected _editor: monaco.editor.IEditor;
private editorInitialized$ = new Subject<void>();
private fileChange$ = new Subject<MonacoFile>();
private nativeElement: HTMLElement;
private destroy$ = new Subject<void>();
private resizeDetector: ResizeSensor;
get fileChange(): Observable<MonacoFile> {
return this.fileChange$.pipe(takeUntil(this.destroy$));
}
get editor(): monaco.editor.IEditor {
return this._editor;
}
constructor(
protected zone: NgZone,
protected codeLensService: CodeLensService,
protected completionService: CompletionService,
protected tokenCodeLensProviders: CodeLensProvider[],
protected tokenCompletionProviders: CompletionProvider[],
) {
BOOTSTRAP$.pipe(first()).subscribe(() => {
this.registerCodeLensListener();
this.registerCompletionListener();
});
}
init({ nativeElement }: ElementRef, options: IEditorOptions = {}): Observable<void> {
this.nativeElement = nativeElement;
this.registerResizeListener();
return BOOTSTRAP$.pipe(
tap(() => {
this.disposeModels();
this._editor = this.createEditor(nativeElement, options);
this.codeLensService.add(this.tokenCodeLensProviders);
this.completionService.add(this.tokenCompletionProviders);
this.openFile();
this.editorInitialized$.next();
}),
);
}
destroy() {
if (this.resizeDetector) {
this.resizeDetector.detach();
}
this.destroy$.next();
}
updateOptions(options: IEditorOptions) {
if (this._editor) {
this._editor.updateOptions(options);
}
}
addCodeLensProvider(providers: CodeLensProvider[]) {
this.codeLensService.add(providers);
}
codeLensProviderRegistered(): Observable<IDisposable[]> {
return this.codeLensService.registered.pipe(takeUntil(this.destroy$));
}
addCompletionProvider(providers: CompletionProvider[]) {
this.completionService.add(providers);
}
completionProviderRegistered(): Observable<IDisposable[]> {
return this.completionService.registered.pipe(takeUntil(this.destroy$));
}
protected abstract createEditor(
el: HTMLElement,
options: IEditorOptions,
): monaco.editor.IEditor;
protected abstract openFile();
protected prepareModel(file: MonacoFile): ITextModel {
const uri = monaco.Uri.file(file.uri);
let model = monaco.editor.getModel(uri);
if (model) {
if (file.language && model.getModeId() !== file.language) {
model.dispose();
model = undefined;
} else {
model.setValue(file.content);
}
} else {
model = monaco.editor.createModel(file.content, file.language, uri);
this.registerModelChangeListener(file, model);
}
return model;
}
protected getLayout() {
return this.nativeElement.getBoundingClientRect();
}
private disposeModels() {
for (const model of monaco.editor.getModels()) {
model.dispose();
}
this.codeLensService.dispose();
this.completionService.dispose();
}
private registerCompletionListener() {
this.completionService.providers.subscribe((providers) =>
this.completionService.register(providers),
);
}
private registerCodeLensListener() {
this.codeLensService.providers.subscribe((providers) =>
this.codeLensService.register(providers),
);
}
private registerModelChangeListener(file: MonacoFile, model: monaco.editor.IModel) {
const destroy = fromDisposable(model.onWillDispose.bind(model)).pipe(take(1));
fromDisposable(model.onDidChangeContent.bind(model))
.pipe(
map(() => model.getValue()),
takeUntil(destroy),
)
.subscribe((content: string) =>
this.zone.run(() =>
this.fileChange$.next({
...file,
content,
}),
),
);
}
private registerResizeListener() {
if (this.resizeDetector) {
this.resizeDetector.detach();
}
this.resizeDetector = new ResizeSensor(this.nativeElement, () => {
this.updateLayoutSize();
});
}
private updateLayoutSize() {
this._editor.layout(this.getLayout());
}
}

View File

@ -1,20 +0,0 @@
import { Observable } from 'rxjs';
import { shareReplay } from 'rxjs/operators';
// eslint-disable-next-line @typescript-eslint/naming-convention
declare const window: {
require: { config: (arg: unknown) => unknown } & ((arg0: string[], arg1: unknown) => unknown);
};
export const BOOTSTRAP$ = new Observable<void>((observer) => {
const script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'libs/vs/loader.js';
script.onload = () => {
window.require.config({ paths: { vs: 'libs/vs' } });
window.require(['vs/editor/editor.main'], () => {
observer.next();
});
};
document.body.appendChild(script);
}).pipe(shareReplay(1));

View File

@ -1,13 +0,0 @@
import { Observable } from 'rxjs';
export function fromDisposable<T>(
source: (listener: (e: T) => void) => monaco.IDisposable,
): Observable<T> {
return new Observable<T>((observer) => {
const disposable = source((e) => {
observer.next(e);
});
return () => disposable.dispose();
});
}

View File

@ -1,4 +0,0 @@
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
/// <reference path="../../../node_modules/monaco-editor/monaco.d.ts" />
export * from './monaco-editor.module';
export * from './model';

View File

@ -1,37 +0,0 @@
// eslint-disable-next-line @typescript-eslint/naming-convention
export type IEditorOptions = monaco.editor.IEditorOptions;
// eslint-disable-next-line @typescript-eslint/naming-convention
export type IDiffEditorOptions = monaco.editor.IDiffEditorOptions;
// eslint-disable-next-line @typescript-eslint/naming-convention
export type ITextModel = monaco.editor.ITextModel;
export type CancellationToken = monaco.CancellationToken;
export type ProviderResult<T> = monaco.languages.ProviderResult<T>;
// eslint-disable-next-line @typescript-eslint/naming-convention
export type IDisposable = monaco.IDisposable;
export type Position = monaco.Position;
export type CompletionList = monaco.languages.CompletionList;
export type CompletionContext = monaco.languages.CompletionContext;
export type CodeLensList = monaco.languages.CodeLensList;
export type CodeLens = monaco.languages.CodeLens;
// eslint-disable-next-line @typescript-eslint/naming-convention
export type IEditor = monaco.editor.IEditor;
// eslint-disable-next-line @typescript-eslint/naming-convention
export type IStandaloneCodeEditor = monaco.editor.IStandaloneCodeEditor;
// eslint-disable-next-line @typescript-eslint/naming-convention
export type IStandaloneDiffEditor = monaco.editor.IStandaloneDiffEditor;
export interface MonacoFile {
uri: string;
content: string;
language?: string;
}
export interface LanguageProvider {
readonly language: string;
}
export interface CodeLensProvider extends monaco.languages.CodeLensProvider, LanguageProvider {}
export interface CompletionProvider
extends monaco.languages.CompletionItemProvider,
LanguageProvider {}

View File

@ -1,26 +0,0 @@
import { Directive, ElementRef, Input, SimpleChanges } from '@angular/core';
import { AbstractMonacoDirective } from './abstract-monaco.directive';
import { MonacoFile } from './model';
import { MonacoDiffEditorService } from './monaco-diff-editor.service';
@Directive({
selector: 'cc-monaco-diff-editor,[ccMonacoDiffEditor]',
})
export class MonacoDiffEditorDirective extends AbstractMonacoDirective {
@Input() original: MonacoFile;
@Input() modified: MonacoFile;
constructor(
protected editorService: MonacoDiffEditorService,
protected editorRef: ElementRef,
) {
super(editorService, editorRef);
}
childOnChanges({ original, modified }: SimpleChanges) {
if (original && modified) {
this.editorService.open(original.currentValue, modified.currentValue);
}
}
}

View File

@ -1,60 +0,0 @@
import { Inject, Injectable, NgZone, Optional } from '@angular/core';
import { AbstractMonacoService } from './abstract-monaco.service';
import { CodeLensProvider, CompletionProvider, IEditorOptions, MonacoFile } from './model';
import { CodeLensService } from './providers/code-lens.service';
import { CompletionService } from './providers/completion.service';
import { CODE_LENS_PROVIDERS, COMPLETION_PROVIDERS } from './tokens';
@Injectable()
export class MonacoDiffEditorService extends AbstractMonacoService {
private original: MonacoFile;
private modified: MonacoFile;
constructor(
@Optional()
@Inject(CODE_LENS_PROVIDERS)
protected tokenCodeLensProviders: CodeLensProvider[],
@Optional()
@Inject(COMPLETION_PROVIDERS)
protected tokenCompletionProviders: CompletionProvider[],
protected zone: NgZone,
protected codeLensService: CodeLensService,
protected completionService: CompletionService,
) {
super(
zone,
codeLensService,
completionService,
tokenCodeLensProviders,
tokenCompletionProviders,
);
}
open(original: MonacoFile, modified: MonacoFile) {
this.original = original;
this.modified = modified;
if (!this._editor || !this.original || !this.modified) {
return;
}
this._editor.setModel({
original: this.prepareModel(original),
modified: this.prepareModel(modified),
});
}
protected createEditor(
el: HTMLElement,
options: IEditorOptions,
): monaco.editor.IStandaloneDiffEditor {
return monaco.editor.createDiffEditor(el, {
...options,
});
}
protected openFile() {
if (this.original && this.modified) {
this.open(this.original, this.modified);
}
}
}

View File

@ -1,26 +0,0 @@
import { Directive, ElementRef, Input } from '@angular/core';
import { ComponentChanges } from '@vality/ng-core';
import { AbstractMonacoDirective } from './abstract-monaco.directive';
import { MonacoFile } from './model';
import { MonacoEditorService } from './monaco-editor.service';
@Directive({
selector: 'cc-monaco-editor,[ccMonacoEditor]',
})
export class MonacoEditorDirective extends AbstractMonacoDirective {
@Input() file: MonacoFile;
constructor(
protected editorService: MonacoEditorService,
protected editorRef: ElementRef,
) {
super(editorService, editorRef);
}
childOnChanges({ file }: ComponentChanges<MonacoEditorDirective>) {
if (file) {
this.editorService.open(file.currentValue);
}
}
}

View File

@ -1,17 +0,0 @@
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { MonacoDiffEditorDirective } from './monaco-diff-editor.directive';
import { MonacoDiffEditorService } from './monaco-diff-editor.service';
import { MonacoEditorDirective } from './monaco-editor.directive';
import { MonacoEditorService } from './monaco-editor.service';
import { CodeLensService } from './providers/code-lens.service';
import { CompletionService } from './providers/completion.service';
@NgModule({
declarations: [MonacoEditorDirective, MonacoDiffEditorDirective],
imports: [CommonModule],
exports: [MonacoEditorDirective, MonacoDiffEditorDirective],
providers: [MonacoEditorService, CodeLensService, CompletionService, MonacoDiffEditorService],
})
export class MonacoEditorModule {}

View File

@ -1,54 +0,0 @@
import { Inject, Injectable, NgZone, Optional } from '@angular/core';
import { AbstractMonacoService } from './abstract-monaco.service';
import { CodeLensProvider, CompletionProvider, IEditorOptions, MonacoFile } from './model';
import { CodeLensService } from './providers/code-lens.service';
import { CompletionService } from './providers/completion.service';
import { CODE_LENS_PROVIDERS, COMPLETION_PROVIDERS } from './tokens';
@Injectable()
export class MonacoEditorService extends AbstractMonacoService {
private file: MonacoFile;
constructor(
@Optional()
@Inject(CODE_LENS_PROVIDERS)
protected tokenCodeLensProviders: CodeLensProvider[],
@Optional()
@Inject(COMPLETION_PROVIDERS)
protected tokenCompletionProviders: CompletionProvider[],
protected codeLensService: CodeLensService,
protected completionService: CompletionService,
protected zone: NgZone,
) {
super(
zone,
codeLensService,
completionService,
tokenCodeLensProviders,
tokenCompletionProviders,
);
}
open(file: MonacoFile) {
this.file = file;
if (!this._editor || !this.file) {
return;
}
this._editor.setModel(this.prepareModel(file));
}
protected createEditor(
el: HTMLElement,
options: IEditorOptions,
): monaco.editor.IStandaloneCodeEditor {
return monaco.editor.create(el, {
...options,
});
}
protected openFile() {
if (this.file) {
this.open(this.file);
}
}
}

View File

@ -1,15 +0,0 @@
import { Injectable } from '@angular/core';
import { CodeLensProvider, IDisposable } from '../model';
import { ProviderRegister } from './provider-register';
@Injectable()
export class CodeLensService extends ProviderRegister<CodeLensProvider> {
protected registerProvider(provider: CodeLensProvider): IDisposable {
if (!provider) {
return undefined;
}
return monaco.languages.registerCodeLensProvider(provider.language, provider);
}
}

Some files were not shown because too many files have changed in this diff Show More