FutureProcessing / glpi-webhook

GNU Affero General Public License v3.0
7 stars 4 forks source link

No `Save` button on form #3

Closed mikron-ia closed 2 years ago

mikron-ia commented 2 years ago

Ok, now I can see that page, but there's no Save button so I couldn't manage to save anything. And it doesn't appear to be saving anything just by getting out of the page. Am I missing something here or a button is really missing?

Screenshot from 2021-12-20 11-13-21

Originally posted by @heizac in https://github.com/FutureProcessing/glpi-webhook/issues/1#issuecomment-997969134

mikron-ia commented 2 years ago

I can't reproduce the problem with the missing ADD button.

@heizac, do you still experience this issue after the usual steps (relogging and reinstalling the plugin)?

If yes, please provide some further data that would allow me to reproduce it locally: GLPI version, user profile (admin? super-admin? another?), errors from the log (if any), accompanying plugins (by name or plugin list screenshot, directory list is not very helpful), etc.

If it is no longer a problem, please report so I can close this.

heizac commented 2 years ago

I reinstalled the plugin, relogged and the button still doesn't appear. I tried with other users too, like the glpi user but it's the same. GLPI version: 9.5.6 User Profile: Super-Admin I couldn't find anything related to plugins on logs (Administration > Logs)

Plugins I'm using at the moment: plugins

I thought that maybe the problem is related to permissions but I'm not sure: Screenshot from 2021-12-22 11-42-34

I also wonder if there's an error in the php file subscription.form.php, but if that was the case you would know I guess.

DockCZ commented 2 years ago

Hello I have same problem.

GLPI 9.5.6

During plugin installation: Error occurred during FP Webhook setup - unable to run schema for 1.0.0. (0 seconds)

After page refresh and new try > Plugin FP Webhook has been installed!

From GLPI DEBUG: SQL Error "1146": Table 'glpidb.glpi_plugin_fpwebhook_subscriptions' doesn't exist in query "SHOW COLUMNS FROM glpi_plugin_fpwebhook_subscriptions"

From Mariadb:

MariaDB [glpidb]> show tables where Tables_in_glpidb like '%fpwebhook%';
+----------------------------------+
| Tables_in_glpidb                 |
+----------------------------------+
| glpi_plugin_fpwebhook_eventtypes |
+----------------------------------+
1 row in set (0.003 sec)

GLPI sql-errors.log

[2021-12-28 11:52:46] glpisqllog.ERROR: DBmysql::query() in /var/www/glpi/inc/dbmysql.class.php line 309 * MySQL query error: SQL: CREATE TABLE IF NOT EXISTS glpi_plugin_fpwebhook_subscriptions ( id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, name VARCHAR(80) NOT NULL, url VARCHAR(255) NOT NULL, event_type_id BIGINT(20) UNSIGNED NOT NULL, created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, is_active TINYINT UNSIGNED NOT NULL DEFAULT 1, is_deleted TINYINT UNSIGNED NOT NULL DEFAULT 0, unsubscribed_at TIMESTAMP DEFAULT NULL, unsubscribed_because TINYINT UNSIGNED DEFAULT NULL, failures SMALLINT UNSIGNED NOT NULL DEFAULT 0, PRIMARY KEY (id), FOREIGN KEY subscriptions_event_type_index (event_type_id) REFERENCES glpi_plugin_fpwebhook_eventtypes (id) ON UPDATE CASCADE ON DELETE RESTRICT ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci Error: Invalid default value for 'unsubscribed_at'** Backtrace : inc/dbmysql.class.php:831 plugins/fpwebhook/inc/installer.class.php:99 DBmysql->runFile() plugins/fpwebhook/hook.php:64 PluginFpwebhookInstaller->applySchema() inc/plugin.class.php:741 plugin_fpwebhook_install() : Plugin->install() inc/marketplace/controller.class.php:483 call_user_func() inc/marketplace/controller.class.php:402 Glpi\Marketplace\Controller->setPluginState() ajax/marketplace.php:77 Glpi\Marketplace\Controller->installPlugin() {"user":"2@itsm"}

Dimitri281 commented 2 years ago

Hello I have same problem.

GLPI 9.5.6

During plugin installation: Error occurred during FP Webhook setup - unable to run schema for 1.0.0. (0 seconds)

After page refresh and new try > Plugin FP Webhook has been installed!

From GLPI DEBUG: SQL Error "1146": Table 'glpidb.glpi_plugin_fpwebhook_subscriptions' doesn't exist in query "SHOW COLUMNS FROM glpi_plugin_fpwebhook_subscriptions"

From Mariadb:

MariaDB [glpidb]> show tables where Tables_in_glpidb like '%fpwebhook%';
+----------------------------------+
| Tables_in_glpidb                 |
+----------------------------------+
| glpi_plugin_fpwebhook_eventtypes |
+----------------------------------+
1 row in set (0.003 sec)

GLPI sql-errors.log

[2021-12-28 11:52:46] glpisqllog.ERROR: DBmysql::query() in /var/www/glpi/inc/dbmysql.class.php line 309 * MySQL query error: SQL: CREATE TABLE IF NOT EXISTS glpi_plugin_fpwebhook_subscriptions ( id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, name VARCHAR(80) NOT NULL, url VARCHAR(255) NOT NULL, event_type_id BIGINT(20) UNSIGNED NOT NULL, created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, is_active TINYINT UNSIGNED NOT NULL DEFAULT 1, is_deleted TINYINT UNSIGNED NOT NULL DEFAULT 0, unsubscribed_at TIMESTAMP DEFAULT NULL, unsubscribed_because TINYINT UNSIGNED DEFAULT NULL, failures SMALLINT UNSIGNED NOT NULL DEFAULT 0, PRIMARY KEY (id), FOREIGN KEY subscriptions_event_type_index (event_type_id) REFERENCES glpi_plugin_fpwebhook_eventtypes (id) ON UPDATE CASCADE ON DELETE RESTRICT ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci Error: Invalid default value for 'unsubscribed_at'** Backtrace : inc/dbmysql.class.php:831 plugins/fpwebhook/inc/installer.class.php:99 DBmysql->runFile() plugins/fpwebhook/hook.php:64 PluginFpwebhookInstaller->applySchema() inc/plugin.class.php:741 plugin_fpwebhook_install() : Plugin->install() inc/marketplace/controller.class.php:483 call_user_func() inc/marketplace/controller.class.php:402 Glpi\Marketplace\Controller->setPluginState() ajax/marketplace.php:77 Glpi\Marketplace\Controller->installPlugin() {"user":"2@itsm"}

Hello I have the same problem i have success to resolve with replace by "0" the default in the line : "updated_at TIMESTAMP NOT NULL ### DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP," but when the button save appear the webhook doesn't work . Cdlt, Dimitri

mikron-ia commented 2 years ago

Thank you! I believe this log entry is the key for the solution, the error comes from a different default behavior of MySQL and MariaDB. The fix should be in db-adjusted-for-mariadb branch. Review pending.

DockCZ commented 2 years ago

Thank you! I believe this log entry is the key for the solution, the error comes from a different default behavior of MySQL and MariaDB. The fix should be in db-adjusted-for-mariadb branch. Review pending.

Works for me. Thx.

heizac commented 2 years ago

It works for me too.

Now I can see the Add button and create webhooks.

I just couldn't find a way to change the template of the notification. For exemple, there's the template for e-mail and browser notifications, which are already made by GLPI but I can change them if I want to.

Just so you know I'm using this plugin to get ticket notifications to Discord, and when I create a ticket the message I get is this: <p>Description</p> where Description is the text the was wrote in the description field when creating the ticket. So not even the title is visible in these notifications.

Is there a way I can change that, like I can with the email template? It would be cool to receive the link of the ticket in the discord notification, so I can click it and go straight to the ticket page.

I wonder if here shouldn't exist another option, because when I install the telegrambot plugin it shows a Telegram option here to activate. image

In each type of notification I can add two templates, one for email and another for browser (also if I install telegrambot it appears here too). Maybe I should be seeing another option here related to your plugin. Screenshot from 2022-01-12 09-59-10

These are all thoughts of mine, I'm not sure how webhooks are supposed to work, it's my first time working with this. I considered changing some php files to alter the content of the notifications I get on discord (to get rid of all that characters in the message), but I don't really know PHP well enough, so I'm asking if it's possible to add some field in the configurations to change some kind of template or the way the notification appears on discord.

Thanks for your time and for creating this plugin!!

Dimitri281 commented 2 years ago

Thank you! I believe this log entry is the key for the solution, the error comes from a different default behavior of MySQL and MariaDB. The fix should be in db-adjusted-for-mariadb branch. Review pending.

Thank's it's good for me too but for rocket chat integration i've a empty message from webhook it's compliant with rocket chat ? WEBHOOK_EMPTY

mikron-ia commented 2 years ago

@heizac, the template/structure of the notification is hardcoded in the specific event classes. If you wish to change them in this version, you'd have to go into code into classes the right classes (PluginFpwebhookTicketSolved, PluginFpwebhookTicketCreated, etc.) and change the code in makeMessage(). While the configurable templates are a good idea, this is not planned as a feature at the moment until more urgent features are implemented; if you want see this done at some point please create a new issue with the request's description so the idea doesn't get lost.

@Dimitri281, the plugin returns plain JSON in order to be most compatible across platforms. But since it was not tested with Rocket Chat, there might be encoding issues or formatting issues. Please create a new issue with details, including: which event you're using, what content do you put into the fields, etc. so I can recreate the problem locally.

mikron-ia commented 2 years ago

Closing since resolution is in master and will be relased in 1.0.1