You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.2 KiB

8 years ago
  1. angular.module('topologyManager').controller('ApplicationController', function($scope,VIRLRestangular,CustomSimRestangular) {
  2. console.log("Application Controller initialized");
  3. $scope.credentials = {username:"",password:"",token:""};
  4. $scope.generateToken = function(){
  5. $scope.credentials.token = btoa($scope.credentials.username+":"+$scope.credentials.password);
  6. VIRLRestangular.setDefaultHeaders({authorization: "Basic ".concat($scope.credentials.token)});
  7. console.log($scope.credentials.token);
  8. };
  9. $scope.verifyCredentials = function() {
  10. VIRLRestangular.one('/simengine/rest/test').get() // GET: /users
  11. .then(function(response) {
  12. $scope.addAlert("Valid credentials","success");
  13. }, function(response) {
  14. console.log(response);
  15. });
  16. };
  17. $scope.alerts = [
  18. ];
  19. $scope.addAlert = function(message,alertType) {
  20. $scope.alerts.push({msg: message,type:alertType});
  21. };
  22. $scope.closeAlert = function(index) {
  23. $scope.alerts.splice(index, 1);
  24. };
  25. });