Skip to content

Commit

Permalink
feat: support multiple Nevermore objects
Browse files Browse the repository at this point in the history
Signed-off-by: Sanaa Hamel <[email protected]>
  • Loading branch information
SanaaHamel committed Jul 11, 2024
1 parent 193eaea commit ca34cbc
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 19 deletions.
28 changes: 18 additions & 10 deletions src/components/panels/Temperature/TemperaturePanelList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
:object-name="objectName"
:is-responsive-mobile="el.is.mobile ?? false" />
<temperature-panel-list-item-nevermore
v-if="existsNevermoreFilter"
v-for="objectName in nevermoreObjects"
:key="objectName"
:object-name="objectName"
:is-responsive-mobile="el.is.mobile ?? false" />
<temperature-panel-list-item
v-for="objectName in temperature_sensors"
Expand Down Expand Up @@ -73,6 +75,12 @@ export default class TemperaturePanelList extends Mixins(BaseMixin) {
return this.$store.state.printer?.heaters?.available_monitors ?? []
}
get available_nevermores() {
return Object.keys(this.$store.state.printer).filter(
(name) => name === 'nevermore' || name.startsWith('nevermore ')
)
}
get monitors() {
return this.available_monitors.sort(this.sortObjectName)
}
Expand All @@ -83,10 +91,6 @@ export default class TemperaturePanelList extends Mixins(BaseMixin) {
.sort(this.sortObjectName)
}
get existsNevermoreFilter() {
return 'nevermore' in this.$store.state.printer
}
get hideMcuHostSensors(): boolean {
return this.$store.state.gui.view.tempchart.hideMcuHostSensors ?? false
}
Expand All @@ -97,20 +101,24 @@ export default class TemperaturePanelList extends Mixins(BaseMixin) {
get temperature_sensors() {
return this.filterNamesAndSort(this.available_sensors).filter((fullName: string) => {
if (this.available_heaters.includes(fullName)) return false
if (this.temperature_fans.includes(fullName)) return false
if (this.available_heaters.includes(fullName)) return false
if (this.temperature_fans.includes(fullName)) return false
// hide MCU & Host sensors, if the function is enabled
if (this.hideMcuHostSensors && this.checkMcuHostSensor(fullName)) return false
// hide MCU & Host sensors, if the function is enabled
if (this.hideMcuHostSensors && this.checkMcuHostSensor(fullName)) return false
return true
})
})
}
get heaterObjects() {
return [...this.filteredHeaters, ...this.temperature_fans]
}
get nevermoreObjects() {
return this.filterNamesAndSort(this.available_nevermores)
}
get settings() {
return this.$store.state.printer?.configfile?.settings ?? {}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ export default class TemperaturePanelListItemEdit extends Mixins(BaseMixin) {
get additionalValues() {
if (this.objectName === 'z_thermal_adjust') return ['current_z_adjust']
if (this.objectName === 'nevermore') return ['temperature', 'pressure', 'humidity', 'rpm']
if (this.objectName === 'nevermore' || this.objectName.startsWith('nevermore '))
return ['temperature', 'pressure', 'humidity', 'rpm']
return Object.keys(this.printerObjectAdditionalSensor).filter((key) => key !== 'temperature')
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,29 @@
</v-icon>
</td>
<td class="name">
<span class="cursor-pointer" @click="showEditDialog = true">Nevermore</span>
<span class="cursor-pointer" @click="showEditDialog = true">{{ formatName }}</span>
</td>
<td class="text-no-wrap text-center" colspan="3">
<temperature-panel-list-item-nevermore-value
:printer-object="printerObject"
:object-name="objectName"
:small="false"
object-name="nevermore"
key-name="gas" />
<temperature-panel-list-item-nevermore-value
v-for="keyName in nevermoreValues"
:key="keyName"
:printer-object="printerObject"
object-name="nevermore"
:object-name="objectName"
:key-name="keyName" />
<div v-if="rpm !== null">
<small :class="rpmClass">{{ rpm }} RPM</small>
</div>
</td>
<temperature-panel-list-item-edit
:bool-show="showEditDialog"
object-name="nevermore"
name="nevermore"
format-name="Nevermore"
:object-name="objectName"
:name="name"
:format-name="formatName"
additional-sensor-name="nevermore"
:icon="mdiFan"
:color="color"
Expand All @@ -40,24 +40,35 @@
import Component from 'vue-class-component'
import { Mixins, Prop } from 'vue-property-decorator'
import BaseMixin from '@/components/mixins/base'
import { convertName } from '@/plugins/helpers'
import { mdiFan } from '@mdi/js'
import { opacityHeaterActive, opacityHeaterInactive } from '@/store/variables'
@Component
export default class TemperaturePanelListItemNevermore extends Mixins(BaseMixin) {
mdiFan = mdiFan
@Prop({ type: String, required: true }) readonly objectName!: string
@Prop({ type: Boolean, required: true }) readonly isResponsiveMobile!: boolean
showEditDialog = false
nevermoreValues = ['temperature', 'pressure', 'humidity']
get printerObject() {
return this.$store.state.printer.nevermore ?? {}
return this.$store.state.printer[this.objectName] ?? {}
}
get name() {
const splits = this.objectName.split(' ')
return splits.length === 1 ? splits[0] : splits[1]
}
get formatName() {
return convertName(this.name)
}
get color() {
return this.$store.state.gui?.view?.tempchart?.datasetSettings?.nevermore?.color ?? '#ffffff'
return this.$store.state.gui?.view?.tempchart?.datasetSettings?.[this.objectName]?.color ?? '#ffffff'
}
get iconColor() {
Expand Down

0 comments on commit ca34cbc

Please sign in to comment.