Browse Source

Refactoring

pull/3898/head
Thomas Kaul 11 months ago
parent
commit
cc855c5921
  1. 10
      apps/api/src/app/portfolio/rules.service.ts
  2. 4
      apps/client/src/app/components/rule/rule.component.html
  3. 3
      apps/client/src/app/components/rule/rule.component.ts
  4. 8
      libs/common/src/lib/interfaces/portfolio-report-rule.interface.ts
  5. 4
      libs/common/src/lib/types/x-ray-rules-settings.type.ts

10
apps/api/src/app/portfolio/rules.service.ts

@ -25,13 +25,13 @@ export class RulesService {
return { return {
evaluation, evaluation,
value, value,
isActive: true, configuration: {
key: rule.getKey(),
name: rule.getName(),
settings: {
thresholdMax: isNumber(settings['thresholdMax']) ? true : false, thresholdMax: isNumber(settings['thresholdMax']) ? true : false,
thresholdMin: isNumber(settings['thresholdMin']) ? true : false thresholdMin: isNumber(settings['thresholdMin']) ? true : false
} as PortfolioReportRule['settings'] } as PortfolioReportRule['configuration'],
isActive: true,
key: rule.getKey(),
name: rule.getName()
}; };
} else { } else {
return { return {

4
apps/client/src/app/components/rule/rule.component.html

@ -64,8 +64,8 @@
<mat-menu #rulesMenu="matMenu" xPosition="before"> <mat-menu #rulesMenu="matMenu" xPosition="before">
@if ( @if (
rule?.isActive && rule?.isActive &&
(rule?.settings.thresholdMax >= 0 || (rule?.configuration?.thresholdMax ||
rule?.settings.thresholdMin >= 0) rule?.configuration?.thresholdMin)
) { ) {
<button mat-menu-item (click)="onCustomizeRule(rule)"> <button mat-menu-item (click)="onCustomizeRule(rule)">
<ng-container i18n>Customize</ng-container>... <ng-container i18n>Customize</ng-container>...

3
apps/client/src/app/components/rule/rule.component.ts

@ -1,4 +1,5 @@
import { UpdateUserSettingDto } from '@ghostfolio/api/app/user/update-user-setting.dto'; import { UpdateUserSettingDto } from '@ghostfolio/api/app/user/update-user-setting.dto';
import { RuleSettings } from '@ghostfolio/api/models/interfaces/rule-settings.interface';
import { PortfolioReportRule } from '@ghostfolio/common/interfaces'; import { PortfolioReportRule } from '@ghostfolio/common/interfaces';
import { XRayRulesSettings } from '@ghostfolio/common/types'; import { XRayRulesSettings } from '@ghostfolio/common/types';
@ -55,7 +56,7 @@ export class RuleComponent implements OnInit {
dialogRef dialogRef
.afterClosed() .afterClosed()
.pipe(takeUntil(this.unsubscribeSubject)) .pipe(takeUntil(this.unsubscribeSubject))
.subscribe((settings: PortfolioReportRule['settings']) => { .subscribe((settings: RuleSettings) => {
if (settings) { if (settings) {
this.ruleUpdated.emit({ this.ruleUpdated.emit({
xRayRules: { xRayRules: {

8
libs/common/src/lib/interfaces/portfolio-report-rule.interface.ts

@ -1,11 +1,11 @@
export interface PortfolioReportRule { export interface PortfolioReportRule {
configuration?: {
thresholdMax: boolean;
thresholdMin: boolean;
};
evaluation?: string; evaluation?: string;
isActive: boolean; isActive: boolean;
key: string; key: string;
name: string; name: string;
settings?: {
thresholdMax: boolean;
thresholdMin: boolean;
};
value?: boolean; value?: boolean;
} }

4
libs/common/src/lib/types/x-ray-rules-settings.type.ts

@ -1,5 +1,3 @@
import { PortfolioReportRule } from '@ghostfolio/common/interfaces';
export type XRayRulesSettings = { export type XRayRulesSettings = {
AccountClusterRiskCurrentInvestment?: RuleSettings; AccountClusterRiskCurrentInvestment?: RuleSettings;
AccountClusterRiskSingleAccount?: RuleSettings; AccountClusterRiskSingleAccount?: RuleSettings;
@ -9,7 +7,7 @@ export type XRayRulesSettings = {
FeeRatioInitialInvestment?: RuleSettings; FeeRatioInitialInvestment?: RuleSettings;
}; };
interface RuleSettings extends Pick<PortfolioReportRule, 'settings'> { interface RuleSettings {
isActive: boolean; isActive: boolean;
thresholdMax?: number; thresholdMax?: number;
thresholdMin?: number; thresholdMin?: number;

Loading…
Cancel
Save