Great big ESLint

This commit is contained in:
Joel Collins 2019-11-11 16:33:43 +00:00
parent 051eabbdc3
commit ebcb938da1
48 changed files with 3890 additions and 2536 deletions

View file

@ -1,31 +1,21 @@
<template>
<div id="appSettings">
<p><label><input v-model="darkMode" class="uk-checkbox" type="checkbox"> Enable dark theme</label></p>
</div>
<div id="appSettings">
<p>
<label
><input v-model="darkMode" class="uk-checkbox" type="checkbox" /> Enable
dark theme</label
>
</p>
</div>
</template>
<script>
// Export main app
export default {
name: 'appSettings',
name: "AppSettings",
data: function () {
return {}
},
mounted() {
// Try loading settings from localStorage. If null, don't change.
this.darkMode = this.getLocalStorageObj('darkMode') || this.darkMode
},
watch: {
darkMode(newdarkMode) {
console.log("Saving darkmode setting")
this.setLocalStorageObj('darkMode', this.darkMode)
}
data: function() {
return {};
},
computed: {
@ -34,13 +24,23 @@ export default {
return this.$store.state.globalSettings.darkMode;
},
set(value) {
this.$store.commit("changeSetting", ['darkMode', value]);
this.$store.commit("changeSetting", ["darkMode", value]);
}
}
}
},
}
watch: {
darkMode() {
console.log("Saving darkmode setting");
this.setLocalStorageObj("darkMode", this.darkMode);
}
},
mounted() {
// Try loading settings from localStorage. If null, don't change.
this.darkMode = this.getLocalStorageObj("darkMode") || this.darkMode;
}
};
</script>
<style lang="less">
</style>
<style lang="less"></style>

View file

@ -1,138 +1,181 @@
<template>
<div id="cameraSettings">
<form @submit.prevent="applyConfigRequest">
<div id="cameraSettings">
<form @submit.prevent="applyConfigRequest">
<div>
<label class="uk-form-label" for="form-stacked-text">Exposure time</label>
<label class="uk-form-label" for="form-stacked-text"
>Exposure time</label
>
<div class="uk-form-controls">
<input v-bind:value="displayShutterSpeed" v-on:input="shutterSpeed = $event.target.value" class="uk-input uk-form-small" type="number">
<input
:value="displayShutterSpeed"
class="uk-input uk-form-small"
type="number"
@input="shutterSpeed = $event.target.value"
/>
</div>
</div>
<div>
<label class="uk-form-label" for="form-stacked-text">Analogue gain</label>
<label class="uk-form-label" for="form-stacked-text"
>Analogue gain</label
>
<div class="uk-form-controls">
<input v-bind:value="displayAnalogGain" v-on:input="analogGain = $event.target.value" class="uk-input uk-form-small" type="number" step="0.1">
<input
:value="displayAnalogGain"
class="uk-input uk-form-small"
type="number"
step="0.1"
@input="analogGain = $event.target.value"
/>
</div>
</div>
<div>
<label class="uk-form-label" for="form-stacked-text">Digital gain</label>
<label class="uk-form-label" for="form-stacked-text"
>Digital gain</label
>
<div class="uk-form-controls">
<input v-bind:value="displayDigitalGain" v-on:input="digitalGain = $event.target.value" class="uk-input uk-form-small" type="number" step="0.1">
<input
:value="displayDigitalGain"
class="uk-input uk-form-small"
type="number"
step="0.1"
@input="digitalGain = $event.target.value"
/>
</div>
</div>
<button type="submit" class="uk-button uk-button-primary uk-form-small uk-float-right uk-margin-small uk-width-1-1">Apply Settings</button>
<!--Show auto calibrate if default plugin is enabled-->
<div v-if="this.$store.state.apiState.plugin.includes('default_camera_calibration')">
<taskSubmitter
v-bind:canTerminate="false"
v-bind:requiresConfirmation="true"
v-bind:confirmationMessage="'Start recalibration? This may take a while, and the microscope will be locked during this time.'"
v-bind:submitURL="recalibrateApiUri"
v-bind:submitLabel="'Auto-Calibrate (Task)'"
v-on:response="onRecalibrateResponse"
v-on:error="onRecalibrateError">
</taskSubmitter>
</div>
</form>
</div>
<button
type="submit"
class="uk-button uk-button-primary uk-form-small uk-float-right uk-margin-small uk-width-1-1"
>
Apply Settings
</button>
<!--Show auto calibrate if default plugin is enabled-->
<div
v-if="
this.$store.state.apiState.plugin.includes(
'default_camera_calibration'
)
"
>
<taskSubmitter
:can-terminate="false"
:requires-confirmation="true"
:confirmation-message="
'Start recalibration? This may take a while, and the microscope will be locked during this time.'
"
:submit-u-r-l="recalibrateApiUri"
:submit-label="'Auto-Calibrate (Task)'"
@response="onRecalibrateResponse"
@error="onRecalibrateError"
>
</taskSubmitter>
</div>
</form>
</div>
</template>
<script>
import axios from 'axios'
import taskSubmitter from "../../genericComponents/taskSubmitter"
import axios from "axios";
import taskSubmitter from "../../genericComponents/taskSubmitter";
// Export main app
export default {
name: 'microscopeSettings',
name: "MicroscopeSettings",
components: {
taskSubmitter
},
data: function () {
data: function() {
return {
shutterSpeed: this.$store.state.apiConfig.camera_settings.picamera_settings.shutter_speed,
analogGain: this.$store.state.apiConfig.camera_settings.picamera_settings.analog_gain,
digitalGain: this.$store.state.apiConfig.camera_settings.picamera_settings.digital_gain,
shutterSpeed: this.$store.state.apiConfig.camera_settings
.picamera_settings.shutter_speed,
analogGain: this.$store.state.apiConfig.camera_settings.picamera_settings
.analog_gain,
digitalGain: this.$store.state.apiConfig.camera_settings.picamera_settings
.digital_gain,
isCalibrating: false
};
},
computed: {
displayDigitalGain: function() {
return Number(this.digitalGain).toFixed(2);
},
displayAnalogGain: function() {
return Number(this.analogGain).toFixed(2);
},
displayShutterSpeed: function() {
return this.shutterSpeed != "0" ? this.shutterSpeed : "auto";
},
recalibrateApiUri: function() {
return (
this.$store.getters.uri +
"/plugin/default/camera_calibration/recalibrate"
);
},
configApiUri: function() {
return this.$store.getters.uri + "/config";
}
},
methods: {
updateInputValues: function () {
this.shutterSpeed = this.$store.state.apiConfig.camera_settings.picamera_settings.shutter_speed
this.digitalGain = this.$store.state.apiConfig.camera_settings.picamera_settings.digital_gain
this.analogGain = this.$store.state.apiConfig.camera_settings.picamera_settings.analog_gain
updateInputValues: function() {
this.shutterSpeed = this.$store.state.apiConfig.camera_settings.picamera_settings.shutter_speed;
this.digitalGain = this.$store.state.apiConfig.camera_settings.picamera_settings.digital_gain;
this.analogGain = this.$store.state.apiConfig.camera_settings.picamera_settings.analog_gain;
},
applyConfigRequest: function() {
console.log("Applying config to the microscope")
console.log("Applying config to the microscope");
var payload = {
camera_settings: {
picamera_settings: {}
}
}
};
//if (this.shutterSpeed != this.$store.state.apiConfig.picamera_settings.shutter_speed) {
payload.camera_settings.picamera_settings.shutter_speed = this.shutterSpeed
payload.camera_settings.picamera_settings.analog_gain = this.analogGain
payload.camera_settings.picamera_settings.digital_gain = this.digitalGain
payload.camera_settings.picamera_settings.shutter_speed = this.shutterSpeed;
payload.camera_settings.picamera_settings.analog_gain = this.analogGain;
payload.camera_settings.picamera_settings.digital_gain = this.digitalGain;
//};
// Send request
axios.post(this.configApiUri, payload)
.then(response => { return new Promise(r => setTimeout(r, 500))}) // why is there no built-in for this??!
.then(response => {
return this.$store.dispatch('updateConfig');
axios
.post(this.configApiUri, payload)
.then(() => {
return new Promise(r => setTimeout(r, 500));
}) // why is there no built-in for this??!
.then(() => {
return this.$store.dispatch("updateConfig");
})
.then(this.updateInputValues)
.then(r=>{console.log("Updated Config: ", payload)})
.catch(error => {
this.modalError(error) // Let mixin handle error
.then(() => {
console.log("Updated Config: ", payload);
})
.catch(error => {
this.modalError(error); // Let mixin handle error
});
},
onRecalibrateResponse: function() {
this.modalNotify("Finished recalibration.")
return new Promise(r => setTimeout(r, 500)) // wait 500ms before updating config, so it's fresh
this.modalNotify("Finished recalibration.");
return new Promise(r => setTimeout(r, 500)); // wait 500ms before updating config, so it's fresh
},
onRecalibrateError: function(error) {
this.modalError(error) // Let mixin handle error
}
},
computed: {
displayDigitalGain: function () {
return Number(this.digitalGain).toFixed(2)
},
displayAnalogGain: function () {
return Number(this.analogGain).toFixed(2)
},
displayShutterSpeed: function () {
return (this.shutterSpeed != "0") ? this.shutterSpeed : "auto"
},
recalibrateApiUri: function () {
return this.$store.getters.uri + "/plugin/default/camera_calibration/recalibrate"
},
configApiUri: function () {
return this.$store.getters.uri + "/config"
this.modalError(error); // Let mixin handle error
}
}
}
};
</script>
<style lang="less">
.center-spinner {
margin-left: auto;
margin-right: auto
margin-right: auto;
}
</style>

View file

@ -1,108 +1,133 @@
<template>
<div id="microscopeSettings">
<form @submit.prevent="applyConfigRequest">
<h4>Stage</h4>
<div id="microscopeSettings">
<form @submit.prevent="applyConfigRequest">
<h4>Stage</h4>
<label class="uk-form-label" for="form-stacked-text">Backlash compensation</label>
<div class="uk-grid-small uk-child-width-1-3" uk-grid>
<div>
<label class="uk-form-label" for="form-stacked-text">x</label>
<div class="uk-form-controls">
<input v-model="stageBacklash.x" class="uk-input uk-form-small" type="number">
<label class="uk-form-label" for="form-stacked-text"
>Backlash compensation</label
>
<div class="uk-grid-small uk-child-width-1-3" uk-grid>
<div>
<label class="uk-form-label" for="form-stacked-text">x</label>
<div class="uk-form-controls">
<input
v-model="stageBacklash.x"
class="uk-input uk-form-small"
type="number"
/>
</div>
</div>
<div>
<label class="uk-form-label" for="form-stacked-text">y</label>
<div class="uk-form-controls">
<input
v-model="stageBacklash.y"
class="uk-input uk-form-small"
type="number"
/>
</div>
</div>
<div>
<label class="uk-form-label" for="form-stacked-text">z</label>
<div class="uk-form-controls">
<input
v-model="stageBacklash.z"
class="uk-input uk-form-small"
type="number"
/>
</div>
</div>
</div>
<div>
<label class="uk-form-label" for="form-stacked-text">y</label>
<div class="uk-form-controls">
<input v-model="stageBacklash.y" class="uk-input uk-form-small" type="number">
</div>
</div>
<h4>Microscope</h4>
<div>
<label class="uk-form-label" for="form-stacked-text">z</label>
<div class="uk-form-controls">
<input v-model="stageBacklash.z" class="uk-input uk-form-small" type="number">
</div>
<label class="uk-form-label" for="form-stacked-text"
>Microscope name</label
>
<input
v-model="microscopeName"
class="uk-input uk-width-1-1 uk-form-small"
name="inputFilename"
placeholder="Leave blank for default"
/>
</div>
</div>
<h4>Microscope</h4>
<div>
<label class="uk-form-label" for="form-stacked-text">Microscope name</label>
<input v-model="microscopeName" class="uk-input uk-width-1-1 uk-form-small" name="inputFilename" placeholder="Leave blank for default">
</div>
<button type="submit" class="uk-button uk-button-primary uk-form-small uk-float-right uk-margin-small uk-width-1-1">Apply Settings</button>
</form>
</div>
<button
type="submit"
class="uk-button uk-button-primary uk-form-small uk-float-right uk-margin-small uk-width-1-1"
>
Apply Settings
</button>
</form>
</div>
</template>
<script>
import axios from 'axios'
import axios from "axios";
// Export main app
export default {
name: 'microscopeSettings',
name: "MicroscopeSettings",
data: function () {
data: function() {
return {
microscopeName: this.$store.state.apiConfig.name,
stageBacklash: this.$store.state.apiConfig.stage_settings.backlash
};
},
computed: {
configApiUri: function() {
return this.$store.getters.uri + "/config";
}
},
methods: {
updateInputValues: function () {
updateInputValues: function() {
this.microscopeName = this.$store.state.apiConfig.name;
this.stageBacklash = this.$store.state.apiConfig.stage_settings.backlash
this.stageBacklash = this.$store.state.apiConfig.stage_settings.backlash;
},
applyConfigRequest: function() {
var payload = {
stage_settings: {}
}
if (this.microscopeName != this.$store.state.apiConfig.name) {
payload.name = this.microscopeName
};
if (this.stageBacklash != this.$store.state.apiConfig.stage_settings.backlash) {
payload.stage_settings.backlash = this.stageBacklash
if (this.microscopeName != this.$store.state.apiConfig.name) {
payload.name = this.microscopeName;
}
console.log(payload)
if (
this.stageBacklash !=
this.$store.state.apiConfig.stage_settings.backlash
) {
payload.stage_settings.backlash = this.stageBacklash;
}
console.log(payload);
// Send request to update config
axios.post(this.configApiUri, payload)
.then(response => {
this.$store.dispatch('updateConfig');
this.updateInputValues
this.modalNotify("Microscope config applied.")
axios
.post(this.configApiUri, payload)
.then(() => {
this.$store.dispatch("updateConfig");
this.updateInputValues;
this.modalNotify("Microscope config applied.");
})
.catch(error => {
this.modalError(error) // Let mixin handle error
})
}
},
computed: {
configApiUri: function () {
return this.$store.getters.uri + "/config"
this.modalError(error); // Let mixin handle error
});
}
}
}
};
</script>
<style lang="less">
.center-spinner {
margin-left: auto;
margin-right: auto
margin-right: auto;
}
</style>

View file

@ -1,34 +1,49 @@
<template>
<div id="streamSettings">
<div id="streamSettings">
<p>
<label
><input v-model="disableStream" class="uk-checkbox" type="checkbox" />
Disable live stream</label
>
</p>
<p><label><input v-model="disableStream" class="uk-checkbox" type="checkbox"> Disable live stream</label></p>
<div class="uk-child-width-1-2" uk-grid>
<p><label v-bind:class="[{'uk-disabled': !this.$store.getters.ready}]"><input v-model="autoGpuPreview" class="uk-checkbox" type="checkbox"> GPU preview</label></p>
<p><label v-bind:class="[{'uk-disabled': !this.$store.getters.ready}]"><input v-model="trackWindow" class="uk-checkbox" type="checkbox"> Track window</label></p>
<div class="uk-child-width-1-2" uk-grid>
<p>
<label :class="[{ 'uk-disabled': !this.$store.getters.ready }]"
><input
v-model="autoGpuPreview"
class="uk-checkbox"
type="checkbox"
/>
GPU preview</label
>
</p>
<p>
<label :class="[{ 'uk-disabled': !this.$store.getters.ready }]"
><input v-model="trackWindow" class="uk-checkbox" type="checkbox" />
Track window</label
>
</p>
</div>
</div>
</div>
</template>
<script>
// Export main app
export default {
name: 'streamSettings',
name: "StreamSettings",
data: function () {
return {}
data: function() {
return {};
},
computed: {
disableStream: {
get() {
return this.$store.state.globalSettings.disableStream;
},
set(value) {
this.$store.commit("changeSetting", ['disableStream', value]);
this.$store.commit("changeSetting", ["disableStream", value]);
}
},
@ -37,8 +52,8 @@ export default {
return this.$store.state.globalSettings.autoGpuPreview;
},
set(value) {
this.$store.commit("changeSetting", ['autoGpuPreview', value]);
this.$root.$emit('globalTogglePreview', value)
this.$store.commit("changeSetting", ["autoGpuPreview", value]);
this.$root.$emit("globalTogglePreview", value);
}
},
@ -47,13 +62,11 @@ export default {
return this.$store.state.globalSettings.trackWindow;
},
set(value) {
this.$store.commit("changeSetting", ['trackWindow', value]);
this.$store.commit("changeSetting", ["trackWindow", value]);
}
}
}
}
};
</script>
<style lang="less">
</style>
<style lang="less"></style>