<link href="css/sparql-templates.css?v=3.4.0-RC3" rel="stylesheet">

<div class="container-fluid" data-test="sparql-templates-page">
    <h1>
        {{title}}
        <page-info-tooltip></page-info-tooltip>
    </h1>
    <div core-errors ontop fedx license></div>
    <inactive-plugin-directive
        plugin-name="{{pluginName}}"
        human-readable-plugin-name="{{'sparql.template.plugin' | translate}}"
        load-saved="getSparqlTemplates()"
        set-plugin-active="setPluginIsActive(isPluginActive)"
        ng-if="isLicenseValid()">
    </inactive-plugin-directive>
    <div class="sparql-templates-list card mb-2"
         ng-if="isLicenseValid() && pluginIsActive && getActiveRepository() && !isActiveRepoOntopType() && !isActiveRepoFedXType()"
         data-test="sparql-templates-content">
        <div class="card-block" ng-init="getSparqlTemplates();">
            <div class="clearfix">
                <a ng-href="sparql-template/create"
                   ng-if="canWriteActiveRepo()"
                   data-test="create-sparql-template-link"
                   class="btn btn-link pull-right create-sparql-template">
                    <span class="ri-add-circle-line create-sql-table-configuration"></span>{{'create.new.sparql.template' | translate}}
                </a>
                <h3 class="mb-0"><span class="collapsible-heading" data-toggle="collapse"
                                       data-target="#configurations-table"><em class="ri-arrow-down-s-line text-muted"></em> {{'existing.sparql.templates' | translate}}</span>
                </h3>
            </div>

            <div class="collapse in mt-1" id="configurations-table">
                <div class="no-indexes"
                     data-test="no-sparql-templates-message"
                     ng-if="!sparqlTemplateIds.items.length"><em>{{'no.sparql.templates.defined' | translate}}</em></div>
                <table class="table table-hover mb-0" aria-describedby="SPARQL templates">
                    <tbody>
                    <tr ng-repeat="template in sparqlTemplateIds.items track by $index"
                        class="configuration-row">
                        <td>
                            <a class="lead configuration-name" ng-href="{{template.href}}">{{template.id}}</a>
                        </td>

                        <td class="text-xs-right">
                            <span class="actions-bar hovered-item">
                                    <a class="btn btn-link edit-query-btn"
                                       ng-if="canWriteActiveRepo()" ng-href="{{template.href}}"
                                       gdb-tooltip="{{'edit.sparql.template.tooltip' | translate}}">
                                        <em class="ri-edit-line"></em>
                                    </a>
                                </span>
                            <button type="button" ng-if="canWriteActiveRepo()" ng-click="deleteTemplate(template.id)"
                                    class="btn btn-link delete-configuration-btn" gdb-tooltip="{{'delete.sparql.template.tooltip' | translate}}"><span
                                class="ri-delete-bin-6-line"></span>
                            </button>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
