{% extends 'TopxiaAdminBundle:App:layout.html.twig' %}

{% block title %}应用中心 - {{ parent() }}{% endblock %}

{% set menu = 'center' %}

{% block main %}
  <div class="page-header">
    <h1>应用中心</h1>
  </div>
  {% if status|default(null) == 'error' %}
    <div class="alert alert-danger">AccessKey或者SecretKey设置不正确，会影响到系统正常的运行，<a href="{{path('admin_setting_cloud')}}">请修改设置。</a></div>
  {% elseif  status|default(null) == 'unlink' %}
    <div class="alert alert-danger">您的服务器无法连接到更新服务器，请检查网络连接状况。</div>
  {% else %}
  <table class="table table-striped table-hover">
    <thead>
      <tr>
        <th>应用描述</th>
        <th>开发者</th>
        <th>操作</th>
      </tr>
    </thead>
    <tbody>
      {% for app in apps %}
        {% set installedApp = installedApps[app.code]|default(null) %}
      <tr>
        <td>
          <div>
            <a target="_blank" href="http://open.edusoho.com/app/{{ app.code }}"><strong class="text-primary">{{ app.name }}</strong></a>
             - 
            <span class="text-info">{{ app.latestVersion }}</span>
            {% if app.licensed %}
              <span class="label label-warning">商业版应用</span>
            {% endif %}
          </div>
          <div class="">{{ app.description|plain_text(100) }}</div>
          <div class="text-muted"><small>最后更新： {{ app.latestTime|date('Y-m-d') }}</small></div>
        </td>
        <td>
          {{ app.developerName }}
        </td>
        <td>
          {% if installedApp %}
            <a href="javascript:;" class="btn btn-default disabled">已安装</a>
          {% else %}
            {% if app.userAccess == 'ok' %}
              <a href="#" data-toggle="modal" data-target="#modal" data-url="{{ path('admin_app_package_update_modal', {id:app.latestPackageId, type:'install'}) }}" class="btn btn-primary" data-keyboard="false" data-backdrop="static">安装</a>
            {% else %}
              <a href="http://open.edusoho.com/app/{{ app.code }}" class="btn btn-warning" target="_blank">购买</a>
            {% endif %}
          {% endif %}
        </td>
      </tr>
      {% endfor %}
    </tbody>
  </table>
  {% endif %}
{% endblock %}