This is an automated email from the ASF dual-hosted git repository.
riemer pushed a commit to branch 2975-configurable-documentation-links
in repository https://gitbox.apache.org/repos/asf/streampipes.git
The following commit(s) were added to
refs/heads/2975-configurable-documentation-links by this push:
new 0efcd5302e feat(#2975): Add configurable application links
0efcd5302e is described below
commit 0efcd5302eb9e388428d004e2e848d165e63240e
Author: Dominik Riemer <[email protected]>
AuthorDate: Sun Jun 30 19:18:31 2024 +0200
feat(#2975): Add configurable application links
---
.idea/runConfigurations/ui.xml | 2 +-
.../model/configuration/LinkSettings.java | 3 ++
.../streampipes/rest/impl/Authentication.java | 1 +
.../core/migrations/AvailableMigrations.java | 4 +-
.../migrations/v970/AddLinkSettingsMigration.java | 52 +++++++++++++++++++
ui/package-lock.json | 4 +-
.../src/lib/model/config/general-config.model.ts | 3 ++
.../src/lib/model/gen/streampipes-model.ts | 28 +++++++++-
ui/src/app/configuration/configuration.module.ts | 2 +
.../general-configuration.component.html | 59 ++++++++++------------
.../general-configuration.component.ts | 50 ++++++++++++++++++
.../link-settings/link-settings.component.html | 49 ++++++++++++++++++
.../link-settings/link-settings.component.ts} | 19 +++----
.../core/components/toolbar/toolbar.component.html | 1 +
.../core/components/toolbar/toolbar.component.ts | 12 ++++-
.../activate-account.component.html | 2 +-
.../activate-account/activate-account.component.ts | 21 +++++---
.../components/auth-box/auth-box.component.html | 24 ++++++++-
.../components/auth-box/auth-box.component.ts | 6 ++-
...x.component.ts => base-login-page.directive.ts} | 28 ++++++----
.../login/components/login/login.component.html | 9 +---
.../app/login/components/login/login.component.ts | 53 +++++++++----------
ui/src/app/login/components/login/login.model.ts | 3 ++
.../components/register/register.component.html | 2 +-
.../components/register/register.component.ts | 45 +++++++++--------
.../restore-password.component.html | 2 +-
.../restore-password/restore-password.component.ts | 33 ++++++------
.../set-new-password.component.html | 2 +-
.../set-new-password/set-new-password.component.ts | 13 +++--
ui/src/app/login/services/login.service.ts | 2 +-
30 files changed, 384 insertions(+), 150 deletions(-)
diff --git a/.idea/runConfigurations/ui.xml b/.idea/runConfigurations/ui.xml
index ce35c11692..b2d00f6ceb 100644
--- a/.idea/runConfigurations/ui.xml
+++ b/.idea/runConfigurations/ui.xml
@@ -1,6 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="ui" type="js.build_tools.npm">
- <package-json
value="$PROJECT_DIR$/../incubator-streampipes/ui/package.json" />
+ <package-json value="$PROJECT_DIR$/ui/package.json" />
<command value="start" />
<node-interpreter value="project" />
<envs />
diff --git
a/streampipes-model/src/main/java/org/apache/streampipes/model/configuration/LinkSettings.java
b/streampipes-model/src/main/java/org/apache/streampipes/model/configuration/LinkSettings.java
index 3cb6fea9fc..1c798007ce 100644
---
a/streampipes-model/src/main/java/org/apache/streampipes/model/configuration/LinkSettings.java
+++
b/streampipes-model/src/main/java/org/apache/streampipes/model/configuration/LinkSettings.java
@@ -18,6 +18,9 @@
package org.apache.streampipes.model.configuration;
+import org.apache.streampipes.model.shared.annotation.TsModel;
+
+@TsModel
public record LinkSettings(String documentationUrl,
String supportUrl,
boolean showDocumentationLinkOnStartScreen,
diff --git
a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/Authentication.java
b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/Authentication.java
index cfbc17722f..2401ee61da 100644
---
a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/Authentication.java
+++
b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/Authentication.java
@@ -138,6 +138,7 @@ public class Authentication extends AbstractRestResource {
Map<String, Object> response = new HashMap<>();
response.put("allowSelfRegistration", config.isAllowSelfRegistration());
response.put("allowPasswordRecovery", config.isAllowPasswordRecovery());
+ response.put("linkSettings", config.getLinkSettings());
return ok(response);
}
diff --git
a/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/AvailableMigrations.java
b/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/AvailableMigrations.java
index 2ee78fea02..8b21c7575a 100644
---
a/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/AvailableMigrations.java
+++
b/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/AvailableMigrations.java
@@ -26,6 +26,7 @@ import
org.apache.streampipes.service.core.migrations.v090.UpdateUsernameViewMig
import org.apache.streampipes.service.core.migrations.v093.AdapterMigration;
import
org.apache.streampipes.service.core.migrations.v093.StoreEmailTemplatesMigration;
import
org.apache.streampipes.service.core.migrations.v095.MergeFilenamesAndRenameDuplicatesMigration;
+import
org.apache.streampipes.service.core.migrations.v970.AddLinkSettingsMigration;
import java.util.Arrays;
import java.util.List;
@@ -40,7 +41,8 @@ public class AvailableMigrations {
new UpdateUsernameViewMigration(),
new AdapterMigration(),
new StoreEmailTemplatesMigration(),
- new MergeFilenamesAndRenameDuplicatesMigration()
+ new MergeFilenamesAndRenameDuplicatesMigration(),
+ new AddLinkSettingsMigration()
);
}
}
diff --git
a/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v970/AddLinkSettingsMigration.java
b/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v970/AddLinkSettingsMigration.java
new file mode 100644
index 0000000000..de932a6fe3
--- /dev/null
+++
b/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v970/AddLinkSettingsMigration.java
@@ -0,0 +1,52 @@
+/*
+ * 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.streampipes.service.core.migrations.v970;
+
+import org.apache.streampipes.model.configuration.DefaultLinkSettings;
+import org.apache.streampipes.service.core.migrations.Migration;
+import org.apache.streampipes.storage.api.ISpCoreConfigurationStorage;
+import org.apache.streampipes.storage.management.StorageDispatcher;
+
+import java.io.IOException;
+
+public class AddLinkSettingsMigration implements Migration {
+
+ private final ISpCoreConfigurationStorage coreConfigStore =
StorageDispatcher
+ .INSTANCE
+ .getNoSqlStore()
+ .getSpCoreConfigurationStorage();
+
+ @Override
+ public boolean shouldExecute() {
+ return coreConfigStore.get().getGeneralConfig().getLinkSettings() ==
null;
+ }
+
+ @Override
+ public void executeMigration() throws IOException {
+ var linkSettings = new DefaultLinkSettings().make();
+ var coreConfig = coreConfigStore.get();
+ coreConfig.getGeneralConfig().setLinkSettings(linkSettings);
+ coreConfigStore.updateElement(coreConfig);
+ }
+
+ @Override
+ public String getDescription() {
+ return "Adding link settings to general config";
+ }
+}
diff --git a/ui/package-lock.json b/ui/package-lock.json
index ebd86a4ffe..93f1538f42 100644
--- a/ui/package-lock.json
+++ b/ui/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "apache-streampipes",
- "version": "0.95.0-SNAPSHOT",
+ "version": "0.97.0-SNAPSHOT",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "apache-streampipes",
- "version": "0.95.0-SNAPSHOT",
+ "version": "0.97.0-SNAPSHOT",
"dependencies": {
"@ali-hm/angular-tree-component": "12.0.5",
"@angular-architects/native-federation": "^17.1.8",
diff --git
a/ui/projects/streampipes/platform-services/src/lib/model/config/general-config.model.ts
b/ui/projects/streampipes/platform-services/src/lib/model/config/general-config.model.ts
index bf1f9fc93c..fbc6db7798 100644
---
a/ui/projects/streampipes/platform-services/src/lib/model/config/general-config.model.ts
+++
b/ui/projects/streampipes/platform-services/src/lib/model/config/general-config.model.ts
@@ -16,6 +16,8 @@
*
*/
+import { LinkSettings } from '../gen/streampipes-model';
+
export interface GeneralConfigModel {
hostname: string;
port: number;
@@ -25,4 +27,5 @@ export interface GeneralConfigModel {
allowSelfRegistration: boolean;
defaultUserRoles: string[];
appName: string;
+ linkSettings: LinkSettings;
}
diff --git
a/ui/projects/streampipes/platform-services/src/lib/model/gen/streampipes-model.ts
b/ui/projects/streampipes/platform-services/src/lib/model/gen/streampipes-model.ts
index e2a8c7bd0d..cf79d51045 100644
---
a/ui/projects/streampipes/platform-services/src/lib/model/gen/streampipes-model.ts
+++
b/ui/projects/streampipes/platform-services/src/lib/model/gen/streampipes-model.ts
@@ -20,7 +20,7 @@
/* tslint:disable */
/* eslint-disable */
// @ts-nocheck
-// Generated using typescript-generator version 3.2.1263 on 2024-06-29
13:34:41.
+// Generated using typescript-generator version 3.2.1263 on 2024-06-30
09:10:19.
export class NamedStreamPipesEntity implements Storable {
'@class':
@@ -2093,6 +2093,32 @@ export class KeepOutputStrategy extends OutputStrategy {
}
}
+export class LinkSettings {
+ documentationUrl: string;
+ showApiDocumentationLinkOnStartScreen: boolean;
+ showDocumentationLinkInProfileMenu: boolean;
+ showDocumentationLinkOnStartScreen: boolean;
+ showSupportUrlOnStartScreen: boolean;
+ supportUrl: string;
+
+ static fromData(data: LinkSettings, target?: LinkSettings): LinkSettings {
+ if (!data) {
+ return data;
+ }
+ const instance = target || new LinkSettings();
+ instance.documentationUrl = data.documentationUrl;
+ instance.showApiDocumentationLinkOnStartScreen =
+ data.showApiDocumentationLinkOnStartScreen;
+ instance.showDocumentationLinkInProfileMenu =
+ data.showDocumentationLinkInProfileMenu;
+ instance.showDocumentationLinkOnStartScreen =
+ data.showDocumentationLinkOnStartScreen;
+ instance.showSupportUrlOnStartScreen =
data.showSupportUrlOnStartScreen;
+ instance.supportUrl = data.supportUrl;
+ return instance;
+ }
+}
+
export class ListOutputStrategy extends OutputStrategy {
'@class': 'org.apache.streampipes.model.output.ListOutputStrategy';
'propertyName': string;
diff --git a/ui/src/app/configuration/configuration.module.ts
b/ui/src/app/configuration/configuration.module.ts
index 4d61b1726f..305a667d6d 100644
--- a/ui/src/app/configuration/configuration.module.ts
+++ b/ui/src/app/configuration/configuration.module.ts
@@ -78,6 +78,7 @@ import { SpExtensionsInstallationDialogComponent } from
'./dialog/extensions-ins
import { EndpointItemComponent } from
'./extensions-installation/endpoint-item/endpoint-item.component';
import { SpExtensionsInstallationComponent } from
'./extensions-installation/extensions-installation.component';
import { MatMenuModule } from '@angular/material/menu';
+import { SpConfigurationLinkSettingsComponent } from
'./general-configuration/link-settings/link-settings.component';
@NgModule({
imports: [
@@ -173,6 +174,7 @@ import { MatMenuModule } from '@angular/material/menu';
SecurityServiceConfigComponent,
MessagingConfigurationComponent,
DatalakeConfigurationComponent,
+ SpConfigurationLinkSettingsComponent,
SpDataExportImportComponent,
SpDataExportDialogComponent,
SpDataExportItemComponent,
diff --git
a/ui/src/app/configuration/general-configuration/general-configuration.component.html
b/ui/src/app/configuration/general-configuration/general-configuration.component.html
index 0b4e2bcd72..b35d761cab 100644
---
a/ui/src/app/configuration/general-configuration/general-configuration.component.html
+++
b/ui/src/app/configuration/general-configuration/general-configuration.component.html
@@ -52,11 +52,11 @@
formControlName="protocol"
>
<mat-button-toggle value="http"
- >http</mat-button-toggle
- >
+ >http
+ </mat-button-toggle>
<mat-button-toggle value="https"
- >https</mat-button-toggle
- >
+ >https
+ </mat-button-toggle>
</mat-button-toggle-group>
</div>
<mat-form-field color="accent" class="ml-10">
@@ -82,22 +82,7 @@
</mat-form-field>
</div>
</div>
- <div class="mt-10">
- <button
- mat-button
- mat-raised-button
- color="accent"
- (click)="updateConfig()"
- style="margin-right: 10px"
- [disabled]="!parentForm.valid"
- data-cy="sp-element-general-config-save"
- >
- <i class="material-icons">save</i
- ><span> Save</span>
- </button>
- </div>
</sp-split-section>
- <mat-divider></mat-divider>
<sp-split-section
title="Registration"
subtitle="Registration process"
@@ -143,20 +128,28 @@
<mat-checkbox formControlName="allowPasswordRecovery"
>Allow self-service password recovery
</mat-checkbox>
-
- <div class="mt-10">
- <button
- mat-button
- mat-raised-button
- color="accent"
- (click)="updateConfig()"
- style="margin-right: 10px"
-
data-cy="sp-element-general-registration-config-save"
- >
- <i class="material-icons">save</i
- ><span> Save</span>
- </button>
- </div>
+ </div>
+ </sp-split-section>
+ <sp-configuration-link-settings
+ [parentForm]="parentForm"
+ [linkSettings]="generalConfig.linkSettings"
+ (updateConfigEmitter)="updateConfig()"
+ >
+ </sp-configuration-link-settings>
+ <sp-split-section>
+ <div class="mt-10">
+ <button
+ mat-button
+ mat-raised-button
+ color="accent"
+ (click)="updateConfig()"
+ style="margin-right: 10px"
+ [disabled]="!parentForm.valid"
+ data-cy="sp-element-general-config-save"
+ >
+ <i class="material-icons">save</i
+ ><span> Save</span>
+ </button>
</div>
</sp-split-section>
</form>
diff --git
a/ui/src/app/configuration/general-configuration/general-configuration.component.ts
b/ui/src/app/configuration/general-configuration/general-configuration.component.ts
index e770dba8d2..d80da2b8e0 100644
---
a/ui/src/app/configuration/general-configuration/general-configuration.component.ts
+++
b/ui/src/app/configuration/general-configuration/general-configuration.component.ts
@@ -90,6 +90,7 @@ export class GeneralConfigurationComponent implements OnInit {
allowPasswordRecovery: false,
defaultUserRoles: [UserRole.ROLE_PIPELINE_USER],
appName: this.appConstants.APP_NAME,
+ linkSettings: undefined,
};
}
this.mailConfig = configs[1];
@@ -141,6 +142,44 @@ export class GeneralConfigurationComponent implements
OnInit {
Validators.required,
),
);
+
+ this.parentForm.addControl(
+ 'documentationUrl',
+ new UntypedFormControl(
+ this.generalConfig.linkSettings.documentationUrl,
+ ),
+ );
+ this.parentForm.addControl(
+ 'showDocumentationLinkOnStartScreen',
+ new UntypedFormControl(
+
this.generalConfig.linkSettings.showDocumentationLinkOnStartScreen,
+ ),
+ );
+ this.parentForm.addControl(
+ 'showDocumentationLinkInProfileMenu',
+ new UntypedFormControl(
+
this.generalConfig.linkSettings.showDocumentationLinkInProfileMenu,
+ ),
+ );
+ this.parentForm.addControl(
+ 'supportUrl',
+ new UntypedFormControl(
+ this.generalConfig.linkSettings.supportUrl,
+ ),
+ );
+ this.parentForm.addControl(
+ 'showSupportUrlOnStartScreen',
+ new UntypedFormControl(
+
this.generalConfig.linkSettings.showSupportUrlOnStartScreen,
+ ),
+ );
+ this.parentForm.addControl(
+ 'showApiDocumentationLinkOnStartScreen',
+ new UntypedFormControl(
+
this.generalConfig.linkSettings.showApiDocumentationLinkOnStartScreen,
+ ),
+ );
+
this.parentForm.valueChanges.subscribe(v => {
this.generalConfig.appName = v.appName;
this.generalConfig.protocol = v.protocol;
@@ -153,6 +192,17 @@ export class GeneralConfigurationComponent implements
OnInit {
this.generalConfig.defaultUserRoles = v.defaultUserRoles.map(
r => UserRole[r],
);
+ this.generalConfig.linkSettings.documentationUrl =
+ v.documentationUrl;
+ this.generalConfig.linkSettings.supportUrl = v.supportUrl;
+
this.generalConfig.linkSettings.showApiDocumentationLinkOnStartScreen =
+ v.showApiDocumentationLinkOnStartScreen;
+ this.generalConfig.linkSettings.showSupportUrlOnStartScreen =
+ v.showSupportUrlOnStartScreen;
+
this.generalConfig.linkSettings.showDocumentationLinkInProfileMenu =
+ v.showDocumentationLinkInProfileMenu;
+
this.generalConfig.linkSettings.showDocumentationLinkOnStartScreen =
+ v.showDocumentationLinkOnStartScreen;
});
this.formReady = true;
diff --git
a/ui/src/app/configuration/general-configuration/link-settings/link-settings.component.html
b/ui/src/app/configuration/general-configuration/link-settings/link-settings.component.html
new file mode 100644
index 0000000000..673315bf9b
--- /dev/null
+++
b/ui/src/app/configuration/general-configuration/link-settings/link-settings.component.html
@@ -0,0 +1,49 @@
+<!--
+ ~ 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.
+ ~
+ -->
+
+<sp-split-section
+ title="Links"
+ subtitle="Configure application links"
+ [formGroup]="parentForm"
+>
+ <div class="subsection-title">Documentation Link</div>
+ <mat-form-field color="accent" class="ml-10">
+ <mat-label>Documentation URL</mat-label>
+ <input formControlName="documentationUrl" fxFlex matInput />
+ </mat-form-field>
+ <mat-checkbox formControlName="showDocumentationLinkOnStartScreen"
+ >Show documentation link on login page
+ </mat-checkbox>
+ <mat-checkbox formControlName="showDocumentationLinkInProfileMenu"
+ >Show documentation link in user menu
+ </mat-checkbox>
+
+ <div class="subsection-title mt-10">API Documentation Link</div>
+ <mat-checkbox formControlName="showApiDocumentationLinkOnStartScreen"
+ >Show API documentation link on login page
+ </mat-checkbox>
+
+ <div class="subsection-title mt-10">Support Link</div>
+ <mat-form-field color="accent" class="ml-10">
+ <mat-label>Support URL</mat-label>
+ <input formControlName="supportUrl" fxFlex matInput />
+ </mat-form-field>
+ <mat-checkbox formControlName="showSupportUrlOnStartScreen"
+ >Show support link on login page
+ </mat-checkbox>
+</sp-split-section>
diff --git
a/ui/projects/streampipes/platform-services/src/lib/model/config/general-config.model.ts
b/ui/src/app/configuration/general-configuration/link-settings/link-settings.component.ts
similarity index 72%
copy from
ui/projects/streampipes/platform-services/src/lib/model/config/general-config.model.ts
copy to
ui/src/app/configuration/general-configuration/link-settings/link-settings.component.ts
index bf1f9fc93c..e8ac67246d 100644
---
a/ui/projects/streampipes/platform-services/src/lib/model/config/general-config.model.ts
+++
b/ui/src/app/configuration/general-configuration/link-settings/link-settings.component.ts
@@ -16,13 +16,14 @@
*
*/
-export interface GeneralConfigModel {
- hostname: string;
- port: number;
- protocol: 'http' | 'https';
- configured: boolean;
- allowPasswordRecovery: boolean;
- allowSelfRegistration: boolean;
- defaultUserRoles: string[];
- appName: string;
+import { Component, Input } from '@angular/core';
+import { FormGroup } from '@angular/forms';
+
+@Component({
+ selector: 'sp-configuration-link-settings',
+ templateUrl: './link-settings.component.html',
+})
+export class SpConfigurationLinkSettingsComponent {
+ @Input()
+ parentForm: FormGroup;
}
diff --git a/ui/src/app/core/components/toolbar/toolbar.component.html
b/ui/src/app/core/components/toolbar/toolbar.component.html
index aee0ff8ef3..febf2638b9 100644
--- a/ui/src/app/core/components/toolbar/toolbar.component.html
+++ b/ui/src/app/core/components/toolbar/toolbar.component.html
@@ -149,6 +149,7 @@
Info
</button>
<button
+ *ngIf="documentationLinkActive"
mat-menu-item
(click)="openDocumentation()"
style="min-width: 0px"
diff --git a/ui/src/app/core/components/toolbar/toolbar.component.ts
b/ui/src/app/core/components/toolbar/toolbar.component.ts
index fb74374423..d8e2a0cba3 100644
--- a/ui/src/app/core/components/toolbar/toolbar.component.ts
+++ b/ui/src/app/core/components/toolbar/toolbar.component.ts
@@ -30,6 +30,7 @@ import { Subscription, timer } from 'rxjs';
import { exhaustMap } from 'rxjs/operators';
import { NotificationCountService } from
'../../../services/notification-count-service';
import { CurrentUserService } from '@streampipes/shared-ui';
+import { LoginService } from '../../../login/services/login.service';
@Component({
selector: 'sp-toolbar',
@@ -51,9 +52,13 @@ export class ToolbarComponent
unreadNotificationCount = 0;
unreadNotificationsSubscription: Subscription;
+ documentationLinkActive = false;
+ documentationLink = '';
+
constructor(
router: Router,
authService: AuthService,
+ private loginService: LoginService,
private profileService: ProfileService,
private restApi: RestApi,
private overlay: OverlayContainer,
@@ -93,6 +98,11 @@ export class ToolbarComponent
this.modifyAppearance(userInfo.darkMode);
});
});
+ this.loginService.fetchLoginSettings().subscribe(res => {
+ this.documentationLinkActive =
+ res.linkSettings?.showDocumentationLinkInProfileMenu;
+ this.documentationLink = res.linkSettings?.documentationUrl || '';
+ });
this.appearanceControl = new UntypedFormControl(
this.currentUserService.darkMode$.getValue(),
@@ -115,7 +125,7 @@ export class ToolbarComponent
}
openDocumentation() {
- window.open('https://streampipes.apache.org/docs', '_blank');
+ window.open(this.documentationLink, '_blank');
}
openInfo() {
diff --git
a/ui/src/app/login/components/activate-account/activate-account.component.html
b/ui/src/app/login/components/activate-account/activate-account.component.html
index b9d61e8959..0a0975d9b8 100644
---
a/ui/src/app/login/components/activate-account/activate-account.component.html
+++
b/ui/src/app/login/components/activate-account/activate-account.component.html
@@ -16,7 +16,7 @@
~
-->
-<sp-auth-box>
+<sp-auth-box [linkSettings]="loginSettings.linkSettings" *ngIf="configReady">
<div fxFlex="100" fxLayout="column" fxLayoutAlign="center start">
<h1>Account activation</h1>
</div>
diff --git
a/ui/src/app/login/components/activate-account/activate-account.component.ts
b/ui/src/app/login/components/activate-account/activate-account.component.ts
index 8bc81272f7..f7eb1ac92c 100644
--- a/ui/src/app/login/components/activate-account/activate-account.component.ts
+++ b/ui/src/app/login/components/activate-account/activate-account.component.ts
@@ -16,16 +16,18 @@
*
*/
-import { Component, OnInit } from '@angular/core';
+import { Component } from '@angular/core';
import { AccountActivationService } from
'../../services/account-activation.service';
import { ActivatedRoute, Router } from '@angular/router';
+import { BaseLoginPageDirective } from '../base-login-page.directive';
+import { LoginService } from '../../services/login.service';
@Component({
selector: 'sp-activate-account',
templateUrl: './activate-account.component.html',
styleUrls: ['../login/login.component.scss'],
})
-export class ActivateAccountComponent implements OnInit {
+export class ActivateAccountComponent extends BaseLoginPageDirective {
activationCode: string;
activationSuccess: boolean;
activationPerformed = false;
@@ -34,9 +36,16 @@ export class ActivateAccountComponent implements OnInit {
private accountActivationService: AccountActivationService,
private route: ActivatedRoute,
private router: Router,
- ) {}
+ protected loginService: LoginService,
+ ) {
+ super(loginService);
+ }
+
+ navigateToLoginPage() {
+ this.router.navigate(['/login']);
+ }
- ngOnInit(): void {
+ onSettingsAvailable(): void {
this.route.queryParams.subscribe(params => {
this.activationCode = params['activationCode'];
if (this.activationCode) {
@@ -56,8 +65,4 @@ export class ActivateAccountComponent implements OnInit {
}
});
}
-
- navigateToLoginPage() {
- this.router.navigate(['/login']);
- }
}
diff --git a/ui/src/app/login/components/auth-box/auth-box.component.html
b/ui/src/app/login/components/auth-box/auth-box.component.html
index d3d29b4add..3f300d2209 100644
--- a/ui/src/app/login/components/auth-box/auth-box.component.html
+++ b/ui/src/app/login/components/auth-box/auth-box.component.html
@@ -44,19 +44,39 @@
</div>
<div fxLayout="row" fxLayoutAlign="end end"
class="auth-box-footer">
<a
+ *ngIf="linkSettings.showDocumentationLinkOnStartScreen"
class="footer-link"
-
href="https://streampipes.apache.org/docs/user-guide-introduction"
+ [href]="linkSettings.documentationUrl"
>
Documentation
</a>
- <span style="margin-left: 10px; margin-right: 10px"> | </span>
+ <span
+ style="margin-left: 10px; margin-right: 10px"
+ *ngIf="linkSettings.showApiDocumentationLinkOnStartScreen"
+ >
+ |
+ </span>
<a
+ *ngIf="linkSettings.showApiDocumentationLinkOnStartScreen"
class="footer-link"
data-cy="view-api-docs-link"
routerLink="/apidocs"
routerLinkActive="active"
>API Documentation</a
>
+ <span
+ style="margin-left: 10px; margin-right: 10px"
+ *ngIf="linkSettings.showSupportUrlOnStartScreen"
+ >
+ |
+ </span>
+ <a
+ *ngIf="linkSettings.showSupportUrlOnStartScreen"
+ class="footer-link"
+ [href]="linkSettings.supportUrl"
+ >
+ Support
+ </a>
</div>
</div>
</div>
diff --git a/ui/src/app/login/components/auth-box/auth-box.component.ts
b/ui/src/app/login/components/auth-box/auth-box.component.ts
index cae0835d61..5996c400d9 100644
--- a/ui/src/app/login/components/auth-box/auth-box.component.ts
+++ b/ui/src/app/login/components/auth-box/auth-box.component.ts
@@ -16,8 +16,9 @@
*
*/
-import { Component } from '@angular/core';
+import { Component, Input } from '@angular/core';
import { AppConstants } from '../../../services/app.constants';
+import { LinkSettings } from '@streampipes/platform-services';
@Component({
selector: 'sp-auth-box',
@@ -25,5 +26,8 @@ import { AppConstants } from
'../../../services/app.constants';
styleUrls: ['./auth-box.component.scss'],
})
export class AuthBoxComponent {
+ @Input()
+ linkSettings: LinkSettings;
+
constructor(public appConstants: AppConstants) {}
}
diff --git a/ui/src/app/login/components/auth-box/auth-box.component.ts
b/ui/src/app/login/components/base-login-page.directive.ts
similarity index 55%
copy from ui/src/app/login/components/auth-box/auth-box.component.ts
copy to ui/src/app/login/components/base-login-page.directive.ts
index cae0835d61..c572a18e5e 100644
--- a/ui/src/app/login/components/auth-box/auth-box.component.ts
+++ b/ui/src/app/login/components/base-login-page.directive.ts
@@ -16,14 +16,24 @@
*
*/
-import { Component } from '@angular/core';
-import { AppConstants } from '../../../services/app.constants';
+import { Directive, OnInit } from '@angular/core';
+import { LoginService } from '../services/login.service';
+import { LoginModel } from './login/login.model';
-@Component({
- selector: 'sp-auth-box',
- templateUrl: './auth-box.component.html',
- styleUrls: ['./auth-box.component.scss'],
-})
-export class AuthBoxComponent {
- constructor(public appConstants: AppConstants) {}
+@Directive()
+export abstract class BaseLoginPageDirective implements OnInit {
+ protected loginSettings: LoginModel;
+ protected configReady = false;
+
+ protected constructor(protected loginService: LoginService) {}
+
+ ngOnInit(): void {
+ this.loginService.fetchLoginSettings().subscribe(result => {
+ this.loginSettings = result;
+ this.configReady = true;
+ this.onSettingsAvailable();
+ });
+ }
+
+ abstract onSettingsAvailable(): void;
}
diff --git a/ui/src/app/login/components/login/login.component.html
b/ui/src/app/login/components/login/login.component.html
index 97a1e8937a..5cd150ce02 100644
--- a/ui/src/app/login/components/login/login.component.html
+++ b/ui/src/app/login/components/login/login.component.html
@@ -16,17 +16,12 @@
~
-->
-<sp-auth-box>
+<sp-auth-box [linkSettings]="loginSettings.linkSettings" *ngIf="configReady">
<div fxFlex="100" fxLayout="column" fxLayoutAlign="center start">
<h1>Login</h1>
</div>
<div fxFlex="100" fxLayout="column" class="mt-10">
- <form
- [formGroup]="parentForm"
- fxFlex="100"
- fxLayout="column"
- *ngIf="configReady"
- >
+ <form [formGroup]="parentForm" fxFlex="100" fxLayout="column">
<div fxFlex="100" fxLayout="column">
<mat-form-field fxFlex color="accent">
<mat-label>Email</mat-label>
diff --git a/ui/src/app/login/components/login/login.component.ts
b/ui/src/app/login/components/login/login.component.ts
index 17f2364b13..af50a53337 100644
--- a/ui/src/app/login/components/login/login.component.ts
+++ b/ui/src/app/login/components/login/login.component.ts
@@ -16,69 +16,44 @@
*
*/
-import { ShepherdService } from '../../../services/tour/shepherd.service';
-import { Component, OnInit } from '@angular/core';
+import { Component } from '@angular/core';
import { LoginService } from '../../services/login.service';
import { ActivatedRoute, Router } from '@angular/router';
import { AuthService } from '../../../services/auth.service';
-import { LoginModel } from './login.model';
import {
UntypedFormBuilder,
UntypedFormControl,
UntypedFormGroup,
Validators,
} from '@angular/forms';
+import { BaseLoginPageDirective } from '../base-login-page.directive';
@Component({
selector: 'sp-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.scss'],
})
-export class LoginComponent implements OnInit {
+export class LoginComponent extends BaseLoginPageDirective {
parentForm: UntypedFormGroup;
- configReady = false;
loading: boolean;
authenticationFailed: boolean;
credentials: any;
- loginSettings: LoginModel;
returnUrl: string;
constructor(
- private loginService: LoginService,
+ loginService: LoginService,
private router: Router,
private route: ActivatedRoute,
- private shepherdService: ShepherdService,
private authService: AuthService,
private fb: UntypedFormBuilder,
) {
+ super(loginService);
this.loading = false;
this.authenticationFailed = false;
this.credentials = {};
}
- ngOnInit() {
- this.loginService.fetchLoginSettings().subscribe(result => {
- this.loginSettings = result;
- this.configReady = true;
- this.parentForm = this.fb.group({});
- this.parentForm.addControl(
- 'username',
- new UntypedFormControl('', Validators.required),
- );
- this.parentForm.addControl(
- 'password',
- new UntypedFormControl('', Validators.required),
- );
-
- this.parentForm.valueChanges.subscribe(v => {
- this.credentials.username = v.username;
- this.credentials.password = v.password;
- });
- this.returnUrl = this.route.snapshot.queryParams.returnUrl || '';
- });
- }
-
logIn() {
this.authenticationFailed = false;
this.loading = true;
@@ -96,4 +71,22 @@ export class LoginComponent implements OnInit {
},
);
}
+
+ onSettingsAvailable(): void {
+ this.parentForm = this.fb.group({});
+ this.parentForm.addControl(
+ 'username',
+ new UntypedFormControl('', Validators.required),
+ );
+ this.parentForm.addControl(
+ 'password',
+ new UntypedFormControl('', Validators.required),
+ );
+
+ this.parentForm.valueChanges.subscribe(v => {
+ this.credentials.username = v.username;
+ this.credentials.password = v.password;
+ });
+ this.returnUrl = this.route.snapshot.queryParams.returnUrl || '';
+ }
}
diff --git a/ui/src/app/login/components/login/login.model.ts
b/ui/src/app/login/components/login/login.model.ts
index 15e2b3b6c4..fc28a3a4fc 100644
--- a/ui/src/app/login/components/login/login.model.ts
+++ b/ui/src/app/login/components/login/login.model.ts
@@ -16,7 +16,10 @@
*
*/
+import { LinkSettings } from '@streampipes/platform-services';
+
export interface LoginModel {
allowSelfRegistration: boolean;
allowPasswordRecovery: boolean;
+ linkSettings: LinkSettings;
}
diff --git a/ui/src/app/login/components/register/register.component.html
b/ui/src/app/login/components/register/register.component.html
index 3a5f40d23a..c4cbac9b3c 100644
--- a/ui/src/app/login/components/register/register.component.html
+++ b/ui/src/app/login/components/register/register.component.html
@@ -16,7 +16,7 @@
~
-->
-<sp-auth-box>
+<sp-auth-box [linkSettings]="loginSettings.linkSettings" *ngIf="configReady">
<div fxFlex="100" fxLayout="column" fxLayoutAlign="center start">
<h1>Register</h1>
</div>
diff --git a/ui/src/app/login/components/register/register.component.ts
b/ui/src/app/login/components/register/register.component.ts
index 6be4c59838..8a210d3939 100644
--- a/ui/src/app/login/components/register/register.component.ts
+++ b/ui/src/app/login/components/register/register.component.ts
@@ -16,7 +16,7 @@
*
*/
-import { Component, OnInit } from '@angular/core';
+import { Component } from '@angular/core';
import {
UntypedFormBuilder,
UntypedFormControl,
@@ -26,13 +26,14 @@ import {
import { RegistrationModel } from './registration.model';
import { LoginService } from '../../services/login.service';
import { checkPasswords } from '../../utils/check-password';
+import { BaseLoginPageDirective } from '../base-login-page.directive';
@Component({
selector: 'sp-register-user',
templateUrl: './register.component.html',
styleUrls: ['../login/login.component.scss'],
})
-export class RegisterComponent implements OnInit {
+export class RegisterComponent extends BaseLoginPageDirective {
parentForm: UntypedFormGroup;
registrationData: RegistrationModel;
@@ -43,10 +44,28 @@ export class RegisterComponent implements OnInit {
constructor(
private fb: UntypedFormBuilder,
- private loginService: LoginService,
- ) {}
+ loginService: LoginService,
+ ) {
+ super(loginService);
+ }
+
+ registerUser() {
+ this.registrationError = undefined;
+ this.registrationInProcess = true;
+ this.loginService.registerUser(this.registrationData).subscribe(
+ response => {
+ this.registrationInProcess = false;
+ this.registrationSuccess = true;
+ },
+ error => {
+ this.registrationInProcess = false;
+ this.registrationSuccess = false;
+ this.registrationError = error.error.notifications[0].title;
+ },
+ );
+ }
- ngOnInit(): void {
+ onSettingsAvailable(): void {
this.parentForm = this.fb.group({});
this.parentForm.addControl(
'username',
@@ -69,20 +88,4 @@ export class RegisterComponent implements OnInit {
};
});
}
-
- registerUser() {
- this.registrationError = undefined;
- this.registrationInProcess = true;
- this.loginService.registerUser(this.registrationData).subscribe(
- response => {
- this.registrationInProcess = false;
- this.registrationSuccess = true;
- },
- error => {
- this.registrationInProcess = false;
- this.registrationSuccess = false;
- this.registrationError = error.error.notifications[0].title;
- },
- );
- }
}
diff --git
a/ui/src/app/login/components/restore-password/restore-password.component.html
b/ui/src/app/login/components/restore-password/restore-password.component.html
index 5d3cf40e55..a73d778d6b 100644
---
a/ui/src/app/login/components/restore-password/restore-password.component.html
+++
b/ui/src/app/login/components/restore-password/restore-password.component.html
@@ -16,7 +16,7 @@
~
-->
-<sp-auth-box>
+<sp-auth-box [linkSettings]="loginSettings.linkSettings" *ngIf="configReady">
<div fxFlex="100" fxLayout="column" fxLayoutAlign="center start">
<h1>Restore password</h1>
<h5>
diff --git
a/ui/src/app/login/components/restore-password/restore-password.component.ts
b/ui/src/app/login/components/restore-password/restore-password.component.ts
index 53d2dbe764..d0fd1a0404 100644
--- a/ui/src/app/login/components/restore-password/restore-password.component.ts
+++ b/ui/src/app/login/components/restore-password/restore-password.component.ts
@@ -16,7 +16,7 @@
*
*/
-import { Component, OnInit } from '@angular/core';
+import { Component } from '@angular/core';
import {
UntypedFormBuilder,
UntypedFormControl,
@@ -24,13 +24,14 @@ import {
Validators,
} from '@angular/forms';
import { LoginService } from '../../services/login.service';
+import { BaseLoginPageDirective } from '../base-login-page.directive';
@Component({
selector: 'sp-restore-password',
templateUrl: './restore-password.component.html',
styleUrls: ['../login/login.component.scss'],
})
-export class RestorePasswordComponent implements OnInit {
+export class RestorePasswordComponent extends BaseLoginPageDirective {
parentForm: UntypedFormGroup;
restoreSuccess = false;
restoreCompleted = false;
@@ -39,19 +40,9 @@ export class RestorePasswordComponent implements OnInit {
constructor(
private fb: UntypedFormBuilder,
- private loginService: LoginService,
- ) {}
-
- ngOnInit(): void {
- this.parentForm = this.fb.group({});
- this.parentForm.addControl(
- 'username',
- new UntypedFormControl('', Validators.required),
- );
-
- this.parentForm.valueChanges.subscribe(result => {
- this.username = result.username;
- });
+ protected loginService: LoginService,
+ ) {
+ super(loginService);
}
sendRestorePasswordLink() {
@@ -67,4 +58,16 @@ export class RestorePasswordComponent implements OnInit {
},
);
}
+
+ onSettingsAvailable(): void {
+ this.parentForm = this.fb.group({});
+ this.parentForm.addControl(
+ 'username',
+ new UntypedFormControl('', Validators.required),
+ );
+
+ this.parentForm.valueChanges.subscribe(result => {
+ this.username = result.username;
+ });
+ }
}
diff --git
a/ui/src/app/login/components/set-new-password/set-new-password.component.html
b/ui/src/app/login/components/set-new-password/set-new-password.component.html
index 425f109784..3e35bbd317 100644
---
a/ui/src/app/login/components/set-new-password/set-new-password.component.html
+++
b/ui/src/app/login/components/set-new-password/set-new-password.component.html
@@ -16,7 +16,7 @@
~
-->
-<sp-auth-box>
+<sp-auth-box [linkSettings]="loginSettings.linkSettings" *ngIf="configReady">
<div fxFlex="100" fxLayout="column" fxLayoutAlign="center start">
<h1>Set new password</h1>
</div>
diff --git
a/ui/src/app/login/components/set-new-password/set-new-password.component.ts
b/ui/src/app/login/components/set-new-password/set-new-password.component.ts
index 65d7eb15f4..8bce1b4de8 100644
--- a/ui/src/app/login/components/set-new-password/set-new-password.component.ts
+++ b/ui/src/app/login/components/set-new-password/set-new-password.component.ts
@@ -16,7 +16,7 @@
*
*/
-import { Component, OnInit } from '@angular/core';
+import { Component } from '@angular/core';
import { RestorePasswordService } from
'../../services/restore-password.service';
import {
UntypedFormBuilder,
@@ -27,13 +27,15 @@ import {
import { checkPasswords } from '../../utils/check-password';
import { RegistrationModel } from '../register/registration.model';
import { ActivatedRoute, Router } from '@angular/router';
+import { BaseLoginPageDirective } from '../base-login-page.directive';
+import { LoginService } from '../../services/login.service';
@Component({
selector: 'sp-set-new-password',
templateUrl: './set-new-password.component.html',
styleUrls: ['../login/login.component.scss'],
})
-export class SetNewPasswordComponent implements OnInit {
+export class SetNewPasswordComponent extends BaseLoginPageDirective {
parentForm: UntypedFormGroup;
registrationModel: RegistrationModel;
recoveryCode: string;
@@ -47,9 +49,12 @@ export class SetNewPasswordComponent implements OnInit {
private restorePasswordService: RestorePasswordService,
private route: ActivatedRoute,
private router: Router,
- ) {}
+ protected loginService: LoginService,
+ ) {
+ super(loginService);
+ }
- ngOnInit(): void {
+ onSettingsAvailable(): void {
this.route.queryParams.subscribe(params => {
this.recoveryCode = params['recoveryCode'];
if (this.recoveryCode) {
diff --git a/ui/src/app/login/services/login.service.ts
b/ui/src/app/login/services/login.service.ts
index fe8ed8a7cb..7c2e12ba10 100644
--- a/ui/src/app/login/services/login.service.ts
+++ b/ui/src/app/login/services/login.service.ts
@@ -16,7 +16,7 @@
*
*/
-import { Injectable, OnInit } from '@angular/core';
+import { Injectable } from '@angular/core';
import { HttpClient, HttpContext } from '@angular/common/http';
import { PlatformServicesCommons } from '@streampipes/platform-services';
import { Observable } from 'rxjs';