Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add: ping-viewer-next-frontend: Widget: Allow cockpit auto request ContinuousMode #93

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions ping-viewer-next-frontend/src/pages/addons/widget/[type]/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,35 @@ export default defineComponent({
};
}

if (device.status !== 'ContinuousMode') {
try {
const setContinuousModeResponse = await fetch(
`${serverUrl.value}/device_manager/request`,
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
Accept: 'application/json',
'Access-Control-Allow-Origin': '*',
},
body: JSON.stringify({
command: 'EnableContinuousMode',
module: 'DeviceManager',
payload: { uuid: deviceId.value },
}),
}
);

if (!setContinuousModeResponse.ok) {
console.warn('Failed to set continuous mode:', setContinuousModeResponse.statusText);
} else {
device.status = 'ContinuousMode';
}
} catch (err) {
console.warn('Failed to set continuous mode:', err);
}
}

if (device.device_type.toLowerCase() !== widgetType.value) {
throw new Error(
`Device type mismatch: expected ${widgetType.value} but got ${device.device_type}`
Expand Down
Loading