Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
accedc82
Commit
accedc82
authored
Nov 17, 2016
by
Franco Fichtner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
firmware: merge packages lists for single sorted list
parent
6c87cd42
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
24 deletions
+60
-24
FirmwareController.php
.../app/controllers/OPNsense/Core/Api/FirmwareController.php
+54
-8
firmware.volt
src/opnsense/mvc/app/views/OPNsense/Core/firmware.volt
+6
-16
No files found.
src/opnsense/mvc/app/controllers/OPNsense/Core/Api/FirmwareController.php
View file @
accedc82
...
...
@@ -92,20 +92,66 @@ class FirmwareController extends ApiControllerBase
);
}
}
}
else
{
$response
=
array
(
'status'
=>
'unknown'
,
'status_msg'
=>
gettext
(
'Current status is unknown.'
));
}
/* XXX array isn't flat, need to refactor this */
if
(
isset
(
$response
[
'upgrade_packages'
]))
{
$sorted
=
array
();
foreach
(
$response
[
'upgrade_packages'
]
as
$key
=>
$value
)
{
$sorted
[
$value
[
'name'
]]
=
$value
;
/*
* new_packages: array with { name: <package_name>, version: <package_version> }
* reinstall_packages: array with { name: <package_name>, version: <package_version> }
* delete_packages: array with { name: <package_name>, version: <package_version> }
* upgrade_packages: array with { name: <package_name>, current_version: <current_version>, new_version: <new_version> }
*/
foreach
(
array
(
'new_packages'
,
'reinstall_packages'
,
'delete_packages'
,
'upgrade_packages'
)
as
$pkg_type
)
{
if
(
isset
(
$response
[
$pkg_type
]))
{
foreach
(
$response
[
$pkg_type
]
as
$value
)
{
switch
(
$pkg_type
)
{
case
'new_packages'
:
$sorted
[
$value
[
'name'
]]
=
array
(
'new'
=>
$value
[
'version'
],
'reason'
=>
gettext
(
'new'
),
'name'
=>
$value
[
'name'
],
'old'
=>
gettext
(
'N/A'
),
);
break
;
case
'reinstall_packages'
:
$sorted
[
$value
[
'name'
]]
=
array
(
'reason'
=>
gettext
(
'reinstall'
),
'new'
=>
$value
[
'version'
],
'old'
=>
$value
[
'version'
],
'name'
=>
$value
[
'name'
],
);
break
;
case
'delete_packages'
:
$sorted
[
$value
[
'name'
]]
=
array
(
'reason'
=>
gettext
(
'delete'
),
'old'
=>
$value
[
'version'
],
'name'
=>
$value
[
'name'
],
'new'
=>
gettext
(
'N/A'
),
);
break
;
case
'upgrade_packages'
:
$sorted
[
$value
[
'name'
]]
=
array
(
'reason'
=>
gettext
(
'update'
),
'old'
=>
$value
[
'current_version'
],
'new'
=>
$value
[
'new_version'
],
'name'
=>
$value
[
'name'
],
);
break
;
default
:
/* undefined */
break
;
}
}
}
}
uksort
(
$sorted
,
function
(
$a
,
$b
)
{
return
strnatcmp
(
$a
,
$b
);
});
$response
[
'upgrade_packages'
]
=
$sorted
;
$response
[
'all_packages'
]
=
$sorted
;
}
else
{
$response
=
array
(
'status'
=>
'unknown'
,
'status_msg'
=>
gettext
(
'Firmware status check was aborted internally. Please try again.'
));
}
return
$response
;
...
...
src/opnsense/mvc/app/views/OPNsense/Core/firmware.volt
View file @
accedc82
...
...
@@ -63,22 +63,12 @@ POSSIBILITY OF SUCH DAMAGE.
// show upgrade list
$('#updatetab > a').tab('show');
$("#updatelist").html("<tr><th>{{ lang._('Package Name') }}</th>" +
"<th>{{ lang._('Current Version') }}</th><th>{{ lang._('New Version') }}</th></tr>");
$.each(['new_packages', 'upgrade_packages', 'reinstall_packages'], function(type_idx,type_name){
if ( data[type_name] != undefined ) {
$.each(data[type_name],function(index,row){
if (type_name == "new_packages") {
$('#updatelist').append('<tr><td>'+row['name']+'</td>' +
"<td><strong>{{ lang._('NEW') }}</strong></td><td>"+row['version']+"</td></tr>");
} else if (type_name == "reinstall_packages") {
$('#updatelist').append('<tr><td>'+row['name']+'</td>' +
"<td>"+row['version']+"</td><td><strong>{{ lang._('REINSTALL') }}</strong></td></tr>");
} else {
$('#updatelist').append('<tr><td>'+row['name']+'</td>' +
'<td>'+row['current_version']+'</td><td>'+row['new_version']+'</td></tr>');
}
});
}
"<th>{{ lang._('Current Version') }}</th><th>{{ lang._('New Version') }}</th>" +
"<th>{{ lang._('Required Action') }}</th></tr>");
$.each(data['all_packages'], function (index, row) {
$('#updatelist').append('<tr><td>'+row['name']+'</td>' +
'<td>'+row['old']+'</td><td>'+row['new']+'</td><td>' +
row['reason'] + '</td></tr>');
});
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment