This is an automated email from the ASF dual-hosted git repository.
smolnar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/knox.git
The following commit(s) were added to refs/heads/master by this push:
new 5610762 KNOX-2571 - Introducing Knox Home page profiles (#430)
5610762 is described below
commit 56107628e8d725b86500ddab8037363ea0ae9360
Author: Sandor Molnar <[email protected]>
AuthorDate: Thu Apr 8 09:48:04 2021 +0200
KNOX-2571 - Introducing Knox Home page profiles (#430)
---
.../gateway/config/impl/GatewayConfigImpl.java | 22 ++++++
.../service/metadata/KnoxMetadataResource.java | 18 +++++
.../apache/knox/gateway/config/GatewayConfig.java | 7 ++
.../apache/knox/gateway/dto/HomePageProfile.java | 84 ++++++++++++++++++++++
.../knox/gateway/dto/HomePageProfileTest.java | 78 ++++++++++++++++++++
.../org/apache/knox/gateway/GatewayTestConfig.java | 6 ++
knox-homepage-ui/home/app/app.module.ts | 11 ++-
.../general.proxy.information.component.html | 12 ++--
.../general.proxy.information.component.ts | 29 +++++++-
knox-homepage-ui/home/app/homepage.service.ts | 16 +++++
.../session.information.component.html | 23 +-----
.../topologies/topology.information.component.ts | 43 ++++++++++-
knox-homepage-ui/home/index.html | 6 +-
13 files changed, 323 insertions(+), 32 deletions(-)
diff --git
a/gateway-server/src/main/java/org/apache/knox/gateway/config/impl/GatewayConfigImpl.java
b/gateway-server/src/main/java/org/apache/knox/gateway/config/impl/GatewayConfigImpl.java
index c0881ac..458026b 100644
---
a/gateway-server/src/main/java/org/apache/knox/gateway/config/impl/GatewayConfigImpl.java
+++
b/gateway-server/src/main/java/org/apache/knox/gateway/config/impl/GatewayConfigImpl.java
@@ -23,6 +23,7 @@ import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.knox.gateway.GatewayMessages;
import org.apache.knox.gateway.config.GatewayConfig;
+import org.apache.knox.gateway.dto.HomePageProfile;
import org.apache.knox.gateway.i18n.messages.MessagesFactory;
import
org.apache.knox.gateway.services.security.impl.ZookeeperRemoteAliasService;
import org.joda.time.Period;
@@ -42,6 +43,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
@@ -262,6 +264,7 @@ public class GatewayConfigImpl extends Configuration
implements GatewayConfig {
private static final long KNOX_TOKEN_ALIAS_PERSISTENCE_INTERVAL_DEFAULT =
TimeUnit.SECONDS.toSeconds(15);
private static final boolean
KNOX_TOKEN_PERMISSIVE_VALIDATION_ENABLED_DEFAULT = false;
+ private static final String KNOX_HOMEPAGE_PROFILE_PREFIX =
"knox.homepage.profile.";
private static final String KNOX_HOMEPAGE_PINNED_TOPOLOGIES =
"knox.homepage.pinned.topologies";
private static final String KNOX_HOMEPAGE_HIDDEN_TOPOLOGIES =
"knox.homepage.hidden.topologies";
private static final Set<String> KNOX_HOMEPAGE_HIDDEN_TOPOLOGIES_DEFAULT =
new HashSet<>(Arrays.asList("admin", "manager", "knoxsso", "metadata",
"homepage"));
@@ -1209,4 +1212,23 @@ public class GatewayConfigImpl extends Configuration
implements GatewayConfig {
public boolean isGatewayServerIncomingXForwardedSupportEnabled() {
return getBoolean(KNOX_INCOMING_XFORWARDED_ENABLED, true);
}
+
+ @Override
+ public Map<String, Collection<String>> getHomePageProfiles() {
+ final Map<String, Collection<String>> profiles =
getPreConfiguredProfiles(); // pre-configured profiles might be overwritten
+ this.forEach(config -> {
+ if (config.getKey().startsWith(KNOX_HOMEPAGE_PROFILE_PREFIX)) {
+
profiles.put(config.getKey().substring(KNOX_HOMEPAGE_PROFILE_PREFIX.length()).toLowerCase(Locale.getDefault()),
getTrimmedStringCollection(config.getKey()));
+ }
+ });
+ return profiles;
+ }
+
+ private Map<String, Collection<String>> getPreConfiguredProfiles() {
+ final Map<String, Collection<String>> profiles = new HashMap<>();
+ profiles.put("full", HomePageProfile.getFullProfileElements());
+ profiles.put("thin", HomePageProfile.getThinProfileElemens());
+ profiles.put("token", HomePageProfile.getTokenProfileElements());
+ return profiles;
+ }
}
diff --git
a/gateway-service-metadata/src/main/java/org/apache/knox/gateway/service/metadata/KnoxMetadataResource.java
b/gateway-service-metadata/src/main/java/org/apache/knox/gateway/service/metadata/KnoxMetadataResource.java
index 9522ae2..564b06e 100644
---
a/gateway-service-metadata/src/main/java/org/apache/knox/gateway/service/metadata/KnoxMetadataResource.java
+++
b/gateway-service-metadata/src/main/java/org/apache/knox/gateway/service/metadata/KnoxMetadataResource.java
@@ -29,9 +29,11 @@ import java.security.cert.Certificate;
import java.security.cert.CertificateEncodingException;
import java.security.cert.CertificateException;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Locale;
+import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.TreeSet;
@@ -50,6 +52,7 @@ import javax.ws.rs.core.Response.ResponseBuilder;
import javax.ws.rs.core.Response.Status;
import org.apache.knox.gateway.config.GatewayConfig;
+import org.apache.knox.gateway.dto.HomePageProfile;
import org.apache.knox.gateway.i18n.messages.MessagesFactory;
import org.apache.knox.gateway.service.definition.Metadata;
import org.apache.knox.gateway.service.definition.ServiceDefinitionPair;
@@ -62,6 +65,7 @@ import
org.apache.knox.gateway.services.security.KeystoreServiceException;
import org.apache.knox.gateway.services.topology.TopologyService;
import org.apache.knox.gateway.topology.Service;
import org.apache.knox.gateway.topology.Topology;
+import org.apache.knox.gateway.util.JsonUtils;
import org.apache.knox.gateway.util.X509CertificateUtil;
import io.swagger.annotations.Api;
@@ -250,4 +254,18 @@ public class KnoxMetadataResource {
return serviceModel;
}
+ @GET
+ @Produces({ APPLICATION_JSON })
+ @Path("profiles/{profile}")
+ public String getProfile(@PathParam("profile") String profileName) {
+ final GatewayConfig config = (GatewayConfig)
request.getServletContext().getAttribute(GatewayConfig.GATEWAY_CONFIG_ATTRIBUTE);
+ final Map<String, Collection<String>> configuredProfiles =
config.getHomePageProfiles();
+ if
(configuredProfiles.containsKey(profileName.toLowerCase(Locale.getDefault()))) {
+ final HomePageProfile profile = new
HomePageProfile(configuredProfiles.get(profileName));
+ return JsonUtils.renderAsJsonString(profile.getProfileElements());
+ } else {
+ return JsonUtils.renderAsJsonString(Collections.emptyMap());
+ }
+ }
+
}
diff --git
a/gateway-spi/src/main/java/org/apache/knox/gateway/config/GatewayConfig.java
b/gateway-spi/src/main/java/org/apache/knox/gateway/config/GatewayConfig.java
index 45e95de..020eb63 100644
---
a/gateway-spi/src/main/java/org/apache/knox/gateway/config/GatewayConfig.java
+++
b/gateway-spi/src/main/java/org/apache/knox/gateway/config/GatewayConfig.java
@@ -20,6 +20,7 @@ package org.apache.knox.gateway.config;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
import java.security.KeyStore;
+import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -740,4 +741,10 @@ public interface GatewayConfig {
* @return true if incoming X-Forwarded headers are enabled
*/
boolean isGatewayServerIncomingXForwardedSupportEnabled();
+
+ /**
+ * Gets the home page profiles (pre-configured and user-defined profiles
too).
+ * It's important that keys in the returned map are converted to lowercase
strings.
+ */
+ Map<String, Collection<String>> getHomePageProfiles();
}
diff --git
a/gateway-spi/src/main/java/org/apache/knox/gateway/dto/HomePageProfile.java
b/gateway-spi/src/main/java/org/apache/knox/gateway/dto/HomePageProfile.java
new file mode 100644
index 0000000..4822e08
--- /dev/null
+++ b/gateway-spi/src/main/java/org/apache/knox/gateway/dto/HomePageProfile.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.knox.gateway.dto;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+public class HomePageProfile {
+ static final String GPI_PREFIX = "gpi_";
+ static final String GPI_VERSION = GPI_PREFIX + "version";
+ static final String GPI_CERT = GPI_PREFIX + "cert";
+ static final String GPI_ADMIN_UI = GPI_PREFIX + "admin_ui";
+ static final String GPI_ADMIN_API = GPI_PREFIX + "admin_api";
+ static final String GPI_METADATA_API = GPI_PREFIX + "md_api";
+ static final String GPI_TOKENS = GPI_PREFIX + "tokens";
+ static final String TOPOLOGIES = "topologies";
+ static final String TOPOLOGY_PREFIX = "top_";
+ static final String ALL_TOPOLOGIES = TOPOLOGY_PREFIX + "all";
+
+ private final Map<String, String> profileElements = new HashMap<>();
+
+ public HomePageProfile(Collection<String> profileConfiguration) {
+ addElement(GPI_VERSION, profileConfiguration);
+ addElement(GPI_CERT, profileConfiguration);
+ addElement(GPI_ADMIN_UI, profileConfiguration);
+ addElement(GPI_ADMIN_API, profileConfiguration);
+ addElement(GPI_METADATA_API, profileConfiguration);
+ addElement(GPI_TOKENS, profileConfiguration);
+ addTopologies(profileConfiguration);
+ }
+
+ private void addTopologies(Collection<String> profileConfiguration) {
+ final Set<String> topologies = new HashSet<>();
+ profileConfiguration.forEach(config -> {
+ if (config.startsWith(TOPOLOGY_PREFIX)) {
+ topologies.add(config.substring(TOPOLOGY_PREFIX.length()));
+ }
+ });
+ profileElements.put(TOPOLOGIES, String.join(",", topologies));
+ }
+
+ private void addElement(String element, Collection<String>
profileConfiguration) {
+ if (profileConfiguration.contains(element)) {
+ profileElements.put(element, Boolean.TRUE.toString());
+ } else {
+ profileElements.put(element, Boolean.FALSE.toString());
+ }
+ }
+
+ public Map<String, String> getProfileElements() {
+ return profileElements;
+ }
+
+ public static Collection<String> getFullProfileElements() {
+ return Arrays.asList(GPI_VERSION, GPI_CERT, GPI_ADMIN_UI, GPI_ADMIN_API,
GPI_METADATA_API, GPI_TOKENS);
+ }
+
+ public static Collection<String> getThinProfileElemens() {
+ return Arrays.asList(GPI_VERSION, GPI_CERT);
+ }
+
+ public static Collection<String> getTokenProfileElements() {
+ return Arrays.asList(GPI_VERSION, GPI_TOKENS);
+ }
+}
diff --git
a/gateway-spi/src/test/java/org/apache/knox/gateway/dto/HomePageProfileTest.java
b/gateway-spi/src/test/java/org/apache/knox/gateway/dto/HomePageProfileTest.java
new file mode 100644
index 0000000..a2239bf
--- /dev/null
+++
b/gateway-spi/src/test/java/org/apache/knox/gateway/dto/HomePageProfileTest.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.knox.gateway.dto;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Arrays;
+import java.util.Collections;
+
+import org.junit.Test;
+
+public class HomePageProfileTest {
+
+ @Test
+ public void testEmptyConfiguration() throws Exception {
+ final HomePageProfile profile = new
HomePageProfile(Collections.emptySet());
+ assertEquals(7, profile.getProfileElements().size());
+ profile.getProfileElements().forEach((key, value) -> {
+ if (key.startsWith(HomePageProfile.GPI_PREFIX)) {
+ assertFalse(Boolean.parseBoolean(value));
+ } else {
+ assertTrue(value.isEmpty());
+ }
+ });
+ }
+
+ @Test
+ public void testGeneralProxyInformationVersion() throws Exception {
+ doTestGeneralProxyInformationElement(HomePageProfile.GPI_VERSION);
+ }
+
+ @Test
+ public void testGeneralProxyInformationCert() throws Exception {
+ doTestGeneralProxyInformationElement(HomePageProfile.GPI_CERT);
+ }
+
+ @Test
+ public void testGeneralProxyInformationAdminUI() throws Exception {
+ doTestGeneralProxyInformationElement(HomePageProfile.GPI_ADMIN_UI);
+ }
+
+ @Test
+ public void testGeneralProxyInformationAdminAPI() throws Exception {
+ doTestGeneralProxyInformationElement(HomePageProfile.GPI_ADMIN_API);
+ }
+
+ @Test
+ public void testGeneralProxyInformatioMetadataAPI() throws Exception {
+ doTestGeneralProxyInformationElement(HomePageProfile.GPI_METADATA_API);
+ }
+
+ @Test
+ public void testGeneralProxyInformationTokens() throws Exception {
+ doTestGeneralProxyInformationElement(HomePageProfile.GPI_TOKENS);
+ }
+
+ private void doTestGeneralProxyInformationElement(String gpiElement) {
+ final HomePageProfile profile = new
HomePageProfile(Arrays.asList(gpiElement));
+
assertTrue(Boolean.parseBoolean(profile.getProfileElements().get(gpiElement)));
+ }
+}
diff --git
a/gateway-test-release-utils/src/main/java/org/apache/knox/gateway/GatewayTestConfig.java
b/gateway-test-release-utils/src/main/java/org/apache/knox/gateway/GatewayTestConfig.java
index ca23af9..b84834d 100644
---
a/gateway-test-release-utils/src/main/java/org/apache/knox/gateway/GatewayTestConfig.java
+++
b/gateway-test-release-utils/src/main/java/org/apache/knox/gateway/GatewayTestConfig.java
@@ -29,6 +29,7 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -847,4 +848,9 @@ public class GatewayTestConfig extends Configuration
implements GatewayConfig {
public boolean isGatewayServerIncomingXForwardedSupportEnabled() {
return true;
}
+
+ @Override
+ public Map<String, Collection<String>> getHomePageProfiles() {
+ return null;
+ }
}
diff --git a/knox-homepage-ui/home/app/app.module.ts
b/knox-homepage-ui/home/app/app.module.ts
index 22dd868..53959a9 100644
--- a/knox-homepage-ui/home/app/app.module.ts
+++ b/knox-homepage-ui/home/app/app.module.ts
@@ -19,6 +19,8 @@ import {BrowserModule} from '@angular/platform-browser';
import {HttpClientModule, HttpClientXsrfModule} from '@angular/common/http';
import {MatGridListModule} from '@angular/material/grid-list';
import {BsModalModule} from 'ng2-bs3-modal/ng2-bs3-modal';
+import {Routes, RouterModule} from '@angular/router';
+import {APP_BASE_HREF} from '@angular/common';
import {GeneralProxyInformationComponent} from
'./generalProxyInformation/general.proxy.information.component';
import {TopologyInformationsComponent} from
'./topologies/topology.information.component';
@@ -30,13 +32,18 @@ import {HomepageService} from './homepage.service';
HttpClientModule,
HttpClientXsrfModule,
MatGridListModule,
- BsModalModule
+ BsModalModule,
+ RouterModule.forRoot([])
],
declarations: [GeneralProxyInformationComponent,
TopologyInformationsComponent,
SessionInformationComponent
],
- providers: [HomepageService
+ providers: [HomepageService,
+ {
+ provide: APP_BASE_HREF,
+ useValue: window['base-href']
+ }
],
bootstrap: [SessionInformationComponent,
GeneralProxyInformationComponent,
diff --git
a/knox-homepage-ui/home/app/generalProxyInformation/general.proxy.information.component.html
b/knox-homepage-ui/home/app/generalProxyInformation/general.proxy.information.component.html
index e5d4fe0..ffe415a 100644
---
a/knox-homepage-ui/home/app/generalProxyInformation/general.proxy.information.component.html
+++
b/knox-homepage-ui/home/app/generalProxyInformation/general.proxy.information.component.html
@@ -22,11 +22,11 @@
<col width="70%">
</colgroup>
<tbody>
- <tr>
+ <tr *ngIf="this['showKnoxVersion']">
<td>Knox Version</td>
<td>{{ getVersion() }}</td>
</tr>
- <tr>
+ <tr *ngIf="this['showPublicCerts']">
<td>TLS Public Certificate</td>
<td>
<a href="{{ getMetadataAPIUrl('publicCert?type=pem')
}}">PEM</a>
@@ -34,11 +34,11 @@
<a href="{{ getMetadataAPIUrl('publicCert?type=jks')
}}">JKS</a>
</td>
</tr>
- <tr>
+ <tr *ngIf="this['showAdminUI']">
<td>Admin UI URL</td>
<td><a href="{{ getAdminUiUrl() }}" target="_blank">{{
getAdminUiUrl() }}</a></td>
</tr>
- <tr>
+ <tr *ngIf="this['showAdminAPI']">
<td>
Admin API Details
<span class="inline-glyph glyphicon glyphicon-info-sign
btn btn-xs"
@@ -48,7 +48,7 @@
<a href="{{ getAdminApiBookUrl() }}" target="_blank">{{
getAdminApiBookUrl() }}</a>
</td>
</tr>
- <tr>
+ <tr *ngIf="this['showMetadataAPI']">
<td>
Metadata API
</td>
@@ -58,7 +58,7 @@
<a href="{{ getMetadataAPIUrl('topologies') }}"
target="_blank">Topologies</a>
</td>
</tr>
- <tr>
+ <tr *ngIf="this['showTokens']">
<td>
Integration Tokens
</td>
diff --git
a/knox-homepage-ui/home/app/generalProxyInformation/general.proxy.information.component.ts
b/knox-homepage-ui/home/app/generalProxyInformation/general.proxy.information.component.ts
index b8212fe..e585166 100644
---
a/knox-homepage-ui/home/app/generalProxyInformation/general.proxy.information.component.ts
+++
b/knox-homepage-ui/home/app/generalProxyInformation/general.proxy.information.component.ts
@@ -15,6 +15,7 @@
* limitations under the License.
*/
import {Component, OnInit} from '@angular/core';
+import {ActivatedRoute} from '@angular/router';
import {HomepageService} from '../homepage.service';
import {GeneralProxyInformation} from './general.proxy.information';
@@ -27,9 +28,16 @@ import {GeneralProxyInformation} from
'./general.proxy.information';
export class GeneralProxyInformationComponent implements OnInit {
generalProxyInformation: GeneralProxyInformation;
+ profile: JSON;
- constructor(private homepageService: HomepageService) {
+ constructor(private homepageService: HomepageService, private route:
ActivatedRoute) {
this['showGeneralProxyInformation'] = false;
+ this['showKnoxVersion'] = true;
+ this['showPublicCerts'] = true;
+ this['showAdminUI'] = true;
+ this['showAdminAPI'] = true;
+ this['showMetadataAPI'] = true;
+ this['showTokens'] = true;
}
getVersion() {
@@ -70,6 +78,25 @@ export class GeneralProxyInformationComponent implements
OnInit {
console.debug('GeneralProxyInformationComponent --> ngOnInit() --> ');
this.homepageService.getGeneralProxyInformation()
.then(generalProxyInformation =>
this.generalProxyInformation = generalProxyInformation);
+ let profileName;
+ this.route.queryParams.subscribe(params => {
+ profileName = params['profile'];
+ console.debug('Profile name = ' + profileName)
+ if (profileName) {
+ console.debug('Fetching profile information...');
+ this.homepageService.getProfile(profileName).then(profile
=> this.setProfileFlags(profile));
+ }
+ });
+ }
+
+ setProfileFlags(profile: JSON) {
+ console.debug('Setting GPI profile flags...');
+ this['showKnoxVersion'] = (profile['gpi_version'] === 'true');
+ this['showPublicCerts'] = (profile['gpi_cert'] === 'true');
+ this['showAdminUI'] = (profile['gpi_admin_ui'] === 'true');
+ this['showAdminAPI'] = (profile['gpi_admin_api'] === 'true');
+ this['showMetadataAPI'] = (profile['gpi_md_api'] === 'true');
+ this['showTokens'] = (profile['gpi_tokens'] === 'true');
}
toggleBoolean(propertyName: string) {
diff --git a/knox-homepage-ui/home/app/homepage.service.ts
b/knox-homepage-ui/home/app/homepage.service.ts
index 8e6b725..9a39218 100644
--- a/knox-homepage-ui/home/app/homepage.service.ts
+++ b/knox-homepage-ui/home/app/homepage.service.ts
@@ -99,6 +99,22 @@ export class HomepageService {
});
}
+ getProfile(profileName): Promise<JSON> {
+ let headers = new HttpHeaders();
+ headers = this.addJsonHeaders(headers);
+ return this.http.get(this.apiUrl + '/profiles/' + profileName, {
headers: headers})
+ .toPromise()
+ .then(response => response)
+ .catch((err: HttpErrorResponse) => {
+ console.debug('HomepageService --> getProfile() --> ' +
this.apiUrl + '/profiles/' + profileName + '\n error: ' + err.message);
+ if (err.status === 401) {
+ window.location.assign(document.location.pathname);
+ } else {
+ return this.handleError(err);
+ }
+ });
+ }
+
addJsonHeaders(headers: HttpHeaders): HttpHeaders {
return this.addCsrfHeaders(headers.append('Accept',
'application/json').append('Content-Type', 'application/json'));
}
diff --git
a/knox-homepage-ui/home/app/sessionInformation/session.information.component.html
b/knox-homepage-ui/home/app/sessionInformation/session.information.component.html
index 3ab7833..5a6e419 100644
---
a/knox-homepage-ui/home/app/sessionInformation/session.information.component.html
+++
b/knox-homepage-ui/home/app/sessionInformation/session.information.component.html
@@ -12,24 +12,5 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<div class="table-responsive">
- <table class="table table-striped table-hover">
- <colgroup>
- <col width="90%">
- <col width="5%">
- <col width="5%">
- </colgroup>
- <tbody>
- <tr>
- <td></td>
- <td>Welcome</td>
- <td>{{ getUser() }}</td>
- </tr>
- <tr *ngIf="logoutSupported">
- <td></td>
- <td></td>
- <td><a class="btn btn-primary"
(click)="logout()">logout</a></td>
- </tr>
- </tbody>
- </table>
-</div>
\ No newline at end of file
+<div style="text-align: right; color: rgb(130, 180, 93);">Welcome {{ getUser()
}}</div>
+<div *ngIf="logoutSupported" style="text-align: right;"><a class="btn
btn-primary" (click)="logout()">logout</a></div>
diff --git
a/knox-homepage-ui/home/app/topologies/topology.information.component.ts
b/knox-homepage-ui/home/app/topologies/topology.information.component.ts
index c3a394c..94fc6f9 100644
--- a/knox-homepage-ui/home/app/topologies/topology.information.component.ts
+++ b/knox-homepage-ui/home/app/topologies/topology.information.component.ts
@@ -15,6 +15,7 @@
* limitations under the License.
*/
import {Component, OnInit, ViewChild} from '@angular/core';
+import {ActivatedRoute} from '@angular/router';
import {MatGridListModule} from '@angular/material/grid-list';
import {BsModalComponent} from 'ng2-bs3-modal/ng2-bs3-modal';
import {HomepageService} from '../homepage.service';
@@ -34,10 +35,12 @@ export class TopologyInformationsComponent implements
OnInit {
apiServiceInformationModal: BsModalComponent;
topologies: TopologyInformation[];
+ desiredTopologies: string[];
selectedApiService : Service;
setTopologies(topologies: TopologyInformation[]) {
this.topologies = topologies;
+ this.filterTopologies();
for (let topology of topologies) {
this['showTopology_' + topology.topology] = topology.pinned;
}
@@ -51,13 +54,51 @@ export class TopologyInformationsComponent implements
OnInit {
this[enableServiceText] = true;
}
- constructor(private homepageService: HomepageService) {
+ constructor(private homepageService: HomepageService, private route:
ActivatedRoute) {
this['showTopologies'] = true;
}
ngOnInit(): void {
console.debug('TopologyInformationsComponent --> ngOnInit()');
this.homepageService.getTopologies().then(topologies =>
this.setTopologies(topologies));
+ this.route.queryParams.subscribe(params => {
+ let topologiesParam = params['topologies'];
+ console.debug('Topologies query param name = ' + topologiesParam)
+ if (topologiesParam) {
+ this.desiredTopologies = topologiesParam.split(',');
+ this.filterTopologies();
+ } else {
+ let profileName = params['profile'];
+ console.debug('Profile name = ' + profileName)
+ if (profileName) {
+ console.debug('Fetching profile information...');
+
this.homepageService.getProfile(profileName).then(profile =>
this.setDesiredTopologiesFromProfile(profile));
+ }
+ }
+ });
+ }
+
+ setDesiredTopologiesFromProfile(profile: JSON) {
+ let topologiesInProfile = profile['topologies'];
+ if (topologiesInProfile !== "") {
+ this.desiredTopologies = topologiesInProfile.split(',');
+ this.filterTopologies();
+ }
+ }
+
+ filterTopologies() {
+ if (this.topologies && this.desiredTopologies &&
this.desiredTopologies.length > 0) {
+ console.debug('Filtering topologies...');
+ let filteredTopologies = [];
+ for (let desiredTopology of this.desiredTopologies) {
+ for (let topology of this.topologies) {
+ if (topology.topology === desiredTopology) {
+ filteredTopologies.push(topology);
+ }
+ }
+ }
+ this.topologies = filteredTopologies;
+ }
}
openApiServiceInformationModal(apiService: Service) {
diff --git a/knox-homepage-ui/home/index.html b/knox-homepage-ui/home/index.html
index cc112e2..4233428 100644
--- a/knox-homepage-ui/home/index.html
+++ b/knox-homepage-ui/home/index.html
@@ -22,6 +22,10 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Custom styles for this template -->
<link href="assets/sticky-footer.css" rel="stylesheet">
+ <script>
+ window['base-href'] = window.location.pathname;
+ console.log(window['base-href']);
+ </script>
</head>
<body>
<div class="navbar-wrapper">
@@ -38,12 +42,12 @@
</button>
<a class="navbar-brand" href="#"> <img
style="max-width:200px; margin-top: -9px;"
src="assets/knox-logo-transparent.gif" alt="Apache Knox Home"></a>
</div>
+ <app-session-information></app-session-information>
</div>
</nav>
</div>
<div class="container-fluid">
- <app-session-information></app-session-information>
<app-general-proxy-information></app-general-proxy-information>
<app-topologies-information></app-topologies-information>
</div>