@@ -2,6 +2,59 @@ $(function () {
2
2
function PiSupportViewModel ( parameters ) {
3
3
var self = this ;
4
4
5
+ const UNDERVOLTAGE_TITLE = gettext ( "Undervoltage detected" ) ;
6
+ const UNDERVOLTAGE_WARNING = gettext (
7
+ "Your Raspberry Pi is reporting insufficient power. " +
8
+ "Switch to an adequate power supply or risk bad " +
9
+ "performance and failed prints."
10
+ ) ;
11
+ const UNDERVOLTAGE_FAQ = "https://faq.octoprint.org/pi-issues" ;
12
+
13
+ const ZERO_TITLE = gettext ( "Unsupported hardware detected" ) ;
14
+ const ZERO_WARNING = gettext (
15
+ "OctoPrint does not and never has supported the " +
16
+ "RPi Zero or Zero W. Use at least a Raspberry Pi 3 or Zero 2, or " +
17
+ "risk bad performance and failed prints."
18
+ ) ;
19
+ const ZERO_DISABLE = gettext (
20
+ "You can disable this message via Settings > " +
21
+ "Pi Support > Disable warning about unsupported hardware"
22
+ ) ;
23
+ const ZERO_FAQ = "https://faq.octoprint.org/recommended-hardware" ;
24
+
25
+ const PASSWORD_TITLE = gettext ( "Default system password not changed" ) ;
26
+ const PASSWORD_WARNING = gettext (
27
+ 'The default password for the system user "pi" has not ' +
28
+ "been changed. This is a security risk - please login to " +
29
+ "your Pi via SSH and change the password."
30
+ ) ;
31
+ const PASSWORD_DISABLE = gettext (
32
+ "You can disable this message via Settings > " +
33
+ "Pi Support > Disable warning about default system password"
34
+ ) ;
35
+ const PASSWORD_FAQ = "https://faq.octoprint.org/pi-default-password" ;
36
+
37
+ const FAQ = gettext (
38
+ 'You can read more <a href="%(url)s" target="_blank">in the FAQ</a>.'
39
+ ) ;
40
+
41
+ const generateHtml = ( warning , faq , disable ) => {
42
+ const html =
43
+ "<p>" +
44
+ warning +
45
+ "</p><p>" +
46
+ _ . sprintf ( FAQ , {
47
+ url : faq
48
+ } ) +
49
+ "</p>" ;
50
+
51
+ if ( disable ) {
52
+ return html + "<p><small>" + disable + "</small></p>" ;
53
+ } else {
54
+ return html ;
55
+ }
56
+ } ;
57
+
5
58
self . loginState = parameters [ 0 ] ;
6
59
self . access = parameters [ 1 ] ;
7
60
self . settings = parameters [ 2 ] ;
@@ -35,34 +88,10 @@ $(function () {
35
88
response . model_unrecommended &&
36
89
! self . settings . settings . plugins . pi_support . ignore_unrecommended_model ( )
37
90
) {
38
- var warning = gettext (
39
- "OctoPrint does not and never has supported the " +
40
- "RPi Zero or Zero W. Use at least a Raspberry Pi 3 or Zero 2, or " +
41
- "risk bad performance and failed prints."
42
- ) ;
43
- var faq = gettext (
44
- "" +
45
- 'You can read more <a href="%(url)s" target="_blank">in the FAQ</a>.'
46
- ) ;
47
- var remove = gettext (
48
- "You can disable this message via Settings > " +
49
- "Pi Support > Disable warning about unsupported hardware"
50
- ) ;
51
-
52
91
if ( self . notifications . unrecommended === undefined ) {
53
92
self . notifications . unrecommended = new PNotify ( {
54
- title : gettext ( "Unsupported hardware detected" ) ,
55
- text :
56
- "<p>" +
57
- warning +
58
- "</p><p>" +
59
- _ . sprintf ( faq , {
60
- url : "https://faq.octoprint.org/recommended-hardware"
61
- } ) +
62
- "</p><p>" +
63
- "<small>" +
64
- remove +
65
- "</small></p>" ,
93
+ title : ZERO_TITLE ,
94
+ text : generateHtml ( ZERO_WARNING , ZERO_FAQ , ZERO_DISABLE ) ,
66
95
type : "error" ,
67
96
hide : false
68
97
} ) ;
@@ -96,27 +125,10 @@ $(function () {
96
125
// Throttle state
97
126
self . fromThrottleState ( response . throttle_state ) ;
98
127
if ( self . currentUndervoltage ( ) || self . pastUndervoltage ( ) ) {
99
- var warning = gettext (
100
- "Your Raspberry Pi is reporting insufficient power. " +
101
- "Switch to an adequate power supply or risk bad " +
102
- "performance and failed prints."
103
- ) ;
104
- var faq = gettext (
105
- "" +
106
- 'You can read more <a href="%(url)s" target="_blank">in the FAQ</a>.'
107
- ) ;
108
-
109
128
if ( self . notifications . throttled === undefined ) {
110
129
self . notifications . throttled = new PNotify ( {
111
- title : gettext ( "Undervoltage detected" ) ,
112
- text :
113
- "<p>" +
114
- warning +
115
- "</p><p>" +
116
- _ . sprintf ( faq , {
117
- url : "https://faq.octoprint.org/pi-issues"
118
- } ) +
119
- "</p>" ,
130
+ title : UNDERVOLTAGE_TITLE ,
131
+ text : generateHtml ( UNDERVOLTAGE_WARNING , UNDERVOLTAGE_FAQ ) ,
120
132
type : "error" ,
121
133
hide : false
122
134
} ) ;
@@ -131,34 +143,14 @@ $(function () {
131
143
response . default_password &&
132
144
! self . settings . settings . plugins . pi_support . ignore_default_password ( )
133
145
) {
134
- var warning = gettext (
135
- 'The default password for the system user "pi" has not ' +
136
- "been changed. This is a security risk - please login to " +
137
- "your Pi via SSH and change the password."
138
- ) ;
139
- var faq = gettext (
140
- "" +
141
- 'You can read more <a href="%(url)s" target="_blank">in the FAQ</a>.'
142
- ) ;
143
- var remove = gettext (
144
- "You can disable this message via Settings > " +
145
- "Pi Support > Disable warning about default system password"
146
- ) ;
147
-
148
146
if ( self . notifications . default_password === undefined ) {
149
147
self . notifications . default_password = new PNotify ( {
150
- title : gettext ( "Default system password not changed" ) ,
151
- text :
152
- "<p>" +
153
- warning +
154
- "</p><p>" +
155
- _ . sprintf ( faq , {
156
- url : "https://faq.octoprint.org/pi-default-password"
157
- } ) +
158
- "</p><p>" +
159
- "<small>" +
160
- remove +
161
- "</small></p>" ,
148
+ title : PASSWORD_TITLE ,
149
+ text : generateHtml (
150
+ PASSWORD_WARNING ,
151
+ PASSWORD_FAQ ,
152
+ PASSWORD_DISABLE
153
+ ) ,
162
154
hide : false
163
155
} ) ;
164
156
}
@@ -326,6 +318,32 @@ $(function () {
326
318
return false ;
327
319
}
328
320
} ;
321
+
322
+ self . getAdditionalHealthCheckHandlers = function ( ) {
323
+ return {
324
+ pi_undervoltage : ( result , context ) => {
325
+ return {
326
+ title : UNDERVOLTAGE_TITLE ,
327
+ html : generateHtml ( UNDERVOLTAGE_WARNING , UNDERVOLTAGE_FAQ ) ,
328
+ result : result
329
+ } ;
330
+ } ,
331
+ pi_unsupported : ( result , context ) => {
332
+ return {
333
+ title : ZERO_TITLE ,
334
+ html : generateHtml ( ZERO_WARNING , ZERO_FAQ ) ,
335
+ result : result
336
+ } ;
337
+ } ,
338
+ pi_default_password : ( result , context ) => {
339
+ return {
340
+ title : PASSWORD_TITLE ,
341
+ html : generateHtml ( PASSWORD_WARNING , PASSWORD_FAQ ) ,
342
+ result : result
343
+ } ;
344
+ }
345
+ } ;
346
+ } ;
329
347
}
330
348
331
349
OCTOPRINT_VIEWMODELS . push ( {
0 commit comments