You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dlab.apache.org by an...@apache.org on 2019/12/19 10:06:09 UTC
[incubator-dlab] 02/02: [DLAB-1239]: Swagger UI integration in DLab
added
This is an automated email from the ASF dual-hosted git repository.
ankovalyshyn pushed a commit to branch DLAB-1239
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git
commit 04e193dd0f8d8bfcbf633b426d3e2466ac584b93
Author: Andriana Kovalyshyn <An...@epam.com>
AuthorDate: Thu Dec 19 12:06:54 2019 +0200
[DLAB-1239]: Swagger UI integration in DLab added
---
.../main/resources/webapp/src/app/app.module.ts | 3 +-
.../resources/webapp/src/app/app.routing.module.ts | 5 ++++
.../src/app/core/directives/scrollTo.directive.ts | 2 +-
.../webapp/src/app/swagger/swagger.component.html | 20 +++++++++++++
.../swagger.component.scss} | 20 +------------
.../swagger.component.ts} | 35 ++++++++++++++--------
6 files changed, 51 insertions(+), 34 deletions(-)
diff --git a/services/self-service/src/main/resources/webapp/src/app/app.module.ts b/services/self-service/src/main/resources/webapp/src/app/app.module.ts
index 680ae7c..aaa125e 100644
--- a/services/self-service/src/main/resources/webapp/src/app/app.module.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/app.module.ts
@@ -40,9 +40,10 @@ import { ReportingModule } from './reporting/reporting.module';
import { AdministrationModule } from './administration/administration.module';
import { WebterminalModule } from './webterminal';
import { CoreModule } from './core/core.module';
+import { SwaggerComponent } from './swagger/swagger.component';
@NgModule({
- declarations: [AppComponent],
+ declarations: [AppComponent, SwaggerComponent],
imports: [
BrowserModule,
BrowserAnimationsModule,
diff --git a/services/self-service/src/main/resources/webapp/src/app/app.routing.module.ts b/services/self-service/src/main/resources/webapp/src/app/app.routing.module.ts
index 0473332..3c8ae3f 100644
--- a/services/self-service/src/main/resources/webapp/src/app/app.routing.module.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/app.routing.module.ts
@@ -31,6 +31,7 @@ import { WebterminalComponent } from './webterminal/webterminal.component';
import { ManagementComponent } from './administration/management/management.component';
import { ProjectComponent } from './administration/project/project.component';
import { RolesComponent } from './administration/roles/roles.component';
+import { SwaggerComponent } from './swagger/swagger.component';
import { AuthorizationGuard, CheckParamsGuard, CloudProviderGuard, AdminGuard } from './core/services';
@@ -67,6 +68,10 @@ const routes: Routes = [{
component: ManagementComponent,
canActivate: [AuthorizationGuard, AdminGuard]
}, {
+ path: 'swagger',
+ component: SwaggerComponent,
+ canActivate: [AuthorizationGuard]
+ }, {
path: 'help/publickeyguide',
component: PublicKeyGuideComponent,
canActivate: [AuthorizationGuard]
diff --git a/services/self-service/src/main/resources/webapp/src/app/core/directives/scrollTo.directive.ts b/services/self-service/src/main/resources/webapp/src/app/core/directives/scrollTo.directive.ts
index 08560b2..fb6e0c3 100644
--- a/services/self-service/src/main/resources/webapp/src/app/core/directives/scrollTo.directive.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/core/directives/scrollTo.directive.ts
@@ -24,7 +24,7 @@ import { Directive } from '@angular/core';
selector: '[scrollTo]'
})
export class ScrollDirective {
- constructor(private elRef: ElementRef) {}
+ constructor(private elRef: ElementRef) { }
@Input()
set scrollTo(condition) {
diff --git a/services/self-service/src/main/resources/webapp/src/app/swagger/swagger.component.html b/services/self-service/src/main/resources/webapp/src/app/swagger/swagger.component.html
new file mode 100644
index 0000000..467bfb5
--- /dev/null
+++ b/services/self-service/src/main/resources/webapp/src/app/swagger/swagger.component.html
@@ -0,0 +1,20 @@
+<!--
+ ~ 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.
+ -->
+
+<div id="swagger-ui"></div>
diff --git a/services/self-service/src/main/resources/webapp/src/app/core/directives/scrollTo.directive.ts b/services/self-service/src/main/resources/webapp/src/app/swagger/swagger.component.scss
similarity index 67%
copy from services/self-service/src/main/resources/webapp/src/app/core/directives/scrollTo.directive.ts
copy to services/self-service/src/main/resources/webapp/src/app/swagger/swagger.component.scss
index 08560b2..3d56d22 100644
--- a/services/self-service/src/main/resources/webapp/src/app/core/directives/scrollTo.directive.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/swagger/swagger.component.scss
@@ -1,4 +1,4 @@
-/*
+/*!
* 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
@@ -16,21 +16,3 @@
* specific language governing permissions and limitations
* under the License.
*/
-
-import { ElementRef, HostBinding, Input } from '@angular/core';
-import { Directive } from '@angular/core';
-
-@Directive({
- selector: '[scrollTo]'
-})
-export class ScrollDirective {
- constructor(private elRef: ElementRef) {}
-
- @Input()
- set scrollTo(condition) {
- if (condition) {
- const scrollable = this.elRef.nativeElement;
- scrollable.scrollIntoView(false);
- }
- }
-}
diff --git a/services/self-service/src/main/resources/webapp/src/app/core/directives/scrollTo.directive.ts b/services/self-service/src/main/resources/webapp/src/app/swagger/swagger.component.ts
similarity index 57%
copy from services/self-service/src/main/resources/webapp/src/app/core/directives/scrollTo.directive.ts
copy to services/self-service/src/main/resources/webapp/src/app/swagger/swagger.component.ts
index 08560b2..f555000 100644
--- a/services/self-service/src/main/resources/webapp/src/app/core/directives/scrollTo.directive.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/swagger/swagger.component.ts
@@ -17,20 +17,29 @@
* under the License.
*/
-import { ElementRef, HostBinding, Input } from '@angular/core';
-import { Directive } from '@angular/core';
+import { Component, OnInit } from '@angular/core';
-@Directive({
- selector: '[scrollTo]'
+declare const SwaggerUIBundle: any;
+
+@Component({
+ selector: 'dlab-swagger',
+ templateUrl: './swagger.component.html',
+ styleUrls: ['./swagger.component.scss']
})
-export class ScrollDirective {
- constructor(private elRef: ElementRef) {}
+export class SwaggerComponent implements OnInit {
- @Input()
- set scrollTo(condition) {
- if (condition) {
- const scrollable = this.elRef.nativeElement;
- scrollable.scrollIntoView(false);
- }
+ ngOnInit(): void {
+ const ui = SwaggerUIBundle({
+ dom_id: '#swagger-ui',
+ layout: 'BaseLayout',
+ presets: [
+ SwaggerUIBundle.presets.apis,
+ SwaggerUIBundle.SwaggerUIStandalonePreset
+ ],
+ url: '../assets/endpoint-api.json',
+ docExpansion: 'none',
+ operationsSorter: 'alpha'
+ });
}
-}
+
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@dlab.apache.org
For additional commands, e-mail: commits-help@dlab.apache.org