Merge branch 'master' of https://github.com/ariasia/OLA_Mirror
This commit is contained in:
@ -14,7 +14,8 @@ var app = angular.module('clientApp', [
|
||||
'ngSanitize',
|
||||
'ngMaterial',
|
||||
'ui.router',
|
||||
'ngMdIcons'
|
||||
'ngMdIcons',
|
||||
'angularFileUpload'
|
||||
]);
|
||||
|
||||
app.config(function ($stateProvider, $urlRouterProvider) {
|
||||
@ -37,10 +38,16 @@ app.config(function ($stateProvider, $urlRouterProvider) {
|
||||
templateUrl: 'views/studentSpace.html',
|
||||
controller: 'StudentSpaceCtrl'
|
||||
})
|
||||
|
||||
|
||||
.state('responsableFormationSpace', {
|
||||
url: '/espace-formation',
|
||||
templateUrl: 'views/responsableFormationSpace.html',
|
||||
controller: 'ResponsableFormationSpaceCtrl'
|
||||
})
|
||||
|
||||
.state('administrationSpace', {
|
||||
url: '/espace-secretariat',
|
||||
templateUrl: 'views/administrationSpace.html',
|
||||
controller: 'AdministrationSpaceCtrl'
|
||||
});
|
||||
});
|
104
frontend/app/scripts/controllers/administrationDialog.js
Normal file
104
frontend/app/scripts/controllers/administrationDialog.js
Normal file
@ -0,0 +1,104 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @ngdoc function
|
||||
* @name frontendApp.controller:AdministrationDialogCtrl
|
||||
* @description
|
||||
* # AdministrationDialogCtrl
|
||||
* Controller of the frontendApp
|
||||
*/
|
||||
angular.module('clientApp')
|
||||
.controller('AdministrationDialogCtrl', function ($scope, $state, FileUploader, $mdDialog, fileNameFilter, illegalFileNamesFilter, type) {
|
||||
|
||||
console.log(type);
|
||||
|
||||
// Public methods -------------------
|
||||
|
||||
$scope.hide = function () {
|
||||
$mdDialog.hide();
|
||||
};
|
||||
|
||||
$scope.cancel = function () {
|
||||
$mdDialog.cancel();
|
||||
};
|
||||
|
||||
$scope.answer = function (answer) {
|
||||
$mdDialog.hide(answer);
|
||||
};
|
||||
|
||||
$scope.allDocumentsAreIllegal = function() {
|
||||
return (fileNameFilter(uploader.queue, type).length === 0);
|
||||
};
|
||||
|
||||
$scope.areThereIllegalFiles = function() {
|
||||
return (illegalFileNamesFilter(uploader.queue, type).length !== 0);
|
||||
};
|
||||
|
||||
var uploader = $scope.uploader = new FileUploader({
|
||||
url: 'upload.php'
|
||||
});
|
||||
|
||||
// Private methods ------------------
|
||||
|
||||
// FILTERS
|
||||
|
||||
// a sync filter
|
||||
uploader.filters.push({
|
||||
name: 'syncFilter',
|
||||
fn: function (item /*{File|FileLikeObject}*/, options) {
|
||||
console.log('syncFilter');
|
||||
return this.queue.length < 10;
|
||||
}
|
||||
});
|
||||
|
||||
// an async filter
|
||||
uploader.filters.push({
|
||||
name: 'asyncFilter',
|
||||
fn: function (item /*{File|FileLikeObject}*/, options, deferred) {
|
||||
console.log('asyncFilter');
|
||||
setTimeout(deferred.resolve, 1e3);
|
||||
}
|
||||
});
|
||||
|
||||
// CALLBACKS
|
||||
|
||||
uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
|
||||
console.info('onWhenAddingFileFailed', item, filter, options);
|
||||
};
|
||||
uploader.onAfterAddingFile = function (fileItem) {
|
||||
console.info('onAfterAddingFile', fileItem);
|
||||
};
|
||||
uploader.onAfterAddingAll = function (addedFileItems) {
|
||||
console.info('onAfterAddingAll', addedFileItems);
|
||||
};
|
||||
uploader.onBeforeUploadItem = function (item) {
|
||||
console.info('onBeforeUploadItem', item);
|
||||
};
|
||||
uploader.onProgressItem = function (fileItem, progress) {
|
||||
console.info('onProgressItem', fileItem, progress);
|
||||
};
|
||||
uploader.onProgressAll = function (progress) {
|
||||
console.info('onProgressAll', progress);
|
||||
};
|
||||
uploader.onSuccessItem = function (fileItem, response, status, headers) {
|
||||
console.info('onSuccessItem', fileItem, response, status, headers);
|
||||
};
|
||||
uploader.onErrorItem = function (fileItem, response, status, headers) {
|
||||
console.info('onErrorItem', fileItem, response, status, headers);
|
||||
};
|
||||
uploader.onCancelItem = function (fileItem, response, status, headers) {
|
||||
console.info('onCancelItem', fileItem, response, status, headers);
|
||||
};
|
||||
uploader.onCompleteItem = function (fileItem, response, status, headers) {
|
||||
console.info('onCompleteItem', fileItem, response, status, headers);
|
||||
};
|
||||
uploader.onCompleteAll = function () {
|
||||
console.info('onCompleteAll');
|
||||
};
|
||||
|
||||
console.info('uploader', uploader);
|
||||
|
||||
});
|
||||
|
||||
})();
|
125
frontend/app/scripts/controllers/administrationSpace.js
Normal file
125
frontend/app/scripts/controllers/administrationSpace.js
Normal file
@ -0,0 +1,125 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @ngdoc function
|
||||
* @name frontendApp.controller:AdministrationSpaceCtrl
|
||||
* @description
|
||||
* # AdministrationSpaceCtrl
|
||||
* Controller of the frontendApp
|
||||
*/
|
||||
angular.module('clientApp')
|
||||
.controller('AdministrationSpaceCtrl', function ($scope, $state, $mdDialog, FileUploader) {
|
||||
|
||||
angular.extend($scope, {
|
||||
logout,
|
||||
deleteAbsence,
|
||||
deleteTrackingSheet,
|
||||
importAbsences,
|
||||
importVisitSheets
|
||||
})
|
||||
|
||||
init();
|
||||
|
||||
// Public methods -------------------
|
||||
|
||||
function logout() {
|
||||
$state.go('login');
|
||||
}
|
||||
|
||||
function deleteAbsence(groupIndex, periodIndex, absenceIndex) {
|
||||
$scope.formationGroups[groupIndex].formattedAbsences[periodIndex].absences.splice(absenceIndex, 1);
|
||||
}
|
||||
|
||||
function deleteTrackingSheet(groupIndex, trackingSheetIndex) {
|
||||
$scope.formationGroups[groupIndex].trackingSheets.splice(trackingSheetIndex, 1);
|
||||
}
|
||||
|
||||
function importVisitSheets(ev) {
|
||||
$mdDialog.show({
|
||||
controller: 'AdministrationDialogCtrl',
|
||||
templateUrl: 'import-fiches-visite',
|
||||
parent: angular.element(document.body),
|
||||
targetEvent: ev,
|
||||
clickOutsideToClose: true,
|
||||
fullscreen: 'false',
|
||||
locals : { type : 'visit'}
|
||||
})
|
||||
.then(function (answer) {
|
||||
$scope.status = 'You said the information was "' + answer + '".';
|
||||
}, function () {
|
||||
$scope.status = 'You cancelled the dialog.';
|
||||
});
|
||||
}
|
||||
|
||||
function importAbsences(ev) {
|
||||
$mdDialog.show({
|
||||
controller: 'AdministrationDialogCtrl',
|
||||
templateUrl: 'import-fiches-absences',
|
||||
parent: angular.element(document.body),
|
||||
targetEvent: ev,
|
||||
clickOutsideToClose: true,
|
||||
fullscreen: 'false',
|
||||
locals : { type : 'absence'}
|
||||
})
|
||||
.then(function (answer) {
|
||||
$scope.status = 'You said the information was "' + answer + '".';
|
||||
}, function () {
|
||||
$scope.status = 'You cancelled the dialog.';
|
||||
});
|
||||
}
|
||||
|
||||
// Private methods ------------------
|
||||
|
||||
function init() {
|
||||
var formationGroups = [{
|
||||
label: "Master2 ICE",
|
||||
absences: [
|
||||
{ id: 1, title: "Absence_Matthieu_Penchenat_P1" },
|
||||
{ id: 2, title: "Absence_Renan_Husson_P1" },
|
||||
{ id: 3, title: "Absence_Renan_Husson_P2" },
|
||||
{ id: 1, title: "Absence_Renan_Husson_P3" },
|
||||
{ id: 2, title: "Absence_Matthieu_Penchenat_P2" },
|
||||
{ id: 3, title: "Absence_Matthieu_Penchenat_P3" },
|
||||
{ id: 1, title: "Absence_Quentin_Rouland_P1" },
|
||||
{ id: 2, title: "Absence_Quentin_Rouland_P2" },
|
||||
{ id: 3, title: "Absence_Quentin_Rouland_P3" },
|
||||
{ id: 1, title: "Absence_Sitan_Coulibaly_P1" },
|
||||
{ id: 2, title: "Absence_Sitan_Coulibaly_P2" },
|
||||
{ id: 3, title: "Absence_Sitan_Coulibaly_P3" }
|
||||
],
|
||||
trackingSheets: [
|
||||
{ id: 3, fileName: "FicheVisite_Sitan_Coulibaly_1" },
|
||||
{ id: 2, fileName: "FicheVisite_Sitan_Coulibaly_2" },
|
||||
{ id: 1, fileName: "FicheVisite_Sitan_Coulibaly_3" }
|
||||
]
|
||||
}, {
|
||||
label: "Master1 ISMAG",
|
||||
absences: [
|
||||
{ id: 1, title: "Absence_Matthieu_Penchenat_P1" },
|
||||
{ id: 2, title: "Absence_Matthieu_Penchenat_P2" },
|
||||
{ id: 3, title: "Absence_Matthieu_Penchenat_P3" }
|
||||
],
|
||||
trackingSheets: [
|
||||
{ id: 3, fileName: "FicheVisite_Renan_Husson_1" },
|
||||
{ id: 2, fileName: "FicheVisite_Renan_Husson_2" },
|
||||
{ id: 1, fileName: "FicheVisite_Renan_Husson_3" }
|
||||
]
|
||||
}];
|
||||
|
||||
$scope.formationGroups = formationGroups.map(function (formationGroup) {
|
||||
formationGroup.formattedAbsences = reformatAbsences(formationGroup.absences);
|
||||
return formationGroup;
|
||||
});
|
||||
}
|
||||
|
||||
function reformatAbsences(absences) {
|
||||
var myObj = _.groupBy(absences, function (absence) { return absence.title.split('_').pop(); });
|
||||
|
||||
return _.map(myObj, function (value, index) {
|
||||
return { period: index, absences: value };
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
})();
|
28
frontend/app/scripts/services/Filters.js
Normal file
28
frontend/app/scripts/services/Filters.js
Normal file
@ -0,0 +1,28 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
|
||||
angular.module('clientApp')
|
||||
.filter('fileName', function () {
|
||||
|
||||
return function (queue, type) {
|
||||
|
||||
var reg = (type === 'absence') ?/^Absence_[A-Z][a-z]*_[A-Z][a-z]*_P\d*.pdf$/ : /^Visite_[A-Z][a-z]*_[A-Z][a-z]*_\d*.pdf$/;
|
||||
return queue.filter(function (item) {
|
||||
return reg.test(item.file.name);
|
||||
});
|
||||
};
|
||||
})
|
||||
.filter('illegalFileNames', function () {
|
||||
|
||||
return function (queue, type) {
|
||||
|
||||
var reg = (type === 'absence') ?/^Absence_[A-Z][a-z]*_[A-Z][a-z]*_P\d*.pdf$/ : /^Visite_[A-Z][a-z]*_[A-Z][a-z]*_\d*.pdf$/;
|
||||
return queue.filter(function (item) {
|
||||
return !reg.test(item.file.name);
|
||||
}).map(function(item) {
|
||||
return item.file.name;
|
||||
});
|
||||
};
|
||||
});
|
||||
})();
|
Reference in New Issue
Block a user