VolkovLabs / business-forms

The Business Forms panel is a conceptually new plugin for Grafana. It is the first plugin that allows inserting and updating application data, as well as modifying configuration directly from your Grafana dashboard.
https://docs.volkovlabs.io
Apache License 2.0
86 stars 10 forks source link

Could not update postgresql from Business Forms #482

Closed 86hakan closed 2 months ago

86hakan commented 2 months ago

Im moving my Grafana to a new server and see that can not dowload Data Manipulation anymore and that this is in Business Forms.

Now my problem is that a code for updating a database from a form is not working in Business form but working in Data manipulation

code in Data manipulation

const payload = {};

elements.forEach((element) => {
  if (!element.value) {
    return;
  }

  payload[element.id] = element.value;
});

return {
  rawSql: `UPDATE double_up_step2 SET status='${payload.new_status || ''}', fidok='${payload.fid_ok || ''}', serialok='${payload.serial_ok || ''}', adressok='${payload.adress_ok || ''}', step1ok='${payload.step1_ok || ''}', comment='${payload.comment || ''}' WHERE fid = '${fid}'`,
  format: 'table',
};

code in Business Forms

const payload = {};

context.panel.elements.forEach((element) => {
  if (!element.value) {
    return;
  }

  payload[element.id] = element.value;
});

return {
  rawSql = `UPDATE sma_double_up_step2 SET status='${payload.new_status || ''}', fidok='${payload.fid_ok || ''}', serialok='${payload.serial_ok || ''}', adressok='${payload.adress_ok || ''}', step1ok='${payload.step1_ok || ''}', comment='${payload.comment || ''}' WHERE fid = '${fid}'`,
  format: 'table',
};

When i try to update with above code i get this error-message

Update An error occured updating values.

86hakan commented 2 months ago

Can you do this for ubuntu instead?

mikhail-vl commented 2 months ago

@86hakan Don't use the provided link, it's most probably malware. I reported the user.

mikhail-vl commented 2 months ago

@86hakan We added support for the Query Editors in payloads, which explained in the blog post and documentation: https://volkovlabs.io/plugins/business-forms/release/