diff --git a/src/components/panels/GcodefilesPanel.vue b/src/components/panels/GcodefilesPanel.vue new file mode 100644 index 000000000..86e97d79b --- /dev/null +++ b/src/components/panels/GcodefilesPanel.vue @@ -0,0 +1,1127 @@ + + + + + diff --git a/src/components/panels/JobqueuePanel.vue b/src/components/panels/JobqueuePanel.vue new file mode 100644 index 000000000..698d836df --- /dev/null +++ b/src/components/panels/JobqueuePanel.vue @@ -0,0 +1,173 @@ + + + diff --git a/src/locales/en.json b/src/locales/en.json index a1958ea3f..76a94751a 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -131,6 +131,7 @@ "Empty": "Empty", "DropFilesToAddGcode": "Drag & Drop files to add G-Code.", "PrintStart": "Print start", + "AddToQueue": "Add to Queue", "Preheat": "Preheat", "Download": "Download", "Rename": "Rename", @@ -168,6 +169,15 @@ "SuccessfullyDeleted": "Successfully deleted {filename}.", "View3D" : "View 3D" }, + "JobQueue": { + "JobQueue": "Job Queue", + "Jobs": "Jobs", + "AllJobs": "All Jobs", + "Empty": "Empty", + "Delete": "Delete", + "Resume": "Resume", + "Pause": "Pause" + }, "Console": { "SetupConsole": "Setup Console", "SendCode": "Send code...", diff --git a/src/pages/Files.vue b/src/pages/Files.vue index e37a0c1e4..b4f9737d9 100644 --- a/src/pages/Files.vue +++ b/src/pages/Files.vue @@ -1,1119 +1,31 @@ - - diff --git a/src/store/gui/index.ts b/src/store/gui/index.ts index d64142132..e85d3fad0 100644 --- a/src/store/gui/index.ts +++ b/src/store/gui/index.ts @@ -141,6 +141,9 @@ export const getDefaultState = (): GuiState => { sortDesc: true, showHiddenFiles: false, }, + jobqueue: { + countPerPage: 10, + }, heightmap: { probed: true, mesh: false, diff --git a/src/store/server/index.ts b/src/store/server/index.ts index 06f76ed25..31fac17f4 100644 --- a/src/store/server/index.ts +++ b/src/store/server/index.ts @@ -9,6 +9,7 @@ import { power } from '@/store/server/power' import { updateManager } from '@/store/server/updateManager' import { history } from '@/store/server/history' import { timelapse } from '@/store/server/timelapse' +import { jobQueue } from '@/store/server/jobQueue' // create getDefaultState export const getDefaultState = (): ServerState => { @@ -50,5 +51,6 @@ export const server: Module = { updateManager, history, timelapse, + jobQueue, } } \ No newline at end of file diff --git a/src/store/server/jobQueue/actions.ts b/src/store/server/jobQueue/actions.ts new file mode 100644 index 000000000..1788a4118 --- /dev/null +++ b/src/store/server/jobQueue/actions.ts @@ -0,0 +1,40 @@ +import Vue from 'vue' +import { ActionTree } from 'vuex' +import {RootState} from '@/store/types' +import {ServerJobQueueState} from '@/store/server/jobQueue/types' + +export const actions: ActionTree = { + reset({ commit }) { + commit('reset') + }, + + init() { + Vue.$socket.emit('server.job_queue.status', { }, { action: 'server/jobQueue/getStatus' }) + }, + + getStatus({ commit }, payload) { + if ('queued_jobs' in payload) commit('setQueuedJobs', payload.queued_jobs) + if ('queue_state' in payload) commit('setQueueState', payload.queue_state) + }, + + async addToQueue({ state }, filenames: string[]) { + Vue.$socket.emit('server.job_queue.post_job', { filenames: filenames }, { action: 'server/jobQueue/getStatus' }) + }, + + deleteFromQueue(_, job_ids: string[]) { + Vue.$socket.emit('server.job_queue.delete_job', { job_ids }, { action: 'server/jobQueue/getStatus' }) + }, + + clearQueue(_) { + Vue.$socket.emit('server.job_queue.delete_job', { all: true }, { action: 'server/jobQueue/getStatus' }) + }, + + resume(_) { + Vue.$socket.emit('server.job_queue.resume', { }, { action: 'server/jobQueue/getStatus', loading: 'resumeJobqueue' }) + }, + + pause(_) { + Vue.$socket.emit('server.job_queue.pause', { }, { action: 'server/jobQueue/getStatus', loading: 'pauseJobqueue' }) + } + +} \ No newline at end of file diff --git a/src/store/server/jobQueue/getters.ts b/src/store/server/jobQueue/getters.ts new file mode 100644 index 000000000..9e8310ad1 --- /dev/null +++ b/src/store/server/jobQueue/getters.ts @@ -0,0 +1,7 @@ +import {GetterTree} from 'vuex' +import {ServerJobQueueState} from '@/store/server/jobQueue/types' + +// eslint-disable-next-line +export const getters: GetterTree = { + +} \ No newline at end of file diff --git a/src/store/server/jobQueue/index.ts b/src/store/server/jobQueue/index.ts new file mode 100644 index 000000000..eb7ea9c28 --- /dev/null +++ b/src/store/server/jobQueue/index.ts @@ -0,0 +1,24 @@ +import { Module } from 'vuex' +import { ServerJobQueueState } from '@/store/server/jobQueue/types' +import { actions } from '@/store/server/jobQueue/actions' +import { mutations } from '@/store/server/jobQueue/mutations' +import { getters } from '@/store/server/jobQueue/getters' + +export const getDefaultState = (): ServerJobQueueState => { + return { + queued_jobs: [], + queue_state: '' + } +} + +// initial state +const state = getDefaultState() + +// eslint-disable-next-line +export const jobQueue: Module = { + namespaced: true, + state, + getters, + actions, + mutations +} \ No newline at end of file diff --git a/src/store/server/jobQueue/mutations.ts b/src/store/server/jobQueue/mutations.ts new file mode 100644 index 000000000..c566da955 --- /dev/null +++ b/src/store/server/jobQueue/mutations.ts @@ -0,0 +1,18 @@ +import { getDefaultState } from './index' +import { MutationTree } from 'vuex' +import {ServerJobQueueState, ServerJobQueueStateJob} from '@/store/server/jobQueue/types' +import Vue from 'vue' + +export const mutations: MutationTree = { + reset(state) { + Object.assign(state, getDefaultState()) + }, + + setQueuedJobs(state, payload: ServerJobQueueStateJob[]) { + Vue.set(state, 'queued_jobs', payload) + }, + + setQueueState(state, payload: string) { + Vue.set(state, 'queue_state', payload) + } +} \ No newline at end of file diff --git a/src/store/server/jobQueue/types.ts b/src/store/server/jobQueue/types.ts new file mode 100644 index 000000000..40efc4553 --- /dev/null +++ b/src/store/server/jobQueue/types.ts @@ -0,0 +1,11 @@ +export interface ServerJobQueueState { + queued_jobs: ServerJobQueueStateJob[], + queue_state: string +} + +export interface ServerJobQueueStateJob { + filename:string + job_id: string + time_added: number + time_in_queue: number +} \ No newline at end of file diff --git a/src/store/variables.ts b/src/store/variables.ts index a72049605..3dd9973ed 100644 --- a/src/store/variables.ts +++ b/src/store/variables.ts @@ -48,6 +48,7 @@ export const initableServerComponents = [ 'power', 'updateManager', 'timelapse', + 'jobQueue', ] export const checkKlipperConfigModules = [