Skip to content

Commit f2ef688

Browse files
committed
fix: clear out the last type warnings
1 parent e34965e commit f2ef688

13 files changed

Lines changed: 80 additions & 146 deletions

File tree

src/components/cards/TemperatureCard.vue

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,7 @@
1717
import { Component, Vue, Watch } from 'vue-property-decorator'
1818
import TemperatureChartWidget from '@/components/widgets/TemperatureChartWidget.vue'
1919
import TemperatureTargetsWidget from '@/components/widgets/TemperatureTargetsWidget.vue'
20-
import { Chart } from 'chart.js'
21-
22-
export interface Data {
23-
label: string;
24-
data: Value[];
25-
}
26-
27-
export interface Value {
28-
x: Date;
29-
y: number;
30-
}
20+
import { ChartData, Chart } from '@/store/socket/types'
3121
3222
@Component({
3323
components: {
@@ -52,19 +42,13 @@ export default class TemperatureCard extends Vue {
5242
}
5343
5444
@Watch('allChartData')
55-
onAllChartDataChanged (val: any) {
56-
if (val.datasets.length) {
45+
onAllChartDataChanged (val: Chart) {
46+
if (val.datasets && val.datasets.length) {
5747
this.start()
5848
}
5949
}
6050
61-
mounted () {
62-
// we should setup a watch and start once we have initial data.
63-
// this.start()
64-
}
65-
6651
private start () {
67-
// this.chartData.datasets = this.$store.state.socket.chart
6852
this.chartData = this.allChartData
6953
this.chartReady = true
7054
}

src/components/widgets/TemperatureChartWidget.vue

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
<script lang="ts">
2-
/* eslint-disable padded-blocks */
3-
import { Vue, Component, Prop, Mixins, Emit } from 'vue-property-decorator'
2+
import { Vue, Component, Prop, Mixins } from 'vue-property-decorator'
43
import Chart from 'chart.js'
54
import VueChart from 'vue-chartjs'
65
import 'chartjs-plugin-colorschemes'
76
87
@Component({})
98
export default class TemperatureChartWidget extends Mixins(VueChart.Line, VueChart.mixins.reactiveProp) {
10-
119
@Prop({ required: true, default: {} })
1210
public chartData!: Chart.ChartData
1311
@@ -69,7 +67,6 @@ export default class TemperatureChartWidget extends Mixins(VueChart.Line, VueCha
6967
7068
private applyDefaultOptions () {
7169
const ticks = this.getXTicks()
72-
// this.options.onClick = this.onClick
7370
this.options.maintainAspectRatio = false
7471
this.options.responsive = true
7572
this.options.scales = {
@@ -150,33 +147,6 @@ export default class TemperatureChartWidget extends Mixins(VueChart.Line, VueCha
150147
mode: undefined
151148
}
152149
}
153-
154-
private onClick (
155-
event?: MouseEvent | undefined,
156-
activeElements?: {}[] | undefined
157-
): any {
158-
const element = this.chart.getElementAtEvent(event)
159-
if (element && element.length > 0) {
160-
this.clickChartElement(element)
161-
}
162-
}
163-
164-
/**
165-
* Reset chart position
166-
*/
167-
// @Watch('resetChart')
168-
// private resetChartPosition() {
169-
// console.log(this.chart);
170-
// if (this.resetChart) {
171-
// const chart: any = this.zoomChartInstance;
172-
// chart.resetZoom();
173-
// }
174-
// }
175-
176-
@Emit('click-chart-element')
177-
public clickChartElement (element: any) {
178-
return element
179-
}
180150
}
181151
182152
</script>

src/components/widgets/TemperatureTargetsWidget.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
import { Component, Mixins } from 'vue-property-decorator'
8787
import InputTemperature from '@/components/inputs/InputTemperature.vue'
8888
import UtilsMixin from '@/mixins/utils'
89+
import { Fan, Heater } from '@/store/socket/types'
8990
9091
@Component({
9192
components: {
@@ -105,11 +106,11 @@ export default class TemperatureTargetsWidget extends Mixins(UtilsMixin) {
105106
return this.$store.getters['socket/getFans']
106107
}
107108
108-
setHeaterTargetTemp (item: any, target: any) {
109+
setHeaterTargetTemp (item: Heater, target: number) {
109110
this.sendGcode(`SET_HEATER_TEMPERATURE HEATER=${item.name} TARGET=${target}`)
110111
}
111112
112-
setFanTargetTemp (item: any, target: any) {
113+
setFanTargetTemp (item: Fan, target: number) {
113114
this.sendGcode(`SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=${item.name} TARGET=${target}`)
114115
}
115116

src/components/widgets/filesystem/FileSystemWidget.vue

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ import { Directory, File } from '@/store/files/types'
163163
import { SocketActions } from '@/socketActions'
164164
import DialogInput from '@/components/dialogs/dialogInput.vue'
165165
import BtnFileUpload from '@/components/inputs/BtnFileUpload.vue'
166-
import { Waits } from '@/globals'
167166
import { DialogData } from '@/types'
168167
import { clone } from 'lodash-es'
169168
import { AxiosResponse } from 'axios'
@@ -299,7 +298,7 @@ export default class FileSystemWidget extends Vue {
299298
}
300299
}
301300
302-
uploadFile (file: any) {
301+
uploadFile (file: globalThis.File) {
303302
const formData = new FormData()
304303
let filename = file.name.replace(' ', '_')
305304
filename = `${this.currentPath}/${filename}`.substring(7)
@@ -317,8 +316,8 @@ export default class FileSystemWidget extends Vue {
317316
}
318317
319318
// This feels hacky...
320-
downloadFile (item: any) {
321-
const filename = item.name
319+
downloadFile (item: File) {
320+
const filename = item.name || ''
322321
const filepath = `/server/files/${this.currentPath}/${item.name}`
323322
this.$http.get(
324323
this.apiUrl + filepath,

src/plugins/axios.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import _Vue from 'vue'
22
import Axios, { AxiosStatic } from 'axios'
33

4-
export function AxiosPlugin<AxiosPlugOptions> (Vue: typeof _Vue, options?: AxiosPluginOptions): void {
4+
export function AxiosPlugin<AxiosPlugOptions> (Vue: typeof _Vue): void {
55
// do stuff with options
66
Vue.prototype.$http = Axios
77
Vue.$http = Axios

src/plugins/filters.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,10 @@ const Filters = {
6565
},
6666

6767
/**
68-
* The filesystem sorted. This is taken from vuetify, and modified to ensure our directories
68+
* The filesystem sorter. This is copied from vuetify, and modified to ensure our directories
6969
* are always sorted to the top.
7070
*/
71+
/* eslint-disable @typescript-eslint/no-explicit-any */
7172
fileSystemSort (items: any, sortBy: string[], sortDesc: boolean[], locale: string) {
7273
if (sortBy === null || !sortBy.length) return items
7374
const stringCollator = new Intl.Collator(locale, { sensitivity: 'accent', usage: 'sort' })
@@ -105,9 +106,9 @@ const Filters = {
105106
}
106107
return 0
107108
})
108-
// items.sort((a: any, b: any) => (a.isDirectory === b.isDirectory) ? 0 : (a.isDirectory ? -1 : 1))
109109
return items
110110
}
111+
/* eslint-enable @typescript-eslint/no-explicit-any */
111112
}
112113

113114
export const FiltersPlugin = {
@@ -133,6 +134,8 @@ declare module 'vue/types/vue' {
133134
capitalize(string: string): string;
134135
formatFileDateTime(datetime: string): string;
135136
getReadableFileSizeString(fileSizeInBytes: number): string;
137+
/* eslint-disable @typescript-eslint/no-explicit-any */
136138
fileSystemSort(items: Array<any>, sortBy: string[], sortDesc: boolean[], locale: string): Array<any>;
139+
/* eslint-enable @typescript-eslint/no-explicit-any */
137140
}
138141
}

src/socketActions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const SocketActions = {
4242
async printerPrintCancel () {
4343
Vue.$socket.emit(
4444
'printer.print.cancel', {
45-
action: 'onPrintCancel',
45+
action: 'socket/onPrintCancel',
4646
wait: Waits.onPrintCancel
4747
}
4848
)
@@ -51,7 +51,7 @@ export const SocketActions = {
5151
async printerPrintPause () {
5252
Vue.$socket.emit(
5353
'printer.print.pause', {
54-
action: 'onPrintPause',
54+
action: 'socket/onPrintPause',
5555
wait: Waits.onPrintPause
5656
}
5757
)
@@ -60,7 +60,7 @@ export const SocketActions = {
6060
async printerPrintResume () {
6161
Vue.$socket.emit(
6262
'printer.print.resume', {
63-
action: 'onPrintResume',
63+
action: 'socket/onPrintResume',
6464
wait: Waits.onPrintResume
6565
}
6666
)

src/store/socket/actions.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Vue from 'vue'
22
import { ActionTree } from 'vuex'
3-
import { SocketState, ChartItem } from './types'
3+
import { SocketState, ChartDataSet } from './types'
44
import { RootState } from '../types'
55
import { configureChartEntry } from '../helpers'
66
import { Globals } from '@/globals'
@@ -59,18 +59,18 @@ export const actions: ActionTree<SocketState, RootState> = {
5959
/**
6060
* Print cancelled confirmation.
6161
*/
62-
async onPrintCancel ({ commit }, payload) {
62+
async onPrintCancel () {
6363
console.log('Print Cancelled')
6464
},
6565

6666
/**
6767
* Print paused confirmation.
6868
*/
69-
async onPrintPause ({ commit }, payload) {
69+
async onPrintPause () {
7070
console.log('Print Paused')
7171
},
7272

73-
async onPrintResume ({ commit }, payload) {
73+
async onPrintResume () {
7474
console.log('Print Resumed')
7575
},
7676

@@ -162,7 +162,7 @@ export const actions: ActionTree<SocketState, RootState> = {
162162
if (originalKey.includes(' ')) {
163163
key = key.split(' ')[1]
164164
}
165-
const data: ChartItem[] = [
165+
const data: ChartDataSet[] = [
166166
{ label: key, data: [], radius: 0 },
167167
{ label: `${key}Target`, data: [], radius: 0 }
168168
]
@@ -283,7 +283,7 @@ export const actions: ActionTree<SocketState, RootState> = {
283283
async notifyFilelistChanged ({ dispatch }, payload) {
284284
dispatch('files/notify' + Vue.$filters.capitalize(payload.action), payload, { root: true }) // Passed on to the files module
285285
},
286-
async notifyMetadataUpdate ({ commit, state }, payload) {
286+
async notifyMetadataUpdate (_, payload) {
287287
console.log('metadataUpdate', payload)
288288
},
289289

@@ -306,7 +306,7 @@ export const actions: ActionTree<SocketState, RootState> = {
306306
}
307307
commit('addConsoleEntry', payload.replace(/(?:\r\n|\r|\n)/g, '<br>'))
308308
},
309-
async addMacro ({ commit, state, rootState }, macro) {
309+
async addMacro ({ commit, rootState }, macro) {
310310
// Macros should include a property to indicate if they're visible
311311
// on the dashboard or not. This comes from the fileConfig.
312312
const hidden = rootState.config?.fileConfig?.dashboard?.hiddenMacros.includes(macro)

src/store/socket/getters.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Vue from 'vue'
22
import { GetterTree } from 'vuex'
3-
import { SocketState, TimeEstimates } from './types'
3+
import { Heater, Fan, SocketState, TimeEstimates, Sensor, Chart, ChartDataSet } from './types'
44
import { RootState } from '../types'
55
import { chartConfiguration } from '@/globals'
66
import { TinyColor } from '@ctrl/tinycolor'
@@ -85,12 +85,12 @@ export const getters: GetterTree<SocketState, RootState> = {
8585
/**
8686
* Return available heaters
8787
*/
88-
getHeaters: (state) => {
88+
getHeaters: (state): Heater[] => {
8989
if (
9090
state.printer.heaters.available_heaters &&
9191
state.printer.heaters.available_heaters.length
9292
) {
93-
const r: any = []
93+
const r: Heater[] = []
9494
state.printer.heaters.available_heaters.forEach((e: string) => {
9595
const config = (state.printer.configfile.config[e]) ? state.printer.configfile.config[e] : undefined
9696
r.push({
@@ -100,7 +100,7 @@ export const getters: GetterTree<SocketState, RootState> = {
100100
maxTemp: (config && config.max_temp) ? parseInt(config.max_temp) : null
101101
})
102102
})
103-
return r.sort((a: any, b: any) => {
103+
return r.sort((a: Heater, b: Heater) => {
104104
const name1 = a.name.toUpperCase()
105105
const name2 = b.name.toUpperCase()
106106
return (name1 < name2) ? -1 : (name1 > name2) ? 1 : 0
@@ -112,12 +112,12 @@ export const getters: GetterTree<SocketState, RootState> = {
112112
/**
113113
* Return available temperature fans
114114
*/
115-
getFans: (state) => {
115+
getFans: (state): Fan[] => {
116116
if (
117117
state.temperature_fans &&
118118
state.temperature_fans.length
119119
) {
120-
const r: any = []
120+
const r: Fan[] = []
121121
state.temperature_fans.forEach((e: string) => {
122122
const config = (state.printer.configfile.config['temperature_fan ' + e]) ? state.printer.configfile.config['temperature_fan ' + e] : undefined
123123
r.push({
@@ -135,12 +135,12 @@ export const getters: GetterTree<SocketState, RootState> = {
135135
/**
136136
* Return available temperature probes / sensors.
137137
*/
138-
getSensors: (state) => {
138+
getSensors: (state): Sensor[] => {
139139
if (
140140
state.temperature_sensors &&
141141
state.temperature_sensors.length
142142
) {
143-
const r: any = []
143+
const r: Sensor[] = []
144144
state.temperature_sensors.forEach((e: string) => {
145145
r.push({
146146
name: e,
@@ -180,7 +180,7 @@ export const getters: GetterTree<SocketState, RootState> = {
180180
},
181181

182182
getChartData: (state) => {
183-
const chartData: {[key: string]: Array<{[key: string]: any}> } = {
183+
const chartData: Chart = {
184184
labels: [],
185185
datasets: []
186186
}
@@ -190,7 +190,7 @@ export const getters: GetterTree<SocketState, RootState> = {
190190
// Beds should probably be some variation of blue;
191191
// Hotends should be some variation of red;
192192
// Other sensors can hue off'f green.
193-
const defaults: {[key: string]: any } = {
193+
const defaults: ChartDataSet = {
194194
data: item.data,
195195
label: item.label,
196196
display: false,

src/store/socket/mutations.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Vue from 'vue'
22
import { MutationTree } from 'vuex'
33
import { get } from 'lodash-es'
4-
import { SocketState, ChartItem, Macro } from './types'
4+
import { SocketState, ChartDataSet, Macro } from './types'
55
import { state as originalState, state } from './index'
66
import { chartConfiguration } from '@/globals'
77

@@ -84,7 +84,7 @@ export const mutations: MutationTree<SocketState> = {
8484
}
8585
},
8686
addInitialChartData (state, payload) {
87-
payload.forEach((item: ChartItem) => {
87+
payload.forEach((item: ChartDataSet) => {
8888
state.chart.push(item)
8989
})
9090
},

0 commit comments

Comments
 (0)