mirror of
https://github.com/SickGear/SickGear.git
synced 2025-01-22 01:23:43 +00:00
Merge pull request #251 from adam111316/feature/ChangeFasterConfig
Change general config's branches and pull request list generation for fa...
This commit is contained in:
commit
43ca775cdb
5 changed files with 121 additions and 38 deletions
|
@ -24,12 +24,14 @@
|
||||||
* Change browser, bs4 parser and classes code to PEP8 standards
|
* Change browser, bs4 parser and classes code to PEP8 standards
|
||||||
* Change common and config code to PEP8 standards
|
* Change common and config code to PEP8 standards
|
||||||
* Change database code to PEP8 standards
|
* Change database code to PEP8 standards
|
||||||
|
* Change general config's branches and pull request list generation for faster page loading
|
||||||
|
|
||||||
[develop changelog]
|
[develop changelog]
|
||||||
* Fix traceback error when using the menu item Manage/Update Kodi
|
* Fix traceback error when using the menu item Manage/Update Kodi
|
||||||
* Change BET network logo filename to lower case
|
* Change BET network logo filename to lower case
|
||||||
* Change redirect from home to showlistView on changing Layout on showlistView
|
* Change redirect from home to showlistView on changing Layout on showlistView
|
||||||
|
|
||||||
|
|
||||||
### 0.7.0 (2015-02-23 11:02:00 UTC)
|
### 0.7.0 (2015-02-23 11:02:00 UTC)
|
||||||
|
|
||||||
* Fix slow database operations (port from midgetspy/sickbeard)
|
* Fix slow database operations (port from midgetspy/sickbeard)
|
||||||
|
|
|
@ -487,33 +487,28 @@
|
||||||
<span class="component-title">Branch version:</span>
|
<span class="component-title">Branch version:</span>
|
||||||
<span class="component-desc">
|
<span class="component-desc">
|
||||||
<select id="branchVersion" class="form-control form-control-inline input-sm pull-left max300">
|
<select id="branchVersion" class="form-control form-control-inline input-sm pull-left max300">
|
||||||
#for $cur_branch in $sickbeard.versionCheckScheduler.action.list_remote_branches():
|
<option>Loading list from github</option>
|
||||||
<option value="$cur_branch" #if $cur_branch == $sickbeard.BRANCH then 'selected="selected"' else ''#>$cur_branch</option>
|
|
||||||
#end for
|
|
||||||
</select>
|
</select>
|
||||||
<input class="btn btn-inline" style="margin-left: 6px;" type="button" id="branchCheckout" value="Checkout Branch">
|
<input class="btn btn-inline" style="margin-left: 6px;" type="button" id="branchCheckout" value="Checkout Branch" disabled="disabled">
|
||||||
<div class="clear-left"><p>select branch to use (restart required)</p></div>
|
<div class="clear-left"><p>select branch to use (restart required)</p></div>
|
||||||
</span>
|
</span>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
#set pulls = sickbeard.versionCheckScheduler.action.list_remote_pulls()
|
#if $sickbeard.BRANCH != 'master':
|
||||||
#if len(pulls) > 0 and $sickbeard.BRANCH != 'master':
|
|
||||||
<div class="field-pair">
|
<div class="field-pair">
|
||||||
<label>
|
<label>
|
||||||
<span class="component-title">Pull request:</span>
|
<span class="component-title">Pull request:</span>
|
||||||
<span class="component-desc">
|
<span class="component-desc">
|
||||||
<select id="pullRequestVersion" class="form-control form-control-inline input-sm pull-left max300">
|
<select id="pullRequestVersion" class="form-control form-control-inline input-sm pull-left max300">
|
||||||
#for $cur_branch in $pulls:
|
<option>Loading list from github</option>
|
||||||
<option value="$cur_branch.fetch_name()" #if $cur_branch == $sickbeard.BRANCH then 'selected="selected"' else ''#>$cur_branch</option>
|
|
||||||
#end for
|
|
||||||
</select>
|
</select>
|
||||||
<input class="btn btn-inline" style="margin-left: 6px;" type="button" id="pullRequestCheckout" value="Checkout Pull Request">
|
<input class="btn btn-inline" style="margin-left: 6px;" type="button" id="pullRequestCheckout" value="Checkout Pull Request" disabled="disabled">
|
||||||
<div class="clear-left"><p>select pull request to test (restart required)</p></div>
|
<div class="clear-left"><p>select pull request to test (restart required)</p></div>
|
||||||
</span>
|
</span>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
#end if
|
#end if
|
||||||
|
|
||||||
<div class="field-pair">
|
<div class="field-pair">
|
||||||
<label for="git_remote">
|
<label for="git_remote">
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
$(document).ready(function(){
|
$(document).ready(function () {
|
||||||
var enabler = $('.enabler'),
|
var enabler = $('.enabler'),
|
||||||
viewIf = $('.viewIf');
|
viewIf = $('.viewIf');
|
||||||
|
|
||||||
enabler.each(function(){
|
enabler.each(function () {
|
||||||
if (!$(this).prop('checked'))
|
if (!$(this).prop('checked'))
|
||||||
$('#content_' + $(this).attr('id')).hide();
|
$('#content_' + $(this).attr('id')).hide();
|
||||||
});
|
});
|
||||||
|
|
||||||
enabler.click(function(){
|
enabler.click(function () {
|
||||||
var content_id = $('#content_' + $(this).attr('id'));
|
var content_id = $('#content_' + $(this).attr('id'));
|
||||||
if ($(this).prop('checked'))
|
if ($(this).prop('checked'))
|
||||||
content_id.fadeIn('fast', 'linear');
|
content_id.fadeIn('fast', 'linear');
|
||||||
|
@ -15,11 +15,11 @@ $(document).ready(function(){
|
||||||
content_id.fadeOut('fast', 'linear');
|
content_id.fadeOut('fast', 'linear');
|
||||||
});
|
});
|
||||||
|
|
||||||
viewIf.each(function(){
|
viewIf.each(function () {
|
||||||
$(($(this).prop('checked') ? '.hide_if_' : '.show_if_') + $(this).attr('id')).hide();
|
$(($(this).prop('checked') ? '.hide_if_' : '.show_if_') + $(this).attr('id')).hide();
|
||||||
});
|
});
|
||||||
|
|
||||||
viewIf.click(function(){
|
viewIf.click(function () {
|
||||||
var if_id = '_if_' + $(this).attr('id');
|
var if_id = '_if_' + $(this).attr('id');
|
||||||
if ($(this).prop('checked')) {
|
if ($(this).prop('checked')) {
|
||||||
$('.hide' + if_id).fadeOut('fast', 'linear');
|
$('.hide' + if_id).fadeOut('fast', 'linear');
|
||||||
|
@ -30,14 +30,14 @@ $(document).ready(function(){
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var ui_update_trim_zero = (function() {
|
var ui_update_trim_zero = (function () {
|
||||||
var secs = ('00' + new Date().getSeconds().toString()).slice(-2),
|
var secs = ('00' + new Date().getSeconds().toString()).slice(-2),
|
||||||
elSecs = $('#trim_info_seconds'),
|
elSecs = $('#trim_info_seconds'),
|
||||||
elTrimZero = $('#trim_zero');
|
elTrimZero = $('#trim_zero');
|
||||||
elTrimZero.each(function() {
|
elTrimZero.each(function () {
|
||||||
var checked = $(this).prop('checked') && $('#fuzzy_dating').prop('checked');
|
var checked = $(this).prop('checked') && $('#fuzzy_dating').prop('checked');
|
||||||
|
|
||||||
$('#time_presets').find('option').each(function() {
|
$('#time_presets').find('option').each(function () {
|
||||||
var text = ($(this).text());
|
var text = ($(this).text());
|
||||||
$(this).text(checked
|
$(this).text(checked
|
||||||
? text.replace(/(\b\d+:\d\d):\d+/mg, '$1')
|
? text.replace(/(\b\d+:\d\d):\d+/mg, '$1')
|
||||||
|
@ -54,13 +54,13 @@ $(document).ready(function(){
|
||||||
elSecs.fadeIn('fast', 'linear');
|
elSecs.fadeIn('fast', 'linear');
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#trim_zero, #fuzzy_dating').click(function() {
|
$('#trim_zero, #fuzzy_dating').click(function () {
|
||||||
ui_update_trim_zero();
|
ui_update_trim_zero();
|
||||||
});
|
});
|
||||||
|
|
||||||
ui_update_trim_zero();
|
ui_update_trim_zero();
|
||||||
|
|
||||||
$('.datePresets').click(function(){
|
$('.datePresets').click(function () {
|
||||||
var elDatePresets = $('#date_presets'),
|
var elDatePresets = $('#date_presets'),
|
||||||
defaultPreset = elDatePresets.val();
|
defaultPreset = elDatePresets.val();
|
||||||
if ($(this).prop('checked') && '%x' == defaultPreset) {
|
if ($(this).prop('checked') && '%x' == defaultPreset) {
|
||||||
|
@ -86,49 +86,113 @@ $(document).ready(function(){
|
||||||
|
|
||||||
// bind 'myForm' and provide a simple callback function
|
// bind 'myForm' and provide a simple callback function
|
||||||
$('#configForm').ajaxForm({
|
$('#configForm').ajaxForm({
|
||||||
beforeSubmit: function(){
|
beforeSubmit: function () {
|
||||||
$('.config_submitter').each(function(){
|
$('.config_submitter').each(function () {
|
||||||
$(this).attr('disabled', 'disabled');
|
$(this).attr('disabled', 'disabled');
|
||||||
$(this).after('<span><img src="' + sbRoot + '/images/loading16' + themeSpinner + '.gif"> Saving...</span>');
|
$(this).after('<span><img src="' + sbRoot + '/images/loading16' + themeSpinner + '.gif"> Saving...</span>');
|
||||||
$(this).hide();
|
$(this).hide();
|
||||||
});
|
});
|
||||||
$('.show_update_hour_value').text($('#show_update_hour').val())
|
$('.show_update_hour_value').text($('#show_update_hour').val())
|
||||||
},
|
},
|
||||||
success: function(response){
|
success: function (response) {
|
||||||
setTimeout(function(){config_success(response)}, 2000);
|
setTimeout(function () {config_success(response)}, 2000);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#api_key').click(function(){ $('#api_key').select() });
|
$('#api_key').click(function () {$('#api_key').select()});
|
||||||
$('#generate_new_apikey').click(function(){
|
$('#generate_new_apikey').click(function () {
|
||||||
$.get(sbRoot + '/config/general/generateKey',
|
$.get(sbRoot + '/config/general/generateKey',
|
||||||
function(data){
|
function (data) {
|
||||||
if (data.error != undefined) {
|
if (data.error != undefined) {
|
||||||
alert(data.error);
|
alert(data.error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$('#api_key').val(data);
|
$('#api_key').val(data);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#branchCheckout').click(function(){
|
$('#branchCheckout').click(function () {
|
||||||
window.location.href = sbRoot + '/home/branchCheckout?branch=' + $('#branchVersion').val();
|
window.location.href = sbRoot + '/home/branchCheckout?branch=' + $('#branchVersion').val();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#pullRequestCheckout').click(function(){
|
$('#pullRequestCheckout').click(function () {
|
||||||
window.location.href = sbRoot + '/home/pullRequestCheckout?branch=' + $('#pullRequestVersion').val();
|
window.location.href = sbRoot + '/home/pullRequestCheckout?branch=' + $('#pullRequestVersion').val();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
fetch_branches();
|
||||||
|
fetch_pullrequests();
|
||||||
});
|
});
|
||||||
|
|
||||||
function config_success(response){
|
function config_success(response) {
|
||||||
if (response == 'reload'){
|
if (response == 'reload') {
|
||||||
window.location.reload(true);
|
window.location.reload(true);
|
||||||
}
|
}
|
||||||
$('.config_submitter').each(function(){
|
$('.config_submitter').each(function () {
|
||||||
$(this).removeAttr('disabled');
|
$(this).removeAttr('disabled');
|
||||||
$(this).next().remove();
|
$(this).next().remove();
|
||||||
$(this).show();
|
$(this).show();
|
||||||
});
|
});
|
||||||
$('#email_show').trigger('notify');
|
$('#email_show').trigger('notify');
|
||||||
|
}
|
||||||
|
|
||||||
|
function fetch_pullrequests() {
|
||||||
|
$.getJSON(sbRoot + '/config/general/fetch_pullrequests', function (data) {
|
||||||
|
$('#pullRequestVersion').find('option').remove();
|
||||||
|
if (data['result'] == 'success') {
|
||||||
|
var pulls = [];
|
||||||
|
$.each(data['pulls'], function (i, pull) {
|
||||||
|
if (pull[0] != '') {
|
||||||
|
pulls.push(pull);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (pulls.length > 0) {
|
||||||
|
$.each(pulls, function (i, text) {
|
||||||
|
add_option_to_pulls(text);
|
||||||
|
});
|
||||||
|
$('#pullRequestCheckout').removeAttr('disabled');
|
||||||
|
} else {
|
||||||
|
add_option_to_pulls(['No pull requests available', '']);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
add_option_to_pulls(['Failed to connect to github', '']);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function fetch_branches() {
|
||||||
|
$.getJSON(sbRoot + '/config/general/fetch_branches', function (data) {
|
||||||
|
$('#branchVersion').find('option').remove();
|
||||||
|
if (data['result'] == 'success') {
|
||||||
|
var branches = [];
|
||||||
|
$.each(data['branches'], function (i, branch) {
|
||||||
|
if (branch != '') {
|
||||||
|
branches.push(branch);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (branches.length > 0) {
|
||||||
|
$.each(branches, function (i, text) {
|
||||||
|
add_option_to_branches(text);
|
||||||
|
});
|
||||||
|
$('#branchCheckout').removeAttr('disabled');
|
||||||
|
} else {
|
||||||
|
add_option_to_branches('No branches available');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
add_option_to_branches('Failed to connect to github');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function add_option_to_pulls(text) {
|
||||||
|
option = $('<option>');
|
||||||
|
option.attr('value', text[1]);
|
||||||
|
option.html(text[0]);
|
||||||
|
option.appendTo('#pullRequestVersion');
|
||||||
|
}
|
||||||
|
|
||||||
|
function add_option_to_branches(text) {
|
||||||
|
option = $('<option>');
|
||||||
|
option.attr('value', text);
|
||||||
|
option.html(text);
|
||||||
|
option.appendTo('#branchVersion');
|
||||||
}
|
}
|
|
@ -98,13 +98,14 @@ class GitHub(object):
|
||||||
access_API = self._access_API(
|
access_API = self._access_API(
|
||||||
['repos', self.github_repo_user, self.github_repo, 'pulls'],
|
['repos', self.github_repo_user, self.github_repo, 'pulls'],
|
||||||
params={'per_page': 100})
|
params={'per_page': 100})
|
||||||
pull = []
|
pulls = []
|
||||||
for x in access_API:
|
for x in access_API:
|
||||||
try:
|
try:
|
||||||
pull.append(PullRequest(x['head']['ref'], x['number']))
|
pull = PullRequest(x['head']['ref'], x['number'])
|
||||||
|
pulls.append((repr(pull), pull.fetch_name()))
|
||||||
except:
|
except:
|
||||||
continue
|
continue
|
||||||
return pull
|
return pulls
|
||||||
|
|
||||||
class PullRequest(object):
|
class PullRequest(object):
|
||||||
def __init__(self, ref, number):
|
def __init__(self, ref, number):
|
||||||
|
|
|
@ -3445,6 +3445,27 @@ class ConfigGeneral(Config):
|
||||||
self.clear_cookie('sickgear-session')
|
self.clear_cookie('sickgear-session')
|
||||||
self.write('reload')
|
self.write('reload')
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def fetch_pullrequests():
|
||||||
|
if sickbeard.BRANCH == 'master':
|
||||||
|
return json.dumps({'result': 'success', 'pulls': []})
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
pulls = sickbeard.versionCheckScheduler.action.list_remote_pulls()
|
||||||
|
return json.dumps({'result': 'success', 'pulls': pulls})
|
||||||
|
except Exception, e:
|
||||||
|
logger.log(u'exception msg: ' + str(e), logger.DEBUG)
|
||||||
|
return json.dumps({'result': 'fail'})
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def fetch_branches():
|
||||||
|
try:
|
||||||
|
branches = sickbeard.versionCheckScheduler.action.list_remote_branches()
|
||||||
|
return json.dumps({'result': 'success', 'branches': branches})
|
||||||
|
except Exception, e:
|
||||||
|
logger.log(u'exception msg: ' + str(e), logger.DEBUG)
|
||||||
|
return json.dumps({'result': 'fail'})
|
||||||
|
|
||||||
|
|
||||||
class ConfigSearch(Config):
|
class ConfigSearch(Config):
|
||||||
def index(self, *args, **kwargs):
|
def index(self, *args, **kwargs):
|
||||||
|
|
Loading…
Reference in a new issue