on xenial help sign in
Give page unique ID, lint Javascript
9d73ee3Dalton Durst
qml/Wizard/Pages/78-firmware-update.qml+67−61
@@ -25,7 +25,7 @@ import Wizard 0.1
25import ".." as LocalComponents
25import ".." as LocalComponents
26
26
27LocalComponents.Page {
27LocalComponents.Page {
28− id: systemUpdatePage
28+ id: firmwareUpdatePage
29 objectName: "firmwareUpdatePage"
29 objectName: "firmwareUpdatePage"
30
30
31 title: i18n.tr("Firmware Update")
31 title: i18n.tr("Firmware Update")
@@ -40,17 +40,19 @@ LocalComponents.Page {
40 property var partitions: ""
40 property var partitions: ""
41
41
42 function check() {
42 function check() {
43− if (!SystemImage.supportsFirmwareUpdate())
43+ if (!SystemImage.supportsFirmwareUpdate()) {
44− return;
44+ return;
45+ }
45− systemUpdatePage.isChecking = true
46+ firmwareUpdatePage.isChecking = true;
46− SystemImage.checkForFirmwareUpdate()
47+ SystemImage.checkForFirmwareUpdate();
47 }
48 }
48
49
49 function flash() {
50 function flash() {
50− if (!SystemImage.supportsFirmwareUpdate())
51+ if (!SystemImage.supportsFirmwareUpdate()) {
51− return pageStack.next();
52+ return pageStack.next();
53+ }
52− systemUpdatePage.isUpdating = true
54+ firmwareUpdatePage.isUpdating = true;
53− SystemImage.updateFirmware()
55+ SystemImage.updateFirmware();
54 }
56 }
55
57
56 Connections {
58 Connections {
@@ -59,29 +61,30 @@ LocalComponents.Page {
59 var updateobj = JSON.parse(updateObj);
61 var updateobj = JSON.parse(updateObj);
60 if (Array.isArray(updateobj) && updateobj.length > 0) {
62 if (Array.isArray(updateobj) && updateobj.length > 0) {
61 for (var u in updateobj) {
63 for (var u in updateobj) {
62− console.log(u)
64+ console.log(u);
63− if (systemUpdatePage.partitions === "")
65+ if (firmwareUpdatePage.partitions === "") {
64− systemUpdatePage.partitions += updateobj[u].file
66+ firmwareUpdatePage.partitions += updateobj[u].file;
65− else
67+ } else {
66− systemUpdatePage.partitions += ", " + updateobj[u].file
68+ firmwareUpdatePage.partitions += ", " + updateobj[u].file;
69+ }
67 }
70 }
68− systemUpdatePage.hasUpdate = true;
71+ firmwareUpdatePage.hasUpdate = true;
69 }
72 }
70 console.log(updateobj);
73 console.log(updateobj);
71− systemUpdatePage.isChecking = false;
74+ firmwareUpdatePage.isChecking = false;
72 }
75 }
73 onUpdateFirmwareDone: {
76 onUpdateFirmwareDone: {
74 var updateobj = JSON.parse(updateObj);
77 var updateobj = JSON.parse(updateObj);
75 if (Array.isArray(updateobj) && updateobj.length === 0) {
78 if (Array.isArray(updateobj) && updateobj.length === 0) {
76 // This means success!
79 // This means success!
77− systemUpdatePage.hasUpdate = false;
80+ firmwareUpdatePage.hasUpdate = false;
78− systemUpdatePage.partitions = "";
81+ firmwareUpdatePage.partitions = "";
79 System.skipUntilFinishedPage();
82 System.skipUntilFinishedPage();
80 SystemImage.reboot();
83 SystemImage.reboot();
81 return;
84 return;
82 }
85 }
83 console.log(updateobj);
86 console.log(updateobj);
84− systemUpdatePage.isUpdating = false;
87+ firmwareUpdatePage.isUpdating = false;
85 }
88 }
86 }
89 }
87
90
@@ -89,9 +92,9 @@ LocalComponents.Page {
89 id: column
92 id: column
90 anchors {
93 anchors {
91 fill: content
94 fill: content
92− leftMargin: systemUpdatePage.leftMargin
95+ leftMargin: firmwareUpdatePage.leftMargin
93− rightMargin: systemUpdatePage.rightMargin
96+ rightMargin: firmwareUpdatePage.rightMargin
94− topMargin: systemUpdatePage.customMargin
97+ topMargin: firmwareUpdatePage.customMargin
95 }
98 }
96 spacing: units.gu(3)
99 spacing: units.gu(3)
97 opacity: spinner.visible ? 0.5 : 1
100 opacity: spinner.visible ? 0.5 : 1
@@ -100,12 +103,12 @@ LocalComponents.Page {
100 }
103 }
101
104
102 Label {
105 Label {
103− visible: !systemUpdatePage.isChecking
106+ visible: !firmwareUpdatePage.isChecking
104 anchors.horizontalCenter: parent.horizontalCenter
107 anchors.horizontalCenter: parent.horizontalCenter
105 font.weight: Font.Light
108 font.weight: Font.Light
106 wrapMode: Text.Wrap
109 wrapMode: Text.Wrap
107 textSize: Label.Medium
110 textSize: Label.Medium
108− text: systemUpdatePage.hasUpdate ? i18n.tr("There is a firmware update available!")
111+ text: firmwareUpdatePage.hasUpdate ? i18n.tr("There is a firmware update available!")
109 : online ? i18n.tr("Firmware is up to date!")
112 : online ? i18n.tr("Firmware is up to date!")
110 : i18n.tr("Please connect to the Internet to check for updates.")
113 : i18n.tr("Please connect to the Internet to check for updates.")
111
114
@@ -137,7 +140,7 @@ LocalComponents.Page {
137 font.weight: Font.Light
140 font.weight: Font.Light
138 wrapMode: Text.WordWrap
141 wrapMode: Text.WordWrap
139 fontSize: "small"
142 fontSize: "small"
140− text: systemUpdatePage.partitions
143+ text: firmwareUpdatePage.partitions
141 }
144 }
142
145
143 Label {
146 Label {
@@ -171,7 +174,7 @@ LocalComponents.Page {
171 anchors.fill: parent
174 anchors.fill: parent
172 anchors.horizontalCenter: parent.horizontalCenter
175 anchors.horizontalCenter: parent.horizontalCenter
173 onClicked: {
176 onClicked: {
174− systemUpdatePage.flash()
177+ firmwareUpdatePage.flash()
175 }
178 }
176 }
179 }
177
180
@@ -188,54 +191,57 @@ LocalComponents.Page {
188
191
189 Column {
192 Column {
190 id: spinner
193 id: spinner
191− anchors.centerIn: systemUpdatePage
194+ anchors.centerIn: firmwareUpdatePage
192− visible: systemUpdatePage.isChecking || systemUpdatePage.isUpdating
195+ visible: firmwareUpdatePage.isChecking || firmwareUpdatePage.isUpdating
193 spacing: units.gu(1)
196 spacing: units.gu(1)
194
197
195− ActivityIndicator {
198+ ActivityIndicator {
196− anchors.horizontalCenter: parent.horizontalCenter
199+ anchors.horizontalCenter: parent.horizontalCenter
197− running: parent.visible
200+ running: parent.visible
198− }
201+ }
199−
202+
200− Label {
203+ Label {
201− wrapMode: Text.Wrap
204+ wrapMode: Text.Wrap
202− width: systemUpdatePage.width - units.gu(3)
205+ width: firmwareUpdatePage.width - units.gu(3)
203− fontSize: "small"
206+ fontSize: "small"
204− text: i18n.tr("Downloading and Flashing firmware updates, this could take a few minutes...")
207+ text: i18n.tr("Downloading and Flashing firmware updates, this could take a few minutes...")
205− visible: systemUpdatePage.isUpdating
208+ visible: firmwareUpdatePage.isUpdating
206− }
209+ }
207−
210+
208− Label {
211+ Label {
209− wrapMode: Text.Wrap
212+ wrapMode: Text.Wrap
210− fontSize: "small"
213+ fontSize: "small"
211− text: i18n.tr("Checking for firmware update")
214+ text: i18n.tr("Checking for firmware update")
212− visible: systemUpdatePage.isChecking
215+ visible: firmwareUpdatePage.isChecking
213− }
216+ }
214−
217+
215− Component.onCompleted: {
218+ Component.onCompleted: {
216− if (online)
219+ if (online) {
217− systemUpdatePage.check();
220+ firmwareUpdatePage.check();
221+ }
218− else
222+ else {
219− systemUpdatePage.isChecking = false;
223+ firmwareUpdatePage.isChecking = false;
224+ }
220− }
225+ }
221 }
226 }
222
227
223 Connections {
228 Connections {
224 target: NetworkingStatus
229 target: NetworkingStatus
225 onOnlineChanged: {
230 onOnlineChanged: {
226− if (online)
231+ if (online) {
227− systemUpdatePage.check();
232+ firmwareUpdatePage.check();
228− else
233+ } else {
229− systemUpdatePage.isChecking = false;
234+ firmwareUpdatePage.isChecking = false;
235+ }
230 }
236 }
231 }
237 }
232
238
233 Component {
239 Component {
234 id: forwardButton
240 id: forwardButton
235 LocalComponents.StackButton {
241 LocalComponents.StackButton {
236− text: !systemUpdatePage.hasUpdate && !systemUpdatePage.spinner.visible
242+ text: !firmwareUpdatePage.hasUpdate && !firmwareUpdatePage.spinner.visible
237− ? i18n.tr("Next") : i18n.tr("Skip")
243+ ? i18n.tr("Next") : i18n.tr("Skip");
238− onClicked: pageStack.next()
244+ onClicked: pageStack.next();
239 }
245 }
240 }
246 }
241}
247}