Skip to content
This repository was archived by the owner on Sep 30, 2022. It is now read-only.

Commit 1d61c38

Browse files
author
Dominik František Bučík
authored
Merge pull request #207 from dBucik/favicons
feat: 🎸 Favicons from config
2 parents efa517f + 8f5d3cc commit 1d61c38

File tree

11 files changed

+38
-30
lines changed

11 files changed

+38
-30
lines changed

gui/src/app/app.component.ts

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,22 @@ import { User } from './core/models/User';
1515
})
1616
export class AppComponent implements OnInit {
1717

18+
static pageConfig: PageConfig;
19+
static user: User;
20+
21+
favIcon: HTMLLinkElement = document.querySelector('#appIcon');
22+
23+
sidenavOpen = true;
24+
loading = true;
25+
minWidth = 768;
26+
sidenavMode: MatDrawerMode = 'side';
27+
currentUrl = '';
28+
logoUrl = '';
29+
appTitle = '';
30+
langs: string[];
31+
32+
lastWindowWidth: number;
33+
1834
constructor(
1935
private configService: ConfigService,
2036
private userService: UsersService,
@@ -55,20 +71,6 @@ export class AppComponent implements OnInit {
5571
this.setAndGetUser();
5672
}
5773

58-
static pageConfig: PageConfig;
59-
static user: User;
60-
61-
sidenavOpen = true;
62-
loading = true;
63-
minWidth = 768;
64-
sidenavMode: MatDrawerMode = 'side';
65-
currentUrl = '';
66-
logoUrl = '';
67-
appTitle = '';
68-
langs: string[];
69-
70-
lastWindowWidth: number;
71-
7274
public static isApplicationAdmin(): boolean {
7375
if (this.user) {
7476
return this.user.isAppAdmin;
@@ -94,7 +96,7 @@ export class AppComponent implements OnInit {
9496
}
9597

9698
@HostListener('window:resize', ['$event'])
97-
onResize(event?) {
99+
onResize(_?) {
98100
if (this.sidenavOpen && this.lastWindowWidth > window.innerWidth &&
99101
window.innerWidth < this.minWidth) {
100102
this.sidenavOpen = false;
@@ -104,8 +106,21 @@ export class AppComponent implements OnInit {
104106
this.lastWindowWidth = window.innerWidth;
105107
}
106108

109+
ngOnInit(): void {
110+
this.configService.getPageConfig().subscribe(pageConfig => {
111+
if (pageConfig !== null && pageConfig !== undefined) {
112+
AppComponent.pageConfig = new PageConfig(pageConfig);
113+
this.appTitle = pageConfig.headerLabel;
114+
this.logoUrl = pageConfig.logoUrl;
115+
this.favIcon.href = pageConfig.faviconUrl;
116+
}
117+
this.loading = false;
118+
});
119+
this.setAndGetUser();
120+
}
121+
107122
public logout(): void {
108-
this.userService.unsetUser().subscribe(resp => {
123+
this.userService.unsetUser().subscribe(_ => {
109124
window.location.href = AppComponent.pageConfig.logoutUrl;
110125
});
111126
}
@@ -142,16 +157,4 @@ export class AppComponent implements OnInit {
142157
AppComponent.setUser(null);
143158
}
144159

145-
ngOnInit(): void {
146-
this.configService.getPageConfig().subscribe(pageConfig => {
147-
if (pageConfig !== null && pageConfig !== undefined) {
148-
AppComponent.pageConfig = new PageConfig(pageConfig);
149-
this.appTitle = pageConfig.headerLabel;
150-
this.logoUrl = pageConfig.logoUrl;
151-
}
152-
this.loading = false;
153-
});
154-
this.setAndGetUser();
155-
}
156-
157160
}

gui/src/app/core/models/PageConfig.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export class PageConfig {
77
this.headerHtml = item.headerHtml;
88
this.logoutUrl = item.logoutUrl;
99
this.externalServices = item.externalServices;
10+
this.faviconUrl = item.faviconUrl;
1011
}
1112

1213
headerLabel: string;
@@ -15,5 +16,6 @@ export class PageConfig {
1516
headerHtml: string;
1617
logoutUrl: string;
1718
externalServices: boolean;
19+
faviconUrl: string;
1820

1921
}

gui/src/assets/img/bbmri.ico

130 KB
Binary file not shown.

gui/src/assets/img/ceitec.ico

318 Bytes
Binary file not shown.

gui/src/assets/img/cesnet.ico

10.9 KB
Binary file not shown.

gui/src/assets/img/einfra.ico

151 KB
Binary file not shown.

gui/src/assets/img/elixir.ico

14.7 KB
Binary file not shown.

gui/src/assets/img/muni.ico

279 Bytes
Binary file not shown.

gui/src/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<meta name="viewport" content="width=device-width, initial-scale=1">
99
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" rel="stylesheet">
1010
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
11+
<link rel="icon" id="appIcon" type="image/x-icon" href="favicon.ico">
1112
</head>
1213
<body>
1314
<app-root></app-root>

src/main/java/cz/metacentrum/perun/spRegistration/common/configs/FrontendProperties.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,13 @@ public class FrontendProperties {
2828
@NonNull private String footerHtml = "";
2929
@NonNull private String headerHtml = "";
3030
@NonNull private String headerTitle = "SP Registration";
31-
@NonNull private String headerLogoUrl = "https://perun.cesnet.cz/signpost/images/perun_3.png";
31+
@NonNull private String headerLogoUrl = "assets/img/perun_3.svg";
32+
@NonNull private String faviconUrl = "assets/img/perun-ico.png";
3233

3334
@PostConstruct
3435
public void postInit() {
3536
log.info("Initialized Frontend properties");
36-
log.debug("{}", this.toString());
37+
log.debug("{}", this);
3738
}
3839

3940
public void setHeaderLogoUrl(@NonNull String headerLogoUrl) {

src/main/java/cz/metacentrum/perun/spRegistration/rest/controllers/ConfigController.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ public Map<String, Object> getPageConfig() {
106106
pageConfig.put("headerHtml", frontendProperties.getHeaderHtml());
107107
pageConfig.put("logoutUrl", applicationProperties.getLogoutUrl());
108108
pageConfig.put("externalServices", applicationProperties.isExternalServicesEnabled());
109+
pageConfig.put("faviconUrl", frontendProperties.getFaviconUrl());
109110
return pageConfig;
110111
}
111112

0 commit comments

Comments
 (0)