From 2ebca4bb031e0feb89cd59ac2ae9b19d2c7ac88a Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Wed, 2 Aug 2017 15:35:23 +0300 Subject: [PATCH] feat: add hide-loading option closes #315 --- README.md | 1 + lib/components/Redoc/redoc.ts | 6 ++++++ lib/services/options.service.ts | 5 ++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f10f44c5ae..469c6a234b 100644 --- a/README.md +++ b/README.md @@ -146,6 +146,7 @@ ReDoc makes use of the following [vendor extensions](http://swagger.io/specifica * `required-props-first` - show required properties first ordered in the same order as in `required` array. * `no-auto-auth` - do not inject Authentication section automatically * `path-in-middle-panel` - show path link and HTTP verb in the middle panel instead of the right one +* `hide-loading` - do not show loading animation. Useful for small docs ## Advanced usage Instead of adding `spec-url` attribute to the `` element you can initialize ReDoc via globally exposed `Redoc` object: diff --git a/lib/components/Redoc/redoc.ts b/lib/components/Redoc/redoc.ts index 600a2a8583..266772187b 100644 --- a/lib/components/Redoc/redoc.ts +++ b/lib/components/Redoc/redoc.ts @@ -89,6 +89,9 @@ export class Redoc extends BaseComponent implements OnInit { } hideLoadingAnimation() { + if (this.options.hideLoading) { + return + } requestAnimationFrame(() => { this.specLoadingRemove = true; setTimeout(() => { @@ -99,6 +102,9 @@ export class Redoc extends BaseComponent implements OnInit { } showLoadingAnimation() { + if (this.options.hideLoading) { + return + } this.specLoading = true; this.specLoadingRemove = false; } diff --git a/lib/services/options.service.ts b/lib/services/options.service.ts index c2972ec201..c046e01e89 100644 --- a/lib/services/options.service.ts +++ b/lib/services/options.service.ts @@ -19,7 +19,8 @@ const OPTION_NAMES = new Set([ 'requiredPropsFirst', 'noAutoAuth', 'pathInMiddlePanel', - 'untrustedSpec' + 'untrustedSpec', + 'hideLoading' ]); export interface Options { @@ -35,6 +36,7 @@ export interface Options { noAutoAuth?: boolean; pathInMiddlePanel?: boolean; untrustedSpec?: boolean; + hideLoading?: boolean; spec?: any; } @@ -104,6 +106,7 @@ export class OptionsService { if (isString(this._options.noAutoAuth)) this._options.noAutoAuth = true; if (isString(this._options.pathInMiddlePanel)) this._options.pathInMiddlePanel = true; if (isString(this._options.untrustedSpec)) this._options.untrustedSpec = true; + if (isString(this._options.hideLoading)) this._options.hideLoading = true; if (isString(this._options.expandResponses)) { let str = this._options.expandResponses as string; if (str === 'all') return;