Browse Source

Refactor info message

pull/2343/head
Thomas 2 years ago
parent
commit
8d417c0ac2
  1. 34
      apps/client/src/app/app.component.html
  2. 48
      apps/client/src/app/app.component.scss
  3. 12
      apps/client/src/app/app.component.ts
  4. 21
      apps/client/src/app/pages/about/about-page.component.ts
  5. 17
      apps/client/src/app/pages/admin/admin-page.component.ts
  6. 21
      apps/client/src/app/pages/home/home-page.component.ts
  7. 31
      apps/client/src/app/pages/portfolio/portfolio-page.component.ts
  8. 10
      apps/client/src/styles.scss

34
apps/client/src/app/app.component.html

@ -1,22 +1,10 @@
<header> <header>
<gf-header
class="position-fixed w-100"
[currentRoute]="currentRoute"
[hasTabs]="hasTabs"
[info]="info"
[pageTitle]="pageTitle"
[user]="user"
(signOut)="onSignOut()"
></gf-header>
</header>
<main role="main">
<div <div
*ngIf="canCreateAccount || (info?.systemMessage && user)" *ngIf="canCreateAccount || (info?.systemMessage && user)"
class="container info-message-container" class="info-message-container"
> >
<div class="row"> <div class="info-message-inner-container position-fixed w-100">
<div class="col-md-8 offset-md-2 text-center"> <div class="align-items-center d-flex h-100 justify-content-center">
<a <a
*ngIf="canCreateAccount" *ngIf="canCreateAccount"
class="text-center" class="text-center"
@ -26,8 +14,8 @@
class="cursor-pointer d-inline-block info-message px-3 py-2" class="cursor-pointer d-inline-block info-message px-3 py-2"
(click)="onCreateAccount()" (click)="onCreateAccount()"
> >
<span>You are using the Live Demo.</span> <span i18n>You are using the Live Demo.</span>
<span class="a ml-2">Create Account</span> <span class="a ml-2" i18n>Create Account</span>
</div></a </div></a
> >
<div <div
@ -41,6 +29,18 @@
</div> </div>
</div> </div>
<gf-header
class="position-fixed w-100"
[currentRoute]="currentRoute"
[hasTabs]="hasTabs"
[info]="info"
[pageTitle]="pageTitle"
[user]="user"
(signOut)="onSignOut()"
></gf-header>
</header>
<main role="main">
<router-outlet></router-outlet> <router-outlet></router-outlet>
</main> </main>

48
apps/client/src/app/app.component.scss

@ -4,20 +4,17 @@
display: block; display: block;
min-height: 100vh; min-height: 100vh;
footer { &.has-info-message {
background-color: rgba(var(--palette-foreground-text), 0.05);
font-size: 90%;
}
header { header {
height: var(--mat-toolbar-standard-height); height: calc(2 * var(--mat-toolbar-standard-height));
}
main {
min-height: calc(100vh - var(--mat-toolbar-standard-height));
.info-message-container { .info-message-container {
height: 3.5rem; height: var(--mat-toolbar-standard-height);
.info-message-inner-container {
background-color: var(--light-background);
height: var(--mat-toolbar-standard-height);
z-index: 999;
.info-message { .info-message {
background-color: rgba(var(--palette-foreground-text), 0.05); background-color: rgba(var(--palette-foreground-text), 0.05);
@ -34,16 +31,41 @@
} }
} }
:host-context(.is-dark-theme) { main {
min-height: calc(100vh - 2 * var(--mat-toolbar-standard-height));
}
}
footer { footer {
background-color: rgba(var(--palette-foreground-text-dark), 0.05); background-color: rgba(var(--palette-foreground-text), 0.05);
font-size: 90%;
}
header {
height: var(--mat-toolbar-standard-height);
} }
main { main {
min-height: calc(100vh - var(--mat-toolbar-standard-height));
}
}
:host-context(.is-dark-theme) {
&.has-info-message {
header {
.info-message-container { .info-message-container {
.info-message-inner-container {
background-color: var(--dark-background);
.info-message { .info-message {
background-color: rgba(var(--palette-foreground-text-dark), 0.05); background-color: rgba(var(--palette-foreground-text-dark), 0.05);
} }
} }
} }
} }
}
footer {
background-color: rgba(var(--palette-foreground-text-dark), 0.05);
}
}

12
apps/client/src/app/app.component.ts

@ -3,6 +3,7 @@ import {
ChangeDetectionStrategy, ChangeDetectionStrategy,
ChangeDetectorRef, ChangeDetectorRef,
Component, Component,
HostBinding,
Inject, Inject,
OnDestroy, OnDestroy,
OnInit OnInit
@ -28,10 +29,15 @@ import { UserService } from './services/user/user.service';
styleUrls: ['./app.component.scss'] styleUrls: ['./app.component.scss']
}) })
export class AppComponent implements OnDestroy, OnInit { export class AppComponent implements OnDestroy, OnInit {
@HostBinding('class.has-info-message') get getHasMessage() {
return this.hasInfoMessage;
}
public canCreateAccount: boolean; public canCreateAccount: boolean;
public currentRoute: string; public currentRoute: string;
public currentYear = new Date().getFullYear(); public currentYear = new Date().getFullYear();
public deviceType: string; public deviceType: string;
public hasInfoMessage: boolean;
public hasPermissionForBlog: boolean; public hasPermissionForBlog: boolean;
public hasPermissionForStatistics: boolean; public hasPermissionForStatistics: boolean;
public hasPermissionForSubscription: boolean; public hasPermissionForSubscription: boolean;
@ -149,6 +155,12 @@ export class AppComponent implements OnDestroy, OnInit {
permissions.createUserAccount permissions.createUserAccount
); );
this.hasInfoMessage =
hasPermission(
this.user?.permissions,
permissions.createUserAccount
) || !!this.info.systemMessage;
this.initializeTheme(this.user?.settings.colorScheme); this.initializeTheme(this.user?.settings.colorScheme);
this.changeDetectorRef.markForCheck(); this.changeDetectorRef.markForCheck();

21
apps/client/src/app/pages/about/about-page.component.ts

@ -1,10 +1,4 @@
import { import { ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core';
ChangeDetectorRef,
Component,
HostBinding,
OnDestroy,
OnInit
} from '@angular/core';
import { DataService } from '@ghostfolio/client/services/data.service'; import { DataService } from '@ghostfolio/client/services/data.service';
import { UserService } from '@ghostfolio/client/services/user/user.service'; import { UserService } from '@ghostfolio/client/services/user/user.service';
import { TabConfiguration, User } from '@ghostfolio/common/interfaces'; import { TabConfiguration, User } from '@ghostfolio/common/interfaces';
@ -20,12 +14,7 @@ import { takeUntil } from 'rxjs/operators';
templateUrl: './about-page.html' templateUrl: './about-page.html'
}) })
export class AboutPageComponent implements OnDestroy, OnInit { export class AboutPageComponent implements OnDestroy, OnInit {
@HostBinding('class.with-info-message') get getHasMessage() {
return this.hasMessage;
}
public deviceType: string; public deviceType: string;
public hasMessage: boolean;
public hasPermissionForSubscription: boolean; public hasPermissionForSubscription: boolean;
public tabs: TabConfiguration[] = []; public tabs: TabConfiguration[] = [];
public user: User; public user: User;
@ -38,7 +27,7 @@ export class AboutPageComponent implements OnDestroy, OnInit {
private deviceService: DeviceDetectorService, private deviceService: DeviceDetectorService,
private userService: UserService private userService: UserService
) { ) {
const { globalPermissions, systemMessage } = this.dataService.fetchInfo(); const { globalPermissions } = this.dataService.fetchInfo();
this.hasPermissionForSubscription = hasPermission( this.hasPermissionForSubscription = hasPermission(
globalPermissions, globalPermissions,
@ -75,12 +64,6 @@ export class AboutPageComponent implements OnDestroy, OnInit {
}); });
this.user = state.user; this.user = state.user;
this.hasMessage =
hasPermission(
this.user?.permissions,
permissions.createUserAccount
) || !!systemMessage;
this.changeDetectorRef.markForCheck(); this.changeDetectorRef.markForCheck();
} }

17
apps/client/src/app/pages/admin/admin-page.component.ts

@ -1,5 +1,4 @@
import { Component, HostBinding, OnDestroy, OnInit } from '@angular/core'; import { Component, OnDestroy, OnInit } from '@angular/core';
import { DataService } from '@ghostfolio/client/services/data.service';
import { TabConfiguration } from '@ghostfolio/common/interfaces'; import { TabConfiguration } from '@ghostfolio/common/interfaces';
import { DeviceDetectorService } from 'ngx-device-detector'; import { DeviceDetectorService } from 'ngx-device-detector';
import { Subject } from 'rxjs'; import { Subject } from 'rxjs';
@ -11,24 +10,12 @@ import { Subject } from 'rxjs';
templateUrl: './admin-page.html' templateUrl: './admin-page.html'
}) })
export class AdminPageComponent implements OnDestroy, OnInit { export class AdminPageComponent implements OnDestroy, OnInit {
@HostBinding('class.with-info-message') get getHasMessage() {
return this.hasMessage;
}
public deviceType: string; public deviceType: string;
public hasMessage: boolean;
public tabs: TabConfiguration[] = []; public tabs: TabConfiguration[] = [];
private unsubscribeSubject = new Subject<void>(); private unsubscribeSubject = new Subject<void>();
public constructor( public constructor(private deviceService: DeviceDetectorService) {}
private dataService: DataService,
private deviceService: DeviceDetectorService
) {
const { systemMessage } = this.dataService.fetchInfo();
this.hasMessage = !!systemMessage;
}
public ngOnInit() { public ngOnInit() {
this.deviceType = this.deviceService.getDeviceInfo().deviceType; this.deviceType = this.deviceService.getDeviceInfo().deviceType;

21
apps/client/src/app/pages/home/home-page.component.ts

@ -1,10 +1,4 @@
import { import { ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core';
ChangeDetectorRef,
Component,
HostBinding,
OnDestroy,
OnInit
} from '@angular/core';
import { DataService } from '@ghostfolio/client/services/data.service'; import { DataService } from '@ghostfolio/client/services/data.service';
import { UserService } from '@ghostfolio/client/services/user/user.service'; import { UserService } from '@ghostfolio/client/services/user/user.service';
import { TabConfiguration, User } from '@ghostfolio/common/interfaces'; import { TabConfiguration, User } from '@ghostfolio/common/interfaces';
@ -20,12 +14,7 @@ import { takeUntil } from 'rxjs/operators';
templateUrl: './home-page.html' templateUrl: './home-page.html'
}) })
export class HomePageComponent implements OnDestroy, OnInit { export class HomePageComponent implements OnDestroy, OnInit {
@HostBinding('class.with-info-message') get getHasMessage() {
return this.hasMessage;
}
public deviceType: string; public deviceType: string;
public hasMessage: boolean;
public hasPermissionToAccessFearAndGreedIndex: boolean; public hasPermissionToAccessFearAndGreedIndex: boolean;
public tabs: TabConfiguration[] = []; public tabs: TabConfiguration[] = [];
public user: User; public user: User;
@ -38,7 +27,7 @@ export class HomePageComponent implements OnDestroy, OnInit {
private deviceService: DeviceDetectorService, private deviceService: DeviceDetectorService,
private userService: UserService private userService: UserService
) { ) {
const { globalPermissions, systemMessage } = this.dataService.fetchInfo(); const { globalPermissions } = this.dataService.fetchInfo();
this.hasPermissionToAccessFearAndGreedIndex = hasPermission( this.hasPermissionToAccessFearAndGreedIndex = hasPermission(
globalPermissions, globalPermissions,
@ -74,12 +63,6 @@ export class HomePageComponent implements OnDestroy, OnInit {
]; ];
this.user = state.user; this.user = state.user;
this.hasMessage =
hasPermission(
this.user?.permissions,
permissions.createUserAccount
) || !!systemMessage;
this.changeDetectorRef.markForCheck(); this.changeDetectorRef.markForCheck();
} }
}); });

31
apps/client/src/app/pages/portfolio/portfolio-page.component.ts

@ -1,18 +1,6 @@
import { import { ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core';
ChangeDetectorRef,
Component,
HostBinding,
OnDestroy,
OnInit
} from '@angular/core';
import { DataService } from '@ghostfolio/client/services/data.service';
import { UserService } from '@ghostfolio/client/services/user/user.service'; import { UserService } from '@ghostfolio/client/services/user/user.service';
import { import { TabConfiguration, User } from '@ghostfolio/common/interfaces';
InfoItem,
TabConfiguration,
User
} from '@ghostfolio/common/interfaces';
import { hasPermission, permissions } from '@ghostfolio/common/permissions';
import { DeviceDetectorService } from 'ngx-device-detector'; import { DeviceDetectorService } from 'ngx-device-detector';
import { Subject } from 'rxjs'; import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators'; import { takeUntil } from 'rxjs/operators';
@ -24,13 +12,7 @@ import { takeUntil } from 'rxjs/operators';
templateUrl: './portfolio-page.html' templateUrl: './portfolio-page.html'
}) })
export class PortfolioPageComponent implements OnDestroy, OnInit { export class PortfolioPageComponent implements OnDestroy, OnInit {
@HostBinding('class.with-info-message') get getHasMessage() {
return this.hasMessage;
}
public deviceType: string; public deviceType: string;
public hasMessage: boolean;
public info: InfoItem;
public tabs: TabConfiguration[] = []; public tabs: TabConfiguration[] = [];
public user: User; public user: User;
@ -38,12 +20,9 @@ export class PortfolioPageComponent implements OnDestroy, OnInit {
public constructor( public constructor(
private changeDetectorRef: ChangeDetectorRef, private changeDetectorRef: ChangeDetectorRef,
private dataService: DataService,
private deviceService: DeviceDetectorService, private deviceService: DeviceDetectorService,
private userService: UserService private userService: UserService
) { ) {
this.info = this.dataService.fetchInfo();
this.userService.stateChanged this.userService.stateChanged
.pipe(takeUntil(this.unsubscribeSubject)) .pipe(takeUntil(this.unsubscribeSubject))
.subscribe((state) => { .subscribe((state) => {
@ -77,12 +56,6 @@ export class PortfolioPageComponent implements OnDestroy, OnInit {
]; ];
this.user = state.user; this.user = state.user;
this.hasMessage =
hasPermission(
this.user?.permissions,
permissions.createUserAccount
) || !!this.info.systemMessage;
this.changeDetectorRef.markForCheck(); this.changeDetectorRef.markForCheck();
} }
}); });

10
apps/client/src/styles.scss

@ -373,6 +373,12 @@ ngx-skeleton-loader {
@include gf-table; @include gf-table;
} }
.has-info-message {
.page.has-tabs {
height: calc(100vh - 2 * var(--mat-toolbar-standard-height));
}
}
.hidden { .hidden {
visibility: hidden; visibility: hidden;
} }
@ -533,10 +539,6 @@ ngx-skeleton-loader {
text-decoration: underline !important; text-decoration: underline !important;
} }
.with-info-message {
height: calc(100vh - var(--mat-toolbar-standard-height) - 3.5rem) !important;
}
.with-placeholder-as-option { .with-placeholder-as-option {
.mat-mdc-select-placeholder { .mat-mdc-select-placeholder {
color: rgba(var(--dark-primary-text)); color: rgba(var(--dark-primary-text));

Loading…
Cancel
Save