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 {
evaluation,
value,
isActive: true,
key: rule.getKey(),
name: rule.getName(),
settings: {
configuration: {
thresholdMax: isNumber(settings['thresholdMax']) ? true : false,
thresholdMin: isNumber(settings['thresholdMin']) ? true : false
} as PortfolioReportRule['settings']
} as PortfolioReportRule['configuration'],
isActive: true,
key: rule.getKey(),
name: rule.getName()
};
} else {
return {

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

@ -64,8 +64,8 @@
<mat-menu #rulesMenu="matMenu" xPosition="before">
@if (
rule?.isActive &&
(rule?.settings.thresholdMax >= 0 ||
rule?.settings.thresholdMin >= 0)
(rule?.configuration?.thresholdMax ||
rule?.configuration?.thresholdMin)
) {
<button mat-menu-item (click)="onCustomizeRule(rule)">
<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 { RuleSettings } from '@ghostfolio/api/models/interfaces/rule-settings.interface';
import { PortfolioReportRule } from '@ghostfolio/common/interfaces';
import { XRayRulesSettings } from '@ghostfolio/common/types';
@ -55,7 +56,7 @@ export class RuleComponent implements OnInit {
dialogRef
.afterClosed()
.pipe(takeUntil(this.unsubscribeSubject))
.subscribe((settings: PortfolioReportRule['settings']) => {
.subscribe((settings: RuleSettings) => {
if (settings) {
this.ruleUpdated.emit({
xRayRules: {

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

@ -1,11 +1,11 @@
export interface PortfolioReportRule {
configuration?: {
thresholdMax: boolean;
thresholdMin: boolean;
};
evaluation?: string;
isActive: boolean;
key: string;
name: string;
settings?: {
thresholdMax: boolean;
thresholdMin: 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 = {
AccountClusterRiskCurrentInvestment?: RuleSettings;
AccountClusterRiskSingleAccount?: RuleSettings;
@ -9,7 +7,7 @@ export type XRayRulesSettings = {
FeeRatioInitialInvestment?: RuleSettings;
};
interface RuleSettings extends Pick<PortfolioReportRule, 'settings'> {
interface RuleSettings {
isActive: boolean;
thresholdMax?: number;
thresholdMin?: number;

Loading…
Cancel
Save