add reset filers button, fix filter saves, download repo only if different
This commit is contained in:
parent
92b049b7a8
commit
39a9ccdea2
|
@ -45,7 +45,7 @@ get_content_from_github($pkg_desc, $desc_file);
|
|||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
<button title="reset filters" type="button" class="reset">Reset</button>
|
||||
: <input id="btnApply" type="button" value="Apply"><input type="button" value="Done" onClick="done()">
|
||||
</form>
|
||||
|
||||
|
|
|
@ -68,19 +68,22 @@ function get_content_from_github($repo, $file){
|
|||
curl_setopt($ch, CURLOPT_URL, $repo);
|
||||
$content = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
if (!empty($content))
|
||||
file_put_contents($file, $content);
|
||||
if ((!empty($content)) && ($content != file_get_contents($file)))
|
||||
file_put_contents($file, $content);
|
||||
}
|
||||
|
||||
// Compare the github sha value of a file
|
||||
function file_check_sha($file, $sha){
|
||||
// Compare the github sha1 value of a file
|
||||
function file_check_sha1($file, $sha1){
|
||||
$size = filesize($file);
|
||||
$handle = fopen($file, "rb");
|
||||
$contents = fread($handle, $size);
|
||||
fclose($handle);
|
||||
|
||||
// create a sha1 like github does
|
||||
$str = "blob ".$size."\0".$contents;
|
||||
$sha_file = sha1($str);
|
||||
$return = ($sha_file == $sha) ? true : false;
|
||||
$sha1_file = sha1($str);
|
||||
|
||||
$return = ($sha1_file == $sha1) ? true : false;
|
||||
return $return;
|
||||
}
|
||||
?>
|
||||
?>
|
|
@ -1,20 +1,4 @@
|
|||
$(function(){
|
||||
//tablesorter options
|
||||
$('#tblPackages').tablesorter({
|
||||
sortList: [[0,1]],
|
||||
widgets: ['saveSort', 'filter', 'stickyHeaders'],
|
||||
widgetOptions: {
|
||||
stickyHeaders_filteredToTop: true,
|
||||
filter_hideEmpty : true,
|
||||
filter_saveFilters : true,
|
||||
filter_functions: {
|
||||
'.filter-version' : true,
|
||||
'.filter-downloaded' : true,
|
||||
'.filter-installed' : true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// "uninstall package" switch and cookie
|
||||
$('#uninstallpkg')
|
||||
.switchButton({
|
||||
|
@ -114,26 +98,43 @@ function packageQuery() {
|
|||
"<input class='pkgvalue' type='hidden' id='"+data[i].pkgname+"_value' name='"+
|
||||
data[i].pkgnver+"' value='"+data[i].config+"'></td>"+
|
||||
"</tr>");
|
||||
|
||||
$('#'+data[i].pkgname)
|
||||
.switchButton({
|
||||
labels_placement: 'right',
|
||||
on_label: 'On',
|
||||
off_label: 'Off',
|
||||
checked: data[i].config == "yes"
|
||||
.switchButton({
|
||||
labels_placement: 'right',
|
||||
on_label: 'On',
|
||||
off_label: 'Off',
|
||||
checked: data[i].config == "yes"
|
||||
})
|
||||
.change(function() {
|
||||
var par = $(this).parent().parent();
|
||||
if(this.checked)
|
||||
par.find('.pkgvalue').val("yes");
|
||||
else
|
||||
par.find('.pkgvalue').val("no");
|
||||
$("#btnApply").prop("disabled", false);
|
||||
checkDepends();
|
||||
.change(function() {
|
||||
var par = $(this).parent().parent();
|
||||
if(this.checked)
|
||||
par.find('.pkgvalue').val("yes");
|
||||
else
|
||||
par.find('.pkgvalue').val("no");
|
||||
$("#btnApply").prop("disabled", false);
|
||||
checkDepends();
|
||||
});
|
||||
}
|
||||
},
|
||||
complete : function () {
|
||||
$("#tblPackages").trigger("update");
|
||||
|
||||
//tablesorter options
|
||||
$('#tblPackages').tablesorter({
|
||||
sortList: [[0,1]],
|
||||
widgets: ['saveSort', 'filter', 'stickyHeaders'],
|
||||
widgetOptions: {
|
||||
stickyHeaders_filteredToTop: true,
|
||||
filter_hideEmpty : true,
|
||||
filter_liveSearch : true,
|
||||
filter_saveFilters : true,
|
||||
filter_reset : 'button.reset',
|
||||
filter_functions: {
|
||||
'.filter-version' : true,
|
||||
'.filter-downloaded' : true,
|
||||
'.filter-installed' : true
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
error: function () {
|
||||
}
|
||||
|
@ -149,4 +150,4 @@ function checkDepends() {
|
|||
$('#python').switchButton({checked: true});
|
||||
$('#python','.pkgvalue').val('yes');
|
||||
}
|
||||
};
|
||||
};
|
File diff suppressed because it is too large
Load Diff
|
@ -95,13 +95,13 @@ foreach($pkg_cfg as $pkg_name => $pkg_pref) { //get preferences for each package
|
|||
$pkg_gitname = array_values($pkg_matches)[0]["name"];
|
||||
$pkg_file = $pkg_path.$pkg_gitname;
|
||||
$pkg_url = array_values($pkg_matches)[0]["download_url"];
|
||||
$pkg_sha = array_values($pkg_matches)[0]["sha"];
|
||||
$pkg_sha1 = array_values($pkg_matches)[0]["sha"];
|
||||
|
||||
logger("Downloading $pkg_gitname package...", $argq);
|
||||
|
||||
get_file_from_url($pkg_file, $pkg_url);
|
||||
|
||||
if(file_check_sha($pkg_file, $pkg_sha))
|
||||
if(file_check_sha1($pkg_file, $pkg_sha1))
|
||||
logger("$pkg_gitname package downloaded sucessfully!", $argq);
|
||||
else
|
||||
logger("$pkg_gitname package download failed!", $argq);
|
||||
|
|
Loading…
Reference in New Issue
Block a user