AngularJS: Fixed Scope Issue & more

Starting to work on the mailController
This commit is contained in:
Sagi Dayan 2015-06-15 18:41:44 +03:00
parent 39a5697fd0
commit 73d9a65dab
4 changed files with 42 additions and 16 deletions

View file

@ -32,11 +32,11 @@
<!-- Angular Material Dependencies --> <!-- Angular Material Dependencies -->
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.6/angular.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular-route.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.6/angular-route.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular-animate.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.6/angular-animate.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular-aria.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.6/angular-aria.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular-cookies.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.6/angular-cookies.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angular_material/0.8.3/angular-material.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/angular_material/0.8.3/angular-material.min.js"></script>

View file

@ -14,8 +14,10 @@ welcome.controller('welcomeController', ['$scope', 'apiService', '$cookies', '$w
console.log("Welcome Controller"); console.log("Welcome Controller");
var uid = $cookies['com.sehub.www']; var uid = $cookies['com.sehub.www'];
if(uid) if(uid){
console.info("Session in Place");
$window.location.href = DEBUG ? 'http://localhost:8080/home' : 'http://se-hub.appspot.com/home'; $window.location.href = DEBUG ? 'http://localhost:8080/home' : 'http://se-hub.appspot.com/home';
}
@ -26,8 +28,7 @@ app.config(['$routeProvider', '$locationProvider',
function($routeProvider, $locationProvider) { function($routeProvider, $locationProvider) {
$routeProvider $routeProvider
.when('/', { .when('/', {
templateUrl: 'templates/views/home.html', templateUrl: 'templates/views/home.html'
controller: 'mainController'
}) })
.when('/register', { .when('/register', {
templateUrl: 'templates/views/register.html', templateUrl: 'templates/views/register.html',

View file

@ -1,19 +1,24 @@
angular.module('SeHub') angular.module('SeHub')
.controller('mainController', ['$scope', '$rootScope', 'apiService', '$cookies', '$location', function ($scope, $rootScope, apiService, $cookies, $location) { .controller('mainController', ['$scope', '$rootScope', 'apiService', '$cookies', '$location', function ($scope, $rootScope, apiService, $cookies, $location) {
$rootScope.seToken = $cookies['com.sehub.www']; var token = $cookies['com.sehub.www'];
var token = $rootScope.seToken;
$scope.loadingData = true; $scope.loadingData = true;
$scope.isInRegisterMode = false;
apiService.getUserByToken(token).success(function(data){ apiService.getUserByToken(token).success(function(data){
console.log(data); if(data.message == 'No User Found'){
if(data.message == 'No User Found')
console.error("No User Found!"); console.error("No User Found!");
}
$scope.user = data; $scope.user = data;
$rootScope.user = data; $rootScope.user = data;
if($scope.user.isFirstLogin) if($scope.user.isFirstLogin){
$scope.menuObj = {};
$scope.isInRegisterMode = true;
$scope.loadingData = false;
$location.path('/register') $location.path('/register')
}
}) })
$scope.loadingData = false; $scope.loadingData = false;

View file

@ -8,8 +8,8 @@
<link rel="stylesheet" href="templates/css/theme.css"> <link rel="stylesheet" href="templates/css/theme.css">
<meta name="viewport" content="initial-scale=1, maximum-scale=1" /> <meta name="viewport" content="initial-scale=1, maximum-scale=1" />
</head> </head>
<!-- <body layout="column" ng-controller="RegisterCtrl"> -->
<body layout="column" > <body layout="column" ng-controller="mainController">
<md-toolbar layout="row"> <md-toolbar layout="row">
<button ng-click="toggleSidenav('left')" hide-gt-sm class="menuBtn"> <button ng-click="toggleSidenav('left')" hide-gt-sm class="menuBtn">
<span class="visually-hidden">Menu</span> <span class="visually-hidden">Menu</span>
@ -23,8 +23,28 @@
<md-sidenav layout="column" class="md-sidenav-left md-whiteframe-z2" md-component-id="left" md-is-locked-open="$mdMedia('gt-sm')"> <md-sidenav layout="column" class="md-sidenav-left md-whiteframe-z2" md-component-id="left" md-is-locked-open="$mdMedia('gt-sm')">
<md-content> <md-content>
<center> <center>
<h1>Menu</h1> <h1><i class="fa fa-compass"></i> Menu</h1>
</center> </center>
<div ng-if="loadingData">
<md-progress-circular></md-progress-circular>
</div>
<div ng-if="isInRegisterMode"> <!-- User Needs To Register -->
<md-card layout-padding>
<div layout=-"row">
<div class="spacer"></div>
<div>
<h3>
<i class="fa fa-exclamation-triangle"></i>
</h3>
</div>
<div class="spacer"></div>
</div>
<p>
You Are Currently Not Assigned To Any Campus Nor Course.
Please Fill The Form On your Right Hand Side, and Confirm Your Academic E-Mail.
</p>
</md-card>
</div>
</md-content> </md-content>
</md-sidenav> </md-sidenav>
<div layout="column" flex id="content"> <div layout="column" flex id="content">