#5397 swagger-ui web application working, layout fixed
authorAndreas Kohlbecker <a.kohlbecker@bgbm.org>
Mon, 14 Dec 2015 09:32:51 +0000 (10:32 +0100)
committerAndreas Kohlbecker <a.kohlbecker@bgbm.org>
Mon, 14 Dec 2015 09:32:51 +0000 (10:32 +0100)
cdmlib-remote-webapp/src/main/webapp/doc/css/cdm.css
cdmlib-remote-webapp/src/main/webapp/doc/index.html
cdmlib-remote-webapp/src/main/webapp/doc/webjars/springfox-swagger-ui/springfox.js
cdmlib-remote-webapp/src/main/webapp/index.html

index b6654b1530a489d00139418934b72e230b8ce82c..10ca6fe6fb3de190d6e84ac1162716e4aef97fba 100644 (file)
@@ -1,8 +1,17 @@
-body.swagger-section #header {
+
+body.swagger-section #header , body.swagger-section #description{
   padding:0 50px;
   background-color:#F4F7E7;
 }
 
+body.swagger-section #content {
+  padding:0 50px;
+}
+
+#swagger-ui-container {
+  clear: both;
+}
+
 #header #banner, #header #menu{
   margin-left:auto;
   margin-right:auto;
index b2e8dc94cd060069d86c45e3856b038931b1ecfb..3ebd9479d27c74739d7799c32c17eb343b9fb587 100644 (file)
@@ -3,11 +3,13 @@
 <head>
   <meta charset="UTF-8">
   <title>Swagger UI</title>
+  <link href='https://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'/>
   <link rel="icon" type="image/png" href="images/favicon-32x32.png" sizes="32x32"/>
   <link rel="icon" type="image/png" href="images/favicon-16x16.png" sizes="16x16"/>
   <link href='webjars/springfox-swagger-ui/css/typography.css' media='screen' rel='stylesheet' type='text/css'/>
   <link href='webjars/springfox-swagger-ui/css/reset.css' media='screen' rel='stylesheet' type='text/css'/>
   <link href='webjars/springfox-swagger-ui/css/screen.css' media='screen' rel='stylesheet' type='text/css'/>
+  <link href='css/cdm.css' rel='stylesheet' type='text/css' />
   <link href='webjars/springfox-swagger-ui/css/reset.css' media='print' rel='stylesheet' type='text/css'/>
   <link href='webjars/springfox-swagger-ui/css/print.css' media='print' rel='stylesheet' type='text/css'/>
   <script src='webjars/springfox-swagger-ui/lib/jquery-1.8.0.min.js' type='text/javascript'></script>
@@ -21,6 +23,7 @@
   <script src='webjars/springfox-swagger-ui/lib/highlight.7.3.pack.js' type='text/javascript'></script>
   <script src='webjars/springfox-swagger-ui/lib/marked.js' type='text/javascript'></script>
   <script src='webjars/springfox-swagger-ui/lib/swagger-oauth.js' type='text/javascript'></script>
+  
 
   <script src='webjars/springfox-swagger-ui/springfox.js' type='text/javascript'></script>
   <script type="text/javascript">
 </head>
 
 <body class="swagger-section">
-<div id='header'>
-  <div class="swagger-ui-wrap">
-    <a id="logo" href="http://swagger.io">swagger</a>
-
-    <form id='api_selector'>
-      <div class='input'>
-        <select id="select_baseUrl" name="select_baseUrl"/>
-      </div>
-      <div class='input'><input placeholder="http://example.com/api" id="input_baseUrl" name="baseUrl" type="text"/>
+  <div id="header">\r
+    <div id="banner">\r
+      <img src="../images/logo_edit.png">\r
+      <div id="title"><h1>CDM remote API</hi></div>\r
       </div>
-      <div class='input'><input placeholder="api_key" id="input_apiKey" name="apiKey" type="text"/></div>
-      <div class='input'><a id="explore" href="#" data-sw-translate>Explore</a></div>
-    </form>
+    <div id="menu">\r
+      <ul id="select_baseUrl">\r
+      </ul>\r
   </div>
 </div>
 
-<div id="message-bar" class="swagger-ui-wrap" data-sw-translate>&nbsp;</div>
-<div id="swagger-ui-container" class="swagger-ui-wrap"></div>
+  <div id="description">\r
+    <div class="swagger-ui-wrap">\r
+  <!--\r
+      <h1>CDM remote REST service API</h1>\r
+   -->\r
+    </div>\r
+  </div>\r
+  <div id="content">\r
+    <div id="message-bar" class="swagger-ui-wrap">&nbsp;</div>\r
+    <div id="swagger-ui-container" class="swagger-ui-wrap"></div>
+  </div>
 </body>
 </html>
index a8e2cf94219886e6cd9ea49860b67e01af453d95..3c36f643377f87889ae884628412587526db6eeb 100644 (file)
@@ -16,21 +16,25 @@ $(function() {
     }
   };
   window.springfox = springfox;
-  window.oAuthRedirectUrl = springfox.baseUrl() + '/webjars/springfox-swagger-ui/o2c.html'
-
-  $('#select_baseUrl').change(function() {
-    window.swaggerUi.headerView.trigger('update-swagger-ui', {swagger-ui
-      url: $('#select_baseUrl').val()
-    });
-  });
+  window.oAuthRedirectUrl = springfox.baseUrl() + 'doc//webjars/springfox-swagger-ui/o2c.html'
 
   function maybePrefix(location, withRelativePath) {
     var pat = /^https?:\/\//i;
     if (pat.test(location)) {
-      return location;swagger-ui
+      return location;
     }
     return withRelativePath + location;
   }
+  
+  function getUrlParam(key){
+      key = key.replace(/[*+?^$.\[\]{}()|\\\/]/g, "\\$&"); // escape RegEx meta chars
+      var match = location.search.match(new RegExp("[?&]"+key+"=([^&]+)(&|$)"));
+      return match && decodeURIComponent(match[1].replace(/\+/g, " "));
+  }
+  
+  function menuItemId(groupName){
+      return 'menu_' + groupName.replace(/\s/g, "_");
+  }
 
   $(document).ready(function() {
     var relativeLocation = springfox.baseUrl();
@@ -39,18 +43,29 @@ $(function() {
 
     $.getJSON(relativeLocation + "/swagger-resources", function(data) {
 
-      var $menulist = $('#menu ul');
+      var $menulist = $('#select_baseUrl');
       $menulist.empty();
       $.each(data, function(i, resource) {
           //  <li id="menu_Generic_REST_API"><a href="?group=Generic+REST+API">Generic REST API</a></li>
-        var id = 'menu_' + resource.name; // TODO replace whitespace by  _
+        var id = menuItemId(resource.name);
         var link = $('<a></a>')
                 .attr("href", maybePrefix(resource.location, relativeLocation))
                 .text(resource.name);
         var option = $('<li></li>').attr("id", id).append(link);
         $menulist.append(option);
       });
-      $menulist.change();
+      $('#select_baseUrl a').click(function(event) {
+          event.preventDefault()
+          window.swaggerUi.headerView.trigger(
+                  'update-swagger-ui', 
+                  {url: $(event.target).attr('href')}
+          );
+      });
+      
+      var initialGroup = getUrlParam('group');
+      if(initialGroup) {
+          $('#' + menuItemId(initialGroup) + " a").click();
+      }
     });
 
   });
index f98ddde9637d97d7146a08e88eac6962e74d749e..18c489e56fd2f28f3283fc1df68d37839d872095 100644 (file)
@@ -3,13 +3,26 @@
 <meta http-equiv="refresh" content="0;url=doc/?group=Generic%20REST%20API">\r
 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">\r
 <title>CDM remote API</title>\r
-  <link href='https://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'/>\r
-  <link href='doc/css/reset.css' media='screen' rel='stylesheet' type='text/css'/>\r
-  <link href='doc/css/screen.css' media='screen' rel='stylesheet' type='text/css'/>\r
-  <link href='doc/css/cdm.css' media='screen' rel='stylesheet' type='text/css' />\r
-  <link href='doc/css/reset.css' media='print' rel='stylesheet' type='text/css'/>\r
-  <link href='doc/css/screen.css' media='print' rel='stylesheet' type='text/css'/>\r
-  <link href='doc/css/cdm.css' media='print' rel='stylesheet' type='text/css' />\r
+  <link href='doc/https://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'/>\r
+  <link rel="icon" type="image/png" href="doc/images/favicon-32x32.png" sizes="32x32"/>\r
+  <link rel="icon" type="image/png" href="doc/images/favicon-16x16.png" sizes="16x16"/>\r
+  <link href='doc/webjars/springfox-swagger-ui/css/typography.css' media='screen' rel='stylesheet' type='text/css'/>\r
+  <link href='doc/webjars/springfox-swagger-ui/css/reset.css' media='screen' rel='stylesheet' type='text/css'/>\r
+  <link href='doc/webjars/springfox-swagger-ui/css/screen.css' media='screen' rel='stylesheet' type='text/css'/>\r
+  <link href='doc/css/cdm.css' rel='stylesheet' type='text/css' />\r
+  <link href='doc/webjars/springfox-swagger-ui/css/reset.css' media='print' rel='stylesheet' type='text/css'/>\r
+  <link href='doc/webjars/springfox-swagger-ui/css/print.css' media='print' rel='stylesheet' type='text/css'/>\r
+  <script src='doc/webjars/springfox-swagger-ui/lib/jquery-1.8.0.min.js' type='text/javascript'></script>\r
+  <script src='doc/webjars/springfox-swagger-ui/lib/jquery.slideto.min.js' type='text/javascript'></script>\r
+  <script src='doc/webjars/springfox-swagger-ui/lib/jquery.wiggle.min.js' type='text/javascript'></script>\r
+  <script src='doc/webjars/springfox-swagger-ui/lib/jquery.ba-bbq.min.js' type='text/javascript'></script>\r
+  <script src='doc/webjars/springfox-swagger-ui/lib/handlebars-2.0.0.js' type='text/javascript'></script>\r
+  <script src='doc/webjars/springfox-swagger-ui/lib/underscore-min.js' type='text/javascript'></script>\r
+  <script src='doc/webjars/springfox-swagger-ui/lib/backbone-min.js' type='text/javascript'></script>\r
+  <script src='doc/webjars/springfox-swagger-ui/swagger-ui.min.js' type='text/javascript'></script>\r
+  <script src='doc/webjars/springfox-swagger-ui/lib/highlight.7.3.pack.js' type='text/javascript'></script>\r
+  <script src='doc/webjars/springfox-swagger-ui/lib/marked.js' type='text/javascript'></script>\r
+  <script src='doc/webjars/springfox-swagger-ui/lib/swagger-oauth.js' type='text/javascript'></script>\r
 </head>\r
 <body class="swagger-section">\r
   <div id="header">\r
@@ -26,7 +39,7 @@
       If the automatic redirect is not working please click the below link:\r
     </p>\r
     <ul>\r
-    <li><a href="doc/?group=Generic+REST+API">Documentation of the CDM remote API.</a>\r
+    <li><a href="doc/index.html?group=Generic+REST+API">Documentation of the CDM remote API.</a>\r
   </div>\r
 </div>\r
 </body>\r