From 784b25754c6b168a6c015aa39837c34339c88444 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Thu, 4 Feb 2016 13:20:45 +0100 Subject: [PATCH 1/9] Add error checking, add method handler for login --- client/index.html | 1 + client/js/controllers/login.js | 48 ++++++++++++++++++---------------- client/js/requests/errors.js | 14 ++++++++++ client/js/requests/identity.js | 9 +++++-- client/partials/login.html | 12 ++++----- 5 files changed, 53 insertions(+), 31 deletions(-) create mode 100644 client/js/requests/errors.js diff --git a/client/index.html b/client/index.html index a4845e8..fe53069 100644 --- a/client/index.html +++ b/client/index.html @@ -73,6 +73,7 @@ + diff --git a/client/js/controllers/login.js b/client/js/controllers/login.js index 2f74414..d08a9f2 100644 --- a/client/js/controllers/login.js +++ b/client/js/controllers/login.js @@ -1,8 +1,3 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ /** * Represents a book. @@ -10,30 +5,37 @@ */ mainApp.controller('loginCtrl', function ($scope,$interval,$sce) { - // Define default states - $('#loginModal').modal({backdrop: 'static', keyboard: false}); - $('#loadingLoginButton').hide(); - $('#failedToLoginAlert').hide(); + // Define default states + $('#loginModal').modal({backdrop: 'static', keyboard: false}); + $('#loadingLoginButton').hide(); + $('#failedToLoginAlert').hide(); - $('#loginButton').click(function(){ - $('#loginButton').hide(); - $('#loadingLoginButton').show(); - $('#failedToLoginAlert').hide(); + $('#loginButton').click(function(){ + $('#loginButton').hide(); + $('#loadingLoginButton').show(); + $('#failedToLoginAlert').hide(); - + var result=identity.login($("#loginFormUsername").val(), $("#loginFormProjectname").val(), $("#loginFormPassword").val()); - $interval( - function() - { - $('#failedToLoginAlert').show(); + $interval( + function() + { + // Check for error + if(!errors.checkForLogin(result)){ + $('#failedToLoginAlert').show(); + } + else { + $('#loginModal').modal('hide'); + } + + // Reset button state $('#loginButton').show(); - $('#loadingLoginButton').hide(); - - }, 2000,1); - + $('#loadingLoginButton').hide(); + }, 2000,1); + }); -}) +}); diff --git a/client/js/requests/errors.js b/client/js/requests/errors.js new file mode 100644 index 0000000..cc9389a --- /dev/null +++ b/client/js/requests/errors.js @@ -0,0 +1,14 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + + +var errors={}; + + +errors.checkForLogin=function(result){ + // TODO + return true; +}; \ No newline at end of file diff --git a/client/js/requests/identity.js b/client/js/requests/identity.js index cad1261..61f06ed 100644 --- a/client/js/requests/identity.js +++ b/client/js/requests/identity.js @@ -1,9 +1,14 @@ // Make Namespace -var identity = {} ; - +var identity = {}; +identity.login=function(username, projectname, password){ + + // Todo + + return "tokens"; +}; diff --git a/client/partials/login.html b/client/partials/login.html index 387b075..aa974ab 100644 --- a/client/partials/login.html +++ b/client/partials/login.html @@ -12,18 +12,18 @@