From 4093d8c6f394c1d0c7414adecb9a3537c58fb0b1 Mon Sep 17 00:00:00 2001 From: Jack Foltz Date: Mon, 15 Jan 2018 11:46:49 -0500 Subject: [PATCH] Add UserSvc and UserCtrl --- app/public/panel/controllers/UserCtrl.js | 9 +++++++++ app/public/panel/shimapan-panel.js | 2 +- app/public/services/UserSvc.js | 22 ++++++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 app/public/panel/controllers/UserCtrl.js create mode 100644 app/public/services/UserSvc.js diff --git a/app/public/panel/controllers/UserCtrl.js b/app/public/panel/controllers/UserCtrl.js new file mode 100644 index 0000000..432a8bd --- /dev/null +++ b/app/public/panel/controllers/UserCtrl.js @@ -0,0 +1,9 @@ +var angular = require('angular'); + +angular.module('UserCtrl', ['UserSvc']).controller('UserController', ['$scope', 'UserService', function($scope, UserService) { + $scope.getUsers = function() { + UserService.getAllUsers(function(users) { + $scope.users = users; + }); + }; +}]); \ No newline at end of file diff --git a/app/public/panel/shimapan-panel.js b/app/public/panel/shimapan-panel.js index f756b9a..e92d5fb 100755 --- a/app/public/panel/shimapan-panel.js +++ b/app/public/panel/shimapan-panel.js @@ -1,6 +1,6 @@ var angular = require('angular'); var uirouter = require('angular-ui-router'); -var app = angular.module('shimapan-panel', ['ui.router', 'AuthSvc', 'ApiSvc', 'InviteSvc', 'ApiCtrl', 'InviteCtrl', 'NavCtrl', 'PanelRoutes']); +var app = angular.module('shimapan-panel', ['ui.router', 'AuthSvc', 'ApiSvc', 'InviteSvc', 'UserSvc', 'ApiCtrl', 'InviteCtrl', 'UserCtrl', 'NavCtrl', 'PanelRoutes']); app.run(['$rootScope', '$state', '$stateParams', function($rootScope, $state, $stateParams) { $rootScope.$state = $state; diff --git a/app/public/services/UserSvc.js b/app/public/services/UserSvc.js new file mode 100644 index 0000000..99d61c8 --- /dev/null +++ b/app/public/services/UserSvc.js @@ -0,0 +1,22 @@ +var angular = require('angular'); + +angular.module('UserSvc', []).service('UserService', ['$http', function($http) { + this.getUser = function(username, cb) { + $http({ + method: 'GET', + url: '/api/users/get', + params: {username: username} + }).then(function(res) { + cb(res.data); + }); + }; + + this.getAllUsers = function(cb) { + $http({ + method: 'GET', + url: '/api/users/get' + }).then(function(res) { + cb(res.data); + }); + }; +}]); \ No newline at end of file