|
|
@ -34,7 +34,7 @@ |
|
|
|
templateUrl: 'views/login.html', |
|
|
|
hideMenus: true |
|
|
|
}).when('/users/:ID', { |
|
|
|
// controller: 'HomeController', |
|
|
|
controller: 'EditController', |
|
|
|
templateUrl: 'views/show.html' |
|
|
|
}).when('/users/:ID/edit', { |
|
|
|
controller: 'EditController', |
|
|
@ -109,8 +109,9 @@ |
|
|
|
$location.path('/login'); |
|
|
|
} |
|
|
|
}); |
|
|
|
}]).controller('EditController', ['$scope', '$routeParams', '$http', function($scope, $routeParams, $http) { |
|
|
|
}]).controller('EditController', ['$scope', '$routeParams', '$http', '$mdDialog', function($scope, $routeParams, $http, $mdDialog) { |
|
|
|
console.log($routeParams.ID); |
|
|
|
$scope.password = {}; |
|
|
|
if ($routeParams.ID == $scope.globals.currentUser.username){ |
|
|
|
$scope.user = $scope.logged_user; |
|
|
|
}else{ |
|
|
@ -120,12 +121,60 @@ |
|
|
|
}); |
|
|
|
} |
|
|
|
$scope.save = function(){ |
|
|
|
console.log($scope.user); |
|
|
|
if ($scope.password.new == $scope.password.confirm){ |
|
|
|
$scope.user.userPassword = $scope.password.new; |
|
|
|
} |
|
|
|
$http.put("/api/users/"+$routeParams.ID, $scope.user).then(function(response) { |
|
|
|
console.log(response.data); |
|
|
|
$scope.password = {}; |
|
|
|
$mdDialog.hide(); |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
$scope.changePassword = function(ev) { |
|
|
|
$scope.password = {}; |
|
|
|
// Appending dialog to document.body to cover sidenav in docs app |
|
|
|
var confirm = { |
|
|
|
clickOutsideToClose: true, |
|
|
|
targetEvent: ev, |
|
|
|
templateUrl: 'views/changePassword.html', |
|
|
|
scope: $scope, |
|
|
|
preserveScope: true, |
|
|
|
} |
|
|
|
|
|
|
|
$mdDialog.show(confirm).then(function(result) { |
|
|
|
console.log(result); |
|
|
|
// $http.post("/api/users", {uid: result}).then(function(response) { |
|
|
|
// console.log(response.data); |
|
|
|
// $rootScope.editUser(result); |
|
|
|
// }); |
|
|
|
}, function(){}); |
|
|
|
}; |
|
|
|
|
|
|
|
$scope.closeDialog = function() { |
|
|
|
$mdDialog.hide(); |
|
|
|
}; |
|
|
|
}]);; |
|
|
|
|
|
|
|
app.directive('valueMatches', ['$parse', function ($parse) { |
|
|
|
return { |
|
|
|
require: 'ngModel', |
|
|
|
link: function (scope, elm, attrs, ngModel) { |
|
|
|
var originalModel = $parse(attrs.valueMatches), |
|
|
|
secondModel = $parse(attrs.ngModel); |
|
|
|
// Watch for changes to this input |
|
|
|
scope.$watch(attrs.ngModel, function (newValue) { |
|
|
|
ngModel.$setValidity(attrs.name, newValue === originalModel(scope)); |
|
|
|
}); |
|
|
|
// Watch for changes to the value-matches model's value |
|
|
|
scope.$watch(attrs.valueMatches, function (newValue) { |
|
|
|
ngModel.$setValidity(attrs.name, newValue === secondModel(scope)); |
|
|
|
}); |
|
|
|
} |
|
|
|
}; |
|
|
|
}]); |
|
|
|
// controller("myCtrl", function($scope, $http, authService) { |
|
|
|
// $scope.$on('event:auth-loginRequired', function() { |
|
|
|
// console.log(54546); |
|
|
|