Add sharedProfile service
This commit is contained in:
parent
a16df328c0
commit
cca5df968e
8 changed files with 42 additions and 33 deletions
|
@ -71,6 +71,9 @@
|
|||
<script src="./vendors/angularjs/angular-sanitize.min.js"></script>
|
||||
<script src="./js/app.js"></script>
|
||||
|
||||
<!-- Include services -->
|
||||
<script src="./js/services/sharedProfile.js"></script>
|
||||
|
||||
<!-- Include resquest dependencies -->
|
||||
<script src="./js/requests/identity.js"></script>
|
||||
|
||||
|
@ -79,7 +82,8 @@
|
|||
<script src="./js/controllers/status.js"></script>
|
||||
<script src="./js/controllers/home/main.js"></script>
|
||||
<script src="./js/controllers/network/main.js"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -15,4 +15,7 @@ mainApp.config(['$routeProvider', function($routeProvider){
|
|||
}).otherwise({
|
||||
redirectTo: '/home'
|
||||
});
|
||||
}]);
|
||||
}]);
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -3,24 +3,27 @@
|
|||
* Represents a book.
|
||||
* @constructor
|
||||
*/
|
||||
mainApp.controller('loginCtrl', function ($scope,$interval,$sce, $http)
|
||||
mainApp.controller('loginCtrl', ['$scope','$sce','$http', 'sharedProfile', function ($scope,$sce, $http, sharedProfile)
|
||||
{
|
||||
// Define default states
|
||||
$('#loginModal').modal({backdrop: 'static', keyboard: false});
|
||||
$('#loadingLoginButton').hide();
|
||||
$('#failedToLoginAlert').hide();
|
||||
|
||||
|
||||
|
||||
$('#loginButton').click(function(){
|
||||
$('#loginButton').hide();
|
||||
$('#loadingLoginButton').show();
|
||||
$('#failedToLoginAlert').hide();
|
||||
|
||||
var result=identity.request.login($http,$("#loginFormUsername").val(), $("#loginFormProjectname").val(), $("#loginFormPassword").val());
|
||||
var username=$("#loginFormUsername").val();
|
||||
var password=$("#loginFormPassword").val();
|
||||
var projectname=$("#loginFormProjectname").val();
|
||||
|
||||
var result=identity.request.login($http,username, password, projectname);
|
||||
|
||||
|
||||
result.then(function (response){
|
||||
|
||||
// Parser result
|
||||
var requestResultObject=identity.requestParser.parseLoginAnswer(response);
|
||||
|
||||
|
@ -31,21 +34,23 @@ mainApp.controller('loginCtrl', function ($scope,$interval,$sce, $http)
|
|||
}
|
||||
else {
|
||||
$('#loginModal').modal('hide');
|
||||
sharedProfile.username=username;
|
||||
sharedProfile.projectname=projectname;
|
||||
|
||||
}
|
||||
|
||||
// Reset button state
|
||||
$('#loginButton').show();
|
||||
$('#loadingLoginButton').hide();
|
||||
},function(response){
|
||||
|
||||
$('#failedToLoginAlert').show();
|
||||
|
||||
// Reset button state
|
||||
$('#loginButton').show();
|
||||
$('#loadingLoginButton').hide();
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
}]);
|
||||
|
|
|
@ -4,25 +4,11 @@
|
|||
|
||||
|
||||
|
||||
mainApp.controller('statusCtrl', function ($scope,$interval,$sce)
|
||||
|
||||
|
||||
mainApp.controller('statusCtrl', ['$scope','sharedProfile', function ($scope, sharedProfile)
|
||||
{
|
||||
$scope.username="John Doe";
|
||||
$scope.projectname="Web Server";
|
||||
// Update status every 2 seconds
|
||||
/*$interval(function(){
|
||||
var status=identity.fetchStatus();
|
||||
$scope.username=status[1];
|
||||
$scope.lastconnection=status[2];
|
||||
if(status[0] == "1"){
|
||||
$scope.connection=$sce.trustAsHtml("<span style=\"color:green;\">Online</span>");
|
||||
}
|
||||
else{
|
||||
$scope.connection=$sce.trustAsHtml("<span style=\"color:red;\">Offline</span>");
|
||||
}
|
||||
}, 2000);*/
|
||||
|
||||
|
||||
|
||||
$scope.profile=sharedProfile;
|
||||
|
||||
|
||||
|
||||
});
|
||||
}]);
|
|
@ -6,7 +6,7 @@ identity.requestParser = {}; // Parser part
|
|||
|
||||
|
||||
|
||||
identity.request.login=function($http,username, projectname, password){
|
||||
identity.request.login=function($http,username, password,projectname){
|
||||
var requestResultObject={};
|
||||
|
||||
return $http.post('http://localhost.istic-openstack/server/index.php',
|
||||
|
|
11
client/js/services/sharedProfile.js
Normal file
11
client/js/services/sharedProfile.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
|
||||
|
||||
|
||||
mainApp.factory('sharedProfile',[function(){
|
||||
var profile={};
|
||||
|
||||
profile.username="None";
|
||||
profile.projectname="None";
|
||||
|
||||
return profile;
|
||||
}]);
|
|
@ -19,7 +19,7 @@
|
|||
<div class="form-group">
|
||||
<label label-default="" for="loginFormProjectname">Project</label>
|
||||
<input class="form-control" id="loginFormProjectname"
|
||||
placeholder="Project Name" type="password" ng-model="identityFormData.project">
|
||||
placeholder="Project Name" type="text" ng-model="identityFormData.project">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label label-default="" for="loginFormPassword">Password</label>
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
|
||||
<ul class="nav navbar-nav">
|
||||
<li class="nav-divider"></li>
|
||||
<li><a href="#">User : {{ username }}</a></li>
|
||||
<li><a href="#">Project Name : {{ projectname }}</a></li>
|
||||
<li><a href="#">User : {{ profile.username }}</a></li>
|
||||
<li><a href="#">Project Name : {{ profile.projectname }}</a></li>
|
||||
|
||||
<!--<li><a href="#" >Connection : <span ng-bind-html="connection"></span></a></li>-->
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue