remove ui-router dependancy

This commit is contained in:
Mo Bitar
2017-03-01 18:31:59 -06:00
parent 5169e3f0ee
commit f54c7ea5cf
6 changed files with 25 additions and 44 deletions

View File

@@ -83,7 +83,6 @@ module.exports = function(grunt) {
lib: {
src: [
'vendor/assets/bower_components/angular/angular.js',
'vendor/assets/bower_components/angular-ui-router/release/angular-ui-router.js',
'vendor/assets/bower_components/lodash/dist/lodash.min.js',
'vendor/assets/javascripts/crypto/*.js'
],

View File

@@ -13,6 +13,4 @@ if(!IEOrEdge && (window.crypto && window.crypto.subtle)) {
Neeto.crypto = new SNCryptoJS();
}
angular.module('app.frontend', [
'ui.router'
])
angular.module('app.frontend', [])

View File

@@ -1,10 +1,18 @@
angular.module('app.frontend')
.controller('HomeCtrl', function ($scope, $stateParams, $rootScope, $timeout, modelManager, syncManager, authManager) {
.controller('HomeCtrl', function ($scope, $location, $rootScope, $timeout, modelManager, syncManager, authManager) {
function urlParam(key) {
return $location.search()[key];
}
function autoSignInFromParams() {
var server = urlParam("server");
var email = urlParam("email");
var pw = urlParam("pw");
if(!authManager.offline()) {
// check if current account
if(syncManager.serverURL == $stateParams.server && authManager.user.email == $stateParams.email) {
if(syncManager.serverURL === server && authManager.user.email === email) {
// already signed in, return
return;
} else {
@@ -14,13 +22,13 @@ angular.module('app.frontend')
})
}
} else {
authManager.login($stateParams.server, $stateParams.email, $stateParams.pw, function(response){
authManager.login(server, email, pw, function(response){
window.location.reload();
})
}
}
if($stateParams.server && $stateParams.email) {
if(urlParam("server")) {
autoSignInFromParams();
}

View File

@@ -1,39 +1,16 @@
angular.module('app.frontend')
.config(function ($stateProvider, $urlRouterProvider, $locationProvider) {
.config(function ($locationProvider) {
$stateProvider
.state('base', {
abstract: true,
})
.state('home', {
url: '/?server&email&pw',
parent: 'base',
views: {
'content@' : {
templateUrl: 'frontend/home.html',
controller: 'HomeCtrl'
}
}
})
// Default fall back route
$urlRouterProvider.otherwise(function($injector, $location){
var state = $injector.get('$state');
state.go('home');
return $location.path();
});
var runningInElectron = window && window.process && window.process.type && window.process.versions["electron"];
if(!runningInElectron) {
if (window.history && window.history.pushState) {
$locationProvider.html5Mode({
enabled: true,
requireBase: false
});
}
} else {
$locationProvider.html5Mode(false);
var runningInElectron = window && window.process && window.process.type && window.process.versions["electron"];
if(!runningInElectron) {
if (window.history && window.history.pushState) {
$locationProvider.html5Mode({
enabled: true,
requireBase: false
});
}
} else {
$locationProvider.html5Mode(false);
}
});

View File

@@ -38,7 +38,7 @@
</head>
<body>
<div ui-view="content"></div>
<div ng-controller="HomeCtrl" ng-include="'frontend/home.html'"></div>
</body>
</html>

View File

@@ -8,7 +8,6 @@
"name": "bower-rails generated vendor assets",
"dependencies": {
"angular": "1.6.1",
"angular-ui-router": "^0.3.2",
"lodash" : "^4.17.4"
},
"resolutions": {