nitweb: add HTML view for ini commands
authorAlexandre Terrasa <alexandre@moz-code.org>
Wed, 2 May 2018 23:41:26 +0000 (19:41 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Tue, 8 May 2018 19:48:00 +0000 (15:48 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

share/nitweb/javascripts/entities.js
share/nitweb/views/doc/contrib.html [new file with mode: 0644]
share/nitweb/views/doc/entity.html
share/nitweb/views/doc/license.html [new file with mode: 0644]

index 2ca4e04..4b08707 100644 (file)
                                        },
                                        controllerAs: 'vm',
                                })
+                               .state('doc.entity.license', {
+                                       url: '/license',
+                                       templateUrl: 'views/doc/license.html',
+                                       resolve: {
+                                               content: function(Model, $q, $stateParams, $state) {
+                                                       var d = $q.defer();
+                                                       Model.loadEntityLicenseContent($stateParams.id, d.resolve,
+                                                               function() {
+                                                                       $state.go('404', null, { location: false })
+                                                               });
+                                                       return d.promise;
+                                               }
+                                       },
+                                       controller: function(mentity, content) {
+                                               this.mentity = mentity;
+                                               this.content = content;
+                                       },
+                                       controllerAs: 'vm',
+                               })
+                               .state('doc.entity.contrib', {
+                                       url: '/contrib',
+                                       templateUrl: 'views/doc/contrib.html',
+                                       resolve: {
+                                               content: function(Model, $q, $stateParams, $state) {
+                                                       var d = $q.defer();
+                                                       Model.loadEntityContribContent($stateParams.id, d.resolve,
+                                                               function() {
+                                                                       $state.go('404', null, { location: false })
+                                                               });
+                                                       return d.promise;
+                                               }
+                                       },
+                                       controller: function(mentity, content) {
+                                               this.mentity = mentity;
+                                               this.content = content;
+                                       },
+                                       controllerAs: 'vm',
+                               })
                })
 
                /* Model */
                                                .error(cbErr);
                                },
 
+                               loadEntityLicenseContent: function(id, cb, cbErr) {
+                                       $http.get('/api/ini/license-content/' + id)
+                                               .success(cb)
+                                               .error(cbErr);
+                               },
+
+                               loadEntityContribContent: function(id, cb, cbErr) {
+                                       $http.get('/api/ini/contrib-content/' + id)
+                                               .success(cb)
+                                               .error(cbErr);
+                               },
+
+                               loadEntityGraph: function(id, cb, cbErr) {
+                                       $http.get('/api/graph/inheritance/' + id + '?format=svg&cdepth=3')
+                                               .success(cb)
+                                               .error(cbErr);
+                               },
+
                                search: function(q, p, n, cb, cbErr) {
                                        $http.get('/api/search?q=' + q + '&p=' + p + '&l=' + n)
                                                .success(cb)
diff --git a/share/nitweb/views/doc/contrib.html b/share/nitweb/views/doc/contrib.html
new file mode 100644 (file)
index 0000000..05f0477
--- /dev/null
@@ -0,0 +1,7 @@
+<div class='card'>
+       <div class='card-body'>
+
+               <p>Contributing rules from file <code>{{vm.content.file}}</code></p>
+               <pre ng-bind-html='vm.content.content' />
+       </div>
+</div>
index e6b559f..9480512 100644 (file)
                                <span class='glyphicon glyphicon-star'/> Grades
                        </a>
                </li>
+
+               <!-- license -->
+               <li role='presentation' ui-sref-active='active' ng-if='
+                               vm.mentity.class_name == "MPackage"'>
+                       <a ui-sref='.license'>
+                               <span class='glyphicon glyphicon-copyright-mark'/> License
+                       </a>
+               </li>
+
+               <!-- contrib -->
+               <li role='presentation' ui-sref-active='active' ng-if='
+                               vm.mentity.class_name == "MPackage"'>
+                       <a ui-sref='.contrib'>
+                               <span class='glyphicon glyphicon-gift'/> Contributing
+                       </a>
+               </li>
        </ul>
        <br>
        <ui-view />
diff --git a/share/nitweb/views/doc/license.html b/share/nitweb/views/doc/license.html
new file mode 100644 (file)
index 0000000..8644b88
--- /dev/null
@@ -0,0 +1,7 @@
+<div class='card'>
+       <div class='card-body'>
+
+               <p>License from file <code>{{vm.content.file}}</code></p>
+               <pre ng-bind-html='vm.content.content' />
+       </div>
+</div>