This commit is contained in:
Loic GUEGAN 2016-04-16 22:06:18 +02:00
parent a3ff4d243e
commit 21b68f1da1
3 changed files with 77 additions and 78 deletions

View file

@ -1,19 +1,19 @@
<head> <head>
<script src="../vendors/angularjs/angular.min.js"></script> <script src="../vendors/angularjs/angular.min.js"></script>
<script src="../vendors/angularjs/angular-route.min.js"></script> <script src="../vendors/angularjs/angular-route.min.js"></script>
<script src="../vendors/angularjs/angular-sanitize.min.js"></script> <script src="../vendors/angularjs/angular-sanitize.min.js"></script>
<script src="../vendors/angularjs/angular-cookies.min.js"></script> <script src="../vendors/angularjs/angular-cookies.min.js"></script>
<script src="../js/services/Test.js"></script> <script src="../js/services/Test.js"></script>
<script src="../js/app.js"></script> <script src="../js/app.js"></script>
</head> </head>
<body ng-app="mainApp"> <body ng-app="mainApp">
<div ng-controller="hassan"> <div ng-controller="hassan">
<ul> <ul>
<li ng-repeat="person in persons"> <li ng-repeat="person in persons">
{{person.Name + ' : ' + person.Age}} {{person.Name + ' : ' + person.Age}}
</li> </li>
</ul> </ul>
</div> </div>
</body> </body>

View file

@ -11,27 +11,27 @@
<link rel="stylesheet" href="./css/style.css"> <link rel="stylesheet" href="./css/style.css">
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]--> <![endif]-->
</head> </head>
<body> <body>
<!-- Overlay --> <!-- Overlay -->
<div ng-include="'./partials/login.html'"></div> <div ng-include="'./partials/login.html'"></div>
<div ng-include="'./partials/home/machineDetails.html'"></div> <div ng-include="'./partials/home/machineDetails.html'"></div>
<div ng-include="'./partials/loading.html'"></div> <div ng-include="'./partials/loading.html'"></div>
<div ng-include="'./partials/image/upload.html'"></div> <div ng-include="'./partials/image/upload.html'"></div>
<!-- MAIN GRID --> <!-- MAIN GRID -->
<div class="container-lg"> <div class="container-lg">
<!-- Status bar --> <!-- Status bar -->
<div class="row" ng-controller="statusCtrl"> <div class="row" ng-controller="statusCtrl">
<div class="col-lg-12"> <div class="col-lg-12">
<!-- Status bar --> <!-- Status bar -->
<div ng-include="'./partials/status.html'"></div> <div ng-include="'./partials/status.html'"></div>
</div> </div>
</div> </div>
@ -57,45 +57,45 @@
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</body> </body>
<!-- Include JQuery --> <!-- Include JQuery -->
<script src="./vendors/jquery/jquery-2.2.0.min.js"></script> <script src="./vendors/jquery/jquery-2.2.0.min.js"></script>
<script src="./vendors/jquery/dmuploader.min.js"></script> <script src="./vendors/jquery/dmuploader.min.js"></script>
<!-- Include Bootstrap --> <!-- Include Bootstrap -->
<script src="./vendors/bootstrap/js/bootstrap.min.js"></script> <script src="./vendors/bootstrap/js/bootstrap.min.js"></script>
<!-- Include AngularJS and dependencies--> <!-- Include AngularJS and dependencies-->
<script src="./vendors/angularjs/angular.min.js"></script> <script src="./vendors/angularjs/angular.min.js"></script>
<script src="./vendors/angularjs/angular-route.min.js"></script> <script src="./vendors/angularjs/angular-route.min.js"></script>
<script src="./vendors/angularjs/angular-sanitize.min.js"></script> <script src="./vendors/angularjs/angular-sanitize.min.js"></script>
<script src="./vendors/angularjs/angular-cookies.min.js"></script> <script src="./vendors/angularjs/angular-cookies.min.js"></script>
<script src="./vendors/angularjs/angular-upload.min.js"></script> <script src="./vendors/angularjs/angular-upload.min.js"></script>
<script src="./js/app.js"></script> <script src="./js/app.js"></script>
<!-- Include services --> <!-- Include services -->
<script src="./js/services/Identity.js"></script> <script src="./js/services/Identity.js"></script>
<script src="./js/services/Image.js"></script> <script src="./js/services/Image.js"></script>
<script src="./js/services/Compute.js"></script> <script src="./js/services/Compute.js"></script>
<script src="./js/services/Loading.js"></script> <script src="./js/services/Loading.js"></script>
<!-- Include controller --> <!-- Include controller -->
<script src="./js/controllers/login.js"></script> <script src="./js/controllers/login.js"></script>
<script src="./js/controllers/status.js"></script> <script src="./js/controllers/status.js"></script>
<script src="./js/controllers/home/home.js"></script> <script src="./js/controllers/home/home.js"></script>
<script src="./js/controllers/home/machineDetails.js"></script> <script src="./js/controllers/home/machineDetails.js"></script>
<script src="./js/controllers/network/network.js"></script> <script src="./js/controllers/network/network.js"></script>
<script src="./js/controllers/image/image.js"></script> <script src="./js/controllers/image/image.js"></script>
<script src="./js/controllers/image/upload.js"></script> <script src="./js/controllers/image/upload.js"></script>

View file

@ -5,62 +5,61 @@
* @param {$sce} $sce The $sce angular service * @param {$sce} $sce The $sce angular service
* @param {$http} $http The $http angular service * @param {$http} $http The $http angular service
* @param {Identity} The Identity service * @param {Identity} The Identity service
*/ */
mainApp.controller('loginCtrl', ['$scope','$sce','Identity', function ($scope,$sce, Identity) mainApp.controller('loginCtrl', ['$scope', '$sce', 'Identity', function ($scope, $sce, Identity)
{ {
// Check for login and define default states // Check for login and define default states
if(!Identity.isAlreadyLogin()){ if (!Identity.isAlreadyLogin()) {
$('#loginModal').modal({backdrop: 'static', keyboard: false}); $('#loginModal').modal({backdrop: 'static', keyboard: false});
} }
// Manager logout event // Manager logout event
$scope.$on('logoutEvent', function(){ $scope.$on('logoutEvent', function () {
$('#loginModal').modal({backdrop: 'static', keyboard: false}); $('#loginModal').modal({backdrop: 'static', keyboard: false});
}); });
// Hide loading button and message alert
$('#loadingLoginButton').hide();
$('#failedToLoginAlert').hide();
// Hide loading button and message alert
// Defined function for login $('#loadingLoginButton').hide();
$scope.loginAction=function(){
// Begin login state for template
$('#loginButton').hide();
$('#loadingLoginButton').show();
$('#failedToLoginAlert').hide(); $('#failedToLoginAlert').hide();
// Get data from templates
var username=$("#loginFormUsername").val();
var password=$("#loginFormPassword").val();
var projectname=$("#loginFormProjectname").val();
// Function to call to handle result // Defined function for login
var responseCallback=function(response){ $scope.loginAction = function () {
if(response.status!==0){ // Begin login state for template
// Set reason of fail $('#loginButton').hide();
$scope.failReason=response.failReason; $('#loadingLoginButton').show();
$('#failedToLoginAlert').hide();
// Display the error // Get data from templates
$('#failedToLoginAlert').show(); var username = $("#loginFormUsername").val();
} var password = $("#loginFormPassword").val();
else { var projectname = $("#loginFormProjectname").val();
// Else the user is online !
$('#loginModal').modal('hide'); // Function to call to handle result
var responseCallback = function (response) {
if (response.status !== 0) {
// Set reason of fail
$scope.failReason = response.failReason;
// Display the error
$('#failedToLoginAlert').show();
} else {
// Else the user is online !
$('#loginModal').modal('hide');
}
// Reset button state
$('#loginButton').show();
$('#loadingLoginButton').hide();
} }
// Reset button state // Try to login
$('#loginButton').show(); Identity.login(username, password, projectname, responseCallback);
$('#loadingLoginButton').hide(); };
}
}]);
// Try to login
Identity.login(username, password, projectname, responseCallback);
};
}]);