From cf9b8ba0e71991ae668351bdcc5b3e7b3c8e88e3 Mon Sep 17 00:00:00 2001 From: Romain_L Date: Sat, 15 Apr 2023 13:27:51 +0000 Subject: [PATCH] Commit last modules changes --- api_glpi_pleiade/api_glpi_pleiade.info.yml | 11 + .../api_glpi_pleiade.libraries.yml | 12 + .../api_glpi_pleiade.links.menu.yml | 6 + api_glpi_pleiade/api_glpi_pleiade.module | 32 + api_glpi_pleiade/api_glpi_pleiade.routing.yml | 16 + api_glpi_pleiade/css/api_glpi_pleiade.css | 0 api_glpi_pleiade/js/api_glpi_pleiade.js | 0 .../src/Controller/GlpiController.php | 26 + api_glpi_pleiade/src/Form/GlpiFields.php | 72 + api_lemon_pleiade/css/api_lemon_pleiade.css | 7 +- .../js/api_lemon_pleiade_desktop_blocks.js | 3 +- .../api_moodle_pleiade.info.yml | 12 + .../api_moodle_pleiade.libraries.yml | 12 + .../api_moodle_pleiade.links.menu.yml | 6 + api_moodle_pleiade/api_moodle_pleiade.module | 38 + .../api_moodle_pleiade.routing.yml | 16 + api_moodle_pleiade/css/api_moodle_pleiade.css | 19 + api_moodle_pleiade/js/api_moodle_pleiade.js | 107 + .../src/Controller/MoodleController.php | 102 + api_moodle_pleiade/src/Form/MoodleFields.php | 84 + .../PleiadeAjaxParapheurController.php | 11 +- .../src/IParapheurDataApiManager.php | 163 -- .../api_pastell_pleiade.info.yml | 4 - .../api_pastell_pleiade.libraries.yml | 1 + api_pastell_pleiade/js/api_pastell_entites.js | 14 +- api_user_pleiade/api_user_pleiade.info.yml | 3 - .../api_user_pleiade.libraries.yml | 4 +- api_user_pleiade/api_user_pleiade.module | 10 +- api_user_pleiade/css/api_user_pleiade.css | 71 +- api_user_pleiade/css/lib/slick.css | 143 ++ api_user_pleiade/js/api_user_pleiade.js | 95 +- api_user_pleiade/js/lib/slick.js | 1940 +++++++++++++++++ .../src/Controller/PleiadeUserController.php | 13 +- .../src/Form/PleiadeUserFieldsConfig.php | 26 +- .../api_zimbra_pleiade.info.yml | 4 - module_api_pleiade/src/ApiPleiadeManager.php | 65 +- 36 files changed, 2926 insertions(+), 222 deletions(-) create mode 100644 api_glpi_pleiade/api_glpi_pleiade.info.yml create mode 100644 api_glpi_pleiade/api_glpi_pleiade.libraries.yml create mode 100644 api_glpi_pleiade/api_glpi_pleiade.links.menu.yml create mode 100644 api_glpi_pleiade/api_glpi_pleiade.module create mode 100644 api_glpi_pleiade/api_glpi_pleiade.routing.yml create mode 100644 api_glpi_pleiade/css/api_glpi_pleiade.css create mode 100644 api_glpi_pleiade/js/api_glpi_pleiade.js create mode 100644 api_glpi_pleiade/src/Controller/GlpiController.php create mode 100644 api_glpi_pleiade/src/Form/GlpiFields.php create mode 100644 api_moodle_pleiade/api_moodle_pleiade.info.yml create mode 100644 api_moodle_pleiade/api_moodle_pleiade.libraries.yml create mode 100644 api_moodle_pleiade/api_moodle_pleiade.links.menu.yml create mode 100644 api_moodle_pleiade/api_moodle_pleiade.module create mode 100644 api_moodle_pleiade/api_moodle_pleiade.routing.yml create mode 100644 api_moodle_pleiade/css/api_moodle_pleiade.css create mode 100644 api_moodle_pleiade/js/api_moodle_pleiade.js create mode 100644 api_moodle_pleiade/src/Controller/MoodleController.php create mode 100644 api_moodle_pleiade/src/Form/MoodleFields.php delete mode 100644 api_parapheur_pleiade/src/IParapheurDataApiManager.php create mode 100644 api_user_pleiade/css/lib/slick.css create mode 100644 api_user_pleiade/js/lib/slick.js diff --git a/api_glpi_pleiade/api_glpi_pleiade.info.yml b/api_glpi_pleiade/api_glpi_pleiade.info.yml new file mode 100644 index 0000000..f6120a7 --- /dev/null +++ b/api_glpi_pleiade/api_glpi_pleiade.info.yml @@ -0,0 +1,11 @@ +name: API Pléiade GLPI +type: module +description: 'API For gets tickets of GLPI instance' +package: Pleiade +core: 8.x +core_version_requirement: ^8 || ^9 + +# Information +version: '1.0.x-dev' +project: 'api_glpi_pleiade' +datestamp: 1624364473 diff --git a/api_glpi_pleiade/api_glpi_pleiade.libraries.yml b/api_glpi_pleiade/api_glpi_pleiade.libraries.yml new file mode 100644 index 0000000..a9d03c5 --- /dev/null +++ b/api_glpi_pleiade/api_glpi_pleiade.libraries.yml @@ -0,0 +1,12 @@ +api_glpi_pleiade_js: + version: 1.x + js: + js/api_glpi_pleiade.js: {} + dependencies: + - core/drupal + - core/once +api_glpi_pleiade_css: + version: 1.x + css: + theme: + css/api_glpi_pleiade.css: {} \ No newline at end of file diff --git a/api_glpi_pleiade/api_glpi_pleiade.links.menu.yml b/api_glpi_pleiade/api_glpi_pleiade.links.menu.yml new file mode 100644 index 0000000..af842ce --- /dev/null +++ b/api_glpi_pleiade/api_glpi_pleiade.links.menu.yml @@ -0,0 +1,6 @@ +api_glpi_pleiade.admin: + title: 'API Pléiade - GLPI module settings' + description: 'Page de configuration du module GLPI Pléiade' + parent: pleiade.group.admin + route_name: api_glpi_pleiade.settings + weight: 2 diff --git a/api_glpi_pleiade/api_glpi_pleiade.module b/api_glpi_pleiade/api_glpi_pleiade.module new file mode 100644 index 0000000..c418270 --- /dev/null +++ b/api_glpi_pleiade/api_glpi_pleiade.module @@ -0,0 +1,32 @@ +get('glpi_url'); + $app_token = $config->get('app_token'); + $bot_id = $config->get('endpoint_ticket'); + + + //Add the JS library + $variables['#attached']['library'][] = 'api_glpi_pleiade/api_glpi_pleiade_js'; + //Add the CSS library + $variables['#attached']['library'][] = 'api_glpi_pleiade/api_glpi_pleiade_css'; + + $variables['#attached']['drupalSettings']['api_glpi_pleiade']['glpi_url'] = $glpi_url; + $variables['#attached']['drupalSettings']['api_glpi_pleiade']['app_token'] = $app_token; + $variables['#attached']['drupalSettings']['api_glpi_pleiade']['endpoint_ticket'] = $endpoint_ticket; + + +} \ No newline at end of file diff --git a/api_glpi_pleiade/api_glpi_pleiade.routing.yml b/api_glpi_pleiade/api_glpi_pleiade.routing.yml new file mode 100644 index 0000000..6be2a9d --- /dev/null +++ b/api_glpi_pleiade/api_glpi_pleiade.routing.yml @@ -0,0 +1,16 @@ +api_glpi_pleiade.settings: + path: '/admin/config/api_glpi_pleiade/settings' + defaults: + _form: '\Drupal\api_glpi_pleiade\Form\GlpiFields' + _title: 'GLPI Pléiade Settings' + requirements: + _permission: 'administer site configuration' + +api_glpi_pleiade.glpi_list_tickets: + path: '/v1/api_glpi_pleiade/glpi_list_tickets' + defaults: + _controller: '\Drupal\api_glpi_pleiade\Controller\GlpiController::glpi_list_tickets' + _title: 'Tickets Query' + _format: json + requirements: + _access: 'TRUE' diff --git a/api_glpi_pleiade/css/api_glpi_pleiade.css b/api_glpi_pleiade/css/api_glpi_pleiade.css new file mode 100644 index 0000000..e69de29 diff --git a/api_glpi_pleiade/js/api_glpi_pleiade.js b/api_glpi_pleiade/js/api_glpi_pleiade.js new file mode 100644 index 0000000..e69de29 diff --git a/api_glpi_pleiade/src/Controller/GlpiController.php b/api_glpi_pleiade/src/Controller/GlpiController.php new file mode 100644 index 0000000..d4060d6 --- /dev/null +++ b/api_glpi_pleiade/src/Controller/GlpiController.php @@ -0,0 +1,26 @@ +moduleExists('api_glpi_pleiade')) { + $this->settings_glpi = \Drupal::config('api_glpi_pleiade.settings'); + } + } + public function glpi_list_tickets(Request $request){ + + } +} \ No newline at end of file diff --git a/api_glpi_pleiade/src/Form/GlpiFields.php b/api_glpi_pleiade/src/Form/GlpiFields.php new file mode 100644 index 0000000..3cf7aa6 --- /dev/null +++ b/api_glpi_pleiade/src/Form/GlpiFields.php @@ -0,0 +1,72 @@ +config('api_glpi_pleiade.settings'); + + $form['glpi_url'] = [ + '#type' => 'textfield', + '#title' => $this->t('Url de l\'instance GLPI'), + '#default_value' => $config->get('glpi_url'), + + ]; + $form['app_token'] = [ + '#type' => 'textfield', + '#title' => $this->t('Token Api ( Configuration -> Générale -> API -> client API )'), + '#default_value' => $config->get('app_token'), + ]; + + $form['endpoint_ticket'] = [ + '#type' => 'textfield', + '#title' => $this->t('Endpoint Url For tickets'), + '#default_value' => $config->get('endpoint_ticket'), + ]; + + + return parent::buildForm($form, $form_state); + } + + /** + * {@inheritdoc} + */ + public function submitForm(array &$form, FormStateInterface $form_state) { + // Retrieve the configuration. + $config = $this->config('api_glpi_pleiade.settings'); + $config->set('glpi_url', $form_state->getValue('glpi_url')); + $config->set('app_token', $form_state->getValue('app_token')); + $config->set('endpoint_ticket', $form_state->getValue('endpoint_ticket')); + + $config->save(); + + parent::submitForm($form, $form_state); + } + +} \ No newline at end of file diff --git a/api_lemon_pleiade/css/api_lemon_pleiade.css b/api_lemon_pleiade/css/api_lemon_pleiade.css index c62a534..760a818 100644 --- a/api_lemon_pleiade/css/api_lemon_pleiade.css +++ b/api_lemon_pleiade/css/api_lemon_pleiade.css @@ -1,5 +1,5 @@ -#menuTestLemon2 .sidebar-link { - padding: 2px 0 0 8px; +#menuTestLemon2 .sidebar-link, #menuPastell .sidebar-link { + padding: 2px 0 0 14px!important; display: flex; white-space: nowrap; align-items: center; @@ -23,3 +23,6 @@ align-items: center; white-space: nowrap; } +.accordion-body { + padding: 0rem 0rem 0rem 0!important; +} \ No newline at end of file diff --git a/api_lemon_pleiade/js/api_lemon_pleiade_desktop_blocks.js b/api_lemon_pleiade/js/api_lemon_pleiade_desktop_blocks.js index 363c0b0..b2f180f 100644 --- a/api_lemon_pleiade/js/api_lemon_pleiade_desktop_blocks.js +++ b/api_lemon_pleiade/js/api_lemon_pleiade_desktop_blocks.js @@ -46,6 +46,7 @@ } // ajout du html dans la div du bloc lemon du thème au lieu du spinner document.getElementById("lemon_block_id").innerHTML = blocLemon; + } }; xhr.onerror = function () { @@ -126,7 +127,7 @@ // }, // }); var recupBlocForDragAndDrop = document.getElementById("zimbra_block_id"); - + new Sortable.create(recupBlocForDragAndDrop, { animation: 150, store: { diff --git a/api_moodle_pleiade/api_moodle_pleiade.info.yml b/api_moodle_pleiade/api_moodle_pleiade.info.yml new file mode 100644 index 0000000..c2d4a10 --- /dev/null +++ b/api_moodle_pleiade/api_moodle_pleiade.info.yml @@ -0,0 +1,12 @@ +name: API Pléiade Moodle Infos +type: module +description: 'API To get entities of Moodle for Pléiade' +# package: Pleiade User Infos +package: Pleiade +core: 8.x +core_version_requirement: ^8 || ^9 + +# Information +version: '1.0.x-dev' +project: 'api_moodle_pleiade' +datestamp: 1624364473 diff --git a/api_moodle_pleiade/api_moodle_pleiade.libraries.yml b/api_moodle_pleiade/api_moodle_pleiade.libraries.yml new file mode 100644 index 0000000..9ebe4cb --- /dev/null +++ b/api_moodle_pleiade/api_moodle_pleiade.libraries.yml @@ -0,0 +1,12 @@ +api_moodle_pleiade_js: + version: 1.x + js: + js/api_moodle_pleiade.js: {} + dependencies: + - core/drupal + - core/once +api_moodle_pleiade_css: + version: 1.x + css: + theme: + css/api_moodle_pleiade.css: {} \ No newline at end of file diff --git a/api_moodle_pleiade/api_moodle_pleiade.links.menu.yml b/api_moodle_pleiade/api_moodle_pleiade.links.menu.yml new file mode 100644 index 0000000..28ceea1 --- /dev/null +++ b/api_moodle_pleiade/api_moodle_pleiade.links.menu.yml @@ -0,0 +1,6 @@ +api_moodle_pleiade.admin: + title: 'API Pléiade - Moodle module settings' + description: 'Page de configuration du odule Moodle Pléiade' + parent: pleiade.group.admin + route_name: api_moodle_pleiade.settings + weight: 12 diff --git a/api_moodle_pleiade/api_moodle_pleiade.module b/api_moodle_pleiade/api_moodle_pleiade.module new file mode 100644 index 0000000..5982909 --- /dev/null +++ b/api_moodle_pleiade/api_moodle_pleiade.module @@ -0,0 +1,38 @@ +get('moodle_url'); + $username_moodle = $config->get('username_moodle'); + $password_moodle = $config->get('password_moodle'); + $function_moodle = $config->get('function_moodle'); + $services_moodle = $config->get('services_moodle'); + + + //Add the JS library + $variables['#attached']['library'][] = 'api_moodle_pleiade/api_moodle_pleiade_js'; + //Add the CSS library + $variables['#attached']['library'][] = 'api_moodle_pleiade/api_moodle_pleiade_css'; + + $variables['#attached']['drupalSettings']['api_moodle_pleiade']['moodle_url'] = $moodle_url; + $variables['#attached']['drupalSettings']['api_moodle_pleiade'] = [ + 'moodle_url' => $moodle_url, + 'username_moodle' => $username_moodle, + 'password_moodle' => $password_moodle, + 'function_moodle' => $function_moodle, + 'services_moodle' => $services_moodle, +]; + +} diff --git a/api_moodle_pleiade/api_moodle_pleiade.routing.yml b/api_moodle_pleiade/api_moodle_pleiade.routing.yml new file mode 100644 index 0000000..c46571f --- /dev/null +++ b/api_moodle_pleiade/api_moodle_pleiade.routing.yml @@ -0,0 +1,16 @@ +api_moodle_pleiade.settings: + path: '/admin/config/api_moodle_pleiade/settings' + defaults: + _form: '\Drupal\api_moodle_pleiade\Form\MoodleFields' + _title: 'moodle Pléiade Settings' + requirements: + _permission: 'administer site configuration' + +api_moodle_pleiade.moodle_entities: + path: '/v1/api_moodle_pleiade/moodle_entities' + defaults: + _controller: '\Drupal\api_moodle_pleiade\Controller\MoodleController::moodle_entities' + _title: 'moodle Query' + _format: json + requirements: + _access: 'TRUE' \ No newline at end of file diff --git a/api_moodle_pleiade/css/api_moodle_pleiade.css b/api_moodle_pleiade/css/api_moodle_pleiade.css new file mode 100644 index 0000000..9dae876 --- /dev/null +++ b/api_moodle_pleiade/css/api_moodle_pleiade.css @@ -0,0 +1,19 @@ +.btn-e-coll{ + background-color: #1f3889!important; + +} +.card-img-top { + width: 300px!important; + max-width: 300px!important; + height: 200px; + object-fit: cover; +} +#moodle_courses .card{ + box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.175) !important; + margin-bottom: 1rem!important; +} + +#moodle_courses p{ + margin: 0 0 0 0!important; + +} \ No newline at end of file diff --git a/api_moodle_pleiade/js/api_moodle_pleiade.js b/api_moodle_pleiade/js/api_moodle_pleiade.js new file mode 100644 index 0000000..9f64bbf --- /dev/null +++ b/api_moodle_pleiade/js/api_moodle_pleiade.js @@ -0,0 +1,107 @@ +(function (Drupal, once, drupalSettings) { + "use strict"; + Drupal.behaviors.APIMoodleBehavior = { + attach: function (context, settings) { + + if (drupalSettings.path.isFront) { + once("APIMoodleBehavior", "body", context).forEach(function () { + + var xhr = new XMLHttpRequest(); + xhr.open("GET", Drupal.url("v1/api_moodle_pleiade/moodle_entities")); + xhr.responseType = "json"; + xhr.onload = function () { + if (xhr.status === 200) { + + var donnees = (xhr.response); + const div = document.querySelector('#moodle_courses'); + var blocMoodle = "" + if(donnees && div) + { + + blocMoodle += '
\ +
\ +
\ +
\ +

Cours E-Learning d\'E-collectivités

\ +
\ + ' + var count_entities = donnees.length - 1 + var usedNumbers = [1]; + for (var i = 0; i < 3; i++) { + var number = Math.floor(Math.random() * count_entities + 1); + if (usedNumbers.includes(number)) { + // Number is already used, decrement the loop index to try again + i--; + } + else + { + usedNumbers.push(number); + + if(donnees[number].overviewfiles[0]) + { + if(donnees[number].overviewfiles[0].fileurl) + { + var imageurl = donnees[number].overviewfiles[0].fileurl + } + } + else + { + var imageurl = "https://ecollectivites.fr/sites/default/files/inline-images/logo-ecollectivites.jpg" + } + if(donnees[number].categoryname) + { + var categoryCourse = donnees[number].categoryname + } + else + { + var categoryCourse= "" + } + + + if(number !== 0){ + blocMoodle += + '\ +
\ +
\ + Course Image\ +
\ +
'+ categoryCourse +'
\ +

Voir ce cours

\ +
\ +
\ +
\ +
'; + } + + + } + } + blocMoodle += "
"; + } + else // if no notification + { + + } + document.getElementById("moodle_courses").innerHTML = + blocMoodle; + } + }; + xhr.onerror = function () { + console.log("Error making AJAX call"); + }; + xhr.onabort = function () { + console.log("AJAX call aborted"); + }; + xhr.ontimeout = function () { + console.log("AJAX call timed out"); + }; + xhr.onloadend = function () { + + }; + + xhr.send(); + }); + } + } + } +})(Drupal, once, drupalSettings); \ No newline at end of file diff --git a/api_moodle_pleiade/src/Controller/MoodleController.php b/api_moodle_pleiade/src/Controller/MoodleController.php new file mode 100644 index 0000000..da466b2 --- /dev/null +++ b/api_moodle_pleiade/src/Controller/MoodleController.php @@ -0,0 +1,102 @@ +moduleExists('api_moodle_pleiade')) { + $this->settings_moodle = \Drupal::config('api_moodle_pleiade.settings'); + } + } + public function moodle_entities(Request $request) { + $this->client = \Drupal::httpClient(); + $moodle_url = $this->settings_moodle->get('moodle_url'); + $username_moodle = $this->settings_moodle->get('username_moodle'); + $password_moodle = $this->settings_moodle->get('password_moodle'); + $function_moodle = $this->settings_moodle->get('function_moodle'); + $services_moodle = $this->settings_moodle->get('services_moodle'); + + $moodleUrl = $moodle_url.'/login/token.php?username='.$username_moodle.'&password='.$password_moodle.'&service='.$services_moodle; + + // Set parameters for retrieving all courses + $requestParams = [ + 'headers' => [], + ]; + + // Make the request + $clientRequest = $this->client->request('POST', $moodleUrl, $requestParams); + $json_string = $clientRequest->getBody()->getContents(); + $data = json_decode($json_string, true); + $token = $data['token']; + + $this->client = \Drupal::httpClient(); + + if ($token !== null) { + // Return the response in JSON format + $moodleUrl1 = $moodle_url.'/webservice/rest/server.php?wstoken='.$token.'&wsfunction='.$function_moodle.'&moodlewsrestformat=json'; + + // Set parameters for retrieving all courses + $requestParams1 = [ + 'headers' => [], + ]; + + // Make the request + $clientRequest1 = $this->client->request('POST', $moodleUrl1, $requestParams1); + + $response = $clientRequest1->getBody()->getContents(); + $array_courses = json_decode($response)->courses; + + foreach($array_courses as $courses){ + $fileurl = $courses->overviewfiles[0]->fileurl; + + if($fileurl){ + $requestParams4 = [ + 'headers' => [ + "Content-Type" => "image/jpeg" + ], + ]; + $clientRequest4 = $this->client->request('GET', $fileurl.'?token=146b998e4049174242a38f4b9a71b271', $requestParams4); + $base = $clientRequest4->getBody()->getContents(); + $base64 = base64_encode($base); + $mime = "image/jpeg"; + $img = ('data:' . $mime . ';base64,' . $base64); + + $courses->overviewfiles[0]->fileurl = $img; + } + } + + // $moodleUrl4 = 'https://preprod.ecollectivites.fr/moodle/webservice/pluginfile.php/26/course/overviewfiles/zimbra-logo-611x378.jpg?token=146b998e4049174242a38f4b9a71b271'; + // // Make the request + // $clientRequest4 = $this->client->request('GET', $moodleUrl4, $requestParams4); + // $base = $clientRequest4->getBody()->getContents(); + // $base64 = base64_encode($base); + // $mime = "image/jpeg"; + // $img = ('data:' . $mime . ';base64,' . $base64); + + if ($response !== null) + { + // Return the response in JSON format + return new JsonResponse(json_encode($array_courses), 200, [], true); + } + else + { + // Handle the case where the response is null + return new JsonResponse(['error' => 'Response is null'], 400); + } + } + else + { + // Handle the case where the response is null + return new JsonResponse(['error' => 'Response is null'], 400); + } + } +} \ No newline at end of file diff --git a/api_moodle_pleiade/src/Form/MoodleFields.php b/api_moodle_pleiade/src/Form/MoodleFields.php new file mode 100644 index 0000000..e4a48e3 --- /dev/null +++ b/api_moodle_pleiade/src/Form/MoodleFields.php @@ -0,0 +1,84 @@ +config('api_moodle_pleiade.settings'); + + $form['moodle_url'] = [ + '#type' => 'textfield', + '#title' => $this->t('Url Moodle'), + '#default_value' => $config->get('moodle_url'), + ]; + $form['username_moodle'] = [ + '#type' => 'textfield', + '#title' => $this->t('Moodle Username'), + '#default_value' => $config->get('username_moodle'), + ]; + + $form['password_moodle'] = [ + '#type' => 'password', + '#title' => $this->t('Moodle Password'), + '#default_value' => $config->get('password_moodle'), + ]; + + $form['function_moodle'] = [ + '#type' => 'textfield', + '#title' => $this->t('Moodle Function'), + '#default_value' => $config->get('function_moodle'), + ]; + + $form['services_moodle'] = [ + '#type' => 'textfield', + '#title' => $this->t('Moodle Services'), + '#default_value' => $config->get('services_moodle'), + ]; + return parent::buildForm($form, $form_state); + } + + /** + * {@inheritdoc} + */ + public function submitForm(array &$form, FormStateInterface $form_state) { + // Retrieve the configuration. + $config = $this->config('api_moodle_pleiade.settings'); + $config->set('moodle_url', $form_state->getValue('moodle_url')); + $config->set('username_moodle', $form_state->getValue('username_moodle')); + $config->set('password_moodle', $form_state->getValue('password_moodle')); + $config->set('function_moodle', $form_state->getValue('function_moodle')); + $config->set('services_moodle', $form_state->getValue('services_moodle')); + + + $config->save(); + + parent::submitForm($form, $form_state); + } + +} \ No newline at end of file diff --git a/api_parapheur_pleiade/src/Controller/PleiadeAjaxParapheurController.php b/api_parapheur_pleiade/src/Controller/PleiadeAjaxParapheurController.php index b671c71..b531598 100644 --- a/api_parapheur_pleiade/src/Controller/PleiadeAjaxParapheurController.php +++ b/api_parapheur_pleiade/src/Controller/PleiadeAjaxParapheurController.php @@ -3,22 +3,21 @@ namespace Drupal\api_parapheur_pleiade\Controller; use Drupal\Core\Controller\ControllerBase; - use Drupal\Component\Serialization\JSON; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; -use Drupal\api_parapheur_pleiade\IParapheurDataApiManager; +use Drupal\module_api_pleiade\ApiPleiadeManager; class PleiadeAjaxParapheurController extends ControllerBase { public function parapheur_entities_query(Request $request){ $return = []; //our variable to fill with data returned by Parapheur - - $parapheurdataApi = new IParapheurDataApiManager(); + $parapheurdataApi = new ApiPleiadeManager(); $return = $parapheurdataApi->searchMyDesktop(); - - return new JsonResponse(json_encode($return), 200, [], true); + if($return){ + return new JsonResponse(json_encode($return), 200, [], true); + } } } \ No newline at end of file diff --git a/api_parapheur_pleiade/src/IParapheurDataApiManager.php b/api_parapheur_pleiade/src/IParapheurDataApiManager.php deleted file mode 100644 index b66b052..0000000 --- a/api_parapheur_pleiade/src/IParapheurDataApiManager.php +++ /dev/null @@ -1,163 +0,0 @@ -error($msg); - return; - } - $this->client = \Drupal::httpClient(); - // get our custom module settings - $this->settings = \Drupal::config('api_parapheur_pleiade.settings'); - - } - - /** - * Do CURL request with authorization. - * - * @param string $endpoint - * A request action of api. - * @param string $method - * A method of curl request. - * @param Array $inputs - * A data of curl request. - * - * @return array - * An associate array with respond data. - */ - private function executeCurl($endpoint, $method, $inputs, $api) { - if (!isset($_COOKIE['lemonldap'])) { - $msg = 'Pas authentifié dans le SSO '; - \Drupal::logger('api_parapheur_pleiade')->error($msg); - return NULL; - } - if( $this->settings->get('field_parapheur_auth_method') == 'cas' || $this->settings->get('field_parapheur_auth_method') == 'oidc'){ - $PARAPHEUR_AP_URL = $api . '?auth=cas'; - } - else - { - $PARAPHEUR_AP_URL = $api; - } - - // ProxyTicket - -// TEST - // $PT_request_url = 'https://iparapheurdev.ecollectivites.fr/iparapheur/proxy/alfresco/parapheur/bureaux?auth=cas'; - - // On utilise le sergvice du module CAS Drupal\cas\Service\CasProxyHelper; - $proxy_ticket = \Drupal::service('cas.proxy_helper')->getProxyTicket($PT_request_url); - // $PARAPHEUR_AP_URL = $PT_request_url . '&ticket=' . $proxy_ticket; - - // $PARAPHEUR_AP_URL = 'https://iparapheurdev.ecollectivites.fr/iparapheur/proxy/alfresco/parapheur/bureaux?auth=cas&ticket='.$proxy_ticket; - // $PARAPHEUR_AP_URL = ' https://iparapheurdev.ecollectivites.fr/'; - - $options = [ - 'headers' => [ - 'Content-Type' => 'application/json', - 'Cookie'=> 'llnglanguage=fr; lemonldap=' . $_COOKIE['lemonldap'] - ], - ]; - $method = 'POST'; - - if (!empty($inputs)) { - - if($method == 'GET'){ - $PARAPHEUR_AP_URL.= '?' . self::arrayKeyfirst($inputs) . '=' . array_shift($inputs); - foreach($inputs as $param => $value){ - $PARAPHEUR_AP_URL.= '&' . $param . '=' . $value; - } - }else{ - //POST request send data in array index form_params. - $options['body'] = $inputs; - } - } - - try { - $clientRequest = $this->client->request($method, 'https://idtest.ecollectivites.fr/remote.php/dav/files/pleiade1%40formation/', $options); - - $body = $clientRequest->getBody()->getContents(); - - } catch (RequestException $e) { - \Drupal::logger('api_parapheur_pleiade')->error('Curl error: @error', ['@error' => $e->getMessage()]); - } - - var_dump($body); - return Json::decode($body); - } - - /** - * Get Request of API. - * - * @param string $endpoint - * A request action. - * @param string $input - * A data of curl request. - * - * @return array - * A respond data. - */ - public function curlGet($endpoint, $inputs, $api) { - return $this->executeCurl($endpoint, "GET", $inputs, $api); - } - - /** - * Post Request of API. - * - * @param string $endpoint - * A request action. - * @param string $inputs - * A data of curl request. - * - * @return array - * A respond data. - */ - public function curlPost($endpoint, $inputs, $api) { - return $this->executeCurl($endpoint, "POST", $inputs, $api); - } - - public function searchMyDesktop() { - $endpoints = $this->settings->get('field_parapheur_bureaux_url'); // Endpoint myapplications de Lemon qui renvoie toutes nos apps - // \Drupal::logger('api_parapheur_documents')->info('function searchMyApps triggered !'); - return $this->curlGet($endpoints, [], $this->settings->get('field_parapheur_url') . $this->settings->get('field_parapheur_bureaux_url')); - } - - /** - * Function to return first element of the array, compatability with PHP 5, note that array_key_first is only available for PHP > 7.3. - * - * @param array $array - * Associative array. - * - * @return string - * The first key data. - */ - public static function arrayKeyfirst($array){ - if (!function_exists('array_key_first')) { - foreach($array as $key => $unused) { - return $key; - } - return NULL; - }else{ - return array_key_first($array); - } - } -} \ No newline at end of file diff --git a/api_pastell_pleiade/api_pastell_pleiade.info.yml b/api_pastell_pleiade/api_pastell_pleiade.info.yml index f55b9db..092a2b6 100644 --- a/api_pastell_pleiade/api_pastell_pleiade.info.yml +++ b/api_pastell_pleiade/api_pastell_pleiade.info.yml @@ -7,10 +7,6 @@ package: Pleiade core: 8.x core_version_requirement: ^8 || ^9 -dependencies: - - api_lemon_pleiade - - module_api_pleiade - # Information version: '1.0.x-dev' project: 'api_pastell_pleiade' diff --git a/api_pastell_pleiade/api_pastell_pleiade.libraries.yml b/api_pastell_pleiade/api_pastell_pleiade.libraries.yml index 1fc7fbb..4d57e50 100644 --- a/api_pastell_pleiade/api_pastell_pleiade.libraries.yml +++ b/api_pastell_pleiade/api_pastell_pleiade.libraries.yml @@ -4,6 +4,7 @@ api_pastell_pleiade_js: js/api_pastell_entites.js: {} js/libs/moment.js: {} js/api_pastell_documents.js: {} + # js/api_pastell_menu.js: {} js/libs/jquery.dataTables.min.js: {} js/libs/dataTables.bootstrap5.min.js: {} diff --git a/api_pastell_pleiade/js/api_pastell_entites.js b/api_pastell_pleiade/js/api_pastell_entites.js index 661cefe..35a2a92 100644 --- a/api_pastell_pleiade/js/api_pastell_entites.js +++ b/api_pastell_pleiade/js/api_pastell_entites.js @@ -9,13 +9,13 @@ function () { // le nom du groupe LDAP pour pastell doit etre renseigné dans l'admin // check si existe + si dans le Drupal tempstore stocké par le module Lemon Pléiade - var pastellLDAPGroup = drupalSettings.api_pastell_pleiade.field_pastell_ldap_group; - var userGroupsTempstore = drupalSettings.api_lemon_pleiade.user_groups; - // console.log('Pastell ldap group from Pastell Pléiade setting: ' + pastellLDAPGroup); - // console.log('Drupal tempstore groups from Lemon Pléiade module: ' + userGroupsTempstore); + // var pastellLDAPGroup = drupalSettings.api_pastell_pleiade.field_pastell_ldap_group; + // var userGroupsTempstore = drupalSettings.api_lemon_pleiade.user_groups; + // // console.log('Pastell ldap group from Pastell Pléiade setting: ' + pastellLDAPGroup); + // // console.log('Drupal tempstore groups from Lemon Pléiade module: ' + userGroupsTempstore); - // Call only if pastell group set and in private tempstore user_groups - if (pastellLDAPGroup && userGroupsTempstore.includes(pastellLDAPGroup)) { + // // Call only if pastell group set and in private tempstore user_groups + // if (pastellLDAPGroup && userGroupsTempstore.includes(pastellLDAPGroup)) { // prepare menu var linkEntitie = document.getElementById("collectiviteChoice"); // make ajax call @@ -121,7 +121,7 @@ }; xhr.send(); - } // end if pastell group & in tempstore + // } // end if pastell group & in tempstore }); // end once } // fin only on frontpage }, diff --git a/api_user_pleiade/api_user_pleiade.info.yml b/api_user_pleiade/api_user_pleiade.info.yml index 27b19dc..e84f056 100644 --- a/api_user_pleiade/api_user_pleiade.info.yml +++ b/api_user_pleiade/api_user_pleiade.info.yml @@ -6,9 +6,6 @@ package: Pleiade core: 8.x core_version_requirement: ^8 || ^9 -dependencies: - - module_api_pleiade - # Information version: '1.0.x-dev' project: 'api_user_pleiade' diff --git a/api_user_pleiade/api_user_pleiade.libraries.yml b/api_user_pleiade/api_user_pleiade.libraries.yml index e18c6b7..5ed6eb8 100644 --- a/api_user_pleiade/api_user_pleiade.libraries.yml +++ b/api_user_pleiade/api_user_pleiade.libraries.yml @@ -3,6 +3,7 @@ api_user_pleiade_js: js: js/api_user_pleiade.js: {} js/lib/steptip.js: {} + js/lib/slick.js: {} dependencies: - core/drupal - core/once @@ -10,4 +11,5 @@ api_user_pleiade_css: version: 1.x css: theme: - css/api_user_pleiade.css: {} \ No newline at end of file + css/api_user_pleiade.css: {} + css/lib/slick.css: {} \ No newline at end of file diff --git a/api_user_pleiade/api_user_pleiade.module b/api_user_pleiade/api_user_pleiade.module index 8e08172..58739ec 100644 --- a/api_user_pleiade/api_user_pleiade.module +++ b/api_user_pleiade/api_user_pleiade.module @@ -15,6 +15,9 @@ function api_user_pleiade_preprocess_page(&$variables){ $config = \Drupal::config('api_user_pleiade.settings'); $have_chatbot = $config->get('have_chatbot'); + $apiKey = $config->get('apiKey'); + $bot_id = $config->get('bot_id'); + //Add the JS library $variables['#attached']['library'][] = 'api_user_pleiade/api_user_pleiade_js'; @@ -22,5 +25,8 @@ function api_user_pleiade_preprocess_page(&$variables){ $variables['#attached']['library'][] = 'api_user_pleiade/api_user_pleiade_css'; $variables['#attached']['drupalSettings']['api_user_pleiade']['have_chatbot'] = $have_chatbot; - -} \ No newline at end of file + $variables['#attached']['drupalSettings']['api_user_pleiade']['apiKey'] = $apiKey; + $variables['#attached']['drupalSettings']['api_user_pleiade']['bot_id'] = $bot_id; + + +} diff --git a/api_user_pleiade/css/api_user_pleiade.css b/api_user_pleiade/css/api_user_pleiade.css index 8cea389..f2d9ac4 100644 --- a/api_user_pleiade/css/api_user_pleiade.css +++ b/api_user_pleiade/css/api_user_pleiade.css @@ -1,10 +1,18 @@ -.alert_popup svg:hover { - transform: scale(1.3); - /* (150% zoom - Note: if the zoom is too large, it will go outside of the viewport) */ -} -.alert_popup svg { + +/* .alert_popup svg:hover { + transform: scale(1.3); + +} */ +/* .alert_popup svg { transition: transform .2s; +} */ +.notification_scale{ + animation: pulse 1s infinite ease-in-out alternate; +} +@keyframes pulse { + from { transform: scale(0.2); } + to { transform: scale(1.9); } } #notification_alert .feather { @@ -485,3 +493,56 @@ tr.introjs-showElement>th { z-index: 1; opacity: 0 } + +#sntch_button{ + right: 20px!important; + bottom: 20px!important; + padding: 25px!important; + animation: bounce 2s infinite ease-in-out; + -webkit-animation: bounce 2s infinite ease-in-out; + -moz-animation: bounce 2s infinite ease-in-out; + -o-animation: bounce 2s infinite ease-in-out; + animation-iteration-count: 5; +} + +@-webkit-keyframes bounce { + 0%, 20%, 50%, 80%, 100% {-webkit-transform: translateY(0);} + 40% {-webkit-transform: translateY(-20px);} + 60% {-webkit-transform: translateY(-15px);} +} + +@-moz-keyframes bounce { + 0%, 20%, 50%, 80%, 100% {-moz-transform: translateY(0);} + 40% {-moz-transform: translateY(-20px);} + 60% {-moz-transform: translateY(-15px);} +} + +@-o-keyframes bounce { + 0%, 20%, 50%, 80%, 100% {-o-transform: translateY(0);} + 40% {-o-transform: translateY(-20px);} + 60% {-o-transform: translateY(-15px);} +} +@keyframes bounce { + 0%, 20%, 50%, 80%, 100% {transform: translateY(0);} + 40% {transform: translateY(-20px);} + 60% {transform: translateY(-15px);} +} + +.btn-accessibility_a-plus { + font-size: 22px; + vertical-align: baseline!important; +} +.btn-accessibility_a-less { + vertical-align: baseline!important; +} +body[data-theme=dark] .btn-accessibility{ + color: #FFF!important; +} +.btn-accessibility { + background: none!important; + color: #1f3889!important; + border: none!important; + padding: 0!important; + +} + diff --git a/api_user_pleiade/css/lib/slick.css b/api_user_pleiade/css/lib/slick.css new file mode 100644 index 0000000..8aeb2d0 --- /dev/null +++ b/api_user_pleiade/css/lib/slick.css @@ -0,0 +1,143 @@ + +.slick-dots, .slick-next, .slick-prev { + position: absolute; + display: block; + padding: 0 +} + +.slick-dots li button:before, .slick-next:before, .slick-prev:before { + font-family: slick; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale +} + + +.slick-next, .slick-prev { + font-size: 0; + line-height: 0; + top: 50%; + width: 20px; + height: 20px; + margin-top: -10px\9; + -webkit-transform: translate(0, -50%); + -ms-transform: translate(0, -50%); + transform: translate(0, -50%); + cursor: pointer; + color: transparent; + border: none; + outline: 0; + background: 0 0 +} + +.slick-next:focus, .slick-next:hover, .slick-prev:focus, .slick-prev:hover { + color: transparent; + outline: 0; + background: 0 0 +} + +.slick-next:focus:before, .slick-next:hover:before, .slick-prev:focus:before, .slick-prev:hover:before { + opacity: 1 +} + +.slick-next.slick-disabled:before, .slick-prev.slick-disabled:before { + opacity: .25 +} + +.slick-next:before, .slick-prev:before { + font-size: 20px; + line-height: 1; + opacity: .75; + color: #fff +} + +.slick-prev { + left: -25px +} + +[dir=rtl] .slick-prev { + right: -25px; + left: auto +} + +.slick-prev:before { + content: '←' +} + +.slick-next:before, [dir=rtl] .slick-prev:before { + content: '→' +} + +.slick-next { + right: -25px +} + +[dir=rtl] .slick-next { + right: auto; + left: -25px +} + +[dir=rtl] .slick-next:before { + content: '←' +} + +.slick-slider { + margin-bottom: 30px +} + +.slick-dots { + bottom: -45px; + width: 100%; + list-style: none; + text-align: center +} + +.slick-dots li { + position: relative; + display: inline-block; + width: 20px; + height: 20px; + margin: 0 5px; + padding: 0; + cursor: pointer +} + +.slick-dots li button { + font-size: 0; + line-height: 0; + display: block; + width: 20px; + height: 20px; + padding: 5px; + cursor: pointer; + color: transparent; + border: 0; + outline: 0; + background: 0 0 +} + +.slick-dots li button:focus, .slick-dots li button:hover { + outline: 0 +} + +.slick-dots li button:focus:before, .slick-dots li button:hover:before { + opacity: 1 +} + +.slick-dots li button:before { + font-size: 6px; + line-height: 20px; + position: absolute; + top: 0; + left: 0; + width: 20px; + height: 20px; + content: '•'; + text-align: center; + opacity: .25; + color: #000 +} + +.slick-dots li.slick-active button:before { + opacity: .75; + color: #000 +} \ No newline at end of file diff --git a/api_user_pleiade/js/api_user_pleiade.js b/api_user_pleiade/js/api_user_pleiade.js index 3189c05..f247989 100644 --- a/api_user_pleiade/js/api_user_pleiade.js +++ b/api_user_pleiade/js/api_user_pleiade.js @@ -3,10 +3,72 @@ Drupal.behaviors.APIzimbraUserInfoBehavior = { attach: function (context, settings) { // Load on front page only, + // ajout diminution and augmentation de la taille de la police + if (drupalSettings.path.isFront) { once("APIzimbraUserInfoBehavior", "body", context).forEach(function () { - // requete + // Augmenter la taille des polices + var increaseBtn = document.getElementById("increase-btn"); + var decreaseBtn = document.getElementById("decrease-btn"); + function toggleAccordion() { + const extendedMenu = localStorage.getItem('extended_menu'); + if (extendedMenu !== null) { + const input = document.querySelector('input[name="extended_menu"]'); + input.setAttribute('checked', 'checked'); + console.log('ok'); + const accordionCollapses = document.querySelectorAll('.accordion-collapse'); + for (let i = 0; i < accordionCollapses.length; i++) { + accordionCollapses[i].classList.toggle('show'); + } + } + } + function handleCheckboxChange() { + const checkbox = document.querySelector('input[name="extended_menu"]'); + const accordionCollapses = document.querySelectorAll('.accordion-collapse'); + if (checkbox.checked) { + localStorage.setItem('extended_menu', true); + for (let i = 0; i < accordionCollapses.length; i++) { + accordionCollapses[i].classList.add('show'); + } + } else { + localStorage.removeItem('extended_menu'); + for (let i = 0; i < accordionCollapses.length; i++) { + accordionCollapses[i].classList.remove('show'); + } + } + } + + window.addEventListener('load', toggleAccordion); + + const checkbox = document.querySelector('input[name="extended_menu"]'); + checkbox.addEventListener('change', handleCheckboxChange); + // Add event listeners to the buttons + increaseBtn.addEventListener("click", function() { + var el = document.body; + var style = window.getComputedStyle(el, null).getPropertyValue('font-size'); + var style_up = window.getComputedStyle(increaseBtn, null).getPropertyValue('font-size'); + var fontSize = parseFloat(style); + var fontSizeUp = parseFloat(style_up); + console.log(style_up) + el.style.fontSize = (fontSize + 3) + 'px'; + increaseBtn.style.fontSize = (fontSizeUp + 3) + 'px'; + decreaseBtn.style.fontSize = (fontSize + 3) + 'px'; + }); + + decreaseBtn.addEventListener("click", function() { + var el = document.body; + var style = window.getComputedStyle(el, null).getPropertyValue('font-size'); + var style_down = window.getComputedStyle(decreaseBtn, null).getPropertyValue('font-size'); + var style_up = window.getComputedStyle(increaseBtn, null).getPropertyValue('font-size'); + var fontSize = parseFloat(style); + var fontSizeDown = parseFloat(style_down); + var fontSizeUp = parseFloat(style_up); + console.log(fontSize) + el.style.fontSize = (fontSize - 3) + 'px'; + decreaseBtn.style.fontSize = (fontSizeDown - 3) + 'px'; + increaseBtn.style.fontSize = (fontSizeUp - 3) + 'px'; + }); var xhr = new XMLHttpRequest(); xhr.open("GET", Drupal.url("v1/api_user_pleiade/user_infos_query")); xhr.responseType = "json"; @@ -20,7 +82,8 @@ // add one hour to current datetime var oneHourAgo = now + (60 * 60); // get notification_alert div - const div = document.querySelector('#notification_alert'); + const div = document.querySelector('#notification_alert'); + const div_chatbot = document.querySelector('.page-wrapper'); //console.log(oneHourAgo); if(donnees && div){ @@ -32,6 +95,7 @@ const div_alert = document.querySelector('.alert_popup'); // add svg with red point if(div_alert) { + div_alert.classList.add("notification_scale"); div_alert.innerHTML += ''; } for (var i = 0; i < donnees.length; i++) { @@ -80,11 +144,7 @@ \