Skip to content

Instantly share code, notes, and snippets.

@hugoalmeidahh
Last active August 29, 2015 14:10
Show Gist options
  • Save hugoalmeidahh/dfe6269789160dde5766 to your computer and use it in GitHub Desktop.
Save hugoalmeidahh/dfe6269789160dde5766 to your computer and use it in GitHub Desktop.
'use strict';
app.controller('homeCtrl', ['$scope', '$http', 'autenticacaoAPI', 'masterAPI', function ($scope, $http, autenticacaoAPI, masterAPI) {
//Autenticacao - carrega usuário
$scope.carregaUsuario = function () {
$scope.users = "";
autenticacaoAPI.getUsuario().success(function (users) {
var result = JSON.parse(users);
var sNome = "";
$.each(result, function (key, item) {
sNome = item.nome;
});
$scope.users = sNome;
});
};
$scope.carregaUsuario();
//Master - carrega empresa
$scope.carregaEmpresa = function () {
$scope.empresa = "";
masterAPI.getEmpresa().success(function (dataEmpresas) {
var sEmpresa = angular.fromJson(dataEmpresas);
$scope.empresas = sEmpresa;
console.log(sEmpresa);
});
};
$scope.carregaEmpresa();
//Master - Carrega Parametros <<<<<<<<<<<<<<<<AQUI>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
$scope.carregaParametros = function () {
//document.getElementById().value = true;
masterAPI.getParametros().success(function (dataParametros) {
var allParametros = angular.fromJson(dataParametros);
console.log(allParametros);
});
};
$scope.carregaParametros();
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<FIM AQUI>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.
//Master - Alterar Senha
$scope.senhaantiga = "";
$scope.novasenha = "";
$scope.AlterarSenha = function () {
var user = { SENHA_USUR_ANT: $scope.senhaantiga, SENHA_USUR: $scope.novasenha }
var url = 'http://localhost:2099/api/master/AlterarSenha';
$http.put(url, user).then(
// success callback
function(response) {
$.bootbar.success("Senha alterada com sucesso");
},
// error callback
function(response) {
$.bootbar.success("Senha não alterada, contate o administrador");
}
);
};
}]);
app.directive('homeCalendar', function () {
return {
restrict: 'C',
link: function (scope, element) {
element.ionCalendar({});
}
}
});
app.service('autenticacaoAPI', function ($http) {
this.getUsuario = function () {
return $http.get('http://localhost:2099/api/autenticacao/NomeUsuarioLogado');
};
this.setPassword = function() {
};
});
app.service('masterAPI', function($http) {
this.getEmpresa = function () {
//return $http.get('http://localhost:2099/api/master/CarregaEmpresa'); ok
return $http.get('web/core/components/home/empresa.json'); //mock
};
this.getParametros = function() {
//return $http.get('http://localhost:2099/api/master/CarregaParametro');
return $http.get('web/core/components/home/alterarParametros.json'); //mock
};
});
$(document).ready(function () {
$('#identicalForm').bootstrapValidator({
feedbackIcons: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
password: {
validators: {
identical: {
field: 'confirmPassword',
message: 'The password and its confirm are not the same'
}
}
},
confirmPassword: {
validators: {
identical: {
field: 'password',
message: 'The password and its confirm are not the same'
}
}
}
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment