. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
| Server IP : 52.223.31.75 / Your IP : 172.31.6.220 [ Web Server : Apache/2.4.66 () OpenSSL/1.0.2k-fips PHP/7.4.33 System : Linux ip-172-31-14-81.eu-central-1.compute.internal 4.14.281-212.502.amzn2.x86_64 #1 SMP Thu May 26 09:52:17 UTC 2022 x86_64 User : apache ( 48) PHP Version : 7.4.33 Disable Function : NONE Domains : 4 Domains MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /var/www/ripara.co/admin/js/controllers/ |
Upload File : |
materialAdmin
//=================================================
// Controller Lista Schede
//=================================================
.controller('schedaCtrl', function($filter, $sce, $state, $scope, ngTableParams, tableService, APIService, animationService, growlService) {
// ACL
if($scope.thisPagesNames.indexOf($state.current.nomePagina) < 0){
// OuttaHere!
$state.go("home");
growlService.growl($scope.outtaHere, 'danger');
}
this.animationService = animationService;
//Caricament dati da API REST
this.getData = function (){
APIService.async({method: "getschede"}).then(function(adata) {
if(adata.status && adata.message.length){
//assegno i dati ricevuti a data
var data = adata.message;
console.log('SVHEDEEEEE', adata.message);
//aggiorno la variabile per ng-repeat della tabella
for (var i = data.length - 1; i >= 0; i--) {
console.log('f',data[i]);
data[i].id = data[i]._id.$id;
// format date per tabella schede lavorazione
data[i].datamodifica = new Date(data[i].datamodifica.sec * 1000);
data[i].datacreazione = new Date(data[i].datacreazione.sec * 1000);
}
$scope.uctrl.data = data;
//instanzio la ng-table
$scope.uctrl.tableUtenti = new ngTableParams({
page: 1, // show first page
count: 10
},
{
total: data.length,// $scope.data.length, // length of data
getData: function($defer, params) {
// use build-in angular filter
var orderedData = params.filter() ? $filter('filter')(data, params.filter()) : data;
this.id_scheda = orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count());
this.titolo = orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count());
this.insert_time = orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count());
this.last_modify = orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count());
params.total(orderedData.length); // set total for recalc pagination
$defer.resolve(this.id_scheda, this.titolo, this.insert_time, this.username, this.last_modify);
}
}
);
}else{
animationService.setAnimationJam("bounceInDown", "alert-red", false, "Errore in fase di carimento dei dati, si prega di aggiornare la pagina!");
}
});
};
this.getData();
this.getGroups = function (){
APIService.async({method: "getgroups"}).then(function(adata) {
console.log(adata);
if(adata.status && adata.message.length){
//assegno i dati ricevuti a data
var data = adata.message;
console.log('getGruppi:__', adata);
$scope.gruppi = data;
}else{
animationService.setAnimationJam("bounceInDown", "alert-red", false, "Errore in fase di carimento dei dati, si prega di aggiornare la pagina!");
}
});
};
this.getGroups();
// Spostamento utente in gruppo
$scope.moveUserToGroup = function(groupID, userID){
APIService.async({method: "addusertogroup", id_group: groupID, id_user: userID}).then(function(adata) {
console.log(adata);
console.log(userID, groupID);
if(adata.status && adata.message){
growlService.growl(adata.message, 'info');
}else{
growlService.growl(adata.message, 'danger');
}
});
}
// Drag/Drop utente in gruppo
$scope.dropped = function(dragged, dropped){
var drop = jQuery('#'+dropped);
var drag = jQuery('#'+dragged);
var groupID = drop[0].getAttribute('group-id');
var userID = drag[0].getAttribute('user-id');
drop.removeClass('lvl-over');
$scope.moveUserToGroup(groupID,userID);
}
//Insert
this.newUser = 0;
this.newScheda = $state.params.newScheda;
this.submit = function() {
this.insertUser.method = "insertutente";
APIService.async(this.insertUser).then(function(adata) {
if(adata.status){
swal(adata.message, "L'utente protrà effettuare l'accesso senza verificare l'account in quanto creato da un'amministratore!", "success")
//aggiorno la lista degli utenti
$scope.uctrl.getData();
//svuoto i valori precedenti
for(x in $scope.uctrl.insertUser){
$scope.uctrl.insertUser[x] = "";
}
//nascondo il menu inserimento
$scope.uctrl.newUser = 0;
}else{
//$scope.uctrl.animationService.setAnimationJam("bounceInDown", "alert-red", false, "Errore in fase di aggiornamento dei dati, si prega di aggiornare la pagina!");
growlService.growl(adata.message, 'danger');
}
});
}
$scope.newUser = 0;
})
//=================================================
// Controller Editazione e Visualizzazione Profilo
//=================================================
.controller('profiloCtrl', function($filter, $sce, $state, $scope, APIService, ngTableParams, tableService, growlService, animationService){
$scope.toggleMin = function() {
$scope.minDate = $scope.minDate ? null : new Date();
};
$scope.toggleMin();
$scope.open = function($event, opened) {
$event.preventDefault();
$event.stopPropagation();
$scope[opened] = true;
};
$scope.dateOptions = {
formatYear: 'yy',
startingDay: 1
};
$scope.formats = ['dd-MMMM-yyyy', 'yyyy/MM/dd', 'dd.MM.yyyy', 'shortDate'];
$scope.format = $scope.formats[0];
//parametri passati dal precedente
this.parametri = $state.params;
this.growlService = growlService;
this.animationService = animationService;
$scope.info = {};
// Gets the scheda from the id passed to $state.params
this.getScheda = function(){
APIService.async({method:"getschedainformazioni",idscheda:$state.params.scheda.id}).then(function(adata) {
console.log('adata------>', adata);
if(adata.status){
//assegno i dati ricevuti a data
$scope.info = adata.message;
//this.info.id_user = this.parametri.id_user;
console.log($scope.info);
var millisec = new Date($scope.info.datacreazione.sec);
$scope.info.datamodifica = new Date($scope.info.datamodifica.sec * 1000);
$scope.info.datacreazione = new Date($scope.info.datacreazione.sec * 1000);
$scope.info.calendardatainizio = new Date($scope.info.calendardatainizio);
$scope.info.calendardatafine = new Date($scope.info.calendardatafine);
if($scope.info.color){
$scope.activeTagColor = $scope.info.color;
}
}else{
//this.animationService.setAnimationJam("bounceInDown", "alert-red", false, "Errore in fase di carimento dei dati, si prega di aggiornare la pagina!");
growlService.growl(adata.message, 'danger');
}
});
}
// Se sto editando (l'id c'è):
if($state.params.id_scheda > 0){
this.getScheda();
$scope.sctrl.editSummary = 0;
}else{
$scope.sctrl.editSummary = 1;
}
//Tags
$scope.tags = [
'bgm-teal',
'bgm-red',
'bgm-pink',
'bgm-blue',
'bgm-lime',
'bgm-green',
'bgm-cyan',
'bgm-orange',
'bgm-purple',
'bgm-gray',
'bgm-black',
];
//Select Tag
$scope.currentTag = '';
$scope.activeTagColor = 'bgm-cyan';
if($scope.info){
$scope.info.color = $scope.activeTagColor;
}
$scope.onTagClick = function(tag, $index) {
$scope.activeState = $index;
$scope.activeTagColor = $scope.info.color = tag;
}
//Edit
//this.editSummary = 0;
this.editSummary2 = 0;
this.editInfo = 0;
this.editContact = 0;
this.getCampiObbligatoriScheda = function(){
APIService.async({method: "getcampiobbligatorischeda"}).then(function(adata) {
console.log(adata);
if(adata.status && adata.message.length){
//assegno i dati ricevuti a data
var data = adata.message;
console.log('getCampiObbligatoriScheda:__', adata);
$scope.campiObbligatori = data;
}else{
animationService.setAnimationJam("bounceInDown", "alert-red", false, "Errore in fase di carimento dei dati, si prega di aggiornare la pagina!");
}
});
};
this.getCampiObbligatoriScheda();
this.isInArray = function(value, array) {
if(array){
return array.indexOf(value) > -1;
}
}
this.submit = function(item) {
if(item === 'profileSummary') {
this.editSummary = 0;
this.info.method = "updateinformazionescheda";
APIService.async(this.info).then(function(adata) {
if(adata.status){
$scope.pctrl.growlService.growl(adata.message, 'success');
}else{
$scope.pctrl.animationService.setAnimationJam("bounceInDown", "alert-red", false, "Errore in fase di aggiornamento dei dati, si prega di aggiornare la pagina!");
}
});
}
if(item === 'profileInfo') {
this.editInfo = 0;
this.info.method = "updateinformazionibasicheda";
APIService.async(this.info).then(function(adata) {
if(adata.status){
$scope.pctrl.growlService.growl(adata.message, 'success');
}else{
$scope.pctrl.animationService.setAnimationJam("bounceInDown", "alert-red", false, "Errore in fase di aggiornamento dei dati, si prega di aggiornare la pagina!");
}
});
}
if(item === 'profileContact') {
this.editContact = 0;
this.info.method = "updateinformazionicontattoutente";
APIService.async(this.info).then(function(adata) {
if(adata.status){
$scope.pctrl.growlService.growl(adata.message, 'success');
}else{
$scope.pctrl.animationService.setAnimationJam("bounceInDown", "alert-red", false, "Errore in fase di aggiornamento dei dati, si prega di aggiornare la pagina!");
}
});
}
if(item === 'profilePhoto') {
//setto l'immagine in real time
var fileInput = $('#foto-input');
var file = fileInput[0].files[0];
this.info.upload = file;
var imageType = /image.*/;
if (file.type.match(imageType)) {
var reader = new FileReader();
reader.addEventListener("load", function () {
$scope.pctrl.info.avatar_location = this.result;
}, false);
reader.readAsDataURL(file);
} else {
alert("File non supportato!");
}
this.info.method = "updatefotocontattoutente";
APIService.async(this.info).then(function(adata) {
if(adata.status){
$scope.pctrl.growlService.growl(adata.message, 'success');
}else{
$scope.pctrl.animationService.setAnimationJam("bounceInDown", "alert-red", false, "Errore in fase di aggiornamento dei dati, si prega di aggiornare la pagina!");
}
});
}
}
// To push campos in campos
$scope.o = {};
$scope.info.keys = {};
this.pushCampo = function(){
this.newCampo = true;
if($scope.o.newKey && $scope.o.newValue){
$scope.info.keys[$scope.o.newKey] = $scope.o.newValue;
$scope.o.newKey = $scope.o.newValue = undefined;
}
};
this.removeCampo = function(key){
//this.newCampo = true;
if($scope.info.keys[key]){
delete $scope.info.keys[key];
}
};
this.updateScheda = function(){
console.log('updateScheda() ----> ', $scope.info);
console.log('updateScheda() ----> ', $scope.$root.qqq);
$scope.info.files = [];
for (var i in $scope.$root.qqq) {
console.log($scope.$root.qqq[i]);
$scope.info.files.push({filename: $scope.$root.qqq[i].name, url: $scope.$root.qqq[i].url});
}
console.log('files: ', $scope.info.files);
var array = [$scope.info];
APIService.async({method: "updateschedainformazioni", scheda: array}).then(function(adata) {
console.log(adata);
if(adata.status && adata.message){
$scope.sctrl.editSummary = 0;
console.log('okzio');
//aggiungo id
console.log('adata.message____', adata.message);
$state.params.scheda = adata.message;
$state.params.scheda.id = adata.message['_id']['$id'];
$scope.sctrl.getScheda();
growlService.growl(adata.message.Hystory[0].message, 'info');
}else{
growlService.growl(adata.message, 'danger');
}
});
}
$scope.uctrl = {};
//Caricament dati da API REST
$scope.cercaLDAP = function (){
APIService.async({method: "getutentildap", nome: $('#ricercaLDAP').val()}).then(function(adata) {
if(adata.status && adata.message.length){
//assegno i dati ricevuti a data
var data = adata.message;
//se è un utente del sistema e non ldap non lo faccio draggare
for (var i = data.length - 1; i >= 0; i--) {
if(data[i]['dn']==undefined){
data[i]['drag'] = false;
data[i]['style'] = "";
}else{
data[i]['drag'] = true;
data[i]['style'] = "cursor: move;";
}
}
//aggiorno la variabile per ng-repeat della tabella
$scope.uctrl.data = data;
//instanzio la ng-table
$scope.uctrl.tableUtentiLDAP = new ngTableParams({
page: 1, // show first page
count: 10
},
{
total: data.length,// $scope.data.length, // length of data
getData: function($defer, params) {
// use build-in angular filter
var orderedData = params.filter() ? $filter('filter')(data, params.filter()) : data;
this.id = orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count());
this.firstname = orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count());
this.email = orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count());
this.username = orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count());
this.dn = orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count());
params.total(orderedData.length); // set total for recalc pagination
$defer.resolve(this.id, this.firstname, this.email, this.username, this.dn);
}
}
);
}else{
growlService.growl("Utente non trovato!", 'warning');
}
});
}
this.getGroups = function (){
APIService.async({method: "getgroups"}).then(function(adata) {
console.log(adata);
if(adata.status && adata.message.length){
//assegno i dati ricevuti a data
var data = adata.message;
console.log('getGruppi:__', adata);
$scope.gruppi = data;
}else{
animationService.setAnimationJam("bounceInDown", "alert-red", false, "Errore in fase di carimento dei dati, si prega di aggiornare la pagina!");
}
});
};
this.getGroups();
$scope.mail = {};
$scope.mail.usersDestinatari = [];
$scope.mail.idUsersDestinatari = [];
$scope.mail.gruppiDestinatari = [];
$scope.mail.idGruppiDestinatari = [];
$scope.addUserToDestinatari = function(w){
$scope.mail.usersDestinatari.push(w);
$scope.mail.idUsersDestinatari.push(w.id_user);
console.log(w);
}
$scope.removeUserFromDestinatari = function(w){
var index = $scope.mail.usersDestinatari.indexOf(w);
if (index > -1) {
$scope.mail.usersDestinatari.splice(index, 1);
$scope.mail.idUsersDestinatari.splice(index, 1);
}
}
$scope.toggleSelection = function(w) {
var idx = $scope.mail.gruppiDestinatari.indexOf(w);
// is currently selected
if (idx > -1) {
console.log('si');
$scope.mail.gruppiDestinatari.splice(idx, 1);
$scope.mail.idGruppiDestinatari.splice(idx, 1);
}
// is newly selected
else {
console.log('no');
$scope.mail.gruppiDestinatari.push(w);
$scope.mail.idGruppiDestinatari.push(w);
}
};
})
.controller('DemoFileUploadController', ['$scope', '$http', '$window',function ($scope, $http) {
$scope.options = {
url: url
};
//$scope.ciao = function () {
var url = 'server/php/';
$scope.loadingFiles = true;
$http.get(url).then(
function (response) {
$scope.loadingFiles = false;
$scope.queue = response.data.files || [];
$scope.$root.qqq = $scope.queue;
},function () {
$scope.loadingFiles = false;
//console.log('5');
}
);
$('#fileupload').fileupload({
url: url,
dataType: 'json',
done: function (e, data) {
$.each(data.result.files, function (index, file) {
$('<p/>').text(file.name).appendTo('#files');
$scope.loadingFiles = true;
$http.get(url).then(
function (response) {
$scope.loadingFiles = false;
$scope.queue = response.data.files || [];
$scope.$root.qqq = $scope.queue;
},function () {
$scope.loadingFiles = false;
//console.log('5');
}
);
});
},
progressall: function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$('#progress .progress-bar').css(
'width',
progress + '%'
);
}
}).prop('disabled', !$.support.fileInput)
.parent().addClass($.support.fileInput ? undefined : 'disabled');
//};
//$scope.ciao();
$scope.$root.filesDeleted = false;
console.log('1',$scope.$root.filesDeleted);
}])
.controller('FileDestroyController', [
'$scope', '$http',
function ($scope, $http) {
var file = $scope.file,
state;
console.log('foooo', $scope.$root.qqq);
// Deletes the files in queue at start
$scope.clearFiles = function(){
if(!$scope.$root.filesDeleted){
for (var i = $scope.$root.qqq.length - 1; i >= 0; i--) {
$http({
url: $scope.$root.qqq[i].deleteUrl,
method: $scope.$root.qqq[i].deleteType
}).then(
function () {
state = 'resolved';
//$scope.clear(file);
},
function () {
state = 'rejected';
}
);
}
$scope.$root.filesDeleted = true;
console.log('2', $scope.$root.filesDeleted);
}
}
if (file.url) {
file.$state = function () {
return state;
};
file.$destroy = function () {
state = 'pending';
return $http({
url: file.deleteUrl,
method: file.deleteType
}).then(
function () {
state = 'resolved';
$scope.clear(file);
},
function () {
state = 'rejected';
}
);
};
} else if (!file.$cancel && !file._index) {
file.$cancel = function () {
$scope.clear(file);
};
}
}
]);
/****
CHIAMATA STANDARD API
//Caricament dati da API REST
APIService.async("method=getmenu").then(function(adata) {
if(adata.status){
//assegno i dati ricevuti a data
var data = adata.message;
}else{
animationService.setAnimationJam("bounceInDown", "alert-red", false, "Errore in fase di carimento dei dati, si prega di aggiornare la pagina!");
}
});
*******/