|
13 | 13 | /** |
14 | 14 | * Returns the branch of a given version. This helps to offer upgrades |
15 | 15 | * for point releases (aka within the branch). |
16 | | -@@ -694,7 +700,7 @@ |
| 16 | +@@ -694,7 +700,8 @@ |
17 | 17 | const data = { |
18 | 18 | system_board: promises[1], |
19 | 19 | advanced_mode: uci.get_first('attendedsysupgrade', 'client', 'advanced_mode') || 0, |
20 | 20 | - url: uci.get_first('attendedsysupgrade', 'server', 'url').replace(/\/+$/, ''), |
21 | 21 | + url: (uci.get_first('attendedsysupgrade', 'server', 'url') || '').replace(/\/+$/, ''), |
| 22 | ++ github_repo: uci.get_first('attendedsysupgrade', 'server', 'github_repo') || 'XXXXXX/YYYYYY', |
22 | 23 | branch: get_branch(promises[1].release.version), |
23 | 24 | revision: promises[1].release.revision, |
24 | 25 | efi: promises[2], |
25 | | -@@ -745,13 +751,218 @@ |
| 26 | +@@ -745,13 +752,218 @@ |
26 | 27 | E( |
27 | 28 | 'button', |
28 | 29 | { |
|
38 | 39 | + 'button', |
39 | 40 | + { |
40 | 41 | + class: 'btn cbi-button cbi-button-positive important', |
41 | | -+ click: ui.createHandlerFn(this, this.handleGithubFirmware, firmware), |
| 42 | ++ click: ui.createHandlerFn(this, this.handleGithubFirmware, data, firmware), |
42 | 43 | + }, |
43 | 44 | + _('Check for GitHub firmware') |
44 | | -+ ), |
45 | | -+ ]); |
46 | | -+ }, |
| 45 | + ), |
| 46 | + ]); |
| 47 | + }, |
47 | 48 | + |
48 | | -+ handleGithubFirmware: function(firmware) { |
| 49 | ++ handleGithubFirmware: function(data, firmware) { |
| 50 | ++ const githubRepo = data.github_repo; |
49 | 51 | + ui.showModal(_('Fetching GitHub firmware info...'), [ |
50 | 52 | + E( |
51 | 53 | + 'p', |
|
55 | 57 | + ]); |
56 | 58 | + |
57 | 59 | + // Call the CGI script to get the list of available firmware releases |
58 | | -+ fetch('/cgi-bin/github_check') |
| 60 | ++ fetch('/cgi-bin/github_check?repo=' + encodeURIComponent(githubRepo)) |
59 | 61 | + .then(response => response.json()) |
60 | 62 | + .then(data => { |
61 | 63 | + if (data.error) { |
|
95 | 97 | + |
96 | 98 | + // Create element for the URL |
97 | 99 | + const urlElement = E('td', { class: 'td left' }); |
98 | | -+ |
99 | 100 | + // Function to update the URL based on selected release |
100 | 101 | + const updateDetails = function() { |
101 | 102 | + const selectedIndex = releaseSelect.value; |
|
104 | 105 | + if (selectedRelease) { |
105 | 106 | + // Clear previous link and create a new one |
106 | 107 | + urlElement.innerHTML = ''; |
107 | | -+ urlElement.appendChild(E('a', { href: 'https://github.com/XXXXXX/YYYYYY/releases/tag/' + selectedRelease.tag, target: '_blank' }, _('View on GitHub'))); |
| 108 | ++ urlElement.appendChild(E('a', { href: 'https://github.com/' + githubRepo + '/releases/tag/' + selectedRelease.tag, target: '_blank' }, _('View on GitHub'))); |
108 | 109 | + } |
109 | 110 | + }; |
110 | 111 | + |
|
146 | 147 | + const selectedRelease = releases[selectedIndex]; |
147 | 148 | + |
148 | 149 | + if (selectedRelease && selectedRelease.tag) { |
149 | | -+ this.handleGithubInstall(selectedRelease.tag, keep.checked); |
| 150 | ++ this.handleGithubInstall(selectedRelease.tag, keep.checked, githubRepo); |
150 | 151 | + } else { |
151 | 152 | + ui.showModal(_('Error'), [ |
152 | 153 | + E('p', _('Invalid release selected')), |
|
177 | 178 | + }); |
178 | 179 | + }, |
179 | 180 | + |
180 | | -+ handleGithubInstall: function(tag, keep) { |
| 181 | ++ handleGithubInstall: function(tag, keep, githubRepo) { |
181 | 182 | + ui.showModal(_('Downloading from GitHub...'), [ |
182 | 183 | + E( |
183 | 184 | + 'p', |
184 | 185 | + { class: 'spinning' }, |
185 | 186 | + _('Downloading firmware from GitHub to device') |
186 | | - ), |
187 | | - ]); |
| 187 | ++ ), |
| 188 | ++ ]); |
188 | 189 | + |
189 | 190 | + // Call the CGI script to download the firmware to /tmp/firmware.bin |
190 | 191 | + // Pass the selected tag as a parameter to the github_fetch script |
191 | | -+ fetch(`/cgi-bin/github_fetch?tag=${encodeURIComponent(tag)}`) |
| 192 | ++ fetch(`/cgi-bin/github_fetch?tag=${encodeURIComponent(tag)}&repo=${encodeURIComponent(githubRepo)}`) |
192 | 193 | + .then(response => response.json()) |
193 | 194 | + .then(data => { |
194 | 195 | + if (data.error) { |
|
238 | 239 | + ]), |
239 | 240 | + ]); |
240 | 241 | + }); |
241 | | - }, |
| 242 | ++ }, |
242 | 243 | + |
243 | 244 | handleSaveApply: null, |
244 | 245 | handleSave: null, |
245 | 246 | handleReset: null, |
| 247 | +--- a/feeds/luci/applications/luci-app-attendedsysupgrade/htdocs/luci-static/resources/view/attendedsysupgrade/configuration.js |
| 248 | ++++ b/feeds/luci/applications/luci-app-attendedsysupgrade/htdocs/luci-static/resources/view/attendedsysupgrade/configuration.js |
| 249 | +@@ -32,6 +32,14 @@ |
| 250 | + ) |
| 251 | + ); |
| 252 | + |
| 253 | ++ o = s.option( |
| 254 | ++ form.Value, |
| 255 | ++ 'github_repo', |
| 256 | ++ _('GitHub Repository'), |
| 257 | ++ _('GitHub repository for firmware releases (owner/name)') |
| 258 | ++ ); |
| 259 | ++ o.placeholder = 'XXXXXX/YYYYYY'; |
| 260 | ++ |
| 261 | + s = m.section(form.TypedSection, 'client', _('Client')); |
| 262 | + s.anonymous = true; |
| 263 | + |
| 264 | +--- a/feeds/packages/utils/attendedsysupgrade-common/files/attendedsysupgrade.defaults |
| 265 | ++++ b/feeds/packages/utils/attendedsysupgrade-common/files/attendedsysupgrade.defaults |
| 266 | +@@ -7,6 +7,7 @@ |
| 267 | + uci -q batch <<EOF |
| 268 | + set attendedsysupgrade.server=server |
| 269 | + set attendedsysupgrade.server.url='https://sysupgrade.openwrt.org' |
| 270 | ++set attendedsysupgrade.server.github_repo='XXXXXX/YYYYYY' |
| 271 | + |
| 272 | + set attendedsysupgrade.client=client |
| 273 | + set attendedsysupgrade.client.upgrade_packages='1' |
0 commit comments