1 |
57321
|
k.triantaf
|
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 |
|
|
|
63 |
|
|
document.documentElement.style.setProperty('--portal-main-color', this.layout.mainColor);
|
64 |
|
|
document.documentElement.style.setProperty('--portal-dark-color', this.layout.secondaryColor);
|
65 |
|
|
let css = `
|
66 |
|
|
/*Panel background*/
|
67 |
|
|
.communityPanelBackground:not(bottom) {
|
68 |
|
|
border-style: ` + (this.layout.panel.background.borderStyle != null ? this.layout.panel.background.borderStyle : 'solid') + `;
|
69 |
|
|
border-color:` + (this.layout.panel.background.borderColor != null ? this.layout.panel.background.borderColor : 'transparent') + `;
|
70 |
|
|
border-width: ` + (this.layout.panel.background.borderWidth != null ? this.layout.panel.background.borderWidth: '1') + `px;`+`
|
71 |
|
|
|
72 |
|
|
}
|
73 |
|
|
.communityPanelBackground, .communityPanelBackground .uk-section-primary {
|
74 |
|
|
background-color: ` + (this.layout.panel.background.color?this.layout.panel.background.color:this.layout.mainColor) + `;
|
75 |
|
|
}
|
76 |
|
|
|
77 |
|
|
/*Panel fonts*/
|
78 |
|
|
|
79 |
|
|
.communityPanelBackground {
|
80 |
|
|
color:` + (this.layout.panel.fonts.color != null ? this.layout.panel.fonts.color : 'white') + ` !important;` +
|
81 |
|
|
(this.layout.panel.fonts.family != null ? ('font-family: ' + this.layout.panel.fonts.family + ' !important;') : '') +
|
82 |
|
|
(this.layout.panel.fonts.size != null ? ('font-size: ' + this.layout.panel.fonts.size + 'px !important;') : '') +
|
83 |
|
|
(this.layout.panel.fonts.weight != null ? ('font-weight: ' + this.layout.panel.fonts.weight + '!important;') : '') +
|
84 |
|
|
|
85 |
|
|
`
|
86 |
|
|
}
|
87 |
|
|
.communityPanelBackground div.uk-modal {
|
88 |
|
|
color:#666 !important;
|
89 |
|
|
}
|
90 |
|
|
|
91 |
|
|
.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) {
|
92 |
|
|
color: ` + (this.layout.panel.title.color != null ? this.layout.panel.title.color : 'white') + ` !important;` +
|
93 |
|
|
(this.layout.panel.title.weight != null ? ('font-weight: ' + this.layout.panel.title.weight + '!important;') : '') +
|
94 |
|
|
`
|
95 |
|
|
}
|
96 |
|
|
.communityPanelBackground .uk-h5:not(.ignoreCommunityPanelBackground){
|
97 |
|
|
`+
|
98 |
|
|
(this.layout.panel.title.family != null ? ('font-family: ' + this.layout.panel.title.family + ' !important;') : '') +
|
99 |
|
|
(this.layout.panel.title.size != null ? ('font-size: ' + this.layout.panel.title.size + 'px !important;') : '') +
|
100 |
|
|
`
|
101 |
|
|
}
|
102 |
|
|
/* Panel links */
|
103 |
|
|
.communityPanelBackground .uk-link:not(.ignoreCommunityPanelBackground), .communityPanelBackground a:not(.uk-button):not(.uk-button-text):not(.ignoreCommunityPanelBackground), .portal-card a {
|
104 |
|
|
color: `
|
105 |
|
|
+ (this.layout.panel.onDarkBackground ? (this.layout.links.darkBackground.color?this.layout.links.darkBackground.color:'white') :(this.layout.links.lightBackground.color?this.layout.links.lightBackground.color:'var(--portal-main-color)') ) + ` !important;`
|
106 |
|
|
+ (this.layout.panel.onDarkBackground ? (this.layout.links.darkBackground.family?('font-family: ' + this.layout.links.darkBackground.family + ' !important;') : '') :'' )
|
107 |
|
|
+ (this.layout.panel.onDarkBackground ? (this.layout.links.darkBackground.size?('font-size: ' + this.layout.links.darkBackground.size + 'px !important;') : '') :'' )
|
108 |
|
|
+`
|
109 |
|
|
}
|
110 |
|
|
/* Panel links - hover */
|
111 |
|
|
|
112 |
|
|
.communityPanelBackground .uk-link:not(.ignoreCommunityPanelBackground):hover, .communityPanelBackground a:not(.uk-button):not(.uk-button-text):not(.ignoreCommunityPanelBackground):hover, .portal-card a:hover {
|
113 |
|
|
color: `
|
114 |
|
|
+ (this.layout.panel.onDarkBackground ? (this.layout.links.darkBackground.onHover.color?this.layout.links.darkBackground.onHover.color:`rgba(255, 255, 255, 0.5)`) :(this.layout.links.lightBackground.onHover.color?this.layout.links.lightBackground.onHover.color:'var(--portal-dark-color)') ) + ` !important;`
|
115 |
|
|
+ `
|
116 |
|
|
}
|
117 |
|
|
|
118 |
|
|
.uk-link, a:not(.uk-button), .uk-navbar-dropdown-nav > li > a, .uk-navbar-nav > li > a, .loginLink,
|
119 |
|
|
.uk-tab > .uk-active > a, .uk-tab > * > a:focus, .uk-tab > * > a:hover {
|
120 |
|
|
color:` + (this.layout.links.lightBackground.color != null ? this.layout.links.lightBackground.color : `var(--portal-main-color)`) + `
|
121 |
|
|
}
|
122 |
|
|
|
123 |
|
|
.uk-link:hover, a:not(.uk-button):hover,
|
124 |
|
|
.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,
|
125 |
|
|
.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 {
|
126 |
|
|
color:` + (this.layout.links.lightBackground.onHover.color != null ? this.layout.links.lightBackground.onHover.color : `var(--portal-dark-color)`) + `
|
127 |
|
|
}
|
128 |
|
|
|
129 |
|
|
.communityBorder {
|
130 |
|
|
border-color: ` + (this.layout.box.borderColor != null ? this.layout.box.borderColor : `var(--portal-main-color)`) + `;
|
131 |
|
|
border-style: ` + (this.layout.box.borderStyle != null ? this.layout.box.borderStyle : `solid`) + `;
|
132 |
|
|
border-width: ` + (this.layout.box.borderWidth != null ? this.layout.box.borderWidth : `2`) + `px;
|
133 |
|
|
border-radius: ` + (this.layout.box.borderRadius != null ? this.layout.box.borderRadius : `6`) + `px;
|
134 |
|
|
}
|
135 |
|
|
|
136 |
|
|
/*Panel Elements & cards*/
|
137 |
|
|
.communityPanelBackground .uk-card:not(.ignoreCommunityPanelBackground), .communityPanelBackground .uk-label:not(.ignoreCommunityPanelBackground) {
|
138 |
|
|
background-color: ` + (this.layout.panel.panelElements.backgroundColor != null ? this.layout.panel.panelElements.backgroundColor : `rgba(255, 255, 255, 0.5)`) + `;
|
139 |
|
|
border-color: ` + (this.layout.panel.panelElements.borderColor != null ? this.layout.panel.panelElements.borderColor : `rgba(255, 255, 255, 0.5)`) + `;
|
140 |
|
|
}
|
141 |
|
|
.communityPanelBackground .uk-label:not(.ignoreCommunityPanelBackground) a{
|
142 |
|
|
border-color: ` +
|
143 |
|
|
+ (this.layout.panel.onDarkBackground ? (this.layout.links.darkBackground.color?this.layout.links.darkBackground.color:'rgba(255, 255, 255, 0.8)') :(this.layout.links.lightBackground.color?this.layout.links.lightBackground.color:'var(--portal-main-color)') ) +
|
144 |
|
|
+ `;
|
145 |
|
|
border-bottom: 1px solid;
|
146 |
|
|
}
|
147 |
|
|
.communityPanelBackground .uk-label:not(.ignoreCommunityPanelBackground) a:hover{
|
148 |
|
|
border-color: ` +
|
149 |
|
|
(this.layout.panel.onDarkBackground ? (this.layout.links.darkBackground.onHover.color?this.layout.links.darkBackground.onHover.color:'rgba(255, 255, 255, 0.5)') :(this.layout.links.lightBackground.onHover.color?this.layout.links.lightBackground.onHover.color:'var(--portal-dark-color)') )+
|
150 |
|
|
+ `;
|
151 |
|
|
}
|
152 |
|
|
.communityPanelBackground .uk-card:not(.ignoreCommunityPanelBackground), .communityPanelBackground .uk-label:not(.ignoreCommunityPanelBackground) {
|
153 |
|
|
color: ` + (this.layout.panel.panelElements.color != null ? this.layout.panel.panelElements.color : `rgba(255, 255, 255, 0.5)`) + `;
|
154 |
|
|
}
|
155 |
|
|
|
156 |
|
|
|
157 |
|
|
.uk-button:not(.uk-button-text){
|
158 |
|
|
border-radius:` + (this.layout.buttons.lightBackground.borderRadius != null ? this.layout.buttons.lightBackground.borderRadius : `4`) + `px;
|
159 |
|
|
}
|
160 |
|
|
.uk-button:not(.uk-button-text):not(.uk-button-default):not(.uk-button-primary), .portal-button {
|
161 |
|
|
background-color:` + (this.layout.buttons.lightBackground.backgroundColor != null ? this.layout.buttons.lightBackground.backgroundColor : `#003052`) + `;
|
162 |
|
|
color: ` + (this.layout.buttons.lightBackground.color != null ? this.layout.buttons.lightBackground.color : `white`) + `;
|
163 |
|
|
border-color: ` + (this.layout.buttons.lightBackground.borderColor != null ? this.layout.buttons.lightBackground.borderColor : `transparent`) + `;
|
164 |
|
|
border-style: ` + (this.layout.buttons.lightBackground.borderStyle != null ? this.layout.buttons.lightBackground.borderStyle : `solid`) + `;
|
165 |
|
|
border-width: ` + (this.layout.buttons.lightBackground.borderWidth != null ? this.layout.buttons.lightBackground.borderWidth : `1`) + `px;
|
166 |
|
|
|
167 |
|
|
|
168 |
|
|
}
|
169 |
|
|
|
170 |
|
|
.uk-button:not(.uk-button-text):not(.uk-button-default):not(.uk-button-primary):hover, .portal-button:hover {
|
171 |
|
|
background-color: ` + (this.layout.buttons.lightBackground.onHover.backgroundColor != null ? this.layout.buttons.lightBackground.onHover.backgroundColor : `#154B71`) + `;
|
172 |
|
|
color: ` + (this.layout.buttons.lightBackground.onHover.color != null ? this.layout.buttons.lightBackground.onHover.color : `white`) + `;
|
173 |
|
|
border-color: ` + (this.layout.buttons.lightBackground.onHover.color != null ? this.layout.buttons.lightBackground.onHover.color : `transparent`) + `;
|
174 |
|
|
}
|
175 |
|
|
|
176 |
|
|
/*Buttons*/
|
177 |
|
|
.communityPanelBackground .uk-button:not(.ignoreCommunityPanelBackground) {
|
178 |
|
|
background-color: `
|
179 |
|
|
+ (this.layout.panel.onDarkBackground ? (this.layout.buttons.darkBackground.backgroundColor?this.layout.buttons.darkBackground.backgroundColor:'white') :(this.layout.buttons.lightBackground.backgroundColor?this.layout.buttons.lightBackground.backgroundColor:'var(--portal-main-color)') )
|
180 |
|
|
+` !important;
|
181 |
|
|
color: `
|
182 |
|
|
+ (this.layout.panel.onDarkBackground ? (this.layout.buttons.darkBackground.color?this.layout.buttons.darkBackground.color:'var(--portal-main-color)') :(this.layout.buttons.lightBackground.color?this.layout.buttons.lightBackground.color:'white') )
|
183 |
|
|
+ ` !important;
|
184 |
|
|
border-color: `
|
185 |
|
|
+ (this.layout.panel.onDarkBackground ? (this.layout.buttons.darkBackground.borderColor?this.layout.buttons.darkBackground.borderColor:'white') :(this.layout.buttons.lightBackground.borderColor?this.layout.buttons.lightBackground.borderColor:'var(--portal-main-color)') )
|
186 |
|
|
+ ` !important;
|
187 |
|
|
border-style: ` +
|
188 |
|
|
(this.layout.panel.onDarkBackground ? (this.layout.buttons.darkBackground.borderStyle?this.layout.buttons.darkBackground.borderStyle:'solid') :(this.layout.buttons.lightBackground.borderStyle?this.layout.buttons.lightBackground.borderStyle:'solid') )
|
189 |
|
|
+ ` !important;
|
190 |
|
|
border-width: ` +
|
191 |
|
|
(this.layout.panel.onDarkBackground ? (this.layout.buttons.darkBackground.borderWidth?this.layout.buttons.darkBackground.borderWidth:'1px') :(this.layout.buttons.lightBackground.borderWidth?this.layout.buttons.lightBackground.borderWidth:'1px') )
|
192 |
|
|
+ ` !important;
|
193 |
|
|
border-radius:` +
|
194 |
|
|
(this.layout.panel.onDarkBackground ? (this.layout.buttons.darkBackground.borderRadius?this.layout.buttons.darkBackground.borderRadius:'4px') :(this.layout.buttons.lightBackground.borderRadius?this.layout.buttons.lightBackground.borderRadius:'4px') )+
|
195 |
|
|
+ ` !important;
|
196 |
|
|
font-weight:`
|
197 |
|
|
// (this.layout.panel.onDarkBackground ? (this.layout.buttons.darkBackground.fontWeight?this.layout.buttons.darkBackground.fontWeight:'4px') :(this.layout.buttons.lightBackground.borderRadius?this.layout.buttons.lightBackground.borderRadius:'4px') )+
|
198 |
|
|
// (this.layout.panel.buttons.fontWeight != null ? this.layout.panel.buttons.fontWeight : `600`) + `;
|
199 |
|
|
+`
|
200 |
|
|
}
|
201 |
|
|
|
202 |
|
|
.communityPanelBackground .uk-button:not(.ignoreCommunityPanelBackground):hover {
|
203 |
|
|
background-color: ` +
|
204 |
|
|
(this.layout.panel.onDarkBackground ? (this.layout.buttons.darkBackground.onHover.backgroundColor?this.layout.buttons.darkBackground.onHover.backgroundColor:' #eeeeee') :(this.layout.buttons.lightBackground.onHover.backgroundColor?this.layout.buttons.lightBackground.onHover.backgroundColor:'var(--portal-dark-color)') )
|
205 |
|
|
+ ` !important;
|
206 |
|
|
color: ` +
|
207 |
|
|
(this.layout.panel.onDarkBackground ? (this.layout.buttons.darkBackground.onHover.color?this.layout.buttons.darkBackground.onHover.color:' var(--portal-main-color) ') :(this.layout.buttons.lightBackground.onHover.color?this.layout.buttons.lightBackground.onHover.color:'white') )
|
208 |
|
|
+ ` !important;
|
209 |
|
|
border-color:`
|
210 |
|
|
+(this.layout.panel.onDarkBackground ? (this.layout.buttons.darkBackground.onHover.borderColor?this.layout.buttons.darkBackground.onHover.borderColor:' #eeeeee ') :(this.layout.buttons.lightBackground.onHover.borderColor?this.layout.buttons.lightBackground.onHover.borderColor:'var(--portal-dark-color)') )
|
211 |
|
|
+ ` !important;
|
212 |
|
|
}
|
213 |
|
|
|
214 |
|
|
|
215 |
|
|
.uk-navbar-dropdown {
|
216 |
|
|
background-color: white;
|
217 |
|
|
color: #666;
|
218 |
|
|
box-shadow: 0 5px 12px rgba(0, 0, 0, .15);
|
219 |
|
|
/*border:var(--portal-main-color) 1px solid;*/
|
220 |
|
|
}
|
221 |
|
|
|
222 |
|
|
.customTabs .uk-tab > .uk-active > a {
|
223 |
|
|
border-color: var(--portal-main-color);
|
224 |
|
|
}
|
225 |
|
|
|
226 |
|
|
.customTabs .uk-tab > .uk-active > a {
|
227 |
|
|
border-color: var(--portal-main-color);
|
228 |
|
|
}
|
229 |
|
|
|
230 |
|
|
.uk-tab > * > a:focus, .uk-tab > * > a:hover {
|
231 |
|
|
border-color: var(--portal-dark-color);
|
232 |
|
|
}
|
233 |
|
|
|
234 |
|
|
|
235 |
|
|
`
|
236 |
|
|
appendCss(css);
|
237 |
|
|
}
|
238 |
|
|
}
|