Skip to content

Commit 1e6e83b

Browse files
authored
Cosmetic UI tweaks for new scripts/preprocessors, also remove _state_ prefix from preprocessor symtable state value (#172)
1 parent 1cd5e92 commit 1e6e83b

8 files changed

+26
-12
lines changed

continuousprint/data/data_test.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,24 +147,29 @@ def test_from_idle(self, pp):
147147
self.assertEqual(
148148
pp(
149149
dict(
150-
current=dict(state="_state_clearing"),
150+
current=dict(state="clearing"),
151151
)
152152
)[0],
153153
False,
154154
)
155155
self.assertEqual(
156156
pp(
157157
dict(
158-
current=dict(state="_state_inactive"),
158+
current=dict(state="inactive"),
159159
)
160160
)[0],
161161
True,
162162
)
163163
self.assertEqual(
164164
pp(
165165
dict(
166-
current=dict(state="_state_idle"),
166+
current=dict(state="idle"),
167167
)
168168
)[0],
169169
True,
170170
)
171+
172+
@test_preprocessor("If externally set variable is True")
173+
def test_extern(self, pp):
174+
self.assertEqual(pp(dict(external=dict(testval=True)))[0], True)
175+
self.assertEqual(pp(dict(external=dict(testval=False)))[0], False)

continuousprint/data/preprocessors.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,9 @@ Preprocessors:
2929
- name: "If starting from idle (first run, or ran finished script)"
3030
body: |
3131
# Both current and previous printer state are checked here to ensure printer is properly idle
32-
current["state"] in ("_state_inactive", "_state_idle")
32+
current["state"] in ("inactive", "idle")
33+
- name: "If externally set variable is True"
34+
body: |
35+
# Set external values via web request, e.g.
36+
# curl -X POST -d '{"testval": true}' http://printer:5000/plugin/continuousprint/automation/external
37+
external["testval"] == True

continuousprint/driver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def action(
113113
path=self._cur_path,
114114
materials=self._cur_materials,
115115
bed_temp=self._bed_temp,
116-
state=self.state.__name__,
116+
state=self.state.__name__.strip("_state_"),
117117
)
118118
)
119119

continuousprint/static/js/continuousprint_job.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ function CPJob(obj, peers, api, profile, materials) {
177177

178178
self.totals = ko.computed(function() {
179179
let r = [
180-
{legend: 'Total items printed', title: ""},
180+
{legend: 'Total items', title: null},
181181
{legend: 'Total time', title: "Uses Octoprint's file analysis estimate; may be inaccurate"},
182182
{legend: 'Total mass', title: "Mass is calculated using active spool(s) in SpoolManager"},
183183
];

continuousprint/static/js/continuousprint_job.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ test('totals', () => {
6161
remaining: "2", // 2 left in this run, one from each set
6262
total: "2", // 2 pending
6363
error: "",
64-
legend: "Total items printed",
65-
title: expect.anything(),
64+
legend: "Total items",
65+
title: null,
6666
});
6767

6868
// Values are as above, but x100 and converted to minutes

continuousprint/static/js/continuousprint_settings.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,11 @@ function CPSettingsViewModel(parameters, profiles=CP_PRINTER_PROFILES, default_s
107107
let result = [];
108108
for (let e of self.events()) {
109109
for (let a of e.actions()) {
110-
if (a.script.name() == nn || a.preprocessor() == nn) {
110+
let ppname = a.preprocessor();
111+
if (ppname !== null && ppname.name) {
112+
ppname = ppname.name();
113+
}
114+
if (a.script.name() === nn || ppname === nn) {
111115
result.push(e.display);
112116
}
113117
}

continuousprint/templates/continuousprint_settings.jinja2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@
144144
<div style="flex: 1">
145145
<div data-bind="hidden: expanded">
146146
<div data-bind="text: name"></div>
147-
<div class="subheader" data-bind="visible: registrations().length > 0">Runs on <span data-bind="text: registrations"></span></div>
147+
<div class="subheader" data-bind="visible: registrations().length > 0">Fires on <span data-bind="text: registrations().join(', ')"></span></div>
148148
</div>
149149
<div data-bind="visible: expanded">
150150
<input type="text" placeholder="Script Name" data-bind="value: name"></input>
@@ -205,7 +205,7 @@
205205
<div style="flex: 1">
206206
<div data-bind="hidden: expanded">
207207
<div data-bind="text: name"></div>
208-
<div class="subheader" data-bind="visible: registrations().length > 0">Runs on <span data-bind="text: registrations"></span></div>
208+
<div class="subheader" data-bind="visible: registrations().length > 0">Fires on <span data-bind="text: registrations().join(', ')"></span></div>
209209
</div>
210210
<div data-bind="visible: expanded">
211211
<input placeholder="Preprocessor name" type="text" data-bind="value: name"></input>

continuousprint/templates/continuousprint_tab.jinja2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@
277277
</div>
278278
<div data-bind="foreach: totals, visible: draft">
279279
<div class="job-stats">
280-
<div style="flex: 1;" data-bind="attr: {title: title}"><span data-bind="text: legend"></span><sup data-bind="display: title">?</sup></div>
280+
<div style="flex: 1;" data-bind="attr: {title: title}"><span data-bind="text: legend"></span><sup data-bind="visible: title">?</sup></div>
281281
<div class="completed" data-bind="text: completed"></div>
282282
<div class="count" data-bind="text: count"></div>
283283
<div class="remaining" data-bind="text: remaining"></div>

0 commit comments

Comments
 (0)