diff --git a/frontend/app/index.html b/frontend/app/index.html index 509f26b..d73d659 100644 --- a/frontend/app/index.html +++ b/frontend/app/index.html @@ -46,6 +46,8 @@ + + @@ -53,6 +55,10 @@ + + + + diff --git a/frontend/app/scripts/app.js b/frontend/app/scripts/app.js index a62f5f9..74d01c7 100755 --- a/frontend/app/scripts/app.js +++ b/frontend/app/scripts/app.js @@ -14,7 +14,8 @@ var app = angular.module('clientApp', [ 'ngSanitize', 'ngMaterial', 'ui.router', - 'ngMdIcons' + 'ngMdIcons', + 'angularFileUpload' ]); app.config(function ($stateProvider, $urlRouterProvider) { @@ -36,5 +37,11 @@ app.config(function ($stateProvider, $urlRouterProvider) { url: '/espace-etudiant', templateUrl: 'views/studentSpace.html', controller: 'StudentSpaceCtrl' + }) + + .state('administrationSpace', { + url: '/espace-secretariat', + templateUrl: 'views/administrationSpace.html', + controller: 'AdministrationSpaceCtrl' }); }); \ No newline at end of file diff --git a/frontend/app/scripts/controllers/administrationDialog.js b/frontend/app/scripts/controllers/administrationDialog.js new file mode 100644 index 0000000..03c9253 --- /dev/null +++ b/frontend/app/scripts/controllers/administrationDialog.js @@ -0,0 +1,103 @@ +(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) { + + + // 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, 'absence').length === 0); + }; + + $scope.areThereIllegalFiles = function() { + return (illegalFileNamesFilter(uploader.queue, 'absence').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); + + }); + +})(); \ No newline at end of file diff --git a/frontend/app/scripts/controllers/administrationSpace.js b/frontend/app/scripts/controllers/administrationSpace.js new file mode 100644 index 0000000..2fbff2b --- /dev/null +++ b/frontend/app/scripts/controllers/administrationSpace.js @@ -0,0 +1,106 @@ +(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 + }) + + 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 importAbsences(ev, type) { + $mdDialog.show({ + controller: 'AdministrationDialogCtrl', + templateUrl: 'import-fiches-absences', + parent: angular.element(document.body), + targetEvent: ev, + clickOutsideToClose: true, + fullscreen: 'false' + }) + .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 }; + }); + } + }); + +})(); \ No newline at end of file diff --git a/frontend/app/scripts/services/Filters.js b/frontend/app/scripts/services/Filters.js new file mode 100644 index 0000000..3eb80dc --- /dev/null +++ b/frontend/app/scripts/services/Filters.js @@ -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]*_P\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]*_P\d*.pdf$/; + return queue.filter(function (item) { + return !reg.test(item.file.name); + }).map(function(item) { + return item.file.name; + }); + }; + }); +})(); \ No newline at end of file diff --git a/frontend/app/styles/main.css b/frontend/app/styles/main.css index dfbcc8f..791a9f6 100644 --- a/frontend/app/styles/main.css +++ b/frontend/app/styles/main.css @@ -34,4 +34,26 @@ body > ui-view > div > div.bg-booklet.layout-align-center-center.layout-row.flex .p-home { font-size: 0.6em; -} \ No newline at end of file +} + +.well { + padding: 15px; + margin: 5px; + background-color: #e0e0e0; + border: dotted 3px lightgray; +} + +.note { + padding: 15px; + margin: 5px; + background-color: #a5d6a7; +} + + +.error { + padding: 15px; + margin: 5px; + background-color: #ef9a9a; +} + + \ No newline at end of file diff --git a/frontend/app/views/administrationSpace.html b/frontend/app/views/administrationSpace.html new file mode 100644 index 0000000..9485665 --- /dev/null +++ b/frontend/app/views/administrationSpace.html @@ -0,0 +1,189 @@ +
+ + +
+

Bienvenue Isabelle Michu

+ + + Se déconnecter + +
+ +
+
+ +
+ +
+ + + + +
+ + + + Fiches d'absence + + + + +
+
+ Période {{formattedAbsence.period}} + +

{{absence.title}}

+ +
+
+
+
+
+ Importer des fiches d'absences +
+
+
+
+ + + + + Fiches de visite + + + + +
+ +

{{sheet.fileName}}

+ +
+
+
+
+ Importer des fiches de visite +
+
+
+
+
+
+
+
+
+
+ + \ No newline at end of file diff --git a/frontend/app/views/login.html b/frontend/app/views/login.html index 6b3e72c..0519410 100644 --- a/frontend/app/views/login.html +++ b/frontend/app/views/login.html @@ -8,6 +8,8 @@ + + Log to administration

The titles of Washed Out's breakthrough song and the first single from Paracosm share the two most important words in Ernest Greene's musical language: feel it. It's a simple request, as well... diff --git a/frontend/bower.json b/frontend/bower.json index fc52ffd..c56f888 100644 --- a/frontend/bower.json +++ b/frontend/bower.json @@ -8,7 +8,9 @@ "angular-sanitize": "^1.4.0", "angular-material": "^1.1.3", "angular-ui-router": "^0.4.2", - "angular-material-icons": "^0.7.1" + "angular-material-icons": "^0.7.1", + "underscore": "^1.8.3", + "angular-file-upload": "^2.5.0" }, "devDependencies": { "angular-mocks": "^1.4.0" diff --git a/frontend/test/karma.conf.js b/frontend/test/karma.conf.js index a076726..7f9e36f 100644 --- a/frontend/test/karma.conf.js +++ b/frontend/test/karma.conf.js @@ -29,6 +29,8 @@ module.exports = function(config) { 'bower_components/angular-material/angular-material.js', 'bower_components/angular-ui-router/release/angular-ui-router.js', 'bower_components/angular-material-icons/angular-material-icons.min.js', + 'bower_components/underscore/underscore.js', + 'bower_components/angular-file-upload/dist/angular-file-upload.min.js', 'bower_components/angular-mocks/angular-mocks.js', // endbower 'app/scripts/**/*.js',