Merge branch 'master' of https://github.com/sagidayan/SE-Hub into UI
This commit is contained in:
commit
69ad2028b8
8 changed files with 189 additions and 78 deletions
|
@ -52,10 +52,6 @@ app.register_blueprint(project_routes)
|
||||||
|
|
||||||
auto = Autodoc(app)
|
auto = Autodoc(app)
|
||||||
|
|
||||||
@app.errorhandler(404)
|
|
||||||
def page_not_found(e):
|
|
||||||
return app.send_static_file('views/404/index.html')
|
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def wellcomePage():
|
def wellcomePage():
|
||||||
return app.send_static_file('index.html')
|
return app.send_static_file('index.html')
|
||||||
|
|
|
@ -79,7 +79,6 @@ def create_campus(token):
|
||||||
except Exception:
|
except Exception:
|
||||||
return bad_request()
|
return bad_request()
|
||||||
|
|
||||||
|
|
||||||
send_create_campus_request(user.email, user.name, campus.title)
|
send_create_campus_request(user.email, user.name, campus.title)
|
||||||
notify_se_hub_campus_request(campus, campus.title)
|
notify_se_hub_campus_request(campus, campus.title)
|
||||||
return ok()
|
return ok()
|
||||||
|
|
|
@ -25,7 +25,7 @@ from SE_API.Respones_Utils import *
|
||||||
user_routes = Blueprint("user_routes", __name__)
|
user_routes = Blueprint("user_routes", __name__)
|
||||||
auto = Autodoc()
|
auto = Autodoc()
|
||||||
|
|
||||||
|
@user_routes.route('/api/users/getUserByToken/', defaults={'token': None})
|
||||||
@user_routes.route('/api/users/getUserByToken/<string:token>', methods=["GET"])
|
@user_routes.route('/api/users/getUserByToken/<string:token>', methods=["GET"])
|
||||||
@auto.doc()
|
@auto.doc()
|
||||||
def getUserByToken(token):
|
def getUserByToken(token):
|
||||||
|
@ -59,6 +59,9 @@ def getUserByToken(token):
|
||||||
<br>
|
<br>
|
||||||
403 - No User Found
|
403 - No User Found
|
||||||
"""
|
"""
|
||||||
|
if token is None:
|
||||||
|
return no_content("Token Is Empty, No User Found")
|
||||||
|
|
||||||
query = User.all()
|
query = User.all()
|
||||||
query.filter("seToken =", token)
|
query.filter("seToken =", token)
|
||||||
|
|
||||||
|
|
|
@ -1,78 +1,89 @@
|
||||||
angular.module('SeHub')
|
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;
|
var token = $cookies['com.sehub.www'];
|
||||||
$scope.isInRegisterMode = false;
|
|
||||||
|
|
||||||
apiService.getUserByToken(token).success(function(data) {
|
$scope.loadingData = true;
|
||||||
if (data.message == 'No User Found') {
|
$scope.isInRegisterMode = false;
|
||||||
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')
|
|
||||||
}
|
|
||||||
|
|
||||||
})
|
apiService.getUserByToken(token).success(function(data) {
|
||||||
|
if (data.message == 'No User Found') {
|
||||||
$scope.menuItems = [{
|
console.error("No User Found!");
|
||||||
"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 = "";
|
|
||||||
}
|
}
|
||||||
};
|
$scope.loadingData = false;
|
||||||
$location.path(route);
|
$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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
]);
|
||||||
|
|
||||||
}]);
|
|
|
@ -1,5 +1,6 @@
|
||||||
angular.module('SeHub')
|
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'];
|
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"
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
}]);
|
}]);
|
21
templates/js/services/dataService.js
Normal file
21
templates/js/services/dataService.js
Normal 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));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
}]);
|
|
@ -81,6 +81,7 @@
|
||||||
|
|
||||||
<!-- Services -->
|
<!-- Services -->
|
||||||
<script src="templates/js/services/apiService.js"></script>
|
<script src="templates/js/services/apiService.js"></script>
|
||||||
|
<script src="templates/js/services/dataService.js"></script>
|
||||||
|
|
||||||
<!-- Controllers -->
|
<!-- Controllers -->
|
||||||
<script src="templates/js/controllers/mainController.js"></script>
|
<script src="templates/js/controllers/mainController.js"></script>
|
||||||
|
|
|
@ -5,6 +5,59 @@
|
||||||
<md-content layout-padding>
|
<md-content layout-padding>
|
||||||
<md-card layout-padding>
|
<md-card layout-padding>
|
||||||
<h1><i class="fa fa-cogs"></i> {{title}}</h1>
|
<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-card>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</md-content>
|
</md-content>
|
||||||
</div>
|
</div>
|
Loading…
Reference in a new issue