summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authormanzerbredes <loic.guegan_secondary@yahoo.fr>2016-02-05 19:35:38 +0100
committermanzerbredes <loic.guegan_secondary@yahoo.fr>2016-02-05 19:35:38 +0100
commitcca5df968e3598b07ee81c1f7f2680f5b9120ec3 (patch)
tree4c8d236f4a49b4daab91ced8b78f5c407e7a8f39 /client
parenta16df328c05b3ac005a3c05237a069786b8d5d6f (diff)
Add sharedProfile service
Diffstat (limited to 'client')
-rw-r--r--client/index.html6
-rw-r--r--client/js/app.js5
-rw-r--r--client/js/controllers/login.js19
-rw-r--r--client/js/controllers/status.js24
-rw-r--r--client/js/requests/identity.js2
-rw-r--r--client/js/services/sharedProfile.js11
-rw-r--r--client/partials/login.html2
-rw-r--r--client/partials/nav.html4
8 files changed, 41 insertions, 32 deletions
diff --git a/client/index.html b/client/index.html
index a4845e8..013b1b4 100644
--- a/client/index.html
+++ b/client/index.html
@@ -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>
-
+
+
diff --git a/client/js/app.js b/client/js/app.js
index 0e9c423..96997eb 100644
--- a/client/js/app.js
+++ b/client/js/app.js
@@ -15,4 +15,7 @@ mainApp.config(['$routeProvider', function($routeProvider){
}).otherwise({
redirectTo: '/home'
});
-}]); \ No newline at end of file
+}]);
+
+
+
diff --git a/client/js/controllers/login.js b/client/js/controllers/login.js
index 07f1d19..3447ab1 100644
--- a/client/js/controllers/login.js
+++ b/client/js/controllers/login.js
@@ -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();
});
-
+
});
-});
+}]);
diff --git a/client/js/controllers/status.js b/client/js/controllers/status.js
index 42a54d4..4ffdb6b 100644
--- a/client/js/controllers/status.js
+++ b/client/js/controllers/status.js
@@ -4,25 +4,11 @@
-mainApp.controller('statusCtrl', function ($scope,$interval,$sce)
-{
- $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);*/
-
+mainApp.controller('statusCtrl', ['$scope','sharedProfile', function ($scope, sharedProfile)
+{
+ $scope.profile=sharedProfile;
+
-
-}); \ No newline at end of file
+}]); \ No newline at end of file
diff --git a/client/js/requests/identity.js b/client/js/requests/identity.js
index 59bbcf2..7a08714 100644
--- a/client/js/requests/identity.js
+++ b/client/js/requests/identity.js
@@ -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',
diff --git a/client/js/services/sharedProfile.js b/client/js/services/sharedProfile.js
new file mode 100644
index 0000000..2a5ab83
--- /dev/null
+++ b/client/js/services/sharedProfile.js
@@ -0,0 +1,11 @@
+
+
+
+mainApp.factory('sharedProfile',[function(){
+ var profile={};
+
+ profile.username="None";
+ profile.projectname="None";
+
+ return profile;
+}]); \ No newline at end of file
diff --git a/client/partials/login.html b/client/partials/login.html
index aa974ab..e0ce876 100644
--- a/client/partials/login.html
+++ b/client/partials/login.html
@@ -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>
diff --git a/client/partials/nav.html b/client/partials/nav.html
index f412597..786c53b 100644
--- a/client/partials/nav.html
+++ b/client/partials/nav.html
@@ -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>-->