I had created an minimal test using metabase + postgres where i have a table like this
create table if not exists "example" (
"id" serial not null primary key,
"name" varchar(100) not null,
"age" int not null default 0
)
And I create an dashboard with simple query like this:
select *
from "example"
where 1 = 1
[[ and "name" ~ {{name}} ]]
In the question the variable is working, In the dashboard the filter is connected with variable of question and it working but when tryed to create an embbed dashboard using them, i the parameters not working.
My example code is like this:
import express from 'express';
import jsonwebtoken from 'jsonwebtoken';
const URL = '{{METABASE_URL}}';
const KEY = '{{METABASE_KEY}}';
const PORT = 3000;
const app = express();
app.get('/embed', (req, res) => {
const payload = {
resource: {dashboard: 4},
params: req.query,
exp: Math.round(Date.now() / 1000) + 10 * 60,
};
const token = jsonwebtoken.sign(payload, KEY);
const iframeUrl = `${URL}/embed/dashboard/${token}#bordered=true&titled=true`;
const htmlContent = `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Test Metabase</title>
</head>
<body>
<iframe
src="${iframeUrl}"
frameborder="0"
style="width: 100%; height: 100vh;"
allowfullscreen
allowtransparency>
</iframe>
</body>
</html>
`;
res.send(htmlContent);
});
app.listen(PORT, () => {
console.log(`Server is running on http://localhost:${ENV.PORT}`);
});
Someone can help me? It's possible to pass filters to embed dashboards?