mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-24 09:33:44 +03:00
Merge branch 'master' into releases
This commit is contained in:
commit
5d1edd0d68
|
@ -12,7 +12,7 @@ git checkout @{-1}
|
||||||
cd -
|
cd -
|
||||||
|
|
||||||
# build
|
# build
|
||||||
gulp build
|
npm run build-dist
|
||||||
cd demo
|
cd demo
|
||||||
cp -R ../dist/* ./dist/
|
cp -R ../dist/* ./dist/
|
||||||
mkdir -p releases
|
mkdir -p releases
|
||||||
|
|
|
@ -11,25 +11,29 @@ var gulp = require('gulp');
|
||||||
var sass = require('gulp-sass');
|
var sass = require('gulp-sass');
|
||||||
var replace = require('gulp-replace');
|
var replace = require('gulp-replace');
|
||||||
var rename = require('gulp-rename');
|
var rename = require('gulp-rename');
|
||||||
|
var argv = require('yargs').argv;
|
||||||
|
|
||||||
gulp.task('build', function (callback) {
|
gulp.task('build', function (callback) {
|
||||||
|
if (argv.skipRebuild) {
|
||||||
|
console.log('>>> Rebuild skipped')
|
||||||
|
return callback();
|
||||||
|
}
|
||||||
return runSequence(
|
return runSequence(
|
||||||
'clean',
|
'clean',
|
||||||
'bundleProd',
|
'concatPrism',
|
||||||
callback
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('buildDev', function (callback) {
|
|
||||||
return runSequence(
|
|
||||||
'clean',
|
|
||||||
'bundle',
|
'bundle',
|
||||||
|
'concatDeps',
|
||||||
callback
|
callback
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('bundle', ['concatPrism', 'buildStatic', 'concatDeps']);
|
gulp.task('rebuild', function(done) {
|
||||||
gulp.task('bundleProd', ['bundle', 'buildStaticMin', 'concatDepsMin']);
|
return runSequence(
|
||||||
|
'bundle',
|
||||||
|
'concatDeps',
|
||||||
|
callback
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
gulp.task('inlineTemplates', ['sass'], function() {
|
gulp.task('inlineTemplates', ['sass'], function() {
|
||||||
return gulp.src(paths.source, { base: './' })
|
return gulp.src(paths.source, { base: './' })
|
||||||
|
@ -38,20 +42,20 @@ gulp.task('inlineTemplates', ['sass'], function() {
|
||||||
.pipe(gulp.dest(paths.tmp));
|
.pipe(gulp.dest(paths.tmp));
|
||||||
});
|
});
|
||||||
|
|
||||||
var JS_DEV_DEPS = [
|
var JS_DEPS = argv.prod ? [
|
||||||
'lib/utils/browser-update.js',
|
'lib/utils/browser-update.js',
|
||||||
'node_modules/zone.js/dist/zone.js',
|
'node_modules/zone.js/dist/zone.js',
|
||||||
'node_modules/zone.js/dist/long-stack-trace-zone.js',
|
'node_modules/zone.js/dist/long-stack-trace-zone.js',
|
||||||
'node_modules/reflect-metadata/Reflect.js',
|
'node_modules/reflect-metadata/Reflect.js',
|
||||||
'node_modules/babel-polyfill/dist/polyfill.js'
|
'node_modules/babel-polyfill/dist/polyfill.js'
|
||||||
];
|
] : [
|
||||||
|
|
||||||
var JS_DEV_DEPS_MIN = [
|
|
||||||
'lib/utils/browser-update.js',
|
'lib/utils/browser-update.js',
|
||||||
'node_modules/zone.js/dist/zone.min.js',
|
'node_modules/zone.js/dist/zone.min.js',
|
||||||
'node_modules/reflect-metadata/Reflect.js',
|
'node_modules/reflect-metadata/Reflect.js',
|
||||||
'node_modules/babel-polyfill/dist/polyfill.min.js'
|
'node_modules/babel-polyfill/dist/polyfill.min.js'
|
||||||
]
|
];
|
||||||
|
|
||||||
|
var outputFileName = paths.redocBuilt + (argv.prod ? '.min.js' : '.js');
|
||||||
|
|
||||||
gulp.task('sass', function () {
|
gulp.task('sass', function () {
|
||||||
return gulp.src(paths.scss, { base: './' })
|
return gulp.src(paths.scss, { base: './' })
|
||||||
|
@ -60,38 +64,22 @@ gulp.task('sass', function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
// concatenate angular2 deps
|
// concatenate angular2 deps
|
||||||
gulp.task('concatDeps', ['buildStatic'], function() {
|
gulp.task('concatDeps', function() {
|
||||||
return concatDeps(JS_DEV_DEPS, paths.redocBuilt + '.js');
|
return gulp.src(JS_DEPS.concat([outputFileName]))
|
||||||
|
.pipe(sourcemaps.init({loadMaps: true}))
|
||||||
|
.pipe(concat(outputFileName))
|
||||||
|
.pipe(sourcemaps.write('.'))
|
||||||
|
.pipe(gulp.dest('.'))
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('concatDepsMin', ['buildStatic'], function() {
|
gulp.task('bundle', ['inlineTemplates'], function bundle(cb) {
|
||||||
return concatDeps(JS_DEV_DEPS_MIN, paths.redocBuilt + '.min.js');
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('buildStatic', ['inlineTemplates'], function(cb) {
|
|
||||||
bundle(paths.redocBuilt + '.js', false, cb);
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('buildStaticMin', ['inlineTemplates'], function(cb) {
|
|
||||||
bundle(paths.redocBuilt + '.min.js', true, cb);
|
|
||||||
});
|
|
||||||
|
|
||||||
function concatDeps(deps, file) {
|
|
||||||
return gulp.src(deps.concat([file]))
|
|
||||||
.pipe(sourcemaps.init({loadMaps: true}))
|
|
||||||
.pipe(concat(file))
|
|
||||||
.pipe(sourcemaps.write('.'))
|
|
||||||
.pipe(gulp.dest('.'))
|
|
||||||
}
|
|
||||||
|
|
||||||
function bundle(outputFile, minify, cb) {
|
|
||||||
fs.existsSync('dist') || fs.mkdirSync('dist');
|
fs.existsSync('dist') || fs.mkdirSync('dist');
|
||||||
var builder = new Builder('./', 'system.config.js');
|
var builder = new Builder('./', 'system.config.js');
|
||||||
|
|
||||||
builder
|
builder
|
||||||
.buildStatic(path.join(paths.tmp, paths.sourceEntryPoint),
|
.buildStatic(path.join(paths.tmp, paths.sourceEntryPoint),
|
||||||
outputFile,
|
outputFileName,
|
||||||
{ format:'umd', sourceMaps: true, lowResSourceMaps: true, minify: minify }
|
{ format:'umd', sourceMaps: !argv.prod, lowResSourceMaps: true, minify: argv.prod }
|
||||||
)
|
)
|
||||||
.then(function() {
|
.then(function() {
|
||||||
// wait some time to allow flush
|
// wait some time to allow flush
|
||||||
|
@ -100,7 +88,7 @@ function bundle(outputFile, minify, cb) {
|
||||||
.catch(function(err) {
|
.catch(function(err) {
|
||||||
cb(new Error(err));
|
cb(new Error(err));
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
|
|
||||||
gulp.task('concatPrism', function() {
|
gulp.task('concatPrism', function() {
|
||||||
require('../../system.config.js');
|
require('../../system.config.js');
|
||||||
|
@ -129,7 +117,7 @@ gulp.task('concatPrism', function() {
|
||||||
'components/prism-scala.js'
|
'components/prism-scala.js'
|
||||||
].map(file => path.join(prismFolder, file));
|
].map(file => path.join(prismFolder, file));
|
||||||
|
|
||||||
gulp.src(prismFiles)
|
return gulp.src(prismFiles)
|
||||||
.pipe(concat(path.join(paths.tmp, 'prismjs-bundle.js')))
|
.pipe(concat(path.join(paths.tmp, 'prismjs-bundle.js')))
|
||||||
.pipe(gulp.dest('.'))
|
.pipe(gulp.dest('.'))
|
||||||
});
|
});
|
||||||
|
|
|
@ -19,7 +19,7 @@ gulp.task('test-server', function (done) {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
gulp.task('e2e', ['bundleProd', 'test-server'], function(done) {
|
gulp.task('e2e', ['build', 'test-server'], function(done) {
|
||||||
gulp.src(['tests/e2e/**/*.js'], { read:false })
|
gulp.src(['tests/e2e/**/*.js'], { read:false })
|
||||||
.pipe(gp.protractor({
|
.pipe(gp.protractor({
|
||||||
configFile: './protractor.conf.js'
|
configFile: './protractor.conf.js'
|
||||||
|
|
|
@ -6,9 +6,9 @@ function changed(event) {
|
||||||
console.log('File ' + event.path + ' was ' + event.type + ', running tasks...');
|
console.log('File ' + event.path + ' was ' + event.type + ', running tasks...');
|
||||||
}
|
}
|
||||||
|
|
||||||
gulp.task('watch', ['buildDev'], function () {
|
gulp.task('watch', ['build'], function () {
|
||||||
gulp.watch([ paths.source ], [ 'bundle', browserSync.reload ]).on('change', changed);
|
gulp.watch([ paths.source ], [ 'rebuild', browserSync.reload ]).on('change', changed);
|
||||||
gulp.watch([ paths.html ], [ 'bundle', browserSync.reload]).on('change', changed);
|
gulp.watch([ paths.html ], [ 'rebuild', browserSync.reload]).on('change', changed);
|
||||||
gulp.watch([ paths.scss ], [ 'bundle', browserSync.reload]).on('change', changed);
|
gulp.watch([ paths.scss ], [ 'rebuild', browserSync.reload]).on('change', changed);
|
||||||
gulp.watch([ paths.demo ], [ '', browserSync.reload ]).on('change', changed);
|
gulp.watch([ paths.demo ], [ '', browserSync.reload ]).on('change', changed);
|
||||||
});
|
});
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
<span class="param-range" *ngIf="prop._range"> {{prop._range}} </span>
|
<span class="param-range" *ngIf="prop._range"> {{prop._range}} </span>
|
||||||
</span>
|
</span>
|
||||||
<span *ngIf="prop.required" class="param-required">Required</span>
|
<span *ngIf="prop.required" class="param-required">Required</span>
|
||||||
|
<div *ngIf="prop.default">Default: {{prop.default | json}}</div>
|
||||||
<div *ngIf="prop.enum && !prop.isDiscriminator" class="param-enum">
|
<div *ngIf="prop.enum && !prop.isDiscriminator" class="param-enum">
|
||||||
<span *ngFor="let enumItem of prop.enum" class="enum-value {{enumItem.type}}"> {{enumItem.val | json}} </span>
|
<span *ngFor="let enumItem of prop.enum" class="enum-value {{enumItem.type}}"> {{enumItem.val | json}} </span>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -11,7 +11,8 @@ import JsonPointer from '../../utils/JsonPointer';
|
||||||
templateUrl: './lib/components/JsonSchema/json-schema.html',
|
templateUrl: './lib/components/JsonSchema/json-schema.html',
|
||||||
styleUrls: ['./lib/components/JsonSchema/json-schema.css'],
|
styleUrls: ['./lib/components/JsonSchema/json-schema.css'],
|
||||||
directives: [JsonSchema, DropDown],
|
directives: [JsonSchema, DropDown],
|
||||||
inputs: ['isArray', 'final', 'nestOdd', 'childFor', 'isRequestSchema']
|
inputs: ['isArray', 'final', 'nestOdd', 'childFor', 'isRequestSchema'],
|
||||||
|
detect: true
|
||||||
})
|
})
|
||||||
@Reflect.metadata('parameters', [[SchemaManager], [ElementRef]])
|
@Reflect.metadata('parameters', [[SchemaManager], [ElementRef]])
|
||||||
export class JsonSchema extends BaseComponent {
|
export class JsonSchema extends BaseComponent {
|
||||||
|
|
|
@ -14,7 +14,8 @@ import { RequestSamples } from '../RequestSamples/request-samples';
|
||||||
templateUrl: './lib/components/Method/method.html',
|
templateUrl: './lib/components/Method/method.html',
|
||||||
styleUrls: ['./lib/components/Method/method.css'],
|
styleUrls: ['./lib/components/Method/method.css'],
|
||||||
directives: [ ParamsList, ResponsesList, ResponsesSamples, SchemaSample, RequestSamples ],
|
directives: [ ParamsList, ResponsesList, ResponsesSamples, SchemaSample, RequestSamples ],
|
||||||
inputs: ['tag']
|
inputs: ['tag'],
|
||||||
|
detect: true
|
||||||
})
|
})
|
||||||
export class Method extends BaseComponent {
|
export class Method extends BaseComponent {
|
||||||
constructor(schemaMgr) {
|
constructor(schemaMgr) {
|
||||||
|
|
|
@ -22,6 +22,8 @@ responses-list, params-list {
|
||||||
background-color: darken($black, 2%);
|
background-color: darken($black, 2%);
|
||||||
display: block;
|
display: block;
|
||||||
font-weight: $light;
|
font-weight: $light;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow-x: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.method-endpoint > h5 {
|
.method-endpoint > h5 {
|
||||||
|
|
|
@ -10,7 +10,8 @@ import { EncodeURIComponentPipe } from '../../utils/pipes';
|
||||||
templateUrl: './lib/components/MethodsList/methods-list.html',
|
templateUrl: './lib/components/MethodsList/methods-list.html',
|
||||||
styleUrls: ['./lib/components/MethodsList/methods-list.css'],
|
styleUrls: ['./lib/components/MethodsList/methods-list.css'],
|
||||||
directives: [ forwardRef(() => Method) ],
|
directives: [ forwardRef(() => Method) ],
|
||||||
pipes: [ EncodeURIComponentPipe ]
|
pipes: [ EncodeURIComponentPipe ],
|
||||||
|
detect: true
|
||||||
})
|
})
|
||||||
export class MethodsList extends BaseComponent {
|
export class MethodsList extends BaseComponent {
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
<span class="param-type {{param.type}}" [ngClass]="{'with-hint': param._displayTypeHint}"
|
<span class="param-type {{param.type}}" [ngClass]="{'with-hint': param._displayTypeHint}"
|
||||||
title="{{param._displayTypeHint}}"> {{param._displayType}} {{param._displayFormat}}</span>
|
title="{{param._displayTypeHint}}"> {{param._displayType}} {{param._displayFormat}}</span>
|
||||||
<span *ngIf="param.required" class="param-required">Required</span>
|
<span *ngIf="param.required" class="param-required">Required</span>
|
||||||
|
<div class="default" *ngIf="param.default">Default: {{param.default | json}}</div>
|
||||||
<div *ngIf="param.enum" class="param-enum">
|
<div *ngIf="param.enum" class="param-enum">
|
||||||
<span *ngFor="let enumItem of param.enum" class="enum-value {{enumItem.type}}"> {{enumItem.val | json}} </span>
|
<span *ngFor="let enumItem of param.enum" class="enum-value {{enumItem.type}}"> {{enumItem.val | json}} </span>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -29,7 +29,9 @@ var _modeLocked = false;
|
||||||
],
|
],
|
||||||
templateUrl: './lib/components/Redoc/redoc.html',
|
templateUrl: './lib/components/Redoc/redoc.html',
|
||||||
styleUrls: ['./lib/components/Redoc/redoc.css'],
|
styleUrls: ['./lib/components/Redoc/redoc.css'],
|
||||||
directives: [ ApiInfo, ApiLogo, MethodsList, SideMenu, StickySidebar ]
|
directives: [ ApiInfo, ApiLogo, MethodsList, SideMenu, StickySidebar ],
|
||||||
|
detect: true,
|
||||||
|
onPushOnly: false
|
||||||
})
|
})
|
||||||
@Reflect.metadata('parameters', [
|
@Reflect.metadata('parameters', [
|
||||||
[SchemaManager], [OptionsService], [ElementRef], [RedocEventsService]])
|
[SchemaManager], [OptionsService], [ElementRef], [RedocEventsService]])
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<header *ngIf="data.schemaPointer || data.samples.length"> Request samples </header>
|
<header *ngIf="data.schemaPointer || data.samples.length"> Request samples </header>
|
||||||
<schema-sample *ngIf="!data.samples.length" [pointer]="data.schemaPointer"> </schema-sample>
|
<schema-sample *ngIf="!data.samples.length" [pointer]="data.schemaPointer"> </schema-sample>
|
||||||
<tabs *ngIf="data.samples.length" (change)=changeLangNotify($event)>
|
<tabs *ngIf="data.samples.length" [selected] = "selectedLang" (change)=changeLangNotify($event)>
|
||||||
<tab tabTitle="JSON">
|
<tab tabTitle="JSON">
|
||||||
<schema-sample [pointer]="data.schemaPointer"> </schema-sample>
|
<schema-sample [pointer]="data.schemaPointer"> </schema-sample>
|
||||||
</tab>
|
</tab>
|
||||||
|
|
|
@ -15,7 +15,9 @@ import { RedocEventsService } from '../../services/index';
|
||||||
styleUrls: ['./lib/components/RequestSamples/request-samples.css'],
|
styleUrls: ['./lib/components/RequestSamples/request-samples.css'],
|
||||||
directives: [SchemaSample, Tabs, Tab],
|
directives: [SchemaSample, Tabs, Tab],
|
||||||
inputs: ['schemaPointer'],
|
inputs: ['schemaPointer'],
|
||||||
pipes: [PrismPipe]
|
pipes: [PrismPipe],
|
||||||
|
detect: true,
|
||||||
|
onPushOnly: false
|
||||||
})
|
})
|
||||||
@Reflect.metadata('parameters', [[SchemaManager], [RedocEventsService], [new ViewChildren(Tabs), QueryList]])
|
@Reflect.metadata('parameters', [[SchemaManager], [RedocEventsService], [new ViewChildren(Tabs), QueryList]])
|
||||||
export class RequestSamples extends BaseComponent {
|
export class RequestSamples extends BaseComponent {
|
||||||
|
@ -25,23 +27,14 @@ export class RequestSamples extends BaseComponent {
|
||||||
this.childTabs = childQuery.first;
|
this.childTabs = childQuery.first;
|
||||||
});
|
});
|
||||||
this.events = events;
|
this.events = events;
|
||||||
|
this.selectedLang = this.events.samplesLanguageChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
init() {
|
|
||||||
this.subscribeForEvents();
|
|
||||||
}
|
|
||||||
|
|
||||||
changeLangNotify(lang) {
|
changeLangNotify(lang) {
|
||||||
this.events.samplesLanguageChanged.next(lang);
|
this.events.samplesLanguageChanged.next(lang);
|
||||||
}
|
}
|
||||||
|
|
||||||
subscribeForEvents() {
|
|
||||||
this.events.samplesLanguageChanged.subscribe((sampleLang) => {
|
|
||||||
if (!this.childTabs) return;
|
|
||||||
this.childTabs.selectyByTitle(sampleLang);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
prepareModel() {
|
prepareModel() {
|
||||||
this.data = {};
|
this.data = {};
|
||||||
this.data.schemaPointer = JsonPointer.join(this.schemaPointer, 'schema');
|
this.data.schemaPointer = JsonPointer.join(this.schemaPointer, 'schema');
|
||||||
|
|
|
@ -8,9 +8,13 @@
|
||||||
<div class="header" *ngFor="let header of response.headers">
|
<div class="header" *ngFor="let header of response.headers">
|
||||||
<div class="header-name"> {{header.name}} </div>
|
<div class="header-name"> {{header.name}} </div>
|
||||||
<div class="header-type"> {{header.type}} </div>
|
<div class="header-type"> {{header.type}} </div>
|
||||||
|
<div *ngIf="header.default" class="header-default"> Default: {{header.default}} </div>
|
||||||
<div class="header-description" innerHtml="{{header.description | marked}}"> </div>
|
<div class="header-description" innerHtml="{{header.description | marked}}"> </div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<header *ngIf="response.headers">
|
||||||
|
Response Schema
|
||||||
|
</header>
|
||||||
<json-schema *ngIf="response.schema && options.disableLazySchemas" class="schema type" pointer="{{response.pointer}}/schema">
|
<json-schema *ngIf="response.schema && options.disableLazySchemas" class="schema type" pointer="{{response.pointer}}/schema">
|
||||||
</json-schema>
|
</json-schema>
|
||||||
<json-schema-lazy #lazySchema pointer="{{response.schema ? response.pointer + '/schema' : null}}">
|
<json-schema-lazy #lazySchema pointer="{{response.schema ? response.pointer + '/schema' : null}}">
|
||||||
|
|
|
@ -16,7 +16,8 @@ function isNumeric(n) {
|
||||||
selector: 'responses-list',
|
selector: 'responses-list',
|
||||||
templateUrl: './lib/components/ResponsesList/responses-list.html',
|
templateUrl: './lib/components/ResponsesList/responses-list.html',
|
||||||
styleUrls: ['./lib/components/ResponsesList/responses-list.css'],
|
styleUrls: ['./lib/components/ResponsesList/responses-list.css'],
|
||||||
directives: [JsonSchema, Zippy, JsonSchemaLazy]
|
directives: [JsonSchema, Zippy, JsonSchemaLazy],
|
||||||
|
detect: true
|
||||||
})
|
})
|
||||||
@Reflect.metadata('parameters', [[SchemaManager], [OptionsService]])
|
@Reflect.metadata('parameters', [[SchemaManager], [OptionsService]])
|
||||||
export class ResponsesList extends BaseComponent {
|
export class ResponsesList extends BaseComponent {
|
||||||
|
|
|
@ -28,6 +28,11 @@ header {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
margin-bottom: 15px;
|
margin-bottom: 15px;
|
||||||
|
|
||||||
|
&:not(:first-child) {
|
||||||
|
margin-top: 15px;
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.header {
|
.header {
|
||||||
|
|
|
@ -11,7 +11,9 @@ import { ScrollService, Hash, MenuService, OptionsService } from '../../services
|
||||||
selector: 'side-menu',
|
selector: 'side-menu',
|
||||||
templateUrl: './lib/components/SideMenu/side-menu.html',
|
templateUrl: './lib/components/SideMenu/side-menu.html',
|
||||||
providers: [ScrollService, MenuService, Hash],
|
providers: [ScrollService, MenuService, Hash],
|
||||||
styleUrls: ['./lib/components/SideMenu/side-menu.css']
|
styleUrls: ['./lib/components/SideMenu/side-menu.css'],
|
||||||
|
detect: true,
|
||||||
|
onPushOnly: false
|
||||||
})
|
})
|
||||||
@Reflect.metadata('parameters', [[SchemaManager], [ElementRef], [BrowserDomAdapter],
|
@Reflect.metadata('parameters', [[SchemaManager], [ElementRef], [BrowserDomAdapter],
|
||||||
[ScrollService], [MenuService], [Hash], [OptionsService], [ChangeDetectorRef]])
|
[ScrollService], [MenuService], [Hash], [OptionsService], [ChangeDetectorRef]])
|
||||||
|
@ -31,10 +33,10 @@ export class SideMenu extends BaseComponent {
|
||||||
this.options = optionsService.options;
|
this.options = optionsService.options;
|
||||||
this.detectorRef = detectorRef;
|
this.detectorRef = detectorRef;
|
||||||
|
|
||||||
this.menuService.changed.subscribe((cat, item) => this.changed(cat, item));
|
this.menuService.changed.subscribe((evt) => this.changed(evt));
|
||||||
}
|
}
|
||||||
|
|
||||||
changed(cat, item) {
|
changed({cat, item}) {
|
||||||
this.activeCatCaption = cat.name || '';
|
this.activeCatCaption = cat.name || '';
|
||||||
this.activeItemCaption = item && item.summary || '';
|
this.activeItemCaption = item && item.summary || '';
|
||||||
|
|
||||||
|
@ -54,11 +56,10 @@ export class SideMenu extends BaseComponent {
|
||||||
this.$mobileNav = this.dom.querySelector(this.$element, '.mobile-nav');
|
this.$mobileNav = this.dom.querySelector(this.$element, '.mobile-nav');
|
||||||
this.$resourcesNav = this.dom.querySelector(this.$element, '#resources-nav');
|
this.$resourcesNav = this.dom.querySelector(this.$element, '#resources-nav');
|
||||||
|
|
||||||
//decorate option.scrollYOffset to account mobile nav
|
//decorate scrollYOffset to account mobile nav
|
||||||
var origOffset = this.options.scrollYOffset;
|
this.scrollService.scrollYOffset = () => {
|
||||||
this.options.scrollYOffset = () => {
|
|
||||||
let mobileNavOffset = this.$mobileNav.clientHeight;
|
let mobileNavOffset = this.$mobileNav.clientHeight;
|
||||||
return origOffset() + mobileNavOffset;
|
return this.options.scrollYOffset() + mobileNavOffset;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,12 +74,14 @@ export class SideMenu extends BaseComponent {
|
||||||
|
|
||||||
toggleMobileNav() {
|
toggleMobileNav() {
|
||||||
let dom = this.dom;
|
let dom = this.dom;
|
||||||
let $overflowParent = (this.$scrollParent === global) ? dom.defaultDoc().body : this.$scrollParent;
|
let $overflowParent = (this.options.$scrollParent === global) ? dom.defaultDoc().body
|
||||||
|
: this.$scrollParent.$scrollParent;
|
||||||
if (dom.hasStyle(this.$resourcesNav, 'height')) {
|
if (dom.hasStyle(this.$resourcesNav, 'height')) {
|
||||||
dom.removeStyle(this.$resourcesNav, 'height');
|
dom.removeStyle(this.$resourcesNav, 'height');
|
||||||
dom.removeStyle($overflowParent, 'overflow-y');
|
dom.removeStyle($overflowParent, 'overflow-y');
|
||||||
} else {
|
} else {
|
||||||
let viewportHeight = this.$scrollParent.innerHeight || this.$scrollParent.clientHeight;
|
let viewportHeight = this.options.$scrollParent.innerHeight
|
||||||
|
|| this.options.$scrollParent.clientHeight;
|
||||||
let height = viewportHeight - this.$mobileNav.getBoundingClientRect().bottom;
|
let height = viewportHeight - this.$mobileNav.getBoundingClientRect().bottom;
|
||||||
dom.setStyle($overflowParent, 'overflow-y', 'hidden');
|
dom.setStyle($overflowParent, 'overflow-y', 'hidden');
|
||||||
dom.setStyle(this.$resourcesNav, 'height', height + 'px');
|
dom.setStyle(this.$resourcesNav, 'height', height + 'px');
|
||||||
|
|
|
@ -67,6 +67,7 @@ export function RedocComponent(options) {
|
||||||
let inputs = safeConcat(options.inputs, commonInputs);
|
let inputs = safeConcat(options.inputs, commonInputs);
|
||||||
let directives = safeConcat(options.directives, CORE_DIRECTIVES);
|
let directives = safeConcat(options.directives, CORE_DIRECTIVES);
|
||||||
let pipes = safeConcat(options.pipes, [JsonPointerEscapePipe, MarkedPipe, JsonPipe, AsyncPipe]);
|
let pipes = safeConcat(options.pipes, [JsonPointerEscapePipe, MarkedPipe, JsonPipe, AsyncPipe]);
|
||||||
|
if (options.onPushOnly === undefined) options.onPushOnly = true;
|
||||||
|
|
||||||
return function decorator(target) {
|
return function decorator(target) {
|
||||||
|
|
||||||
|
@ -75,7 +76,9 @@ export function RedocComponent(options) {
|
||||||
inputs: inputs,
|
inputs: inputs,
|
||||||
outputs: options.outputs,
|
outputs: options.outputs,
|
||||||
providers: options.providers,
|
providers: options.providers,
|
||||||
changeDetection: options.changeDetection || ChangeDetectionStrategy.Default,
|
changeDetection: options.detect ?
|
||||||
|
(options.onPushOnly ? ChangeDetectionStrategy.OnPush : ChangeDetectionStrategy.Default) :
|
||||||
|
ChangeDetectionStrategy.Detached,
|
||||||
templateUrl: options.templateUrl,
|
templateUrl: options.templateUrl,
|
||||||
template: options.template,
|
template: options.template,
|
||||||
styles: options.styles,
|
styles: options.styles,
|
||||||
|
@ -83,6 +86,9 @@ export function RedocComponent(options) {
|
||||||
pipes: pipes
|
pipes: pipes
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log(options.selector, options.detect ?
|
||||||
|
(options.onPushOnly ? 'OnPush' : 'Default') : 'Detached');
|
||||||
|
|
||||||
return componentDecorator(target) || target;
|
return componentDecorator(target) || target;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@ export class MenuService {
|
||||||
this.activeMethodPtr = currentItem.pointer;
|
this.activeMethodPtr = currentItem.pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.changed.next(menu[catIdx], currentItem);
|
this.changed.next({cat: menu[catIdx], item: currentItem});
|
||||||
}
|
}
|
||||||
|
|
||||||
_calcActiveIndexes(offset) {
|
_calcActiveIndexes(offset) {
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import {Component, EventEmitter} from '@angular/core';
|
import { Component, EventEmitter } from '@angular/core';
|
||||||
import {CORE_DIRECTIVES} from '@angular/common';
|
import { CORE_DIRECTIVES } from '@angular/common';
|
||||||
|
import { ChangeDetectorRef, ChangeDetectionStrategy } from '@angular/core';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'tabs',
|
selector: 'tabs',
|
||||||
events: ['change'],
|
events: ['change'],
|
||||||
|
inputs: ['selected'],
|
||||||
template: `
|
template: `
|
||||||
<ul>
|
<ul>
|
||||||
<li *ngFor="let tab of tabs" [ngClass]="{active: tab.active}" (click)="selectTab(tab)"
|
<li *ngFor="let tab of tabs" [ngClass]="{active: tab.active}" (click)="selectTab(tab)"
|
||||||
|
@ -14,12 +16,15 @@ import {CORE_DIRECTIVES} from '@angular/common';
|
||||||
<ng-content></ng-content>
|
<ng-content></ng-content>
|
||||||
`,
|
`,
|
||||||
directives: [CORE_DIRECTIVES],
|
directives: [CORE_DIRECTIVES],
|
||||||
styleUrls: ['./lib/shared/components/Tabs/tabs.css']
|
styleUrls: ['./lib/shared/components/Tabs/tabs.css'],
|
||||||
|
changeDetection: ChangeDetectionStrategy.OnPush
|
||||||
})
|
})
|
||||||
|
@Reflect.metadata('parameters', [[ChangeDetectorRef]])
|
||||||
export class Tabs {
|
export class Tabs {
|
||||||
constructor() {
|
constructor(changeDetector) {
|
||||||
this.tabs = [];
|
this.tabs = [];
|
||||||
this.change = new EventEmitter();
|
this.change = new EventEmitter();
|
||||||
|
this.changeDetector = changeDetector;
|
||||||
}
|
}
|
||||||
|
|
||||||
selectTab(tab, notify = true) {
|
selectTab(tab, notify = true) {
|
||||||
|
@ -47,6 +52,7 @@ export class Tabs {
|
||||||
prevActive.active = true;
|
prevActive.active = true;
|
||||||
}
|
}
|
||||||
notify && this.change.next(tabTitle);
|
notify && this.change.next(tabTitle);
|
||||||
|
this.changeDetector.markForCheck();
|
||||||
}
|
}
|
||||||
|
|
||||||
addTab(tab) {
|
addTab(tab) {
|
||||||
|
@ -55,6 +61,10 @@ export class Tabs {
|
||||||
}
|
}
|
||||||
this.tabs.push(tab);
|
this.tabs.push(tab);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
if (this.selected) this.selected.subscribe(title => this.selectyByTitle(title));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "redoc",
|
"name": "redoc",
|
||||||
"description": "Swagger-generated API Reference Documentation",
|
"description": "Swagger-generated API Reference Documentation",
|
||||||
"version": "0.10.0",
|
"version": "0.11.0",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git://github.com/Rebilly/ReDoc"
|
"url": "git://github.com/Rebilly/ReDoc"
|
||||||
|
@ -11,10 +11,10 @@
|
||||||
"test": "gulp lint && ./build/run_tests.sh",
|
"test": "gulp lint && ./build/run_tests.sh",
|
||||||
"jspm-install": "jspm install",
|
"jspm-install": "jspm install",
|
||||||
"start": "gulp serve",
|
"start": "gulp serve",
|
||||||
"build-dist": "gulp build",
|
"build-dist": "gulp build --prod",
|
||||||
"branch-release": "git reset --hard && branch-release",
|
"branch-release": "git reset --hard && branch-release",
|
||||||
"unit": "gulp test",
|
"unit": "gulp test",
|
||||||
"e2e": "gulp e2e",
|
"e2e": "gulp e2e --prod",
|
||||||
"deploy": "build/prepare_deploy.sh && deploy-to-gh-pages demo"
|
"deploy": "build/prepare_deploy.sh && deploy-to-gh-pages demo"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
@ -114,6 +114,7 @@
|
||||||
"sinon": "^1.17.2",
|
"sinon": "^1.17.2",
|
||||||
"systemjs-builder": "^0.15.16",
|
"systemjs-builder": "^0.15.16",
|
||||||
"vinyl-paths": "^2.0.0",
|
"vinyl-paths": "^2.0.0",
|
||||||
|
"yargs": "^4.7.1",
|
||||||
"zone.js": "^0.6.12"
|
"zone.js": "^0.6.12"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,12 +43,39 @@ describe('Scroll sync', () => {
|
||||||
fixFFTest(done);
|
fixFFTest(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update active menu entries on page scroll', () => {
|
it('should update active menu entries on page scroll forwards', () => {
|
||||||
scrollToEl('[tag="store"]').then(function() {
|
scrollToEl('[tag="store"]').then(() => {
|
||||||
expect($('.menu-cat-header.active').getInnerHtml()).toContain('store');
|
expect($('.menu-cat-header.active').getInnerHtml()).toContain('store');
|
||||||
expect($('.selected-tag').getInnerHtml()).toContain('store');
|
expect($('.selected-tag').getInnerHtml()).toContain('store');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should update active menu entries on page scroll backwards', () => {
|
||||||
|
scrollToEl('[operation-id="getPetById"]').then(() => {
|
||||||
|
expect($('.menu-cat-header.active').getInnerHtml()).toContain('pet');
|
||||||
|
expect($('.selected-tag').getInnerHtml()).toContain('pet');
|
||||||
|
expect($('.menu-cat li.active').getInnerHtml()).toContain('Find pet by ID');
|
||||||
|
expect($('.selected-endpoint').getInnerHtml()).toContain('Find pet by ID');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Language tabs sync', () => {
|
||||||
|
let specUrl = URL;
|
||||||
|
|
||||||
|
beforeEach((done) => {
|
||||||
|
browser.get(specUrl);
|
||||||
|
fixFFTest(done);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should sync language tabs', () => {
|
||||||
|
var $item = $$('[operation-id="addPet"] tabs > ul > li').last();
|
||||||
|
// check if correct item
|
||||||
|
expect($item.getText()).toContain('PHP');
|
||||||
|
$item.click().then(() => {
|
||||||
|
expect($('[operation-id="updatePet"] li.active').getText()).toContain('PHP');
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
if (process.env.JOB === 'e2e-guru') {
|
if (process.env.JOB === 'e2e-guru') {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user