From: Alexandre Terrasa Date: Wed, 25 Oct 2017 19:03:22 +0000 (-0400) Subject: nitweb: migrate frontend to new json/commands X-Git-Url: http://nitlanguage.org nitweb: migrate frontend to new json/commands Signed-off-by: Alexandre Terrasa --- diff --git a/share/nitweb/directives/entity/card.html b/share/nitweb/directives/entity/card.html index 18675a0..9b295be 100644 --- a/share/nitweb/directives/entity/card.html +++ b/share/nitweb/directives/entity/card.html @@ -6,29 +6,28 @@
- + {{tag}} ,
- +
- +
diff --git a/share/nitweb/directives/entity/defcard.html b/share/nitweb/directives/entity/defcard.html index 2d14d83..cff100d 100644 --- a/share/nitweb/directives/entity/defcard.html +++ b/share/nitweb/directives/entity/defcard.html @@ -19,8 +19,8 @@
-
-			
+			
+			
 		
diff --git a/share/nitweb/directives/entity/link.html b/share/nitweb/directives/entity/link.html index 740ea8b..60b9348 100644 --- a/share/nitweb/directives/entity/link.html +++ b/share/nitweb/directives/entity/link.html @@ -1,3 +1 @@ - - {{mentity.name}} - +{{mentity.name}} diff --git a/share/nitweb/directives/entity/location.html b/share/nitweb/directives/entity/location.html index 05f8ccb..8e058fc 100644 --- a/share/nitweb/directives/entity/location.html +++ b/share/nitweb/directives/entity/location.html @@ -1,4 +1,3 @@ - - {{mentity.location.file}} - :{{mentity.location.line_start}} + + {{vm.loc.file}}:{{vm.loc.line_start}} diff --git a/share/nitweb/directives/entity/signature.html b/share/nitweb/directives/entity/signature.html index f3f2dc6..28de5e7 100644 --- a/share/nitweb/directives/entity/signature.html +++ b/share/nitweb/directives/entity/signature.html @@ -14,7 +14,7 @@ : - , + ,
]
@@ -22,7 +22,7 @@ ( - + {{mparam.name}} diff --git a/share/nitweb/directives/ui/pagination.html b/share/nitweb/directives/ui/pagination.html index 4af87d2..3b7d62d 100644 --- a/share/nitweb/directives/ui/pagination.html +++ b/share/nitweb/directives/ui/pagination.html @@ -1,14 +1,16 @@ diff --git a/share/nitweb/javascripts/catalog.js b/share/nitweb/javascripts/catalog.js index 2667db3..9926712 100644 --- a/share/nitweb/javascripts/catalog.js +++ b/share/nitweb/javascripts/catalog.js @@ -122,8 +122,8 @@ .success(cb) .error(cbErr); }, - packages: function(p, n, cb, cbErr) { - $http.get('/api/catalog/packages?p=' + p + '&n=' + n) + packages: function(p, l, cb, cbErr) { + $http.get('/api/catalog/packages?p=' + p + '&l=' + l) .success(cb) .error(cbErr); }, @@ -137,18 +137,18 @@ .success(cb) .error(cbErr); }, - personMaintaining: function(id, p, n, cb, cbErr) { - $http.get('/api/catalog/person/' + id + '/maintaining?p=' + p + '&n=' + n) + personMaintaining: function(id, p, l, cb, cbErr) { + $http.get('/api/catalog/person/' + id + '/maintaining?p=' + p + '&l=' + l) .success(cb) .error(cbErr); }, - personContributing: function(id, p, n, cb, cbErr) { - $http.get('/api/catalog/person/' + id + '/contributing?p=' + p + '&n=' + n) + personContributing: function(id, p, l, cb, cbErr) { + $http.get('/api/catalog/person/' + id + '/contributing?p=' + p + '&l=' + l) .success(cb) .error(cbErr); }, - tag: function(id, p, n, cb, cbErr) { - $http.get('/api/catalog/tag/' + id + '?p=' + p + '&n=' + n) + tag: function(id, p, l, cb, cbErr) { + $http.get('/api/catalog/tag/' + id + '?p=' + p + '&l=' + l) .success(cb) .error(cbErr); } @@ -162,7 +162,6 @@ vm.packages = packages; vm.tags = tags; vm.stats = stats; - $scope.$on('change-page', function(e, page, limit) { $state.go('catalog', {p: page, l: limit}); }) @@ -175,23 +174,22 @@ vm.contributing = contributing; var p1 = $stateParams.p1 ? $stateParams.p1 : 1; - var n1 = $stateParams.n1 ? $stateParams.n1 : 10; + var l1 = $stateParams.l1 ? $stateParams.l1 : 10; var p2 = $stateParams.p2 ? $stateParams.p2 : 1; - var n2 = $stateParams.n2 ? $stateParams.n2 : 10; + var l2 = $stateParams.l2 ? $stateParams.l2 : 10; $scope.$on('change-page1', function(e, page, limit) { - $state.go('person', {id: $stateParams.id, p1: page, n1: limit, p2: p2, n2: n2}); + $state.go('person', {id: $stateParams.id, p1: page, l1: limit, p2: p2, l2: l2}); }) $scope.$on('change-page2', function(e, page, limit) { - $state.go('person', {id: $stateParams.id, p1: p1, n1: n1, p2: page, n2: limit}); + $state.go('person', {id: $stateParams.id, p1: p1, l1: l1, p2: page, l2: limit}); }) }) .controller('TagCtrl', function($state, $scope, tag) { var vm = this; vm.tag = tag; - $scope.$on('change-page', function(e, page, limit) { $state.go('tag', {id: vm.tag.tag, p: page, l: limit}); }) diff --git a/share/nitweb/javascripts/entities.js b/share/nitweb/javascripts/entities.js index 545e487..2ca4e04 100644 --- a/share/nitweb/javascripts/entities.js +++ b/share/nitweb/javascripts/entities.js @@ -61,11 +61,56 @@ $state.go('404', null, { location: false }) }); return d.promise; + }, + parents: function(Model, $q, $stateParams, $state) { + var d = $q.defer(); + Model.loadEntityParents($stateParams.id, d.resolve, + function() { + $state.go('404', null, { location: false }) + }); + return d.promise; + }, + children: function(Model, $q, $stateParams, $state) { + var d = $q.defer(); + Model.loadEntityChildren($stateParams.id, d.resolve, + function() { + $state.go('404', null, { location: false }) + }); + return d.promise; + }, + intros: function(Model, $q, $stateParams, $state) { + var d = $q.defer(); + Model.loadEntityIntros($stateParams.id, d.resolve, + function() { + $state.go('404', null, { location: false }) + }); + return d.promise; + }, + redefs: function(Model, $q, $stateParams, $state) { + var d = $q.defer(); + Model.loadEntityRedefs($stateParams.id, d.resolve, + function() { + $state.go('404', null, { location: false }) + }); + return d.promise; + }, + meta: function(Model, $q, $stateParams, $state) { + var d = $q.defer(); + Model.loadEntityMeta($stateParams.id, d.resolve, + function() { + $state.go('404', null, { location: false }) + }); + return d.promise; } }, - controller: function(mentity, doc) { + controller: function(mentity, doc, parents, children, intros, redefs, meta) { this.mentity = mentity; this.doc = doc; + this.parents = parents; + this.children = children; + this.intros = intros; + this.redefs = redefs; + this.meta = meta; this.date = function(date) { return new Date(date); @@ -85,18 +130,45 @@ }); return d.promise; }, - inh: function(Model, $q, $stateParams, $state) { + ancestors: function(Model, $q, $stateParams, $state) { var d = $q.defer(); - Model.loadEntityInh($stateParams.id, d.resolve, + Model.loadEntityAncestors($stateParams.id, d.resolve, function() { $state.go('404', null, { location: false }) }); return d.promise; - } + }, + parents: function(Model, $q, $stateParams, $state) { + var d = $q.defer(); + Model.loadEntityParents($stateParams.id, d.resolve, + function() { + $state.go('404', null, { location: false }) + }); + return d.promise; + }, + children: function(Model, $q, $stateParams, $state) { + var d = $q.defer(); + Model.loadEntityChildren($stateParams.id, d.resolve, + function() { + $state.go('404', null, { location: false }) + }); + return d.promise; + }, + descendants: function(Model, $q, $stateParams, $state) { + var d = $q.defer(); + Model.loadEntityDescendants($stateParams.id, d.resolve, + function() { + $state.go('404', null, { location: false }) + }); + return d.promise; + }, }, - controller: function(inh, graph, $sce) { - this.graph = $sce.trustAsHtml(graph); - this.inh = inh; + controller: function(ancestors, parents, children, descendants, graph, $sce) { + this.graph = $sce.trustAsHtml(graph.graph); + this.ancestors = ancestors; + this.parents = parents; + this.children = children; + this.descendants = descendants; }, controllerAs: 'vm', }) @@ -163,7 +235,7 @@ resolve: { lin: function(Model, $q, $stateParams, $state) { var d = $q.defer(); - Model.loadEntityLinearization($stateParams.id, d.resolve, + Model.loadEntityLin($stateParams.id, d.resolve, function() { $state.go('404', null, { location: false }) }); @@ -173,7 +245,7 @@ controller: function(mentity, lin, $scope, $location, $anchorScroll) { var vm = this; vm.focus = $location.hash() ? - $location.hash() : mentity.intro.full_name; + $location.hash() : lin.results[0].full_name; vm.mentity = mentity; vm.linearization = lin; setTimeout(function() { @@ -183,7 +255,7 @@ return $location.hash(); }, function (value) { vm.focus = $location.hash() ? - $location.hash() : mentity.intro.full_name; + $location.hash() : lin.results[0].full_name; $anchorScroll(); }); }, @@ -191,9 +263,20 @@ }) .state('doc.entity.all', { url: '/all', - templateUrl: 'views/doc/all.html', - controller: function(mentity) { + templateUrl: 'views/doc/defs.html', + resolve: { + defs: function(Model, $q, $stateParams, $state) { + var d = $q.defer(); + Model.loadEntityAll($stateParams.id, d.resolve, + function() { + $state.go('404', null, { location: false }) + }); + return d.promise; + } + }, + controller: function(mentity, defs) { this.mentity = mentity; + this.defs = defs; }, controllerAs: 'vm', }) @@ -211,13 +294,13 @@ }, loadEntityDoc: function(id, cb, cbErr) { - $http.get('/api/entity/' + id + '/doc') + $http.get('/api/doc/' + id + '?format=html') .success(cb) .error(cbErr); }, - loadEntityLinearization: function(id, cb, cbErr) { - $http.get('/api/linearization/' + id) + loadEntityLin: function(id, cb, cbErr) { + $http.get('/api/lin/' + id) .success(cb) .error(cbErr); }, @@ -228,25 +311,68 @@ .error(cbErr); }, + loadEntityIntros: function(id, cb, cbErr) { + $http.get('/api/intros/' + id) + .success(cb) + .error(cbErr); + }, + + loadEntityRedefs: function(id, cb, cbErr) { + $http.get('/api/redefs/' + id) + .success(cb) + .error(cbErr); + }, + + loadEntityAll: function(id, cb, cbErr) { + $http.get('/api/all/' + id) + .success(cb) + .error(cbErr); + }, + loadEntityCode: function(id, cb, cbErr) { - $http.get('/api/code/' + id) + $http.get('/api/code/' + id + '?format=html') .success(cb) .error(cbErr); }, - loadEntityGraph: function(id, cb, cbErr) { - $http.get('/api/graph/inheritance/' + id + '?cdepth=3') + loadEntityAncestors: function(id, cb, cbErr) { + $http.get('/api/ancestors/' + id) + .success(cb) + .error(cbErr); + }, + + loadEntityParents: function(id, cb, cbErr) { + $http.get('/api/parents/' + id) + .success(cb) + .error(cbErr); + }, + + loadEntityChildren: function(id, cb, cbErr) { + $http.get('/api/children/' + id) + .success(cb) + .error(cbErr); + }, + + loadEntityDescendants: function(id, cb, cbErr) { + $http.get('/api/descendants/' + id) + .success(cb) + .error(cbErr); + }, + + loadEntityMeta: function(id, cb, cbErr) { + $http.get('/api/meta/' + id) .success(cb) .error(cbErr); }, - loadEntityInh: function(id, cb, cbErr) { - $http.get('/api/inheritance/' + id) + 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 + '&n=' + n) + $http.get('/api/search?q=' + q + '&p=' + p + '&l=' + n) .success(cb) .error(cbErr); } @@ -261,6 +387,7 @@ scope: { mentity: '=' }, + replace: true, templateUrl: '/directives/entity/link.html' }; }) @@ -320,9 +447,13 @@ .directive('entityLocation', function() { return { restrict: 'E', - scope: { - mentity: '=' + replace: true, + scope: {}, + bindToController: { + loc: '=' }, + controller: function() {}, + controllerAs: 'vm', templateUrl: '/directives/entity/location.html' }; }) diff --git a/share/nitweb/javascripts/ui.js b/share/nitweb/javascripts/ui.js index 5327782..e3d13d7 100644 --- a/share/nitweb/javascripts/ui.js +++ b/share/nitweb/javascripts/ui.js @@ -298,6 +298,7 @@ return { restrict: 'E', replace: true, + scope: {}, bindToController: { pagination: '=', suffix: '=?' @@ -305,7 +306,7 @@ controller: function($scope) { var vm = this; - $scope.$watch('pagination.pagination', function(pagination) { + $scope.$watch('vm.pagination', function(pagination) { if(!pagination) return; vm.computePages(pagination); }) @@ -336,7 +337,7 @@ $scope.$emit('change-page' + suffix, page, limit); } }, - controllerAs: 'pagination', + controllerAs: 'vm', templateUrl: 'directives/ui/pagination.html' }; }) diff --git a/share/nitweb/views/catalog/index.html b/share/nitweb/views/catalog/index.html index 2333a0a..c45e0dc 100644 --- a/share/nitweb/views/catalog/index.html +++ b/share/nitweb/views/catalog/index.html @@ -29,7 +29,7 @@
- +
diff --git a/share/nitweb/views/catalog/tag.html b/share/nitweb/views/catalog/tag.html index 6c0a37e..e4bc086 100644 --- a/share/nitweb/views/catalog/tag.html +++ b/share/nitweb/views/catalog/tag.html @@ -1,16 +1,16 @@

{{vm.tag.tag}} - {{vm.tag.packages.total}} packages + {{vm.tag.count}} packages


-
+
- +
-
- +
+
diff --git a/share/nitweb/views/doc/code.html b/share/nitweb/views/doc/code.html index 48f4282..517bf47 100644 --- a/share/nitweb/views/doc/code.html +++ b/share/nitweb/views/doc/code.html @@ -1,6 +1,6 @@
-
-		
+		
+		
 	
diff --git a/share/nitweb/views/doc/defs.html b/share/nitweb/views/doc/defs.html index 7cd0ea2..17d9a92 100644 --- a/share/nitweb/views/doc/defs.html +++ b/share/nitweb/views/doc/defs.html @@ -1,10 +1,13 @@
+ list-entities='vm.defs.results' list-object-filter='{}' /> + list-entities='vm.defs.results' list-object-filter='{}' /> + list-entities='vm.defs.results' list-object-filter='{}' /> + +
diff --git a/share/nitweb/views/doc/doc.html b/share/nitweb/views/doc/doc.html index eadcf37..d29b2cd 100644 --- a/share/nitweb/views/doc/doc.html +++ b/share/nitweb/views/doc/doc.html @@ -7,32 +7,30 @@ }'>
-
+
-
+
No documentation for this entity.
- + - + - + - +
@@ -40,47 +38,47 @@ "hidden": vm.mentity.class_name != "MPackage" }'>
-

+

{{maintainer.name}}

- + - {{vm.mentity.metadata.license}} + {{vm.meta.license}} license
-
+

Links

-
+

Git

    -
  • - {{vm.mentity.metadata.git}} +
  • + {{vm.meta.git}}

  • {{vm.mentity.stats.commits}} commits
  • -
  • Last: {{vm.date(vm.mentity.metadata.last_date) | date: 'medium'}}
  • -
  • First: {{vm.date(vm.mentity.metadata.first_date) | date: 'medium'}}
  • +
  • Last: {{vm.date(vm.meta.last_date) | date: 'medium'}}
  • +
  • First: {{vm.date(vm.meta.first_date) | date: 'medium'}}
@@ -100,31 +98,31 @@
-
+

Tags

- + {{tag}},
-
+

Requirements

- - {{parent.name}}, + + ,
-
+

Clients

- - {{client.name}}, + + ,
-
+

Contributors

    -
  • +
  • {{contributor.name}} diff --git a/share/nitweb/views/doc/graph.html b/share/nitweb/views/doc/graph.html index 2968cce..fdd9668 100644 --- a/share/nitweb/views/doc/graph.html +++ b/share/nitweb/views/doc/graph.html @@ -7,9 +7,9 @@ + list-entities='vm.parents.results' list-object-filter='{}' /> + list-entities='vm.children.results' list-object-filter='{}' />
diff --git a/share/nitweb/views/doc/lin.html b/share/nitweb/views/doc/lin.html index 96d9b82..f99473c 100644 --- a/share/nitweb/views/doc/lin.html +++ b/share/nitweb/views/doc/lin.html @@ -1,6 +1,6 @@