nitweb: replace ngRouter by ui.router
authorAlexandre Terrasa <alexandre@moz-code.org>
Fri, 9 Jun 2017 18:01:24 +0000 (14:01 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Fri, 9 Jun 2017 18:01:24 +0000 (14:01 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

share/nitweb/index.html
share/nitweb/javascripts/docdown.js
share/nitweb/javascripts/entities.js
share/nitweb/javascripts/index.js
share/nitweb/javascripts/nitweb.js
share/nitweb/javascripts/ui.js
share/nitweb/javascripts/users.js

index fe80e63..b9144a6 100644 (file)
@@ -54,7 +54,7 @@
                                </div>
                        </div>
                </nav>
-               <div ng-view></div>
+               <ui-view></ui-view>
 
                <script src='https://code.jquery.com/jquery-1.12.4.min.js'
                        integrity='sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ='
@@ -64,8 +64,7 @@
                        crossorigin='anonymous'></script>
                <script src='https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.5/angular.min.js'>
                </script>
-               <script src='https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.5/angular-route.js'>
-               </script>
+               <script src='http://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.3.1/angular-ui-router.min.js'></script>
                <script src='https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.5/angular-sanitize.js'>
                </script>
                <script src='//cdnjs.cloudflare.com/ajax/libs/angular-loading-bar/0.9.0/loading-bar.min.js'>
index 365b8c9..3a352ac 100644 (file)
@@ -18,7 +18,7 @@
        angular
                .module('docdown', ['model', 'ngSanitize'])
 
-               .controller('DocdownCtrl', ['$routeParams', '$sce', '$scope', '$location', 'DocDown', function($routeParams, $sce, $scope, $location, DocDown) {
+               .controller('DocdownCtrl', ['$sce', '$scope', '$location', 'DocDown', function($sce, $scope, $location, DocDown) {
 
                        this.updateSnippet = function() {
                                this.updateLink();
index e48b40a..8cf648e 100644 (file)
        angular
                .module('entities', ['ngSanitize', 'ui', 'model'])
 
-               .controller('EntityCtrl', ['Model', 'Metrics', 'Feedback', '$routeParams', '$scope', '$sce', function(Model, Metrics, Feedback, $routeParams, $scope, $sce) {
-                       $scope.entityId = $routeParams.id;
+               .controller('EntityCtrl', ['Model', 'Metrics', 'Feedback', '$stateParams', '$scope', '$sce', function(Model, Metrics, Feedback, $stateParams, $scope, $sce) {
+                       $scope.entityId = $stateParams.id;
 
                        this.loadEntityLinearization = function() {
-                               Model.loadEntityLinearization($routeParams.id,
+                               Model.loadEntityLinearization($stateParams.id,
                                        function(data) {
                                                $scope.linearization = data;
                                        }, function(err) {
@@ -31,7 +31,7 @@
                        };
 
                        this.loadEntityDefs = function() {
-                               Model.loadEntityDefs($routeParams.id,
+                               Model.loadEntityDefs($stateParams.id,
                                        function(data) {
                                                $scope.defs = data;
                                        }, function(err) {
@@ -40,7 +40,7 @@
                        };
 
                        this.loadEntityCode = function() {
-                               Model.loadEntityCode($routeParams.id,
+                               Model.loadEntityCode($stateParams.id,
                                        function(data) {
                                                $scope.code = data;
                                        }, function(err) {
@@ -49,7 +49,7 @@
                        };
 
                        this.loadEntityGraph = function(e) {
-                               Model.loadEntityGraph($routeParams.id,
+                               Model.loadEntityGraph($stateParams.id,
                                        function(data) {
                                                $scope.graph = $sce.trustAsHtml(data);
                                        }, function(err) {
@@ -58,7 +58,7 @@
                        };
 
                        this.loadStructuralMetrics = function() {
-                               Metrics.loadStructuralMetrics($routeParams.id,
+                               Metrics.loadStructuralMetrics($stateParams.id,
                                        function(data) {
                                                $scope.metrics = data;
                                        }, function(message, status) {
@@ -66,7 +66,7 @@
                                        });
                        };
 
-                       Model.loadEntity($routeParams.id,
+                       Model.loadEntity($stateParams.id,
                                function(data) {
                                        $scope.mentity = data;
                                }, function(message, status) {
index 534f462..86f9902 100644 (file)
@@ -22,7 +22,7 @@
                        $anchorScroll.yOffset = 80;
                }])
 
-               .controller('IndexCtrl', ['Catalog', '$routeParams', '$sce', '$scope', '$location', '$anchorScroll', function(Catalog, $routeParams, $sce, $scope, $location, $anchorScroll) {
+               .controller('IndexCtrl', ['Catalog', '$sce', '$scope', '$location', '$anchorScroll', function(Catalog, $sce, $scope, $location, $anchorScroll) {
                        this.loadHighlighted = function() {
                                Catalog.loadHightlighted(
                                        function(data) {
index 78f0f71..551f558 100644 (file)
  */
 
 (function() {
-       angular.module('nitweb', ['ngRoute', 'ngSanitize', 'angular-loading-bar', 'entities', 'docdown', 'index', 'metrics', 'users', 'grades'])
+       angular.module('nitweb', ['ui.router', 'ngSanitize', 'angular-loading-bar', 'index', 'entities', 'docdown', 'metrics', 'users', 'grades'])
+
        .config(['cfpLoadingBarProvider', function(cfpLoadingBarProvider) {
                cfpLoadingBarProvider.includeSpinner = false;
        }])
-       .config(function($routeProvider, $locationProvider) {
-               $routeProvider
-                       .when('/', {
+       .config(function($stateProvider, $locationProvider) {
+               $stateProvider
+                       .state('index', {
+                               url: '/',
                                templateUrl: 'views/index.html',
                                controller: 'IndexCtrl',
                                controllerAs: 'indexCtrl'
                        })
-                       .when('/user', {
+                       .state('user', {
+                               url: '/user',
                                templateUrl: 'views/user.html',
                                controller: 'UserCtrl',
                                controllerAs: 'userCtrl'
                        })
-                       .when('/docdown', {
+                       .state('docdown', {
+                               url: '/docdown',
                                templateUrl: 'views/docdown.html',
                                controller: 'DocdownCtrl',
                                controllerAs: 'docdownCtrl'
                        })
-                       .when('/grades', {
+                       .state('grades', {
+                               url: '/grades',
                                templateUrl: 'views/grades.html',
                                controller: 'GradesCtrl',
                                controllerAs: 'gradesCtrl'
                        })
-                       .when('/login', {
+                       .state('login', {
+                               url: '/login',
                                controller : function(){
                                        window.location.replace('/login');
                                },
                            template : "<div></div>"
                        })
-                       .when('/logout', {
+                       .state('logout', {
                                controller : function(){
                                        window.location.replace('/logout');
                                },
                            template : "<div></div>"
                        })
-                       .when('/doc/:id', {
+                       .state('doc', {
+                               url: '/doc/:id',
                                templateUrl: 'views/doc.html',
                                controller: 'EntityCtrl',
                                controllerAs: 'entityCtrl',
-                               reloadOnSearch: false
                        })
-                       .otherwise({
+                       .state({
+                               name: '404',
+                               url: '*path',
                                templateUrl: 'views/error.html'
-                       });
+                       })
                $locationProvider.html5Mode(true);
        })
 
index f6f5eca..218b7e9 100644 (file)
@@ -18,7 +18,7 @@
        angular
                .module('ui', [ 'model' ])
 
-               .controller('SearchCtrl', function(Model, $routeParams, $scope, $location, $document) {
+               .controller('SearchCtrl', function(Model, $scope, $location, $document) {
 
                        $scope.query = '';
 
index bd446b7..7f3a9b4 100644 (file)
@@ -18,7 +18,7 @@
        angular
                .module('users', ['ngSanitize', 'model'])
 
-               .controller('UserCtrl', ['User', '$routeParams', '$scope', function(User, $routeParams, $scope) {
+               .controller('UserCtrl', ['User', '$scope', function(User, $scope) {
                        this.loadUser = function() {
                                User.loadUser(
                                        function(data) {