Skip to content

Commit

Permalink
fixes issue #5 start/stop UI
Browse files Browse the repository at this point in the history
  • Loading branch information
bitkarrot committed Sep 16, 2023
1 parent 63d02b3 commit 8444607
Showing 1 changed file with 32 additions and 12 deletions.
44 changes: 32 additions & 12 deletions templates/scheduler/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ <h5 class="text-subtitle1 q-my-none">Scheduled Jobs List</h5>
flat
dense
size="s"
@click="pauseJob(props.row.id, false)"
icon="stop"
color="red"
@click="toggleButton(props.row.id)"
:icon="getButtonIcon(props.row.id)"
:color="getButtonColor(props.row.id)"
>
<q-tooltip>Stop Job</q-tooltip>
<q-tooltip>{{ getButtonText(props.row.id) }}</q-tooltip>
</q-btn>
</q-btn>

Expand Down Expand Up @@ -120,7 +120,7 @@ <h6 class="text-subtitle1 q-my-none">

<q-card>
<h5 class="text-subtitle1 q-my-none">Schedule</h5>
<p> todo: add shortcut buttons here: daily, hourly, etc.</p>
<!-- <p> todo: add shortcut buttons here: daily, hourly, etc.</p> -->
<q-tr>
<q-th v-for="slot in slots" :key="slot" class="text-center">
<q-input v-model="cron[slot]" :label="slot" dense filled />
Expand Down Expand Up @@ -165,8 +165,10 @@ <h5 class="text-subtitle1 q-my-none">Schedule</h5>
mixins: [windowMixin],
data: function () {
return {
jobStates: {}, // A data property to keep track of button states for each id
wallets: [],
jobs: [],
shortcuts: ['@reboot','@hourly','@daily','@weekly','@monthly','@yearly'],
slots: ['minute', 'hour', 'day', 'month', 'weekday'],
cron: {
minute: '*',
Expand Down Expand Up @@ -328,12 +330,28 @@ <h5 class="text-subtitle1 q-my-none">Schedule</h5>
})
})
},

toggleButton(id) {
this.$set(this.jobStates, id, !this.jobStates[id]);
this.pauseJob(id, !this.jobStates[id]);
},
getButtonIcon(id) {
return this.jobStates[id] ? 'play_arrow' : 'stop';
},
getButtonText(id) {
return this.jobStates[id] ? 'Play' : 'Stop';
},
getButtonColor(id) {
return this.jobStates[id] ? 'green' : 'red';
},
pauseJob: function (jobId, status) {
var self = this
console.log(jobId)
console.log(jobId, status)
let confirm_msg = 'Are you sure you want to Stop this Job?'
if (status) {
confirm_msg = 'Are you sure you want to Start this Job?'
}
LNbits.utils
.confirmDialog('Are you sure you want to stop this Job?')
.confirmDialog(confirm_msg)
.onOk(function () {
LNbits.api
.request(
Expand All @@ -353,15 +371,17 @@ <h5 class="text-subtitle1 q-my-none">Schedule</h5>
})
})
},

// add start job method here


exportJobsCSV: function () {
LNbits.utils.exportCSV(this.jobsTable.columns, this.jobs)
},

},
props: {
row: {
type: Object,
default: () => ({ id: null }) // Define a default row object if none is provided
}
},
created: function () {
if (this.g.user.wallets.length) {
this.getJobs()
Expand Down

0 comments on commit 8444607

Please sign in to comment.