2016-01-31 20:37:51 +03:00
|
|
|
'use strict';
|
|
|
|
|
2016-05-25 18:34:31 +03:00
|
|
|
import { ViewChildren, QueryList, EventEmitter, Input} from '@angular/core';
|
2016-02-10 14:19:50 +03:00
|
|
|
|
2016-06-22 21:17:48 +03:00
|
|
|
import { RedocComponent, BaseComponent, SpecManager } from '../base';
|
2016-01-31 20:37:51 +03:00
|
|
|
import JsonPointer from '../../utils/JsonPointer';
|
2016-05-09 22:55:16 +03:00
|
|
|
import { Tabs, Tab } from '../../shared/components/index';
|
|
|
|
import { SchemaSample } from '../SchemaSample/schema-sample';
|
2016-05-06 00:48:41 +03:00
|
|
|
import { PrismPipe } from '../../utils/pipes';
|
|
|
|
import { RedocEventsService } from '../../services/index';
|
2016-02-03 17:47:20 +03:00
|
|
|
|
2016-07-17 18:07:51 +03:00
|
|
|
import { CopyButton } from '../../shared/components/CopyButton/copy-button.directive';
|
|
|
|
|
2016-01-31 20:37:51 +03:00
|
|
|
@RedocComponent({
|
|
|
|
selector: 'request-samples',
|
2016-05-25 18:34:31 +03:00
|
|
|
templateUrl: './request-samples.html',
|
|
|
|
styleUrls: ['./request-samples.css'],
|
2016-07-17 18:07:51 +03:00
|
|
|
directives: [SchemaSample, Tabs, Tab, CopyButton],
|
2016-05-06 00:48:41 +03:00
|
|
|
inputs: ['schemaPointer'],
|
2016-05-18 16:59:54 +03:00
|
|
|
pipes: [PrismPipe],
|
|
|
|
detect: true,
|
|
|
|
onPushOnly: false
|
2016-01-31 20:37:51 +03:00
|
|
|
})
|
2016-05-06 00:48:41 +03:00
|
|
|
export class RequestSamples extends BaseComponent {
|
2016-05-25 18:34:31 +03:00
|
|
|
childTabs: Tabs;
|
|
|
|
selectedLang: EventEmitter<any>;
|
2016-07-20 11:07:08 +03:00
|
|
|
|
|
|
|
samples: Array<any>;
|
|
|
|
|
2016-05-25 18:34:31 +03:00
|
|
|
@Input() schemaPointer:string;
|
|
|
|
@ViewChildren(Tabs) childQuery:QueryList<Tabs>;
|
2016-06-23 17:36:38 +03:00
|
|
|
constructor(specMgr:SpecManager, public events:RedocEventsService) {
|
|
|
|
super(specMgr);
|
2016-06-06 19:32:20 +03:00
|
|
|
|
2016-05-18 16:59:54 +03:00
|
|
|
this.selectedLang = this.events.samplesLanguageChanged;
|
2016-05-06 00:48:41 +03:00
|
|
|
}
|
|
|
|
|
2016-02-03 17:47:20 +03:00
|
|
|
|
|
|
|
changeLangNotify(lang) {
|
2016-05-06 00:48:41 +03:00
|
|
|
this.events.samplesLanguageChanged.next(lang);
|
2016-02-03 17:47:20 +03:00
|
|
|
}
|
|
|
|
|
2016-07-20 11:07:08 +03:00
|
|
|
init() {
|
|
|
|
this.schemaPointer = JsonPointer.join(this.schemaPointer, 'schema');;
|
|
|
|
this.samples = this.componentSchema['x-code-samples'] || [];
|
2016-01-31 20:37:51 +03:00
|
|
|
}
|
|
|
|
}
|