1
|
import {Component, Input} from '@angular/core';
|
2
|
import {ActivatedRoute, Router} from '@angular/router';
|
3
|
import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties';
|
4
|
import {LayoutService} from "../../openaireLibrary/services/layout.service";
|
5
|
import {CustomizationOptions} from "../../openaireLibrary/connect/community/CustomizationOptions";
|
6
|
import {ConnectHelper} from "../../openaireLibrary/connect/connectHelper";
|
7
|
import {PiwikHelper} from "../piwikHelper";
|
8
|
import {StringUtils} from "../../openaireLibrary/utils/string-utils.class";
|
9
|
|
10
|
declare var appendCss: any;
|
11
|
|
12
|
@Component({
|
13
|
selector: 'customization',
|
14
|
template: `
|
15
|
|
16
|
<!-- <p>This is customizing layout component</p>-->
|
17
|
`
|
18
|
})
|
19
|
|
20
|
export class CustomizationComponent {
|
21
|
@Input() communityId;
|
22
|
layout: CustomizationOptions;
|
23
|
|
24
|
constructor(private route: ActivatedRoute,
|
25
|
private router: Router, private _layoutService: LayoutService
|
26
|
) {
|
27
|
}
|
28
|
|
29
|
public ngOnInit() {
|
30
|
this.route.data
|
31
|
.subscribe((data: { envSpecific: EnvProperties }) => {
|
32
|
this.route.queryParams.subscribe(params => {
|
33
|
|
34
|
if(params['layout']) {
|
35
|
this.layout = JSON.parse(StringUtils.URIDecode(params['layout']));
|
36
|
this.buildCss();
|
37
|
}else{
|
38
|
// this.properties = data.envSpecific;
|
39
|
//com.communityId,
|
40
|
// data.envSpecific.adminToolsAPIURL + '/'
|
41
|
|
42
|
this._layoutService.mockLayout().subscribe(
|
43
|
layout => {
|
44
|
this.layout = layout;
|
45
|
|
46
|
this.buildCss();
|
47
|
}
|
48
|
);
|
49
|
}
|
50
|
|
51
|
});
|
52
|
|
53
|
|
54
|
|
55
|
});
|
56
|
|
57
|
|
58
|
}
|
59
|
|
60
|
private buildCss() {
|
61
|
// console.log(this.layout);
|
62
|
document.documentElement.style.setProperty('--portal-main-color', this.layout.mainColor);
|
63
|
document.documentElement.style.setProperty('--portal-dark-color', this.layout.secondaryColor);
|
64
|
let css = `
|
65
|
/*Panel background*/
|
66
|
.communityPanelBackground:not(bottom) {
|
67
|
border-style: ` + (this.layout.panel.background.borderStyle != null ? this.layout.panel.background.borderStyle : 'solid') + `;
|
68
|
border-color:` + (this.layout.panel.background.borderColor != null ? this.layout.panel.background.borderColor : 'transparent') + `;
|
69
|
border-width: ` + (this.layout.panel.background.borderWidth != null ? this.layout.panel.background.borderWidth : '1px') + `;`+`
|
70
|
}
|
71
|
.communityPanelBackground, .communityPanelBackground .uk-section-primary {
|
72
|
background-color: ` + this.layout.mainColor + `;
|
73
|
}
|
74
|
|
75
|
/*Panel fonts*/
|
76
|
|
77
|
.communityPanelBackground {
|
78
|
color:` + (this.layout.panel.fonts.color != null ? this.layout.panel.fonts.color : 'white') + ` !important;` +
|
79
|
(this.layout.panel.fonts.family != null ? ('font-family: ' + this.layout.panel.fonts.family + ' !important;') : '') +
|
80
|
(this.layout.panel.fonts.size != null ? ('font-size: ' + this.layout.panel.fonts.size + ' !important;') : '') +
|
81
|
|
82
|
`
|
83
|
}
|
84
|
.communityPanelBackground div.uk-modal {
|
85
|
color:#666 !important;
|
86
|
}
|
87
|
|
88
|
.communityPanelBackground .uk-h6:not(.ignoreCommunityPanelBackground),.communityPanelBackground .uk-h5:not(.ignoreCommunityPanelBackground),.communityPanelBackground .uk-h4:not(.ignoreCommunityPanelBackground),.communityPanelBackground .uk-h3:not(.ignoreCommunityPanelBackground), .communityPanelBackground .uk-h2:not(.ignoreCommunityPanelBackground),.communityPanelBackground .uk-h1:not(.ignoreCommunityPanelBackground) {
|
89
|
color: ` + (this.layout.panel.title.color != null ? this.layout.panel.title.color : 'white') + ` !important;` +
|
90
|
|
91
|
`
|
92
|
}
|
93
|
.communityPanelBackground .uk-h5:not(.ignoreCommunityPanelBackground){
|
94
|
`+
|
95
|
(this.layout.panel.title.family != null ? ('font-family: ' + this.layout.panel.title.family + ' !important;') : '') +
|
96
|
(this.layout.panel.title.size != null ? ('font-size: ' + this.layout.panel.title.size + ' !important;') : '') +
|
97
|
`
|
98
|
}
|
99
|
/* Panel links */
|
100
|
.communityPanelBackground .uk-link:not(.ignoreCommunityPanelBackground), .communityPanelBackground a:not(.uk-button):not(.uk-button-text):not(.ignoreCommunityPanelBackground), .portal-card a {
|
101
|
color: `
|
102
|
+ (this.layout.panel.links.color != null ? this.layout.panel.links.color : 'white') + ` !important;` +
|
103
|
(this.layout.panel.links.family != null ? ('font-family: ' + this.layout.panel.links.family + ' !important;') : '') +
|
104
|
(this.layout.panel.links.size != null ? ('font-size: ' + this.layout.panel.links.size + ' !important;') : '') +
|
105
|
`
|
106
|
}
|
107
|
/* Panel links - hover */
|
108
|
|
109
|
.communityPanelBackground .uk-link:not(.ignoreCommunityPanelBackground):hover, .communityPanelBackground a:not(.uk-button):not(.uk-button-text):not(.ignoreCommunityPanelBackground):hover, .portal-card a:hover {
|
110
|
color: `
|
111
|
+ (this.layout.panel.links.onHover.color != null ? this.layout.panel.links.onHover.color : `rgba(255, 255, 255, 0.5)`) + ` !important;` + `
|
112
|
}
|
113
|
|
114
|
.uk-link, a:not(.uk-button), .uk-navbar-dropdown-nav > li > a, .uk-navbar-nav > li > a, .loginLink,
|
115
|
.uk-tab > .uk-active > a, .uk-tab > * > a:focus, .uk-tab > * > a:hover {
|
116
|
color:` + (this.layout.links.color != null ? this.layout.links.color : `var(--portal-main-color)`) + `
|
117
|
}
|
118
|
|
119
|
.uk-link:hover, a:not(.uk-button):hover,
|
120
|
.uk-navbar-dropdown-nav > li > a:focus, .uk-navbar-dropdown-nav > li > a:hover, .uk-navbar-nav > li > a:hover, .uk-navbar-nav > li > a:focus, .uk-navbar-nav > li > a:active, .uk-navbar-nav > li:hover > a,
|
121
|
.uk-navbar-dropdown-nav > li.uk-active > a, .uk-tab > .uk-active > a, .uk-navbar-nav > li.uk-active > a, .uk-navbar-container:not(.uk-navbar-transparent) .uk-navbar-nav > li.uk-active > a {
|
122
|
color:` + (this.layout.links.onHover.color != null ? this.layout.links.onHover.color : `var(--portal-dark-color)`) + `
|
123
|
}
|
124
|
|
125
|
.communityBorder {
|
126
|
border-color: ` + (this.layout.box.borderColor != null ? this.layout.box.borderColor : `var(--portal-main-color)`) + `;
|
127
|
border-style: ` + (this.layout.box.borderStyle != null ? this.layout.box.borderStyle : `solid`) + `;
|
128
|
border-width: ` + (this.layout.box.borderWidth != null ? this.layout.box.borderWidth : `2px`) + `;
|
129
|
border-radius: ` + (this.layout.box.borderRadius != null ? this.layout.box.borderRadius : `6px`) + `;
|
130
|
}
|
131
|
|
132
|
/*Panel Elements & cards*/
|
133
|
.communityPanelBackground .uk-card:not(.ignoreCommunityPanelBackground), .communityPanelBackground .uk-label:not(.ignoreCommunityPanelBackground) {
|
134
|
background-color: ` + (this.layout.panel.panelElements.backgroundColor != null ? this.layout.panel.panelElements.backgroundColor : `rgba(255, 255, 255, 0.5)`) + `;
|
135
|
border-color: ` + (this.layout.panel.panelElements.borderColor != null ? this.layout.panel.panelElements.borderColor : `rgba(255, 255, 255, 0.5)`) + `;
|
136
|
}
|
137
|
.communityPanelBackground .uk-label:not(.ignoreCommunityPanelBackground) a{
|
138
|
border-color: ` + (this.layout.panel.links.color != null ? this.layout.panel.links.color : `rgba(255, 255, 255, 0.8)`) + `;
|
139
|
border-bottom: 1px solid;
|
140
|
}
|
141
|
.communityPanelBackground .uk-label:not(.ignoreCommunityPanelBackground) a:hover{
|
142
|
border-color: ` + (this.layout.panel.links.onHover.color != null ? this.layout.panel.links.onHover.color : `rgba(255, 255, 255, 0.5)`) + `;
|
143
|
}
|
144
|
.communityPanelBackground .uk-card:not(.ignoreCommunityPanelBackground), .communityPanelBackground .uk-label:not(.ignoreCommunityPanelBackground) {
|
145
|
color: ` + (this.layout.panel.panelElements.color != null ? this.layout.panel.panelElements.color : `rgba(255, 255, 255, 0.5)`) + `;
|
146
|
}
|
147
|
|
148
|
|
149
|
.uk-button:not(.uk-button-text){
|
150
|
border-radius:` + (this.layout.buttons.borderRadius != null ? this.layout.buttons.borderRadius : `4px`) + `;
|
151
|
}
|
152
|
.uk-button:not(.uk-button-text):not(.uk-button-default):not(.uk-button-primary), .portal-button {
|
153
|
background-color:` + (this.layout.buttons.backgroundColor != null ? this.layout.buttons.backgroundColor : `#003052`) + `;
|
154
|
color: ` + (this.layout.buttons.color != null ? this.layout.buttons.color : `white`) + `;
|
155
|
border-color: ` + (this.layout.buttons.borderColor != null ? this.layout.buttons.borderColor : `transparent`) + `;
|
156
|
border-style: ` + (this.layout.buttons.borderStyle != null ? this.layout.buttons.borderStyle : `solid`) + `;
|
157
|
border-width: ` + (this.layout.buttons.borderWidth != null ? this.layout.buttons.borderWidth : `1px`) + `;
|
158
|
|
159
|
|
160
|
}
|
161
|
|
162
|
.uk-button:not(.uk-button-text):not(.uk-button-default):not(.uk-button-primary):hover, .portal-button:hover {
|
163
|
background-color: ` + (this.layout.buttons.onHover.backgroundColor != null ? this.layout.buttons.onHover.backgroundColor : `#154B71`) + `;
|
164
|
color: ` + (this.layout.buttons.onHover.color != null ? this.layout.buttons.onHover.color : `white`) + `;
|
165
|
border-color: ` + (this.layout.buttons.onHover.color != null ? this.layout.buttons.onHover.color : `transparent`) + `;
|
166
|
}
|
167
|
|
168
|
/*Buttons*/
|
169
|
.communityPanelBackground .uk-button:not(.ignoreCommunityPanelBackground) {
|
170
|
background-color: ` + (this.layout.panel.buttons.backgroundColor != null ? this.layout.panel.buttons.backgroundColor : `white`) + ` !important;
|
171
|
color: ` + (this.layout.panel.buttons.color != null ? this.layout.panel.buttons.color : `var(--portal-main-color)`) + ` !important;
|
172
|
border-color: ` + (this.layout.panel.buttons.borderColor != null ? this.layout.panel.buttons.borderColor : `transparent`) + ` !important;
|
173
|
border-style: ` + (this.layout.panel.buttons.borderStyle != null ? this.layout.panel.buttons.borderStyle : `solid`) + ` !important;
|
174
|
border-width: ` + (this.layout.panel.buttons.borderWidth != null ? this.layout.panel.buttons.borderWidth : `1px`) + ` !important;
|
175
|
border-radius:` + (this.layout.panel.buttons.borderRadius != null ? this.layout.panel.buttons.borderRadius : `4px`) + ` !important;
|
176
|
font-weight:` + (this.layout.panel.buttons.fontWeight != null ? this.layout.panel.buttons.fontWeight : `600`) + `;
|
177
|
|
178
|
}
|
179
|
|
180
|
.communityPanelBackground .uk-button:not(.ignoreCommunityPanelBackground):hover {
|
181
|
background-color: ` + (this.layout.panel.buttons.onHover.backgroundColor != null ? this.layout.panel.buttons.onHover.backgroundColor : ` #eeeeee `) + ` !important;
|
182
|
color: ` + (this.layout.panel.buttons.onHover.color != null ? this.layout.panel.buttons.onHover.color : ` var(--portal-main-color) `) + ` !important;
|
183
|
border-color:` + (this.layout.panel.buttons.onHover.borderColor != null ? this.layout.panel.buttons.onHover.borderColor : `transparent`) + ` !important;
|
184
|
}
|
185
|
|
186
|
|
187
|
.uk-navbar-dropdown {
|
188
|
background-color: white;
|
189
|
color: #666;
|
190
|
box-shadow: 0 5px 12px rgba(0, 0, 0, .15);
|
191
|
/*border:var(--portal-main-color) 1px solid;*/
|
192
|
}
|
193
|
|
194
|
.customTabs .uk-tab > .uk-active > a {
|
195
|
border-color: var(--portal-main-color);
|
196
|
}
|
197
|
|
198
|
.customTabs .uk-tab > .uk-active > a {
|
199
|
border-color: var(--portal-main-color);
|
200
|
}
|
201
|
|
202
|
.uk-tab > * > a:focus, .uk-tab > * > a:hover {
|
203
|
border-color: var(--portal-dark-color);
|
204
|
}
|
205
|
|
206
|
|
207
|
`
|
208
|
appendCss(css);
|
209
|
}
|
210
|
}
|