Blame view

app/views/general/documentation.phtml 7.15 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
  
5824f1c9   Alex Savenko   add get_report_da...
30
31
32
33
34
35
36
      <div class="list-group">
          <a href="#" class="list-group-item active">
              Анкоры
          </a>
          <a ng-repeat="collection in vm.documentation.collections" href="#{{collection.prefix}}" class="list-group-item">{{collection.name}}</a>
      </div>
  
15479603   Alex Savenko   initialize
37
38
      <div ng-repeat="collection in vm.documentation.collections">
  
5824f1c9   Alex Savenko   add get_report_da...
39
          <div class="panel panel-primary" id="{{collection.prefix}}">
15479603   Alex Savenko   initialize
40
41
42
43
44
              <div class="panel-heading">
                  {{ collection.name || collection.prefix }}
              </div>
              <table class="table table-bordered">
                  <tr ng-show="collection.description">
ec2de8a1   Alex Savenko   docs
45
                      <th>Описание</th>
15479603   Alex Savenko   initialize
46
47
48
                      <td>{{ collection.description }}</td>
                  </tr>
                  <tr>
ec2de8a1   Alex Savenko   docs
49
                      <th>Префикс</th>
15479603   Alex Savenko   initialize
50
51
52
                      <td>{{ collection.prefix }}</td>
                  </tr>
                  <tr ng-show="collection.fields">
ec2de8a1   Alex Savenko   docs
53
                      <th>Поля</th>
15479603   Alex Savenko   initialize
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
                      <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
69
70
71
72
73
74
                  <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
75
                              <th>Описание</th>
15479603   Alex Savenko   initialize
76
77
78
                              <th>{{ endpoint.description }}</th>
                          </tr>
                          <tr>
ec2de8a1   Alex Savenko   docs
79
                              <th>URL</th>
15479603   Alex Savenko   initialize
80
81
82
83
84
85
                              <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
86
87
88
89
                          <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...
90
                          <tr ng-show="endpoint.exampleRequest">
ec2de8a1   Alex Savenko   docs
91
                              <th>Пример запроса</th>
76b75f99   Alex Savenko   docs
92
93
                              <th><pre style="font-weight: normal;">{{ endpoint.exampleRequest | json }}</pre></th>
                          </tr>
15479603   Alex Savenko   initialize
94
                          <tr ng-show="endpoint.exampleResponse">
ec2de8a1   Alex Savenko   docs
95
                              <th>Пример ответа</th>
15479603   Alex Savenko   initialize
96
97
98
                              <th><pre style="font-weight: normal;">{{ endpoint.exampleResponse | json }}</pre></th>
                          </tr>
                          <tr>
ec2de8a1   Alex Savenko   docs
99
                              <th>Доступ</th>
15479603   Alex Savenko   initialize
100
101
102
103
104
105
106
107
108
109
110
                              <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
111
      <h2>Другие запросы</h2>
15479603   Alex Savenko   initialize
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
  
      <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>
365177f8   Alex Savenko   angular sinitize ...
128
129
130
  <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-sanitize/1.4.8/angular-sanitize.min.js"></script>
  <!--<script src="https://code.angularjs.org/1.4.8/angular-sanitize.min.js"></script>-->
  
15479603   Alex Savenko   initialize
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
187
188
189
190
191
192
193
194
195
  <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>