From 8a6f3bf221f6161ead3c8cad59f802913eea0d21 Mon Sep 17 00:00:00 2001 From: nau Date: Sun, 21 Aug 2016 23:24:02 +0200 Subject: [PATCH] signup new user from webapp implemented --- web/controllers.js | 32 ++++++++++++++++++++ web/login.html | 2 +- web/menu.htm | 4 +-- web/signup.html | 75 ++++++++++++++++++++++++++++++++++++++++++++++ web/user.html | 59 ++++++++++++++++++++++++++++++++++++ 5 files changed, 169 insertions(+), 3 deletions(-) create mode 100644 web/signup.html create mode 100644 web/user.html diff --git a/web/controllers.js b/web/controllers.js index 017abdf..07ac72a 100644 --- a/web/controllers.js +++ b/web/controllers.js @@ -1,10 +1,12 @@ + var url="http://localhost:3000/api/"; angular.module('thoughtsApp', []) .controller('ThoughtsController', function( $scope, $http ) { + var thoughtsList = this; if(window.sessionStorage.getItem('thoughtsToken')) { @@ -13,6 +15,11 @@ angular.module('thoughtsApp', []) $scope.userLogged=false; } + $scope.availableAvatars=[ + "img/icons/animals/cat.png", + "img/icons/animals/crab.png", + "img/icons/animals/toucan.png" + ]; $http({ method : "GET", url : url + "thoughts" @@ -22,11 +29,36 @@ angular.module('thoughtsApp', []) $scope.myWelcome = response.statusText; }); + thoughtsList.addTodo = function() { todoList.todos.push({text:todoList.todoText, done:false}); todoList.todoText = ''; }; + $scope.signin = function(){ + ActivateLoadBar(); + + var obj = { + username: $scope.username, + password: $scope.password, + description: $scope.description, + mail: $scope.mail, + avatar: $scope.avatar + }; + $http({ + method : "POST", + url : url + "users", + data: obj + }).then(function mySucces(response) { + toastr.success("Signed in, now login"); + setTimeout(function(){ + window.location="login.html"; + }, 1000); + }, function myError(response) { + toastr.error(response.statusText); + }); + }; + $scope.login = function(){ ActivateLoadBar(); diff --git a/web/login.html b/web/login.html index 849c018..43105b6 100644 --- a/web/login.html +++ b/web/login.html @@ -9,7 +9,7 @@ - Thoughts - new thought + Thoughts - login diff --git a/web/menu.htm b/web/menu.htm index c43b28b..f3e2570 100644 --- a/web/menu.htm +++ b/web/menu.htm @@ -24,8 +24,8 @@ diff --git a/web/signup.html b/web/signup.html new file mode 100644 index 0000000..cb35b9e --- /dev/null +++ b/web/signup.html @@ -0,0 +1,75 @@ + + + + + + + + + + + + Thoughts - signup + + + + + + + +
+ +
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+ + +
+
+ + Cancel + Login + +
+ + + + + + + + + + + + + + + + + + + + diff --git a/web/user.html b/web/user.html new file mode 100644 index 0000000..1048574 --- /dev/null +++ b/web/user.html @@ -0,0 +1,59 @@ + + + + + + + + + + + + Thoughts + + + + + + + +
+ +
+ +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + +