Project

General

Profile

Revision ae797143

IDae797143897f15b256ca922b1d8a00ca780cb7f0
Parent ef485f52
Child c8e611f0

Added by Andreas Kohlbecker 10 months ago

ref #7770 fixing layout issue and menu items active state and updating diffs

View differences:

cdmlib-remote-webapp/src/main/webapp/doc/README.md
33 33

  
34 34
Now **MANUALLY** apply the chnages recorded in the diffs `index.html.diff` and  `springfox.js.diff`. Patching the files with the diff might not work since the diffs have been made from the last version.
35 35

  
36
Once you are ready and the swagger UI is is working properly with the updated version you need to create the diffs for the next update to come:
37

  
36
Once you are ready and the swagger UI is is working properly with the updated version you need to create the unified diffs for the next update to come:
38 37

  
39 38
~~~
40
diff index-orig.html index.html > index.html.diff
39
diff -u index-orig.html index.html > index.html.diff
41 40
cd ./webjars/springfox-swagger-ui/
42
diff springfox-last.js springfox.js > springfox.js.diff
41
diff -u springfox-last.js springfox.js > springfox.js.diff
43 42
~~~
44 43

  
45 44
**Congratulations, your are done and you can commit your work.**
cdmlib-remote-webapp/src/main/webapp/doc/css/cdm.css
4 4
  background-color:#F4F7E7;
5 5
}
6 6

  
7
body.swagger-section #header{
8
  height: auto;
9
}
10

  
7 11
body.swagger-section #content {
8 12
  padding:0 50px;
9 13
}
......
12 16
  clear: both;
13 17
}
14 18

  
19

  
20

  
15 21
#header #banner, #header #menu{
16 22
  margin-left:auto;
17 23
  margin-right:auto;
cdmlib-remote-webapp/src/main/webapp/doc/index-last.html
1
<!DOCTYPE html>
2
<html>
3
<head>
4
  <meta charset="UTF-8">
5
  <title>Swagger UI</title>
6
  <link href='https://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'/>
7
  <link rel="icon" type="image/png" href="images/favicon-32x32.png" sizes="32x32"/>
8
  <link rel="icon" type="image/png" href="images/favicon-16x16.png" sizes="16x16"/>
9
  <link href='webjars/springfox-swagger-ui/css/typography.css' media='screen' rel='stylesheet' type='text/css'/>
10
  <link href='webjars/springfox-swagger-ui/css/reset.css' media='screen' rel='stylesheet' type='text/css'/>
11
  <link href='webjars/springfox-swagger-ui/css/screen.css' media='screen' rel='stylesheet' type='text/css'/>
12
  <link href='css/cdm.css' rel='stylesheet' type='text/css' />
13
  <link href='webjars/springfox-swagger-ui/css/reset.css' media='print' rel='stylesheet' type='text/css'/>
14
  <link href='webjars/springfox-swagger-ui/css/print.css' media='print' rel='stylesheet' type='text/css'/>
15
  <script src='webjars/springfox-swagger-ui/lib/jquery-1.8.0.min.js' type='text/javascript'></script>
16
  <script src='webjars/springfox-swagger-ui/lib/jquery.slideto.min.js' type='text/javascript'></script>
17
  <script src='webjars/springfox-swagger-ui/lib/jquery.wiggle.min.js' type='text/javascript'></script>
18
  <script src='webjars/springfox-swagger-ui/lib/jquery.ba-bbq.min.js' type='text/javascript'></script>
19
  <script src='webjars/springfox-swagger-ui/lib/handlebars-2.0.0.js' type='text/javascript'></script>
20
  <script src='webjars/springfox-swagger-ui/lib/underscore-min.js' type='text/javascript'></script>
21
  <script src='webjars/springfox-swagger-ui/lib/backbone-min.js' type='text/javascript'></script>
22
  <script src='webjars/springfox-swagger-ui/swagger-ui.min.js' type='text/javascript'></script>
23
  <script src='webjars/springfox-swagger-ui/lib/highlight.7.3.pack.js' type='text/javascript'></script>
24
  <script src='webjars/springfox-swagger-ui/lib/marked.js' type='text/javascript'></script>
25
  <script src='webjars/springfox-swagger-ui/lib/swagger-oauth.js' type='text/javascript'></script>
26
  
27

  
28
  <script src='webjars/springfox-swagger-ui/springfox.js' type='text/javascript'></script>
29
  <script type="text/javascript">
30
    $(function() {
31

  
32
      window.springfox.uiConfig(function(data) {
33
        window.swaggerUi = new SwaggerUi({
34
          dom_id: "swagger-ui-container",
35
          validatorUrl: data.validatorUrl,
36
          supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
37
          onComplete: function(swaggerApi, swaggerUi) {
38

  
39
            initializeSpringfox();
40

  
41
            if (window.SwaggerTranslator) {
42
              window.SwaggerTranslator.translate();
43
            }
44

  
45
            $('pre code').each(function(i, e) {
46
              hljs.highlightBlock(e)
47
            });
48

  
49
          },
50
          onFailure: function(data) {
51
            log("Unable to Load SwaggerUI");
52
          },
53
          docExpansion: "none",
54
          apisSorter: "alpha",
55
          showRequestHeaders: false
56
        });
57

  
58
        function addApiKeyAuthorization() {
59
          var key = encodeURIComponent($('#input_apiKey')[0].value);
60
          if (key && key.trim() != "") {
61
            var apiKeyAuth = new SwaggerClient.ApiKeyAuthorization("api_key", key, window.apiKeyVehicle);
62
            window.swaggerUi.api.clientAuthorizations.add("api_key", apiKeyAuth);
63
            log("added key " + key);
64
          }
65
        }
66

  
67
        $('#input_apiKey').change(addApiKeyAuthorization);
68

  
69
        function log() {
70
          if ('console' in window) {
71
            console.log.apply(console, arguments);
72
          }
73
        }
74

  
75
        function oAuthIsDefined(security) {
76
          return security.clientId
77
              && security.clientSecret
78
              && security.appName
79
              && security.realm;
80
        }
81

  
82
        function initializeSpringfox() {
83
          var security = {};
84
          window.springfox.securityConfig(function(data) {
85
            security = data;
86
            window.apiKeyVehicle = security.apiKeyVehicle || 'query';
87
            if (security.apiKey) {
88
              $('#input_apiKey').val(security.apiKey);
89
              addApiKeyAuthorization();
90
            }
91
            if (typeof initOAuth == "function" && oAuthIsDefined(security)) {
92
              initOAuth(security);
93
            }
94
          });
95
        }
96
      });
97
    });
98
  </script>
99
</head>
100

  
101
<body class="swagger-section">
102
  <div id="header">
103
    <div id="banner">
104
      <img src="../images/logo_edit.png">
105
      <div id="title"><h1>CDM remote API</hi></div>
106
      </div>
107
    <div id="menu">
108
      <ul id="select_baseUrl">
109
      </ul>
110
  </div>
111
</div>
112

  
113
  <div id="description">
114
    <div class="swagger-ui-wrap">
115
  <!--
116
      <h1>CDM remote REST service API</h1>
117
   -->
118
    </div>
119
  </div>
120
  <div id="content">
121
    <div id="message-bar" class="swagger-ui-wrap">&nbsp;</div>
122
    <div id="swagger-ui-container" class="swagger-ui-wrap"></div>
123
  </div>
124
</body>
125
</html>
cdmlib-remote-webapp/src/main/webapp/doc/index.html.diff
1
--- swagger-ui.html	2016-10-27 09:08:52.000000000 +0200
1
--- /home/andreas/spring-fox/2.6.1/META-INF/resources/swagger-ui.html	2016-10-27 09:08:52.000000000 +0200
2 2
+++ index.html	2018-10-18 18:58:35.504819565 +0200
3 3
@@ -3,11 +3,13 @@
4 4
 <head>
cdmlib-remote-webapp/src/main/webapp/doc/index.html.diff.last
1
diff --git a/cdmlib-remote-webapp/src/main/webapp/doc/index.html b/cdmlib-remote-webapp/src/main/webapp/doc/index.html
2
index b2e8dc9..3ebd947 100644
3
--- a/cdmlib-remote-webapp/src/main/webapp/doc/index.html
4
+++ b/cdmlib-remote-webapp/src/main/webapp/doc/index.html
5
@@ -3,11 +3,13 @@
6
 <head>
7
   <meta charset="UTF-8">
8
   <title>Swagger UI</title>
9
+  <link href='https://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'/>
10
   <link rel="icon" type="image/png" href="images/favicon-32x32.png" sizes="32x32"/>
11
   <link rel="icon" type="image/png" href="images/favicon-16x16.png" sizes="16x16"/>
12
   <link href='webjars/springfox-swagger-ui/css/typography.css' media='screen' rel='stylesheet' type='text/css'/>
13
   <link href='webjars/springfox-swagger-ui/css/reset.css' media='screen' rel='stylesheet' type='text/css'/>
14
   <link href='webjars/springfox-swagger-ui/css/screen.css' media='screen' rel='stylesheet' type='text/css'/>
15
+  <link href='css/cdm.css' rel='stylesheet' type='text/css' />
16
   <link href='webjars/springfox-swagger-ui/css/reset.css' media='print' rel='stylesheet' type='text/css'/>
17
   <link href='webjars/springfox-swagger-ui/css/print.css' media='print' rel='stylesheet' type='text/css'/>
18
   <script src='webjars/springfox-swagger-ui/lib/jquery-1.8.0.min.js' type='text/javascript'></script>
19
@@ -22,6 +24,7 @@
20
   <script src='webjars/springfox-swagger-ui/lib/marked.js' type='text/javascript'></script>
21
   <script src='webjars/springfox-swagger-ui/lib/swagger-oauth.js' type='text/javascript'></script>
22
   
23
+
24
   <script src='webjars/springfox-swagger-ui/springfox.js' type='text/javascript'></script>
25
   <script type="text/javascript">
26
     $(function() {
27
@@ -96,23 +99,27 @@
28
 </head>
29
 
30
 <body class="swagger-section">
31
-<div id='header'>
32
-  <div class="swagger-ui-wrap">
33
-    <a id="logo" href="http://swagger.io">swagger</a>
34
-
35
-    <form id='api_selector'>
36
-      <div class='input'>
37
-        <select id="select_baseUrl" name="select_baseUrl"/>
38
-      </div>
39
-      <div class='input'><input placeholder="http://example.com/api" id="input_baseUrl" name="baseUrl" type="text"/>
40
+  <div id="header">
41
+    <div id="banner">
42
+      <img src="../images/logo_edit.png">
43
+      <div id="title"><h1>CDM remote API</hi></div>
44
       </div>
45
-      <div class='input'><input placeholder="api_key" id="input_apiKey" name="apiKey" type="text"/></div>
46
-      <div class='input'><a id="explore" href="#" data-sw-translate>Explore</a></div>
47
-    </form>
48
+    <div id="menu">
49
+      <ul id="select_baseUrl">
50
+      </ul>
51
   </div>
52
 </div>
53
 
54
-<div id="message-bar" class="swagger-ui-wrap" data-sw-translate>&nbsp;</div>
55
+  <div id="description">
56
+    <div class="swagger-ui-wrap">
57
+  <!--
58
+      <h1>CDM remote REST service API</h1>
59
+   -->
60
+    </div>
61
+  </div>
62
+  <div id="content">
63
+    <div id="message-bar" class="swagger-ui-wrap">&nbsp;</div>
64
     <div id="swagger-ui-container" class="swagger-ui-wrap"></div>
65
+  </div>
66
 </body>
67
 </html>
cdmlib-remote-webapp/src/main/webapp/doc/webjars/springfox-swagger-ui/springfox-last.js
1
$(function() {
2
  var springfox = {
3
    "baseUrl": function() {
4
      var urlMatches = /(.*)\/doc\/.*/.exec(window.location.href); 
5
      return urlMatches[1];
6
    },
7
    "securityConfig": function(cb) {
8
      $.getJSON(this.baseUrl() + "/configuration/security", function(data) {
9
        cb(data);
10
      });
11
    },
12
    "uiConfig": function(cb) {
13
      $.getJSON(this.baseUrl() + "/configuration/ui", function(data) {
14
        cb(data);
15
      });
16
    }
17
  };
18
  window.springfox = springfox;
19
  window.oAuthRedirectUrl = springfox.baseUrl() + 'doc//webjars/springfox-swagger-ui/o2c.html'
20

  
21
  function maybePrefix(location, withRelativePath) {
22
    var pat = /^https?:\/\//i;
23
    if (pat.test(location)) {
24
      return location;
25
    }
26
    return withRelativePath + location;
27
  }
28
  
29
  function getUrlParam(key){
30
      key = key.replace(/[*+?^$.\[\]{}()|\\\/]/g, "\\$&"); // escape RegEx meta chars
31
      var match = location.search.match(new RegExp("[?&]"+key+"=([^&]+)(&|$)"));
32
      return match && decodeURIComponent(match[1].replace(/\+/g, " "));
33
  }
34
  
35
  function menuItemId(groupName){
36
      return 'menu_' + groupName.replace(/\s/g, "_");
37
  }
38

  
39
  $(document).ready(function() {
40
    var relativeLocation = springfox.baseUrl();
41

  
42
    $('#input_baseUrl').hide();
43

  
44
    $.getJSON(relativeLocation + "/swagger-resources", function(data) {
45

  
46
      var $menulist = $('#select_baseUrl');
47
      $menulist.empty();
48
      $.each(data, function(i, resource) {
49
          //  <li id="menu_Generic_REST_API"><a href="?group=Generic+REST+API">Generic REST API</a></li>
50
        var id = menuItemId(resource.name);
51
        var link = $('<a></a>')
52
                .attr("href", maybePrefix(resource.location, relativeLocation))
53
                .text(resource.name);
54
        var option = $('<li></li>').attr("id", id).append(link);
55
        $menulist.append(option);
56
      });
57
      $('#select_baseUrl a').click(function(event) {
58
          event.preventDefault()
59
          window.swaggerUi.headerView.trigger(
60
                  'update-swagger-ui', 
61
                  {url: $(event.target).attr('href')}
62
          );
63
      });
64
      
65
      var initialGroup = getUrlParam('group');
66
      if(initialGroup) {
67
          $('#' + menuItemId(initialGroup) + " a").click();
68
      }
69
    });
70

  
71
  });
72

  
73
});
74

  
75

  
cdmlib-remote-webapp/src/main/webapp/doc/webjars/springfox-swagger-ui/springfox.js
128 128
          $menulist.append(option);
129 129
      });
130 130
      $('#select_baseUrl a').click(function(event) {
131
            event.preventDefault()
131
            event.preventDefault();
132
            $('#select_baseUrl li.active').removeClass('active');
133
            $(this).parent().addClass('active');
132 134
            window.swaggerUi.headerView.trigger(
133 135
                    'update-swagger-ui', 
134 136
                    {url: $(event.target).attr('href')}
cdmlib-remote-webapp/src/main/webapp/doc/webjars/springfox-swagger-ui/springfox.js.diff
1
--- springfox.orig.js	2016-11-06 18:08:34.000000000 +0100
2
+++ springfox.js	2018-10-18 18:45:02.381106203 +0200
1
--- /home/andreas/spring-fox/2.6.1/META-INF/resources/webjars/springfox-swagger-ui/springfox.orig.js	2016-11-06 18:08:34.000000000 +0100
2
+++ springfox.js	2018-10-18 19:58:56.530758949 +0200
3 3
@@ -1,7 +1,7 @@
4 4
 $(function() {
5 5
   var springfox = {
......
37 37
 
38 38
   function initializeBaseUrl() {
39 39
     var relativeLocation = springfox.baseUrl();
40
@@ -106,15 +116,28 @@
40
@@ -106,15 +116,30 @@
41 41
 
42 42
     $.getJSON(relativeLocation + "/swagger-resources", function(data) {
43 43
 
......
59 59
+          $menulist.append(option);
60 60
+      });
61 61
+      $('#select_baseUrl a').click(function(event) {
62
+            event.preventDefault()
62
+            event.preventDefault();
63
+            $('#select_baseUrl li.active').removeClass('active');
64
+            $(this).parent().addClass('active');
63 65
+            window.swaggerUi.headerView.trigger(
64 66
+                    'update-swagger-ui', 
65 67
+                    {url: $(event.target).attr('href')}
cdmlib-remote-webapp/src/main/webapp/doc/webjars/springfox-swagger-ui/springfox.js.diff.last
1
diff --git a/cdmlib-remote-webapp/src/main/webapp/doc/webjars/springfox-swagger-ui/springfox.js b/cdmlib-remote-webapp/src/main/webapp/doc/webjars/springfox-swagger-ui/springfox.js
2
index 481fa73..4ad1d26 100644
3
--- a/cdmlib-remote-webapp/src/main/webapp/doc/webjars/springfox-swagger-ui/springfox.js
4
+++ b/cdmlib-remote-webapp/src/main/webapp/doc/webjars/springfox-swagger-ui/springfox.js
5
@@ -1,7 +1,7 @@
6
 $(function() {
7
   var springfox = {
8
     "baseUrl": function() {
9
-      var urlMatches = /(.*)\/swagger-ui.html.*/.exec(window.location.href);
10
+      var urlMatches = /(.*)\/doc\/.*/.exec(window.location.href); 
11
       return urlMatches[1];
12
     },
13
     "securityConfig": function(cb) {
14
@@ -16,13 +16,7 @@ $(function() {
15
     }
16
   };
17
   window.springfox = springfox;
18
-  window.oAuthRedirectUrl = springfox.baseUrl() + '/webjars/springfox-swagger-ui/o2c.html'
19
-
20
-  $('#select_baseUrl').change(function() {
21
-    window.swaggerUi.headerView.trigger('update-swagger-ui', {
22
-      url: $('#select_baseUrl').val()
23
-    });
24
-  });
25
+  window.oAuthRedirectUrl = springfox.baseUrl() + 'doc//webjars/springfox-swagger-ui/o2c.html'
26
 
27
   function maybePrefix(location, withRelativePath) {
28
     var pat = /^https?:\/\//i;
29
@@ -32,6 +26,16 @@ $(function() {
30
     return withRelativePath + location;
31
   }
32
+  function getUrlParam(key){
33
+      key = key.replace(/[*+?^$.\[\]{}()|\\\/]/g, "\\$&"); // escape RegEx meta chars
34
+      var match = location.search.match(new RegExp("[?&]"+key+"=([^&]+)(&|$)"));
35
+      return match && decodeURIComponent(match[1].replace(/\+/g, " "));
36
+  }
37
+  
38
+  function menuItemId(groupName){
39
+      return 'menu_' + groupName.replace(/\s/g, "_");
40
+  }
41
+
42
   $(document).ready(function() {
43
   
44
     var relativeLocation = springfox.baseUrl();
45
 
46
@@ -39,15 +43,29 @@ $(function() {
47
 
48
     $.getJSON(relativeLocation + "/swagger-resources", function(data) {
49
 
50
-      var $urlDropdown = $('#select_baseUrl');
51
-      $urlDropdown.empty();
52
+      var $menulist = $('#select_baseUrl');
53
+      $menulist.empty();
54
       $.each(data, function(i, resource) {
55
-        var option = $('<option></option>')
56
-            .attr("value", maybePrefix(resource.location, relativeLocation))
57
-            .text(resource.name + " (" + resource.location + ")");
58
-        $urlDropdown.append(option);
59
+         //  <li id="menu_Generic_REST_API"><a href="?group=Generic+REST+API">Generic REST API</a></li>
60
+        var id = menuItemId(resource.name);
61
+        var link = $('<a></a>')
62
+                .attr("href", maybePrefix(resource.location, relativeLocation))
63
+                .text(resource.name);
64
+        var option = $('<li></li>').attr("id", id).append(link);
65
+        $menulist.append(option);
66
+      });
67
+      $('#select_baseUrl a').click(function(event) {
68
+          event.preventDefault()
69
+          window.swaggerUi.headerView.trigger(
70
+                  'update-swagger-ui', 
71
+                  {url: $(event.target).attr('href')}
72
+          );
73
       });
74
-      $urlDropdown.change();
75
+      
76
+      var initialGroup = getUrlParam('group');
77
+      if(initialGroup) {
78
+          $('#' + menuItemId(initialGroup) + " a").click();
79
+      }
80
     });
81
 
82
   });

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)