{% extends "base.html" %}
{% block content %}
<div>
  {{ macros.m_button_group([['globalSettingSaveBtn', '설정 저장'], ['celery_test_btn', 'Celery 테스트']])}}
  {{ macros.m_row_start('5') }}
  {{ macros.m_row_end() }}
  {{ macros.m_hr() }}

  <div class="tab-content" id="nav-tabContent">
    {{ macros.info_text('use_celery', 'use_celery 값', arg['use_celery']) }}
    {{ macros.info_text('running_type', 'running_type 값', arg['running_type']) }}
    {{ macros.info_text('_tmp', '설명', "보통 시작시 celery 실행 On 상태로 동작하며 개발시에만 Off로 설정.", desc=None) }}
    {{ macros.m_hr() }}
    <form id='setting' name='setting'>
    {{ macros.setting_checkbox('celery_start_by_web', '시작시 celery 실행', value=arg['celery_start_by_web']) }}

    {{ macros.setting_input_textarea('celery_start_command', 'celery 실행 명령', desc=['', 
    
    '예: celery -A flaskfarm.main.celery worker --loglevel=info --pool=gevent --concurrency=2 --config_filepath={F.config["config_filepath"]} --running_type=native', 
    '',
    '패키지로 실행시 : -A flaskfarm.main.celery',
    'Git 소스로 실행시 : -A main.celery', '',
    'Linux는 사용자에 따라 export C_FORCE_ROOT=true 필요'
    ], 
    value=arg['celery_start_command'], row='5') }}
    </form>
    {{ macros.setting_buttons([['celery_excute_btn', '실행 테스트'], ['celery_excute_back_btn', '실행(Background) ']]) }}
  </div>
</div>


<script type="text/javascript">
var running_type = "{{arg['running_type']}}";

$(document).ready(function(){
  /*
  if (running_type.startsWith('docker')) {
    $('#celery_start_by_web').bootstrapToggle('off');
    $('#celery_start_by_web').prop('disabled', true);
  }
  */
});

$("body").on('click', '#celery_excute_btn', function(e){
  e.preventDefault();
  globalSendCommand('celery_execute', $('#celery_start_command').val());
});

$("body").on('click', '#celery_excute_back_btn', function(e){
  e.preventDefault();
  globalSendCommand('celery_execute_back', $('#celery_start_command').val());
});

$("body").on('click', '#celery_test_btn', function(e){
  e.preventDefault();
  globalSendCommand('celery_test');
});


</script>    
{% endblock %}
