@@ -2,7 +2,7 @@ import { LitElement, html, css} from 'lit-element';
2
2
import { unsafeHTML } from 'lit-html/directives/unsafe-html.js' ;
3
3
import MLogo from '@/components/m-logo' ;
4
4
import EndPoints from '@/components/end-points' ;
5
-
5
+ import SecuritySchemes from '@/components/security-schemes' ;
6
6
7
7
import FontStyles from '@/styles/font-styles' ;
8
8
import InputStyles from '@/styles/input-styles' ;
@@ -109,15 +109,23 @@ class RapiDoc extends LitElement {
109
109
background- color : var(- - bg);
110
110
font- family: var(- - font- regular);
111
111
}
112
+ .body-container {
113
+ margin : 0 16px ;
114
+ }
112
115
.header {
113
116
background-color : var (--header-bg );
114
117
color : var (--header-fg );
115
118
width : 100% ;
116
119
}
117
- .header . title {
120
+ .header- title {
118
121
font-size : 24px ;
119
122
padding : 0 8px ;
120
123
}
124
+
125
+ .section-gap {
126
+ padding : 28px 0px 4px 20px ;
127
+ }
128
+
121
129
input .header-input {
122
130
background : ${ this . headerColor ?vars . color . brightness ( this . headerColor , - 20 ) :vars . color . inputReverseBg } ;
123
131
color : var (--header-fg );
@@ -126,25 +134,19 @@ class RapiDoc extends LitElement {
126
134
border-radius : 3px ;
127
135
}
128
136
.tag {
129
- font-size : 18px ;
130
- color : var (--fg );
131
- padding : 28px 0px 4px 20px ;
132
137
text-transform : uppercase;
133
138
}
134
139
.doc-info {
135
140
padding : 16px 20px ;
136
141
}
137
- .doc-info .title {
138
- font-size : 32px ;
139
- }
140
142
141
143
</ style >
142
144
143
145
${ this . showHeader === 'false' ?'' :html `
144
146
< div class ="row header regular-font " style ="padding:8px 4px 8px 4px;min-height:48px;position:sticky;top:0; ">
145
147
< div style ="display:flex; align-items: center; ">
146
148
< m-logo style ="height:36px;width:36px;margin-left:5px "> </ m-logo >
147
- < div class ="title "> ${ this . headingText } </ div >
149
+ < div class ="header- title "> ${ this . headingText } </ div >
148
150
</ div >
149
151
< div style ="margin: 0px 8px;display:flex ">
150
152
< input id ="spec-url " type ="text " class ="large header-input " placeholder ="Spec URL " value ="${ this . specUrl } " @change ="${ this . onSepcUrlChange } ">
@@ -153,65 +155,82 @@ class RapiDoc extends LitElement {
153
155
</ div >
154
156
< div style ="flex:1 "> </ div >
155
157
</ div > ` }
158
+ < div class ="body-container regular-font ">
159
+ ${ this . showInfo === 'false' || ! this . resolvedSpec || ! this . resolvedSpec . info ?`` :html `
160
+ < div class ="doc-info ">
161
+ < div class ="title ">
162
+ ${ this . resolvedSpec . info . title }
163
+ ${ ! this . resolvedSpec . info . version ?"" :html `
164
+ < span style ="font-size:14px;font-weight:bold ">
165
+ ${ this . resolvedSpec . info . version }
166
+ </ span > `
167
+ }
168
+ </ div >
169
+ ${ this . resolvedSpec . info . description ?html `
170
+ ${ unsafeHTML ( `<div class='m-markdown regular-font'>${ marked ( this . resolvedSpec . info . description ) } </div>` ) }
171
+ ` :`` }
172
+ </ div > `
173
+ }
156
174
157
- ${ this . showInfo === 'false' || ! this . resolvedSpec || ! this . resolvedSpec . info ?`` :html `
158
- < div class ="doc-info ">
159
- < div class ="title ">
160
- ${ this . resolvedSpec . info . title }
161
- ${ ! this . resolvedSpec . info . version ?"" :html `
162
- < span style ="font-size:14px;font-weight:bold ">
163
- ${ this . resolvedSpec . info . version }
164
- </ span > `
165
- }
166
- </ div >
167
- ${ this . resolvedSpec . info . description ?html `
168
- ${ unsafeHTML ( `<div class='m-markdown regular-font'>${ marked ( this . resolvedSpec . info . description ) } </div>` ) }
169
- ` :`` }
170
- </ div > `
171
- }
175
+ ${ ( this . developerMode === 'false' || ! this . resolvedSpec || ! this . resolvedSpec . servers || this . resolvedSpec . servers . length === 0 ) ?`` :html `
176
+ < div class ="sub-title regular-font section-gap "> API SERVER:
177
+ < div style ="margin: 8px 0; font-size:12px ">
178
+ ${ this . resolvedSpec . servers . map ( server => html `
179
+ < input type ='radio ' name ='api_server ' value ='${ server . url } ' @change ="${ this . onApiServerChange } " checked style ='margin:0 0 5px 8px '/>
180
+ ${ server . url } < br />
181
+ ` ) }
182
+ </ div >
183
+ </ div >
184
+ `
185
+ }
186
+ < div class ="section-gap ">
187
+ < security-schemes > </ security-schemes >
188
+ </ div >
172
189
173
-
190
+ ${ this . resolvedSpec && this . resolvedSpec . tags ?html `
191
+ ${ this . resolvedSpec . tags . map ( tag => html `
192
+ < div class ="sub-title tag regular-font section-gap "> ${ tag . name } </ div >
193
+ < div style ="margin:4px 20px ">
194
+ ${ unsafeHTML ( `<div class='m-markdown regular-font'>${ marked ( tag . description ?tag . description :'' ) } </div>` ) }
195
+ </ div >
196
+ < end-points
197
+ server = "${ this . server ?this . server :'' } "
198
+ layout = "${ this . layout ?this . layout :'row' } "
199
+ .paths = "${ tag . paths } "
200
+ > </ end-points >
201
+ ` ) } `
202
+ :'' }
203
+ </ div >
204
+ ` }
174
205
175
- ${ ( this . developerMode === 'false' || ! this . resolvedSpec || ! this . resolvedSpec . servers || this . resolvedSpec . servers . length === 0 ) ?`` :html `
176
- < div style ="display:flex; align-items: center;margin:16px 36px; ">
177
- < div class ="regular-font "> API Server : </ div >
178
- < input type ="text " class ="large " style ="width:400px " readonly placeholder ="API Server " value ="${ this . resolvedSpec . servers [ 0 ] . url } ">
179
- </ div > `
206
+ // Initialize the server property b
207
+ updated ( changedProperties ) {
208
+ if ( ! this . server ) {
209
+ let apiServerRadioEl = this . shadowRoot . querySelector ( "input[name='api_server']:checked" ) ;
210
+ if ( apiServerRadioEl !== null ) {
211
+ //this.setAttribute('api-server', apiServerRadioEl.value);
212
+ this . server = apiServerRadioEl . value ;
213
+ }
180
214
}
181
-
182
-
183
- ${ this . resolvedSpec && this . resolvedSpec . tags ?html `< div id ="searchInput " style ="margin:0 16px ">
184
- ${ this . resolvedSpec . tags . map ( tag => html `
185
- < div class ="tag regular-font "> ${ tag . name } </ div >
186
- < div style ="margin:4px 20px ">
187
- ${ unsafeHTML ( `<div class='m-markdown regular-font'>${ marked ( tag . description ?tag . description :'' ) } </div>` ) }
188
- </ div >
189
- < end-points
190
- server = "${ this . resolvedSpec . servers && this . resolvedSpec . servers [ 0 ] && this . resolvedSpec . servers [ 0 ] . url ?this . resolvedSpec . servers [ 0 ] . url :'' } "
191
- layout = "${ this . layout ?this . layout :'row' } "
192
- .paths = "${ tag . paths } "
193
- > </ end-points >
194
- ` ) }
195
- </ div > `
196
- :'' }
197
- ` }
215
+ }
198
216
199
217
static get properties ( ) {
200
218
return {
201
- specUrl : { type : String , attribute : 'spec-url' , } ,
202
- specFile : { type : String , attribute : false , } ,
203
- headingText : { type : String , attribute : 'heading-text' } ,
204
- headerColor : { type : String , attribute : 'header-color' } ,
205
- primaryColor : { type : String , attribute : 'primary-color' } ,
206
- regularFont : { type : String , attribute : 'regular-font' } ,
207
- monoFont : { type : String , attribute : 'mono-font' } ,
208
- showHeader : { type : String , attribute : 'show-header' } ,
209
- layout : { type : String } ,
210
- theme : { type : String } ,
211
- logoUrl : { type : String , attribute : 'logo-url' } ,
212
- showTry : { type : Boolean , attribute : 'show-try' } ,
213
- showInfo : { type : Boolean , attribute : 'show-info' } ,
214
- showAuthentication : { type : Boolean , attribute : 'show-authentication' } ,
219
+ specUrl : { type : String , attribute : 'spec-url' } ,
220
+ specFile : { type : String , attribute : false } ,
221
+ server : { type : String } ,
222
+ headingText : { type : String , attribute : 'heading-text' } ,
223
+ headerColor : { type : String , attribute : 'header-color' } ,
224
+ primaryColor : { type : String , attribute : 'primary-color' } ,
225
+ regularFont : { type : String , attribute : 'regular-font' } ,
226
+ monoFont : { type : String , attribute : 'mono-font' } ,
227
+ showHeader : { type : String , attribute : 'show-header' } ,
228
+ layout : { type : String } ,
229
+ theme : { type : String } ,
230
+ logoUrl : { type : String , attribute : 'logo-url' } ,
231
+ showTry : { type : Boolean , attribute : 'show-try' } ,
232
+ showInfo : { type : Boolean , attribute : 'show-info' } ,
233
+ showAuthentication : { type : Boolean , attribute : 'show-authentication' } ,
215
234
} ;
216
235
}
217
236
attributeChangedCallback ( name , oldVal , newVal ) {
@@ -254,6 +273,15 @@ class RapiDoc extends LitElement {
254
273
this . shadowRoot . getElementById ( 'spec-file' ) . click ( ) ;
255
274
}
256
275
276
+ onApiServerChange ( ) {
277
+ let apiServerRadioEl = this . shadowRoot . querySelector ( "input[name='api_server']:checked" ) ;
278
+ if ( apiServerRadioEl !== null ) {
279
+ //this.setAttribute('api-server', apiServerRadioEl.value);
280
+ this . server = apiServerRadioEl . value ;
281
+ }
282
+ }
283
+
284
+
257
285
loadSpec ( specUrl ) {
258
286
var me = this ;
259
287
if ( ! specUrl ) {
0 commit comments