Skip to content

Commit

Permalink
Auth Twig UI
Browse files Browse the repository at this point in the history
  • Loading branch information
cconard96 committed Apr 19, 2024
1 parent d405f4c commit 91b0dd2
Show file tree
Hide file tree
Showing 8 changed files with 365 additions and 368 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -62,6 +62,7 @@ The present file will list all changes made to the project; according to the
- External Links `Link or filename` and `File content` fields now use Twig templates instead of a custom tag syntax.
- Itemtypes associated with External links are now in the main form rather than a separate tab.
- The `Computer_Item` class has been replaced by the `\Glpi\Asset\Asset_PeripheralAsset` class.
- Testing LDAP replicates now shows results as toast notifications rather than inside the replicate tab after a page reload.

### Deprecated
- Survey URL tags `TICKETCATEGORY_ID` and `TICKETCATEGORY_NAME` are deprecated and replaced by `ITILCATEGORY_ID` and `ITILCATEGORY_NAME` respectively.
Expand All @@ -84,6 +85,7 @@ The present file will list all changes made to the project; according to the
#### Added
- `phpCAS` library is now bundled in GLPI, to prevent version compatibility issues.
- `Glpi\DBAL\QueryFunction` class with multiple static methods for building SQL query function strings in an abstract way.
- `fetchSessionMessages()` global JS function to display new session messages as toast notifications without requiring a page reload.

#### Changes
- Many methods have their signature changed to specify both their return type and the types of their parameters.
Expand Down Expand Up @@ -322,6 +324,7 @@ The present file will list all changes made to the project; according to the
- `$CFG_GLPI['debug_sql']` and `$CFG_GLPI['debug_vars']` configuration options.
- `DropdownTranslation::getTranslationByName()`
- `addgroup` and `deletegroup` actions in `front/user.form.php`.
- `test_ldap` and `test_ldap_replicate` actions in `front/authldap.form.php`. Use `ajax/ldap.php` instead.


## [10.0.15] unreleased
Expand Down
41 changes: 0 additions & 41 deletions front/authldap.form.php
Expand Up @@ -75,47 +75,6 @@
$config_ldap->delete($_POST, 1);
$_SESSION['glpi_authconfig'] = 1;
$config_ldap->redirectToList();
} else if (isset($_POST["test_ldap"])) {
$config_ldap->getFromDB($_POST["id"]);

if (AuthLDAP::testLDAPConnection($_POST["id"])) {
//TRANS: %s is the description of the test
$_SESSION["LDAP_TEST_MESSAGE"] = sprintf(
__('Test successful: %s'),
//TRANS: %s is the name of the LDAP main server
sprintf(__('Main server %s'), $config_ldap->fields["name"])
);
} else {
//TRANS: %s is the description of the test
$_SESSION["LDAP_TEST_MESSAGE"] = sprintf(
__('Test failed: %s'),
//TRANS: %s is the name of the LDAP main server
sprintf(__('Main server %s'), $config_ldap->fields["name"])
);
GLPINetwork::addErrorMessageAfterRedirect();
}
Html::back();
} else if (isset($_POST["test_ldap_replicate"])) {
$replicate = new AuthLdapReplicate();
$replicate->getFromDB($_POST["ldap_replicate_id"]);

if (AuthLDAP::testLDAPConnection($_POST["id"], $_POST["ldap_replicate_id"])) {
//TRANS: %s is the description of the test
$_SESSION["LDAP_TEST_MESSAGE"] = sprintf(
__('Test successful: %s'),
//TRANS: %s is the name of the LDAP replica server
sprintf(__('Replicate %s'), $replicate->fields["name"])
);
} else {
//TRANS: %s is the description of the test
$_SESSION["LDAP_TEST_MESSAGE"] = sprintf(
__('Test failed: %s'),
//TRANS: %s is the name of the LDAP replica server
sprintf(__('Replicate %s'), $replicate->fields["name"])
);
GLPINetwork::addErrorMessageAfterRedirect();
}
Html::back();
} else if (isset($_POST["add_replicate"])) {
$replicate = new AuthLdapReplicate();
unset($_POST["next"]);
Expand Down
26 changes: 26 additions & 0 deletions js/common.js
Expand Up @@ -34,6 +34,7 @@
/* global bootstrap */
/* global L */
/* global glpi_html_dialog */
/* global glpi_toast_info, glpi_toast_warning, glpi_toast_error */

var timeoutglobalvar;

Expand Down Expand Up @@ -1862,3 +1863,28 @@ function setupAjaxDropdown(config) {

return select2_el;
}

function fetchSessionMessages() {
$.ajax({
method: 'GET',
url: (CFG_GLPI.root_doc + "/ajax/displayMessageAfterRedirect.php"),
data: {
'get_raw': true
}
}).done((messages) => {
$.each(messages, (level, level_messages) => {
$.each(level_messages, (index, message) => {
switch (parseInt(level)) {
case 1:
glpi_toast_error(message);
break;
case 2:
glpi_toast_warning(message);
break;
default:
glpi_toast_info(message);
}
});
});
});
}
23 changes: 1 addition & 22 deletions js/src/vue/Kanban/Column.vue
Expand Up @@ -149,28 +149,7 @@
closeItemForms();
showAddItemForm(itemtype, is_bulk);
}).always(() => {
$.ajax({
method: 'GET',
url: (CFG_GLPI.root_doc + "/ajax/displayMessageAfterRedirect.php"),
data: {
'get_raw': true
}
}).done((messages) => {
$.each(messages, (level, level_messages) => {
$.each(level_messages, (index, message) => {
switch (parseInt(level)) {
case 1:
glpi_toast_error(message);
break;
case 2:
glpi_toast_warning(message);
break;
default:
glpi_toast_info(message);
}
});
});
});
fetchSessionMessages();
});
}
Expand Down

0 comments on commit 91b0dd2

Please sign in to comment.