Blame view

app/views/general/documentation.phtml 6.74 KB
15479603   Alex Savenko   initialize
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
  
  <!DOCTYPE html>
  <html lang="en">
  <head>
      <meta charset="utf-8">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <meta name="viewport" content="width=device-width, initial-scale=1">
  
      <title><?php echo $title ?></title>
  
      <!-- Bootstrap core CSS -->
      <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
  
      <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
      <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
      <![endif]-->
  </head>
  
  <body ng-app="app" ng-controller="AppController as vm">
  
  <div class="container">
  
      <h1><?php echo $title ?></h1>
ec2de8a1   Alex Savenko   docs
26
      <p class="lead">Документация</p>
15479603   Alex Savenko   initialize
27
  
ec2de8a1   Alex Savenko   docs
28
      <h2>Коллекции</h2>
15479603   Alex Savenko   initialize
29
30
31
32
33
34
35
36
37
  
      <div ng-repeat="collection in vm.documentation.collections">
  
          <div class="panel panel-primary">
              <div class="panel-heading">
                  {{ collection.name || collection.prefix }}
              </div>
              <table class="table table-bordered">
                  <tr ng-show="collection.description">
ec2de8a1   Alex Savenko   docs
38
                      <th>Описание</th>
15479603   Alex Savenko   initialize
39
40
41
                      <td>{{ collection.description }}</td>
                  </tr>
                  <tr>
ec2de8a1   Alex Savenko   docs
42
                      <th>Префикс</th>
15479603   Alex Savenko   initialize
43
44
45
                      <td>{{ collection.prefix }}</td>
                  </tr>
                  <tr ng-show="collection.fields">
ec2de8a1   Alex Savenko   docs
46
                      <th>Поля</th>
15479603   Alex Savenko   initialize
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
                      <td>
                          <table class="table table-bordered">
                              <tr ng-repeat="(field, dataType) in collection.fields">
                                  <th>
                                      {{ field }}
                                  </th>
                                  <td>
                                      <div class="label label-primary">{{ dataType | dataType }}</div>
                                  </td>
                              </tr>
                          </table>
                      </td>
                  </tr>
              </table>
              <div class="panel-footer">
15479603   Alex Savenko   initialize
62
63
64
65
66
67
                  <div class="panel panel-primary" ng-repeat="endpoint in collection.endpoints">
                      <div class="panel-heading">
                          <span ng-bind-html="endpoint.httpMethod | method"></span> {{ collection.prefix + endpoint.path }}
                      </div>
                      <table class="table table-bordered">
                          <tr ng-show="endpoint.description">
ec2de8a1   Alex Savenko   docs
68
                              <th>Описание</th>
15479603   Alex Savenko   initialize
69
70
71
                              <th>{{ endpoint.description }}</th>
                          </tr>
                          <tr>
ec2de8a1   Alex Savenko   docs
72
                              <th>URL</th>
15479603   Alex Savenko   initialize
73
74
75
76
77
78
                              <td>
                                  <a ng-href="{{ vm.documentation.basePath + collection.prefix + endpoint.path }}" target="_blank">
                                      {{ vm.documentation.basePath + collection.prefix + endpoint.path }}
                                  </a>
                              </td>
                          </tr>
ec2de8a1   Alex Savenko   docs
79
80
81
82
                          <tr ng-show="endpoint.paramsDescription">
                              <th>Описание параметров</th>
                              <th><pre style="font-weight: normal;">{{ endpoint.paramsDescription | json }}</pre></th>
                          </tr>
fc76b396   Alex Savenko   docs example requ...
83
                          <tr ng-show="endpoint.exampleRequest">
ec2de8a1   Alex Savenko   docs
84
                              <th>Пример запроса</th>
76b75f99   Alex Savenko   docs
85
86
                              <th><pre style="font-weight: normal;">{{ endpoint.exampleRequest | json }}</pre></th>
                          </tr>
15479603   Alex Savenko   initialize
87
                          <tr ng-show="endpoint.exampleResponse">
ec2de8a1   Alex Savenko   docs
88
                              <th>Пример ответа</th>
15479603   Alex Savenko   initialize
89
90
91
                              <th><pre style="font-weight: normal;">{{ endpoint.exampleResponse | json }}</pre></th>
                          </tr>
                          <tr>
ec2de8a1   Alex Savenko   docs
92
                              <th>Доступ</th>
15479603   Alex Savenko   initialize
93
94
95
96
97
98
99
100
101
102
103
                              <td>
                                  <div class="label label-primary" ng-repeat="role in endpoint.allowedRoles" style="margin-right: 5px">{{ role }}</div>
                              </td>
                          </tr>
                      </table>
                  </div>
              </div>
          </div>
  
      </div>
  
ec2de8a1   Alex Savenko   docs
104
      <h2>Другие запросы</h2>
15479603   Alex Savenko   initialize
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
  
      <div class="panel panel-default" ng-repeat="route in vm.documentation.routes">
          <div class="panel-heading">
              {{ route.pattern }}
          </div>
      </div>
  
  </div><!-- /.container -->
  
  
  <!-- Bootstrap core JavaScript
  ================================================== -->
  <!-- Placed at the end of the document so the pages load faster -->
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
  <script src="https://code.angularjs.org/1.4.8/angular-sanitize.min.js"></script>
  <script>
      var documentationPath = '<?php echo $documentationPath ?>';
      var app = angular.module('app', [
          'ngSanitize'
      ]);
  
      app.controller('AppController', AppController);
  
      function AppController($http) {
  
          var vm = this;
  
          $http.get(documentationPath).then(function(response) {
              vm.documentation = response.data.documentation;
          });
      }
  
      app.filter('method', function() {
  
          return function(input) {
  
              switch(input) {
                  case 'GET':
                      return '<div class="label label-success">' + input + '</div>';
                  case 'POST':
                      return '<div class="label label-warning">' + input + '</div>';
                  case 'PUT':
                      return '<div class="label label-info">' + input + '</div>';
                  case 'DELETE':
                      return '<div class="label label-danger">' + input + '</div>';
                  default:
                      return null;
              }
          }
      });
  
      app.filter('dataType', function() {
  
          return function(input) {
  
              switch(input) {
                  case 1:
                      return 'Integer';
                  case 2:
                      return 'Float';
                  case 3:
                      return 'Double';
                  case 4:
                      return 'Boolean';
                  case 5:
                      return 'String';
                  case 6:
                      return 'Timestamp';
                  case 7:
                      return 'JSON';
                  default:
                      return 'Unknown';
              }
          }
      });
  
  </script>
  
  </body>
  </html>