diff --git a/canapGEST/API/app/Helpers/AccessLevelHelper.php b/canapGEST/API/app/Helpers/AccessLevelHelper.php index f3cd92c1d7bbafc8da1514c430a5eda24d725c72..62545517f2f4660c6aa7bf1f9decce4526169124 100644 --- a/canapGEST/API/app/Helpers/AccessLevelHelper.php +++ b/canapGEST/API/app/Helpers/AccessLevelHelper.php @@ -55,7 +55,7 @@ class AccessLevelHelper { $default_access_groups = self::getDefaultAccessGroups(); $user_alloweds = []; - $user_role = 'responsable'; // formateur + $user_role = 'formateur'; // formateur $user_groups = explode(',', $user_groups); foreach ($default_access_groups as $group => $accesses) { diff --git a/canapGEST/API/app/Http/Controllers/UsersController.php b/canapGEST/API/app/Http/Controllers/UsersController.php index 60ec8a91e62e8aefb324fc8a7f17a5b2c0b9c3fe..19de5230aaff78e321627d04ede67f25049c9f43 100644 --- a/canapGEST/API/app/Http/Controllers/UsersController.php +++ b/canapGEST/API/app/Http/Controllers/UsersController.php @@ -69,4 +69,31 @@ class UsersController extends Controller "mail" => $info[0]['mail'][0] ]); } + + public function getLastConnection () + { + $last_connection = DB::table('last_connection')->where('last_connection_sciper', $this->user_sciper)->first(); + return $last_connection ? ["last_connection" => $last_connection] : ["last_connection" => null]; + } + + public function setLastConnection () + { + $last_connection = DB::table('last_connection')->where('last_connection_sciper', $this->user_sciper)->first(); + if ($last_connection) { + // Get tmp -> set to date, actual date to tmp + $new_date = date("Y-m-d H:i:s"); + DB::table('last_connection')->where('last_connection_id', $last_connection->last_connection_id)->update([ + 'last_connection_date' => $last_connection->last_connection_tmp_date, + 'last_connection_tmp_date' => $new_date + ]); + } else { + // insert + $new_date = date("Y-m-d H:i:s"); + $inserted_id = DB::table('last_connection')->insert([ + "last_connection_sciper" => $this->user_sciper, + "last_connection_date" => $new_date, + 'last_connection_tmp_date' => $new_date + ]); + } + } } diff --git a/canapGEST/API/routes/web.php b/canapGEST/API/routes/web.php index 55f172dc54947c40004a2381bfbf437e3d15c913..26dfeaed74605e63c8a5866b253ab7cdda4b7dd4 100644 --- a/canapGEST/API/routes/web.php +++ b/canapGEST/API/routes/web.php @@ -9,6 +9,8 @@ $router->group(['middleware' => 'jwt.auth'], function () use ($router) { $router->get('api/user/permittedjobs', 'UsersController@getPermittedJobs'); $router->get('api/user/hascommentedormarked', 'UsersController@getCommentedAndMarkedApplicantsByUser'); $router->get('api/user/data/{sciper}', 'UsersController@getUserDataBySciper'); + $router->get('api/user/connection', 'UsersController@getLastConnection'); + $router->patch('api/user/connection', 'UsersController@setLastConnection'); // Applicants $router->get('api/applicants', 'ApplicantsController@getAll'); diff --git a/canapGEST/DB/Valeurs de tests/table_job.sql b/canapGEST/DB/Valeurs de tests/table_job.sql index c7cbede13f9f02fc7b95204da2027fca11103208..bb4649816601d6a3d245e45b663a999bc637c8a7 100644 --- a/canapGEST/DB/Valeurs de tests/table_job.sql +++ b/canapGEST/DB/Valeurs de tests/table_job.sql @@ -1,14 +1,14 @@ -INSERT INTO `job` (`job_id`, `job_short_value`, `job_full_value`) VALUES (1, 'informaticienEntreprise', 'Informaticien-ne CFC; filière entreprise'); -INSERT INTO `job` (`job_id`, `job_short_value`, `job_full_value`) VALUES (2, 'informaticienSysteme', 'Informaticien-ne CFC; filière technique des systèmes'); -INSERT INTO `job` (`job_id`, `job_short_value`, `job_full_value`) VALUES (3, 'informaticienDev', 'Informaticien-ne CFC; filière développement d\'applications'); +INSERT INTO `job` (`job_id`, `job_short_value`, `job_full_value`) VALUES (1, 'informaticienEntreprise', 'Informaticien-ne CFC; filière entreprise'); +INSERT INTO `job` (`job_id`, `job_short_value`, `job_full_value`) VALUES (2, 'informaticienSysteme', 'Informaticien-ne CFC; filière technique des systèmes'); +INSERT INTO `job` (`job_id`, `job_short_value`, `job_full_value`) VALUES (3, 'informaticienDev', 'Informaticien-ne CFC; filière dèveloppement d\'applications'); INSERT INTO `job` (`job_id`, `job_short_value`, `job_full_value`) VALUES (4, 'laborantinBiologie', 'Laborantin-e CFC; option biologie'); INSERT INTO `job` (`job_id`, `job_short_value`, `job_full_value`) VALUES (5, 'laborantinChimie', 'Laborantin-e CFC; option chimie'); INSERT INTO `job` (`job_id`, `job_short_value`, `job_full_value`) VALUES (6, 'laborantinPhysique', 'Laborantin-e CFC; option physique'); INSERT INTO `job` (`job_id`, `job_short_value`, `job_full_value`) VALUES (14, 'logisticien', 'Logisticien-ne CFC'); -INSERT INTO `job` (`job_id`, `job_short_value`, `job_full_value`) VALUES (15, 'planificateurElectricien', 'Planificateur-trice éléctricien-ne CFC'); +INSERT INTO `job` (`job_id`, `job_short_value`, `job_full_value`) VALUES (15, 'planificateurElectricien', 'Planificateur-trice éléctricien-ne CFC'); INSERT INTO `job` (`job_id`, `job_short_value`, `job_full_value`) VALUES (16, 'electronicien', 'Electronicien-ne CFC'); -INSERT INTO `job` (`job_id`, `job_short_value`, `job_full_value`) VALUES (17, 'polyMecanicien', 'Polymécanicien-ne CFC'); -INSERT INTO `job` (`job_id`, `job_short_value`, `job_full_value`) VALUES (18, 'employeCommerce', 'Employé-e de commerce CFC'); +INSERT INTO `job` (`job_id`, `job_short_value`, `job_full_value`) VALUES (17, 'polyMecanicien', 'Polymécanicien-ne CFC'); +INSERT INTO `job` (`job_id`, `job_short_value`, `job_full_value`) VALUES (18, 'employeCommerce', 'Employé-e de commerce CFC'); INSERT INTO `job` (`job_id`, `job_short_value`, `job_full_value`) VALUES (19, 'gardienAnimaux', 'Gardien-ne d\'animaux CFC'); INSERT INTO `job` (`job_id`, `job_short_value`, `job_full_value`) VALUES (20, 'interactiveMediaDesigner', 'Interactive Media Designer CFC'); -INSERT INTO `job` (`job_id`, `job_short_value`, `job_full_value`) VALUES (21, 'informaticien', 'Informaticien-ne CFC; pas de filière préférée'); +INSERT INTO `job` (`job_id`, `job_short_value`, `job_full_value`) VALUES (21, 'informaticien', 'Informaticien-ne CFC; pas de filière préfèrèe'); diff --git a/canapGEST/DB/Valeurs de tests/table_status.sql b/canapGEST/DB/Valeurs de tests/table_status.sql index 3805b5a702cc927a0cb6af0978aa1389f39ba51c..37bd7dbda9597523d21c24399540080f2017bde4 100644 --- a/canapGEST/DB/Valeurs de tests/table_status.sql +++ b/canapGEST/DB/Valeurs de tests/table_status.sql @@ -2,4 +2,4 @@ INSERT INTO `status` (`status_value`) VALUES ('Nouveau'); INSERT INTO `status` (`status_value`) VALUES ('Valide'); INSERT INTO `status` (`status_value`) VALUES ('Incomplet'); INSERT INTO `status` (`status_value`) VALUES ('Invalide'); -INSERT INTO `status` (`status_value`) VALUES ('Refusé'); +INSERT INTO `status` (`status_value`) VALUES ('Refusé'); diff --git a/canapGEST/DB/new_version_script.sql b/canapGEST/DB/create_db_script.sql similarity index 94% rename from canapGEST/DB/new_version_script.sql rename to canapGEST/DB/create_db_script.sql index 36b44286ca6aa86872286e6b6ee2ed73fa2615fa..e84c32238754d7a7da071cf4417beb20fa8132e8 100644 --- a/canapGEST/DB/new_version_script.sql +++ b/canapGEST/DB/create_db_script.sql @@ -1,5 +1,5 @@ -- MySQL Script generated by MySQL Workbench --- Thu Apr 18 09:44:04 2019 +-- Tue May 7 09:00:54 2019 -- Model: New Model Version: 1.0 -- MySQL Workbench Forward Engineering @@ -295,3 +295,18 @@ CREATE TABLE IF NOT EXISTS `canap_db`.`training` ( ON UPDATE NO ACTION) ENGINE = InnoDB DEFAULT CHARACTER SET = utf8; + + +-- ----------------------------------------------------- +-- Table `canap_db`.`last_connection` +-- ----------------------------------------------------- +DROP TABLE IF EXISTS `canap_db`.`last_connection` ; + +CREATE TABLE IF NOT EXISTS `canap_db`.`last_connection` ( + `last_connection_id` INT NOT NULL AUTO_INCREMENT, + `last_connection_sciper` VARCHAR(10) NOT NULL, + `last_connection_date` DATETIME NOT NULL, + `last_connection_tmp_date` DATETIME NULL, + PRIMARY KEY (`last_connection_id`), + UNIQUE INDEX `last_connection_sciper_UNIQUE` (`last_connection_sciper` ASC)) +ENGINE = InnoDB; \ No newline at end of file diff --git a/canapGEST/DB/model.mwb b/canapGEST/DB/model.mwb index e884c903f7c26c83d2e031ff866276dc94b96cb4..e1fba0e51aa6545d050bdbecdf3b62f35fbf634b 100644 Binary files a/canapGEST/DB/model.mwb and b/canapGEST/DB/model.mwb differ diff --git a/canapGEST/DB/model.mwb.bak b/canapGEST/DB/model.mwb.bak index b6ee36d0fb7ba3bb17438f9b28940c6fd6e30b29..d1c61be18a51bd0636cecef84fe60bde32a8a1aa 100644 Binary files a/canapGEST/DB/model.mwb.bak and b/canapGEST/DB/model.mwb.bak differ diff --git a/canapGEST/Documentation/journal_travail.xlsx b/canapGEST/Documentation/journal_travail.xlsx index c01d87990971e9e32ae529ed6b03ec573103f9c6..99451734e8c3ce88eae8c5b7f9f69a337789175d 100644 Binary files a/canapGEST/Documentation/journal_travail.xlsx and b/canapGEST/Documentation/journal_travail.xlsx differ diff --git a/canapGEST/Site/src/App.vue b/canapGEST/Site/src/App.vue index ffb15bc0518eb5ceb133f15c948f97e0624e9411..d77a918ce50494a2b8da56ae230679657fce9a9d 100644 --- a/canapGEST/Site/src/App.vue +++ b/canapGEST/Site/src/App.vue @@ -19,9 +19,11 @@ import MainFooter from '@/layouts/MainFooter.vue' import alertSnackbar from '@/components/alertSnackbar.vue' export default { - created () { + created() { if (!this.$store.getters['moduleUser/userIsLogedIn']) { this.$store.dispatch('moduleUser/login') + } else { + this.$store.dispatch('moduleUser/getLastConnection') } }, components: { diff --git a/canapGEST/Site/src/store/modules/applications/getters.js b/canapGEST/Site/src/store/modules/applications/getters.js index 2807e4ad9907f96c84efa2744bd05e63cd773d8d..e7c123e764d58b9c8eab947fdb2e099b4f34bb11 100644 --- a/canapGEST/Site/src/store/modules/applications/getters.js +++ b/canapGEST/Site/src/store/modules/applications/getters.js @@ -32,6 +32,6 @@ export function getResponsibleNewApplications(state) { return state.applications.filter(x => x.fk_status == 'Nouveau') } -export function getFormateurNewApplications(state) { - return state.applications +export function getFormateurNewApplications(state, getters, rootState) { + return state.applications.filter(x => x.applicant_application_date > rootState.moduleUser.lastConnection.last_connection_date) } \ No newline at end of file diff --git a/canapGEST/Site/src/store/modules/user/actions.js b/canapGEST/Site/src/store/modules/user/actions.js index bed8e154f88696b37bb4d746c0675cf9521f3bd1..9647182eeb9d91e876f9ce471249f5e926754434 100644 --- a/canapGEST/Site/src/store/modules/user/actions.js +++ b/canapGEST/Site/src/store/modules/user/actions.js @@ -11,15 +11,19 @@ export function login() { } else { localStorage.setItem('stored_token', response.data.token); location.reload() + // setLastConnection().then(() => { + // }) } }) } export function logout(context, fullLogout) { - localStorage.removeItem('stored_token'); - if (fullLogout) { - window.location = 'https://tequila.epfl.ch/logout' - } + setLastConnection().then(() => { + localStorage.removeItem('stored_token'); + if (fullLogout) { + window.location = 'https://tequila.epfl.ch/logout' + } + }) } export function getUserData(context) { @@ -46,4 +50,24 @@ export function getUserPermittedJobs(context) { .then(response => { context.commit('setPermittedJobs', response.data) }) +} + +export function getLastConnection(context) { + axios({ + method: 'get', + url: '/user/connection' + }) + .then(response => { + context.commit('setLastConnection', response.data.last_connection) + }) +} + +export function setLastConnection() { + return new Promise((resolve) => { + axios({ + method: 'patch', + url: '/user/connection' + }) + .then(resolve()) + }) } \ No newline at end of file diff --git a/canapGEST/Site/src/store/modules/user/mutations.js b/canapGEST/Site/src/store/modules/user/mutations.js index 97740bf7781a4face8985c60ea16227a38641de4..a15c49d46f76cabad3231b16e1341b85b98a4029 100644 --- a/canapGEST/Site/src/store/modules/user/mutations.js +++ b/canapGEST/Site/src/store/modules/user/mutations.js @@ -4,4 +4,8 @@ export function setUserData(state, data) { export function setPermittedJobs(state, data) { state.permittedJobs = data +} + +export function setLastConnection(state, data) { + state.lastConnection = data } \ No newline at end of file diff --git a/canapGEST/Site/src/store/modules/user/state.js b/canapGEST/Site/src/store/modules/user/state.js index 269c66cb0de3d840e66be5d4e8d654b1a1e8ae41..b8b79ef62bdb85111e0ef5e71c000f1a2da5fd8c 100644 --- a/canapGEST/Site/src/store/modules/user/state.js +++ b/canapGEST/Site/src/store/modules/user/state.js @@ -10,5 +10,6 @@ export default { role: '', permissions: [] }, - permittedJobs: [] + permittedJobs: [], + lastConnection: {} } \ No newline at end of file diff --git a/canapGEST/Site/src/views/ApplicationsView.vue b/canapGEST/Site/src/views/ApplicationsView.vue index 967578ee4e91379b7a8d3f0b4d8fa643e891551d..92745bdf6adf3ea838c9ca05bed441d4bd2c3443 100644 --- a/canapGEST/Site/src/views/ApplicationsView.vue +++ b/canapGEST/Site/src/views/ApplicationsView.vue @@ -27,7 +27,10 @@ :search="$store.state.moduleApplications.filters.search" > <template v-slot:items="props"> - <tr :class="props.item.fk_status === 'Nouveau' ? 'isNew' : ''"> + <span></span> + <tr + :class="{ isNew: isNew(props.item.fk_status, props.item.applicant_application_date) }" + > <td v-if="$store.getters['moduleUser/userIsResponsible']"> <v-checkbox v-model="props.selected" hide-details color="primary"></v-checkbox> </td> @@ -160,6 +163,13 @@ export default { }) this.$store.dispatch('moduleApplications/getApplications') } + }, + isNew(status, date) { + if (this.$store.getters['moduleUser/userIsResponsible']) { + return status === 'Nouveau' + } else { + return date > this.$store.state.moduleUser.lastConnection.last_connection_date + } } }, components: { diff --git a/canapGEST/Site/src/views/HomeView.vue b/canapGEST/Site/src/views/HomeView.vue index 0a6323221ca6f019de0951d010e54896a1157b50..4493e00f447d52f0eb36d94ca92117731a98a714 100644 --- a/canapGEST/Site/src/views/HomeView.vue +++ b/canapGEST/Site/src/views/HomeView.vue @@ -3,10 +3,13 @@ <h1>Accueil</h1> <v-container id="grid" fluid grid-list-sm tag="section"> <v-layout row wrap> - <v-flex d-flex xs12 order-xs5> - <v-layout column> - <h2><router-link to="applications">{{applicationNumber}} nouvelles candidatures</router-link> à traiter</h2> - </v-layout> + <v-flex d-flex xs12 order-xs5 v-if="applicationNumber"> + <v-alert + style="cursor: pointer;" + :value="true" + type="info" + @click="$router.push('/applications')" + >Il y a <b>{{applicationNumber}}</b> nouvelles candidatures à traiter depuis votre dernière connexion.</v-alert> </v-flex> </v-layout> </v-container>