feat: add note to history job (#716)
This commit is contained in:
parent
556179adaa
commit
faa83e7932
@ -172,7 +172,17 @@
|
|||||||
</template>
|
</template>
|
||||||
</td>
|
</td>
|
||||||
<td class=" ">{{ item.filename }}</td>
|
<td class=" ">{{ item.filename }}</td>
|
||||||
<td class="text-center">
|
<td class="text-right text-no-wrap">
|
||||||
|
<template v-if="'note' in item && item.note">
|
||||||
|
<v-tooltip top>
|
||||||
|
<template #activator="{ on, attrs }">
|
||||||
|
<v-icon small class="mr-2" v-bind="attrs" v-on="on">
|
||||||
|
{{ mdiNotebook }}
|
||||||
|
</v-icon>
|
||||||
|
</template>
|
||||||
|
<span v-html="item.note.replaceAll('\n', '<br />')"></span>
|
||||||
|
</v-tooltip>
|
||||||
|
</template>
|
||||||
<v-tooltip top>
|
<v-tooltip top>
|
||||||
<template #activator="{ on, attrs }">
|
<template #activator="{ on, attrs }">
|
||||||
<span v-bind="attrs" v-on="on">
|
<span v-bind="attrs" v-on="on">
|
||||||
@ -213,6 +223,16 @@
|
|||||||
<v-icon class="mr-1">{{ mdiTextBoxSearch }}</v-icon>
|
<v-icon class="mr-1">{{ mdiTextBoxSearch }}</v-icon>
|
||||||
{{ $t('History.Details') }}
|
{{ $t('History.Details') }}
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
|
<v-list-item
|
||||||
|
v-if="'note' in contextMenu.item && contextMenu.item.note"
|
||||||
|
@click="editNote(contextMenu.item)">
|
||||||
|
<v-icon class="mr-1">{{ mdiNotebookEdit }}</v-icon>
|
||||||
|
{{ $t('History.EditNote') }}
|
||||||
|
</v-list-item>
|
||||||
|
<v-list-item v-else @click="createNote(contextMenu.item)">
|
||||||
|
<v-icon class="mr-1">{{ mdiNotebookPlus }}</v-icon>
|
||||||
|
{{ $t('History.AddNote') }}
|
||||||
|
</v-list-item>
|
||||||
<v-list-item
|
<v-list-item
|
||||||
v-if="contextMenu.item.exists"
|
v-if="contextMenu.item.exists"
|
||||||
:disabled="printerIsPrinting || !klipperReadyForGui"
|
:disabled="printerIsPrinting || !klipperReadyForGui"
|
||||||
@ -429,6 +449,35 @@
|
|||||||
</v-card-actions>
|
</v-card-actions>
|
||||||
</panel>
|
</panel>
|
||||||
</v-dialog>
|
</v-dialog>
|
||||||
|
<v-dialog v-model="noteDialog.boolShow" :max-width="600" persistent @keydown.esc="noteDialog.boolShow = false">
|
||||||
|
<panel
|
||||||
|
:title="noteDialog.type === 'create' ? $t('History.CreateNote') : $t('History.EditNote')"
|
||||||
|
:icon="noteDialog.type === 'create' ? mdiNotebookPlus : mdiNotebookEdit"
|
||||||
|
card-class="history-note-dialog"
|
||||||
|
:margin-bottom="false">
|
||||||
|
<template #buttons>
|
||||||
|
<v-btn icon tile @click="noteDialog.boolShow = false">
|
||||||
|
<v-icon>{{ mdiCloseThick }}</v-icon>
|
||||||
|
</v-btn>
|
||||||
|
</template>
|
||||||
|
<v-card-text class="pb-0">
|
||||||
|
<v-row>
|
||||||
|
<v-col>
|
||||||
|
<v-textarea
|
||||||
|
v-model="noteDialog.note"
|
||||||
|
outlined
|
||||||
|
hide-details
|
||||||
|
:label="$t('History.Note')"></v-textarea>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
</v-card-text>
|
||||||
|
<v-card-actions>
|
||||||
|
<v-spacer></v-spacer>
|
||||||
|
<v-btn color="" text @click="noteDialog.boolShow = false">{{ $t('History.Cancel') }}</v-btn>
|
||||||
|
<v-btn color="primary" text @click="saveNote">{{ $t('History.Save') }}</v-btn>
|
||||||
|
</v-card-actions>
|
||||||
|
</panel>
|
||||||
|
</v-dialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -451,6 +500,9 @@ import {
|
|||||||
mdiMagnify,
|
mdiMagnify,
|
||||||
mdiCloseThick,
|
mdiCloseThick,
|
||||||
mdiUpdate,
|
mdiUpdate,
|
||||||
|
mdiNotebookEdit,
|
||||||
|
mdiNotebookPlus,
|
||||||
|
mdiNotebook,
|
||||||
} from '@mdi/js'
|
} from '@mdi/js'
|
||||||
@Component({
|
@Component({
|
||||||
components: { Panel },
|
components: { Panel },
|
||||||
@ -467,6 +519,9 @@ export default class HistoryListPanel extends Mixins(BaseMixin) {
|
|||||||
mdiMagnify = mdiMagnify
|
mdiMagnify = mdiMagnify
|
||||||
mdiUpdate = mdiUpdate
|
mdiUpdate = mdiUpdate
|
||||||
mdiCloseThick = mdiCloseThick
|
mdiCloseThick = mdiCloseThick
|
||||||
|
mdiNotebookPlus = mdiNotebookPlus
|
||||||
|
mdiNotebookEdit = mdiNotebookEdit
|
||||||
|
mdiNotebook = mdiNotebook
|
||||||
|
|
||||||
formatFilesize = formatFilesize
|
formatFilesize = formatFilesize
|
||||||
|
|
||||||
@ -487,6 +542,18 @@ export default class HistoryListPanel extends Mixins(BaseMixin) {
|
|||||||
boolShow: false,
|
boolShow: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private noteDialog: {
|
||||||
|
item: ServerHistoryStateJob | null
|
||||||
|
note: string
|
||||||
|
boolShow: boolean
|
||||||
|
type: 'create' | 'edit'
|
||||||
|
} = {
|
||||||
|
item: null,
|
||||||
|
note: '',
|
||||||
|
boolShow: false,
|
||||||
|
type: 'create',
|
||||||
|
}
|
||||||
|
|
||||||
private deleteSelectedDialog = false
|
private deleteSelectedDialog = false
|
||||||
|
|
||||||
get jobs() {
|
get jobs() {
|
||||||
@ -985,5 +1052,28 @@ export default class HistoryListPanel extends Mixins(BaseMixin) {
|
|||||||
}
|
}
|
||||||
} else return '--'
|
} else return '--'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
createNote(item: ServerHistoryStateJob) {
|
||||||
|
this.noteDialog.item = item
|
||||||
|
this.noteDialog.note = ''
|
||||||
|
this.noteDialog.type = 'create'
|
||||||
|
this.noteDialog.boolShow = true
|
||||||
|
}
|
||||||
|
|
||||||
|
editNote(item: ServerHistoryStateJob) {
|
||||||
|
this.noteDialog.item = item
|
||||||
|
this.noteDialog.note = item.note ?? ''
|
||||||
|
this.noteDialog.type = 'edit'
|
||||||
|
this.noteDialog.boolShow = true
|
||||||
|
}
|
||||||
|
|
||||||
|
saveNote() {
|
||||||
|
this.$store.dispatch('server/history/saveHistoryNote', {
|
||||||
|
job_id: this.noteDialog.item?.job_id,
|
||||||
|
note: this.noteDialog.note,
|
||||||
|
})
|
||||||
|
|
||||||
|
this.noteDialog.boolShow = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -245,12 +245,15 @@
|
|||||||
"Wireframe": "Wireframe"
|
"Wireframe": "Wireframe"
|
||||||
},
|
},
|
||||||
"History": {
|
"History": {
|
||||||
|
"AddNote": "Add note",
|
||||||
"AllJobs": "All",
|
"AllJobs": "All",
|
||||||
"AvgPrinttime": "Printtime - Ø",
|
"AvgPrinttime": "Printtime - Ø",
|
||||||
"Cancel": "Cancel",
|
"Cancel": "Cancel",
|
||||||
|
"CreateNote": "Create Note",
|
||||||
"Delete": "Delete",
|
"Delete": "Delete",
|
||||||
"DeleteSelectedQuestion": "Do you really want to delete {count} selected jobs?",
|
"DeleteSelectedQuestion": "Do you really want to delete {count} selected jobs?",
|
||||||
"Details": "Details",
|
"Details": "Details",
|
||||||
|
"EditNote": "Edit Note",
|
||||||
"Empty": "empty",
|
"Empty": "empty",
|
||||||
"EndTime": "End Time",
|
"EndTime": "End Time",
|
||||||
"EstimatedFilament": "Estimated Filament",
|
"EstimatedFilament": "Estimated Filament",
|
||||||
@ -271,12 +274,14 @@
|
|||||||
"LastModified": "Last Modified",
|
"LastModified": "Last Modified",
|
||||||
"LayerHeight": "Layer Height",
|
"LayerHeight": "Layer Height",
|
||||||
"LongestPrinttime": "Longest Printtime",
|
"LongestPrinttime": "Longest Printtime",
|
||||||
|
"Note": "Note",
|
||||||
"ObjectHeight": "Object Height",
|
"ObjectHeight": "Object Height",
|
||||||
"PrintDuration": "Print Time",
|
"PrintDuration": "Print Time",
|
||||||
"PrintHistory": "Print History",
|
"PrintHistory": "Print History",
|
||||||
"PrintTime": "Print Time",
|
"PrintTime": "Print Time",
|
||||||
"PrinttimeAvg": "Printtime - Ø",
|
"PrinttimeAvg": "Printtime - Ø",
|
||||||
"Reprint": "Reprint",
|
"Reprint": "Reprint",
|
||||||
|
"Save": "save",
|
||||||
"Search": "search",
|
"Search": "search",
|
||||||
"SelectedFilamentUsed": "Selected Filament Used",
|
"SelectedFilamentUsed": "Selected Filament Used",
|
||||||
"SelectedJobs": "Selected Jobs",
|
"SelectedJobs": "Selected Jobs",
|
||||||
|
@ -17,7 +17,7 @@ export const actions: ActionTree<ServerHistoryState, RootState> = {
|
|||||||
commit('setTotals', payload.job_totals)
|
commit('setTotals', payload.job_totals)
|
||||||
},
|
},
|
||||||
|
|
||||||
getHistory({ commit, state }, payload) {
|
getHistory({ commit, dispatch, state }, payload) {
|
||||||
if ('requestParams' in payload && 'start' in payload.requestParams && payload.requestParams.start === 0)
|
if ('requestParams' in payload && 'start' in payload.requestParams && payload.requestParams.start === 0)
|
||||||
commit('resetJobs')
|
commit('resetJobs')
|
||||||
|
|
||||||
@ -34,6 +34,28 @@ export const actions: ActionTree<ServerHistoryState, RootState> = {
|
|||||||
},
|
},
|
||||||
{ action: 'server/history/getHistory' }
|
{ action: 'server/history/getHistory' }
|
||||||
)
|
)
|
||||||
|
else dispatch('loadHistoryNotes')
|
||||||
|
},
|
||||||
|
|
||||||
|
loadHistoryNotes({ rootState }) {
|
||||||
|
if (rootState.server?.dbNamespaces.includes('history_notes'))
|
||||||
|
Vue.$socket.emit(
|
||||||
|
'server.database.get_item',
|
||||||
|
{ namespace: 'history_notes' },
|
||||||
|
{ action: 'server/history/initHistoryNotes' }
|
||||||
|
)
|
||||||
|
},
|
||||||
|
|
||||||
|
initHistoryNotes({ commit, state }, payload) {
|
||||||
|
const job_ids = Object.keys(payload.value)
|
||||||
|
|
||||||
|
job_ids.forEach((job_id: string) => {
|
||||||
|
const noteObject: { text: string } = payload.value[job_id]
|
||||||
|
commit('setHistoryNotes', {
|
||||||
|
job_id,
|
||||||
|
text: noteObject.text,
|
||||||
|
})
|
||||||
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
getChanged({ commit }, payload) {
|
getChanged({ commit }, payload) {
|
||||||
@ -50,4 +72,17 @@ export const actions: ActionTree<ServerHistoryState, RootState> = {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
saveHistoryNote({ commit }, payload: { job_id: string; note: string }) {
|
||||||
|
Vue.$socket.emit('server.database.post_item', {
|
||||||
|
namespace: 'history_notes',
|
||||||
|
key: payload.job_id,
|
||||||
|
value: { text: payload.note },
|
||||||
|
})
|
||||||
|
|
||||||
|
commit('setHistoryNotes', {
|
||||||
|
job_id: payload.job_id,
|
||||||
|
text: payload.note,
|
||||||
|
})
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,11 @@ export const mutations: MutationTree<ServerHistoryState> = {
|
|||||||
Vue.set(state, 'job_totals', payload)
|
Vue.set(state, 'job_totals', payload)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
setHistoryNotes(state, payload) {
|
||||||
|
const job = state.jobs.find((job) => job.job_id === payload.job_id)
|
||||||
|
if (job) Vue.set(job, 'note', payload.text)
|
||||||
|
},
|
||||||
|
|
||||||
addJob(state, payload) {
|
addJob(state, payload) {
|
||||||
state.jobs.push(payload)
|
state.jobs.push(payload)
|
||||||
},
|
},
|
||||||
@ -29,8 +34,6 @@ export const mutations: MutationTree<ServerHistoryState> = {
|
|||||||
|
|
||||||
destroyJob(state, payload) {
|
destroyJob(state, payload) {
|
||||||
const index = state.jobs.findIndex((job) => job.job_id === payload)
|
const index = state.jobs.findIndex((job) => job.job_id === payload)
|
||||||
if (index !== -1) {
|
if (index !== -1) state.jobs.splice(index, 1)
|
||||||
state.jobs.splice(index, 1)
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ export interface ServerHistoryStateJob {
|
|||||||
filename: string
|
filename: string
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
metadata: any
|
metadata: any
|
||||||
|
note?: string
|
||||||
print_duration: number
|
print_duration: number
|
||||||
status: string
|
status: string
|
||||||
start_time: number
|
start_time: number
|
||||||
|
Loading…
x
Reference in New Issue
Block a user