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

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


{% block title %}{{ updateName }}应用{% endblock %}

{% block body %}

<table class="table">
  <thead>
    <tr>
      <th width="40%">应用名称</th>
      <th width="25%">版本</th>
      <th>备份数据库</th>
      <th>备份文件</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 %}是{% elseif package.backupDB == 0 %}否{% endif %}</td>
      <td>{% if package.backupFile == 1 %}是{% elseif package.backupFile == 0 %}否{% 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')}) }}"
  >开始{{ updateName }}</button>

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

  <button id="finish-update-btn" class="btn btn-primary" style="display:none">完成安装/升级</button>
{% endblock %}