Merge branch 'master' of https://github.com/sagidayan/SE-Hub into UI

This commit is contained in:
Matan Bar Yosef 2015-06-17 22:13:40 +03:00
commit 69ad2028b8
8 changed files with 189 additions and 78 deletions

View file

@ -52,10 +52,6 @@ app.register_blueprint(project_routes)
auto = Autodoc(app)
@app.errorhandler(404)
def page_not_found(e):
return app.send_static_file('views/404/index.html')
@app.route('/')
def wellcomePage():
return app.send_static_file('index.html')

View file

@ -79,7 +79,6 @@ def create_campus(token):
except Exception:
return bad_request()
send_create_campus_request(user.email, user.name, campus.title)
notify_se_hub_campus_request(campus, campus.title)
return ok()

View file

@ -25,7 +25,7 @@ from SE_API.Respones_Utils import *
user_routes = Blueprint("user_routes", __name__)
auto = Autodoc()
@user_routes.route('/api/users/getUserByToken/', defaults={'token': None})
@user_routes.route('/api/users/getUserByToken/<string:token>', methods=["GET"])
@auto.doc()
def getUserByToken(token):
@ -59,6 +59,9 @@ def getUserByToken(token):
<br>
403 - No User Found
"""
if token is None:
return no_content("Token Is Empty, No User Found")
query = User.all()
query.filter("seToken =", token)

View file

@ -1,78 +1,89 @@
angular.module('SeHub')
.controller('mainController', ['$scope', '$rootScope', 'apiService', '$cookies', '$location', function($scope, $rootScope, apiService, $cookies, $location) {
.controller('mainController', ['$scope', '$rootScope', 'dataService','apiService', '$cookies', '$cookieStore', '$location', '$window',
var token = $cookies['com.sehub.www'];
function($scope, $rootScope, dataService, apiService, $cookies, $cookieStore, $location, $window) {
$scope.loadingData = true;
$scope.isInRegisterMode = false;
var token = $cookies['com.sehub.www'];
apiService.getUserByToken(token).success(function(data) {
if (data.message == 'No User Found') {
console.error("No User Found!");
}
$scope.loadingData = false;
$scope.user = data;
console.log(data);
if ($scope.user.isFirstLogin) {
$scope.menuObj = {};
$scope.isInRegisterMode = true;
$scope.loadingData = false;
$location.path('/register')
} else {
$location.path('/home')
}
$scope.loadingData = true;
$scope.isInRegisterMode = false;
})
$scope.menuItems = [{
"title": "Home",
"icon": "fa fa-home",
"style": "selected",
"route": "/home"
}, {
"title": "My Campuses",
"icon": "fa fa-university",
"style": "",
"route": "/campuses"
}, {
"title": "My Classes",
"icon": "fa fa-graduation-cap",
"style": "",
"route": "/campuses"
}, {
"title": "My Projects",
"icon": "fa fa-cube",
"style": "",
"route": "/campuses"
}, {
"title": "Tasks",
"icon": "fa fa-clipboard",
"style": "",
"route": "/campuses"
}, {
"title": "Settings",
"icon": "fa fa-cogs",
"style": "",
"route": "/Settings"
}, {
"title": "Log Out",
"icon": "fa fa-power-off",
"style": "",
"route": "/logout"
}];
$scope.menuClicked = function(item){
var route = ""
for (var i = $scope.menuItems.length - 1; i >= 0; i--) {
if($scope.menuItems[i].title === item.title){
$scope.menuItems[i].style="selected";
route = $scope.menuItems[i].route;
}else{
$scope.menuItems[i].style = "";
apiService.getUserByToken(token).success(function(data) {
if (data.message == 'No User Found') {
console.error("No User Found!");
}
};
$location.path(route);
$scope.loadingData = false;
$scope.user = data;
dataService.initService($scope); //Start Data Sync Service (For User)
console.log(data);
if ($scope.user.isFirstLogin) {
$scope.menuObj = {};
$scope.isInRegisterMode = true;
$scope.loadingData = false;
$location.path('/register')
} else {
$location.path('/home')
}
});
$scope.menuItems = [{
"title": "Dash Board",
"icon": "fa fa-tachometer",
"style": "selected",
"route": "/home"
}, {
"title": "My Campuses",
"icon": "fa fa-university",
"style": "",
"route": "/campuses"
}, {
"title": "My Classes",
"icon": "fa fa-graduation-cap",
"style": "",
"route": "/campuses"
}, {
"title": "My Projects",
"icon": "fa fa-cube",
"style": "",
"route": "/campuses"
}, {
"title": "Tasks",
"icon": "fa fa-clipboard",
"style": "",
"route": "/campuses"
}, {
"title": "Settings",
"icon": "fa fa-cogs",
"style": "",
"route": "/Settings"
}, {
"title": "Log Out",
"icon": "fa fa-power-off",
"style": "",
"route": "/logout"
}];
$scope.menuClicked = function(item) {
var route = ""
if (item.title == "Log Out") {
console.info('Logging Out!');
$cookieStore.remove('com.sehub.www');
$window.location.href = 'http://se-hub.appspot.com'; // Reference to 'welcome' page
}
for (var i = $scope.menuItems.length - 1; i >= 0; i--) {
if ($scope.menuItems[i].title === item.title) {
$scope.menuItems[i].style = "selected";
route = $scope.menuItems[i].route;
} else {
$scope.menuItems[i].style = "";
}
};
$location.path(route);
}
}
}]);
]);

View file

@ -1,5 +1,6 @@
angular.module('SeHub')
.controller('settingsController', ['$scope', '$rootScope', 'apiService', '$cookies', '$location', function($scope, $rootScope, apiService, $cookies, $location) {
.controller('settingsController', ['$scope', '$rootScope', 'dataService','apiService', '$cookies', '$location',
function($scope, $rootScope, dataService ,apiService, $cookies, $location) {
var token = $cookies['com.sehub.www'];
@ -24,7 +25,33 @@ angular.module('SeHub')
});
$scope.isEditMode = false;
$scope.profileMode = "Edit Profile";
$scope.profileModeIcon = "fa fa-pencil";
$scope.changeProfileMode = function() {
$scope.isEditMode = !$scope.isEditMode;
if ($scope.isEditMode) {
$scope.profileMode = "Save Profile";
$scope.profileModeIcon = "fa fa-floppy-o";
} else {
dataService.userBrodcast($scope.user);
$scope.profileMode = "Edit Profile";
$scope.profileModeIcon = "fa fa-pencil";
}
}
// {
// name: ";"
// isLecturer: false
// email: "sagidayan@gmail.com"
// username: "sagidayan"
// seToken: "76cd4178-94dd-4cb4-b464-111d2239e567"
// isFirstLogin: true
// campuses_id_list: [0]
// classes_id_list: [0]
// avatar_url: "https://avatars.githubusercontent.com/u/2984053?v=3"
// }
}]);

View file

@ -0,0 +1,21 @@
var DEBUG = true;
angular.module('seHub.services').
factory('dataService', ['$http', function($http) {
var scope = null;
return {
initService: function(mainScope) {
// this.token = user.seToken;
// this.user = user;
scope = mainScope;
},
userBrodcast: function(user) {
scope.user = JSON.parse(JSON.stringify(user));
}
};
}]);

View file

@ -81,6 +81,7 @@
<!-- Services -->
<script src="templates/js/services/apiService.js"></script>
<script src="templates/js/services/dataService.js"></script>
<!-- Controllers -->
<script src="templates/js/controllers/mainController.js"></script>

View file

@ -5,6 +5,59 @@
<md-content layout-padding>
<md-card layout-padding>
<h1><i class="fa fa-cogs"></i> {{title}}</h1>
<div layout="row">
<div>
<md-card layout-padding>
<div id="profile" layout="column">
<div class="user-box" layout="row">
<div>
<img ng-src="{{user.avatar_url}}" alt="" style="width:20%">
</div>
<div flex="70%">
<md-button class="md-raised" ng-click="changeProfileMode()">
<i ng-class="profileModeIcon"></i> {{profileMode}}
</md-button>
</div>
</div>
</div>
<div layout="column" ng-if="!isEditMode">
<div>
<h2>{{user.name}}</h2>
</div>
<div>
Email: {{user.email}}
</div>
<div>
I Am a: {{(user.isLecturer) ? "Lecturer" : "Student"}}
</div>
</div>
<!-- Starting Edit Mode Div -->
<div layout="column" ng-if="isEditMode">
<div>
<md-input-container>
<label>Full Name</label>
<input ng-model="user.name">
</md-input-container>
</div>
<div>
<md-input-container>
<label>Email</label>
<input ng-model="user.email">
</md-input-container>
</div>
<div>
<md-switch ng-model="user.isLecturer" aria-label="Switch 1">
I Am a: {{(user.isLecturer) ? "Lecturer" : "Student"}}
</md-switch>
</div>
</div>
</md-card>
</div>
</div>
</md-card>
</md-content>
</div>