giyu
giyu
WWindmill
Created by giyu on 11/26/2024 in #help
Support for HTTP Browser Redirects in Windmill Functions (302 Response Handling)
@Hugo I managed to figure it out, I put the database resource in a separate folder and granted g/all users access to that folder so that when they reference that database resource the script manages to execute
13 replies
WWindmill
Created by giyu on 11/26/2024 in #help
Support for HTTP Browser Redirects in Windmill Functions (302 Response Handling)
Hey @Hugo , thanks again for your advice on using a meta refresh for URL redirects. I’m now using this setup to track email clicks (logging them in Windmill before redirecting the user). It works great for non-logged-in visitors using a webhook token, but I’ve hit a snag with logged-in Windmill users who don’t have the right resource permissions—Windmill tries to use their session instead of honoring the token. Ideally, I’d like to override the session whenever a valid token is present, so the link works for everyone without them having to log out or use incognito. Is there any built-in approach (or upcoming feature) that allows token-based auth to override existing sessions? I’m attaching a short video showing my current flow. Please let me know if there’s a known workaround or if you plan to add a “prefer token over session” option in the future. Thank you again!
13 replies
WWindmill
Created by giyu on 12/19/2024 in #help
Issue with button functionality working in preview mode but not in deployed mode
perfect it works!
7 replies
WWindmill
Created by giyu on 12/19/2024 in #help
Issue with button functionality working in preview mode but not in deployed mode
let me try to update it
7 replies
WWindmill
Created by giyu on 12/19/2024 in #help
Issue with button functionality working in preview mode but not in deployed mode
this is self hosted - CE v1.435.2-17-g8e9cb9c4d
7 replies
WWindmill
Created by giyu on 12/19/2024 in #help
Issue with button functionality working in preview mode but not in deployed mode
The code for modifying the table "c" is below
// Ensure c and c.result are valid
if (!c || !Array.isArray(c.result)) {
console.error("No valid data found in c.result.");
return c;
}

console.log("Original rows:", c.result);

// Update all rows to have is_ready_for_review = true
const updatedData = c.result.map((row, i) => {
console.log(`Row ${i} before:`, row);
const newRow = { ...row, is_ready_for_review: true };
console.log(`Row ${i} after:`, newRow);
return newRow;
});

console.log("updatedData:", updatedData);

// Create updatedC
const updatedC = { ...c, result: updatedData };

// Update selectedRow if applicable
if (typeof c.selectedRowIndex === 'number' && c.selectedRowIndex < updatedData.length) {
updatedC.selectedRow = updatedData[c.selectedRowIndex];
}

// Remove 'newChange' if it exists
if ('newChange' in updatedC) {
delete updatedC.newChange;
}

// Update Windmill's stored value for c
setValue("c", updatedC);

console.log("Updated Data in c:", updatedC);

// Try to get the AG Grid instance
let grid = getAgGrid("c");
console.log("Grid at initial attempt:", grid);

// Sometimes in production, the grid might not be ready immediately.
// We'll try a short delay to ensure the UI updates with new data first.
setTimeout(() => {
grid = getAgGrid("c");
console.log("Grid after timeout:", grid);

if (grid && grid.api) {

grid.api.forEachNode(node => {
node.setDataValue('is_ready_for_review', true);
});
console.log("All rows in the grid have been marked as ready for review via forEachNode.");
} else {
console.warn("Grid still not available after timeout, cannot update UI directly.");
}

}, 500); // Adjust delay if needed

return updatedC;
// Ensure c and c.result are valid
if (!c || !Array.isArray(c.result)) {
console.error("No valid data found in c.result.");
return c;
}

console.log("Original rows:", c.result);

// Update all rows to have is_ready_for_review = true
const updatedData = c.result.map((row, i) => {
console.log(`Row ${i} before:`, row);
const newRow = { ...row, is_ready_for_review: true };
console.log(`Row ${i} after:`, newRow);
return newRow;
});

console.log("updatedData:", updatedData);

// Create updatedC
const updatedC = { ...c, result: updatedData };

// Update selectedRow if applicable
if (typeof c.selectedRowIndex === 'number' && c.selectedRowIndex < updatedData.length) {
updatedC.selectedRow = updatedData[c.selectedRowIndex];
}

// Remove 'newChange' if it exists
if ('newChange' in updatedC) {
delete updatedC.newChange;
}

// Update Windmill's stored value for c
setValue("c", updatedC);

console.log("Updated Data in c:", updatedC);

// Try to get the AG Grid instance
let grid = getAgGrid("c");
console.log("Grid at initial attempt:", grid);

// Sometimes in production, the grid might not be ready immediately.
// We'll try a short delay to ensure the UI updates with new data first.
setTimeout(() => {
grid = getAgGrid("c");
console.log("Grid after timeout:", grid);

if (grid && grid.api) {

grid.api.forEachNode(node => {
node.setDataValue('is_ready_for_review', true);
});
console.log("All rows in the grid have been marked as ready for review via forEachNode.");
} else {
console.warn("Grid still not available after timeout, cannot update UI directly.");
}

}, 500); // Adjust delay if needed

return updatedC;
7 replies
WWindmill
Created by giyu on 11/26/2024 in #help
Support for HTTP Browser Redirects in Windmill Functions (302 Response Handling)
this is perfect @Hugo C. thanks! this script below correctly redirects to google.com:
export async function main() {
return {
"windmill_content_type": "text/html",
"result": `
<html>
<head>
<meta http-equiv="refresh" content="0; url=https://www.google.com">
</head>
<body>
Redirecting to Google...
</body>
</html>
`
}
}
export async function main() {
return {
"windmill_content_type": "text/html",
"result": `
<html>
<head>
<meta http-equiv="refresh" content="0; url=https://www.google.com">
</head>
<body>
Redirecting to Google...
</body>
</html>
`
}
}
13 replies
WWindmill
Created by giyu on 11/26/2024 in #help
Support for HTTP Browser Redirects in Windmill Functions (302 Response Handling)
ok thanks for clarifying
13 replies
WWindmill
Created by giyu on 11/26/2024 in #help
Support for HTTP Browser Redirects in Windmill Functions (302 Response Handling)
how would I do that in the script? I've tried this but it doesnt work import { Response } from '@windmill/worker-typescript' export async function main(): Promise<Response<any>> { return { statusCode: 302, headers: { 'Location': 'https://www.google.com' }, response: 'Redirecting to Google...' } }
13 replies
WWindmill
Created by giyu on 11/26/2024 in #help
Support for HTTP Browser Redirects in Windmill Functions (302 Response Handling)
I mean my intention is to call a windmill function via GET URL and then some custom code runs on the backend and then it redirects the client browser to "google.com" - the video below explains it
13 replies
WWindmill
Created by giyu on 11/16/2024 in #help
[FIXED] Windmill Database Studio Type Conversion Issue
yes it works now 🙂
7 replies
WWindmill
Created by giyu on 11/16/2024 in #help
[FIXED] Windmill Database Studio Type Conversion Issue
I figured it out - its to do with the latest v.1425.0 issue (https://newreleases.io/project/github/windmill-labs/windmill/release/v1.425.0) which was just released yesterday - I rolled back to 1.424 and its working 🙂
7 replies
WWindmill
Created by giyu on 11/16/2024 in #help
[FIXED] Windmill Database Studio Type Conversion Issue
This is the autogenerated code
7 replies
WWindmill
Created by joetong on 9/6/2024 in #help
playwright chromium could not be successfully closed
hey @Alper would 0 0 * * * /usr/bin/killall -9 windmil run on windmill itself - e.g. should I make it a bash script on windmill that automatically runs?
6 replies