2015-10-07 12:47:57 +03:00
|
|
|
'use strict';
|
2016-12-29 20:20:29 +03:00
|
|
|
import { Component, ChangeDetectionStrategy, OnInit, ElementRef } from '@angular/core';
|
2017-08-17 11:42:12 +03:00
|
|
|
import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';
|
2016-08-22 12:12:13 +03:00
|
|
|
import { SpecManager, BaseComponent } from '../base';
|
2016-12-29 20:20:29 +03:00
|
|
|
import { OptionsService, Marker } from '../../services/index';
|
2015-10-07 12:47:57 +03:00
|
|
|
|
2016-08-22 12:12:13 +03:00
|
|
|
@Component({
|
2015-10-09 23:19:35 +03:00
|
|
|
selector: 'api-info',
|
2016-05-25 18:34:31 +03:00
|
|
|
styleUrls: ['./api-info.css'],
|
2016-08-22 12:12:13 +03:00
|
|
|
templateUrl: './api-info.html',
|
|
|
|
changeDetection: ChangeDetectionStrategy.OnPush
|
2015-10-07 12:47:57 +03:00
|
|
|
})
|
2016-08-28 21:46:10 +03:00
|
|
|
export class ApiInfo extends BaseComponent implements OnInit {
|
|
|
|
info: any = {};
|
2017-08-17 11:42:12 +03:00
|
|
|
specUrl: String | SafeResourceUrl;
|
|
|
|
downloadFilename = '';
|
2018-02-16 13:45:24 +03:00
|
|
|
|
|
|
|
hideDownloadButton = this.optionsService.options.hideDownloadButton;
|
|
|
|
|
2016-12-29 20:20:29 +03:00
|
|
|
constructor(specMgr: SpecManager,
|
|
|
|
private optionsService: OptionsService,
|
|
|
|
elRef: ElementRef,
|
2017-08-17 11:42:12 +03:00
|
|
|
marker: Marker,
|
|
|
|
private sanitizer: DomSanitizer
|
2016-12-29 20:20:29 +03:00
|
|
|
) {
|
2016-06-23 17:36:38 +03:00
|
|
|
super(specMgr);
|
2016-12-29 20:20:29 +03:00
|
|
|
marker.addElement(elRef.nativeElement);
|
2015-10-07 12:47:57 +03:00
|
|
|
}
|
2016-06-13 20:54:24 +03:00
|
|
|
|
2016-07-20 11:07:08 +03:00
|
|
|
init() {
|
|
|
|
this.info = this.componentSchema.info;
|
2017-04-23 15:22:04 +03:00
|
|
|
this.specUrl = this.specMgr.specUrl;
|
2017-08-17 11:42:12 +03:00
|
|
|
if (!this.specUrl && window.Blob && window.URL) {
|
|
|
|
const blob = new Blob([JSON.stringify(this.specMgr.rawSpec, null, 2)], {type : 'application/json'});
|
|
|
|
this.specUrl = this.sanitizer.bypassSecurityTrustResourceUrl(window.URL.createObjectURL(blob));
|
|
|
|
this.downloadFilename = 'swagger.json';
|
|
|
|
}
|
|
|
|
|
2017-02-26 01:44:21 +03:00
|
|
|
if (!isNaN(parseInt(this.info.version.toString().substring(0, 1)))) {
|
2016-07-20 11:07:08 +03:00
|
|
|
this.info.version = 'v' + this.info.version;
|
2016-07-01 18:09:42 +03:00
|
|
|
}
|
2015-10-07 12:47:57 +03:00
|
|
|
}
|
2016-08-28 21:46:10 +03:00
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
this.preinit();
|
|
|
|
}
|
2015-10-07 12:47:57 +03:00
|
|
|
}
|