-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pause resume workcell button, not tested on modules with no pause adm…
…in action
- Loading branch information
1 parent
f7eb49e
commit e0f27db
Showing
5 changed files
with
100 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<template> | ||
<div> | ||
<v-btn | ||
@click="togglePauseResume" | ||
:color="isPaused ? 'green darken-3' : 'red darken-3'" | ||
dark | ||
elevation="5"> | ||
<v-icon> | ||
{{ isPaused ? 'mdi-play' : 'mdi-pause' }} | ||
</v-icon> | ||
</v-btn> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
// TODO: Currently this changes all modules to BUSY regardless of starting state on resume. | ||
import {defineProps, ref, watchEffect} from 'vue'; | ||
const props = defineProps(['main_url']) | ||
const pause_url = ref() | ||
const resume_url = ref() | ||
const isPaused = ref(false); | ||
// Format pause and resume urls | ||
pause_url.value = props.main_url.concat('/admin/pause') | ||
resume_url.value = props.main_url.concat('/admin/resume') | ||
// Function to toggle pause/resume | ||
const togglePauseResume = async () => { | ||
if (isPaused.value) { | ||
await sendResumeCommand(); | ||
} else { | ||
await sendPauseCommand(); | ||
} | ||
isPaused.value = !isPaused.value; | ||
}; | ||
// Function to send pause command | ||
const sendPauseCommand = async () => { | ||
try { | ||
const response = await fetch(pause_url.value, { | ||
method: 'POST', | ||
}); | ||
if (!response.ok) { | ||
throw new Error(`HTTP error! status: ${response.status}`); | ||
} | ||
console.log('Workcell Paused'); | ||
} catch (error) { | ||
console.error('Error pausing module:', error); | ||
} | ||
}; | ||
// Function to send resume command | ||
const sendResumeCommand = async () => { | ||
try { | ||
const response = await fetch(resume_url.value, { | ||
method: 'POST', | ||
}); | ||
if (!response.ok) { | ||
throw new Error(`HTTP error! status: ${response.status}`); | ||
} | ||
console.log('Workcell Resumed'); | ||
} catch (error) { | ||
console.error('Error resuming module:', error); | ||
} | ||
}; | ||
</script> | ||
|
||
<style scoped> | ||
button { | ||
padding: 10px 20px; | ||
font-size: 16px; | ||
background-color: #007bff; | ||
color: white; | ||
border: none; | ||
border-radius: 5px; | ||
cursor: pointer; | ||
} | ||
button:hover { | ||
background-color: #0056b3; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters