Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
chrishamm committed Oct 8, 2019
2 parents 3a9accb + 2798afe commit 6d619f6
Show file tree
Hide file tree
Showing 29 changed files with 388 additions and 200 deletions.
7 changes: 6 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "duetwebcontrol",
"version": "2.0.0",
"repository": "github:chrishamm/DuetWebControl#next",
"version": "2.0.1",
"repository": "github:chrishamm/DuetWebControl",
"homepage": "https://forum.duet3d.com/category/27/duet-web-control",
"license": "GPL-3.0",
"author": "Christian Hammacher <chr.hammacher@gmail.com> (https://chrishamm.io)",
Expand All @@ -20,7 +20,8 @@
"piecon": "^0.5.0",
"roboto-fontface": "*",
"three": "^0.105.2",
"three-orbitcontrols": "^2.102.2",
"three-orbitcontrols": "2.102.2",
"turbo-crc32": "^1.0.1",
"vue": "^2.6.10",
"vue-i18n": "^8.14.1",
"vue-router": "^3.1.3",
Expand Down
4 changes: 4 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ input::-webkit-inner-spin-button {
a:not(:hover) {
text-decoration: none;
}
.v-item-group.theme--dark .v-btn__content {
color: #FFF !important;
}
</style>

<template>
Expand Down
25 changes: 23 additions & 2 deletions src/components/buttons/EmergencyBtn.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<code-btn v-bind="$props" :code="'M112\nM999'" color="$props.color || error" :title="$t('button.emergencyStop.title')">
<code-btn v-bind="$props" :code="'M112\nM999'" color="$props.color || error" :disabled="$props.disabled || isDisabled" :title="$t('button.emergencyStop.title')">
<v-icon class="mr-1">flash_on</v-icon> {{ $t('button.emergencyStop.caption') }}
</code-btn>
</template>
Expand All @@ -10,6 +10,27 @@
import { VBtn } from 'vuetify/lib'
export default {
extends: VBtn
extends: VBtn,
data() {
return {
isDisabled: false
}
},
mounted() {
this.$root.$on('dialog-closing', this.onDialogClosing);
},
beforeDestroy() {
this.$root.$off('dialog-closing', this.onDialogClosing);
},
methods: {
onDialogClosing() {
this.isDisabled = true;
const that = this;
setTimeout(function() {
that.isDisabled = false;
}, 500);
}
}
}
</script>
44 changes: 30 additions & 14 deletions src/components/dialogs/FileEditDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
.edit-textarea > div > div {
align-items: stretch;
flex-grow: 1;
padding: 0 !important;
}
.edit-textarea > div > div > div {
align-items: stretch !important;
Expand All @@ -13,6 +14,7 @@
display: flex;
flex-grow: 1;
font-family: monospace;
padding-left: 12px;
margin-top: 0 !important;
resize: none;
}
Expand All @@ -36,7 +38,7 @@
<v-dialog v-model="shown" fullscreen hide-overlay transition="dialog-bottom-transition">
<v-card tile class="card">
<v-toolbar card dark color="primary">
<v-btn icon dark @click="close">
<v-btn icon dark @click="close(false)">
<v-icon>close</v-icon>
</v-btn>
<v-toolbar-title>{{ filename }}</v-toolbar-title>
Expand All @@ -56,7 +58,7 @@
</v-toolbar-items>
</v-toolbar>

<v-textarea ref="textarea" :value="innerValue" @blur="innerValue = $event.target.value" @keydown.tab.exact.prevent="onTextareaTab" @keydown.esc="close" :rows="null" hide-details solo class="edit-textarea" browser-autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></v-textarea>
<v-textarea ref="textarea" :value="innerValue" @blur="setInnerValue($event.target.value)" @keydown.tab.exact.prevent="onTextareaTab" @keydown.esc="close(false)" :rows="null" hide-details solo class="edit-textarea" browser-autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></v-textarea>
</v-card>
</v-dialog>
</template>
Expand Down Expand Up @@ -94,18 +96,30 @@ export default {
},
data() {
return {
innerValue: ''
innerValue: '',
valueChanged: false
}
},
methods: {
...mapActions('machine', ['upload']),
close() {
setInnerValue(value) {
if (value != this.innerValue) {
this.valueChanged = true;
this.innerValue = value;
}
},
close(fileSaved) {
if (this.valueChanged && !fileSaved && !confirm(this.$t('dialog.fileEdit.confirmClose'))) {
return;
}
this.$emit('input', '');
this.$emit('update:shown', false);
this.$root.$emit('dialog-closing')
},
async save() {
const content = new Blob([this.innerValue]);
this.close();
this.close(true);
try {
await this.upload({ filename: this.filename, content });
Expand All @@ -115,10 +129,11 @@ export default {
}
},
onBeforeLeave(e) {
// Cancel the event
e.preventDefault();
// Chrome requires returnValue to be set
e.returnValue = '';
if (this.valueChanged) {
// Cancel the event. Chrome also requires returnValue to be set
e.preventDefault();
e.returnValue = '';
}
},
onTextareaTab(e) {
const originalSelectionStart = e.target.selectionStart;
Expand All @@ -131,18 +146,19 @@ export default {
watch: {
shown(to) {
// Set textarea content
this.valueChanged = false;
this.innerValue = this.value;
// Notify users that they may not have saved their changes yet
if (to) {
// Notify users that they may not have saved their changes yet
window.addEventListener('beforeunload', this.onBeforeLeave);
// Auto-focus textarea
const textarea = this.$refs.textarea;
setTimeout(function() { textarea.focus(); }, 100);
} else {
window.removeEventListener('beforeunload', this.onBeforeLeave);
}
// Auto-focus textarea
const textarea = this.$refs.textarea;
setTimeout(function() { textarea.focus(); }, 100);
}
}
}
Expand Down
58 changes: 32 additions & 26 deletions src/components/inputs/CodeInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,44 +67,50 @@ export default {
this.send();
}
},
hasUnprecedentedParameters: (code) => !code || code.trim() === '' || /(M23|M30|M32|M36)[^0-9]/i.test(code),
async send() {
this.$refs.input.isMenuActive = false; // FIXME There must be a better solution than this
const code = (this.code.constructor === String) ? this.code : this.code.value;
if (code && code.trim() !== '' && !this.sendingCode) {
// Convert the input to upper-case and remove comments
let codeToSend = '', inQuotes = false, inWhiteSpace = false;
for (let i = 0; i < code.length; i++) {
const char = code[i];
if (inQuotes) {
if (i < code.length - 1 && char === '\\' && code[i + 1] === '"') {
codeToSend += '\\"';
i++;
if (this.hasUnprecedentedParameters(code)) {
// Don't convert certain codes to upper-case
codeToSend = code.trim();
} else {
// Convert code to upper-case and remove comments
for (let i = 0; i < code.length; i++) {
const char = code[i];
if (inQuotes) {
if (i < code.length - 1 && char === '\\' && code[i + 1] === '"') {
codeToSend += '\\"';
i++;
} else {
if (char === '"') {
inQuotes = false;
}
codeToSend += char;
}
} else {
if (char === '"') {
inQuotes = false;
}
codeToSend += char;
}
} else {
if (char === '"') {
// don't convert escaped strings
inQuotes = true;
} else if (char === ' ' || char === '\t') {
// remove duplicate white spaces
if (inWhiteSpace) {
continue;
// don't convert escaped strings
inQuotes = true;
} else if (char === ' ' || char === '\t') {
// remove duplicate white spaces
if (inWhiteSpace) {
continue;
}
inWhiteSpace = true;
} else if (char === ';' || char === '(') {
// stop when comments start
break;
}
inWhiteSpace = true;
} else if (char === ';' || char === '(') {
// stop when comments start
break;
inWhiteSpace = false;
codeToSend += char.toUpperCase();
}
inWhiteSpace = false;
codeToSend += char.toUpperCase();
}
codeToSend = codeToSend.trim();
}
codeToSend = codeToSend.trim();
// Send the code and wait for completion
this.sendingCode = true;
Expand Down
8 changes: 7 additions & 1 deletion src/components/inputs/ToolInput.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<style scoped>
.tool-input {
min-width: 4rem;
}
</style>

<template>
<v-combobox ref="input" type="number" min="-273" max="1999" step="any" v-model.number="value" :items="items" @keydown.native="onkeydown" @keyup.enter="apply" @change="onchange" @blur="onblur" :label="label" :loading="applying" :disabled="uiFrozen" :menu-props="$vuetify.breakpoint.xsOnly ? { maxHeight: 125 } : undefined">
<v-combobox ref="input" type="number" min="-273" max="1999" step="any" v-model.number="value" :items="items" @keydown.native="onkeydown" @keyup.enter="apply" @change="onchange" @blur="onblur" :label="label" :loading="applying" :disabled="uiFrozen" class="tool-input">
</v-combobox>
</template>

Expand Down
32 changes: 16 additions & 16 deletions src/components/lists/BaseFileList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ th.checkbox {
<v-data-table v-model="innerValue" v-bind="$props" :items="innerFilelist" :loading="loading || innerLoading" :custom-sort="sort" :pagination.sync="innerPagination" select-all hide-actions item-key="name" class="elevation-3" :class="{ 'empty-table-fix' : innerFilelist.length === 0, 'loading-cursor' : (loading || innerLoading || doingFileOperation || innerDoingFileOperation) }">
<template slot="progress">
<slot name="progress">
<v-progress-linear indeterminate></v-progress-linear>
<v-progress-linear indeterminate></v-progress-linear>
</slot>
</template>

Expand All @@ -45,24 +45,24 @@ th.checkbox {
</template>

<template slot="items" slot-scope="props">
<tr :active="props.selected" @touchstart="onItemTouchStart(props, $event)" @touchend="onItemTouchEnd" @click="onItemClick(props)" @contextmenu.prevent="onItemContextmenu(props, $event)" :data-filename="(props.item.isDirectory ? '*' : '') + props.item.name" draggable="true" @dragstart="onItemDragStart(props.item, $event)" @dragover="onItemDragOver(props.item, $event)" @drop.prevent="onItemDragDrop(props.item, $event)" v-tab-control.contextmenu @keydown.space="props.selected = !props.selected">
<tr :active="props.selected" :key="props.item.name" @touchstart="onItemTouchStart(props, $event)" @touchend="onItemTouchEnd" @click="onItemClick(props)" @contextmenu.prevent="onItemContextmenu(props, $event)" :data-filename="(props.item.isDirectory ? '*' : '') + props.item.name" draggable="true" @dragstart="onItemDragStart(props.item, $event)" @dragover="onItemDragOver(props.item, $event)" @drop.prevent="onItemDragDrop(props.item, $event)" v-tab-control.contextmenu @keydown.space="props.selected = !props.selected">
<td class="pr-0">
<v-checkbox :input-value="props.selected" @touchstart.stop="" @touchend.stop="" @click.stop.prevent="props.selected = !props.selected" primary hide-details></v-checkbox>
</td>
<template v-for="header in headers">
<td v-if="header.value === 'name'" :key="header.value">
<td v-for="header in headers" :key="header.value">
<template v-if="header.value === 'name'">
<v-layout row align-center>
<v-icon class="mr-1">{{ props.item.isDirectory ? 'folder' : 'assignment' }}</v-icon>
<span>{{ props.item.name }}</span>
</v-layout>
</td>
<td v-else-if="header.unit === 'bytes'" :key="header.value">
</template>
<template v-else-if="header.unit === 'bytes'">
{{ (props.item[header.value] !== null) ? $displaySize(props.item[header.value]) : '' }}
</td>
<td v-else-if="header.unit === 'date'" :key="header.value">
</template>
<template v-else-if="header.unit === 'date'">
{{ props.item.lastModified ? props.item.lastModified.toLocaleString() : $t('generic.noValue') }}
</td>
<td v-else-if="header.unit === 'filaments'" :key="header.value">
</template>
<template v-else-if="header.unit === 'filaments'">
<v-tooltip bottom :disabled="!props.item[header.value] || props.item[header.value].length <= 1">
<span slot="activator">
{{ displayLoadingValue(props.item, header.value, 1, 'mm') }}
Expand All @@ -72,14 +72,14 @@ th.checkbox {
{{ $display(props.item[header.value], 1, 'mm') }}
</span>
</v-tooltip>
</td>
<td v-else-if="header.unit === 'time'" :key="header.value">
</template>
<template v-else-if="header.unit === 'time'">
{{ displayTimeValue(props.item, header.value) }}
</td>
<td v-else :key="header.value">
</template>
<template v-else>
{{ displayLoadingValue(props.item, header.value, header.precision, header.unit) }}
</td>
</template>
</template>
</td>
</tr>
</template>
</v-data-table>
Expand Down
Loading

0 comments on commit 6d619f6

Please sign in to comment.