{% extends 'old-bootstrap-modal-layout.html.twig' %}

{% set updateName = package.type == 'upgrade' ? '升级'|trans : '安装'|trans %}



{% block title %}{{ updateName }}{{ '应用'|trans }}{% endblock %}

{% block body %}
  <input type="hidden" name="package-type" value="{{ app.request.get('type')|default('') }}">

  <div class="alert alert-warning">
    您好，为了保证网站升级顺利进行，升级过程中会出现短暂（2分钟内）网站无法访问的情况，请在学员访问少的时候进行系统升级，给您带来了不便，还望理解
  </div>

  <table class="table">
    <thead>
    <tr>
      <th width="40%">{{ '应用名称'|trans }}</th>
      <th width="25%">{{ '版本'|trans }}</th>
      <th>{{ '备份数据库'|trans }}</th>
      <th>{{ '备份文件'|trans }}</th>
    </tr>
    </thead>
    <tbody>
    <tr>
      <td>{{ package.product.name }}</td>
      <td>
        {% if package.type == 'upgrade' %}
          <strong class="text-muted">{{ package.fromVersion }}</strong> -&gt; <strong
            class="text-success">{{ package.toVersion }}</strong>
        {% else %}
          <strong class="text-success">{{ package.toVersion }}</strong>
        {% endif %}
      </td>
      <td>{% if package.backupDB == 1 %}{{ '是'|trans }}{% elseif package.backupDB == 0 %}{{ '否'|trans }}{% endif %}</td>
      <td>{% if package.backupFile == 1 %}{{ '是'|trans }}{% elseif package.backupFile == 0 %}{{ '否'|trans }}{% endif %}</td>
    </tr>

    </tbody>
  </table>

  <div id="package-update-progress" class="package-update-progress" style="display:none;">
    <div class="progress progress-striped active">
      <div class="progress-bar progress-bar-success" style="width: 0%"></div>
    </div>
    <div class="text-success progress-text"></div>
  </div>

  <script type="text/javascript"> app.load('app/package-update-modal'); </script>
{% endblock %}

{% block footer %}
  <button id="begin-update" type="button" class="btn btn-primary pull-right"
          data-check-environment-url="{{ path('admin_app_package_update_check_environment', {id:package.id}) }}"
          data-check-depends-url="{{ path('admin_app_package_update_check_depends', {id:package.id}) }}"
          data-check-last-error-url="{{ path('admin_app_package_update_check_last_error', {id:package.id}) }}"
          data-backup-file-url="{{ path('admin_app_package_update_backup_file', {id:package.id}) }}"
          data-backup-db-url="{{ path('admin_app_package_update_backup_db', {id:package.id}) }}"
          data-check-download-extract-url="{{ path('admin_app_package_update_check_download_and_extract', {id:package.id}) }}"
          data-download-extract-url="{{ path('admin_app_package_update_download_and_extract', {id:package.id}) }}"
          data-begin-upgrade-url="{{ path('admin_app_package_update_begin_upgrade', {id:package.id, type:app.request.get('type')}) }}"
      {% if app.request.get('type') == 'upgrade' %}
        data-check-newest-url="{{ path('admin_app_package_update_check_newest',{code:package['product'].code|default('')}) }}"
      {% endif %}
  >{{ '开始'|trans }}{{ updateName }}</button>

  <strong class="text text-danger" id="updating-hint" style="display:none;">{{ '正在安装，请不要关闭当前窗口...'|trans }}</strong>

  <button id="finish-update-btn" data-loading-text="{{ '正在完成安装/升级, 请稍等...'|trans }}" class="btn btn-primary"
          style="display:none">{{ '完成安装/升级'|trans }}</button>
{% endblock %}