<?
/**
 * Copyright © 2012 Alcatel-Lucent.
 *
 * See the NOTICE file distributed with this work for additional information regarding copyright ownership. Licensed to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the specific language governing permissions and limitations under the License.
 */
$addButtonTip = $this->translate("Click to add a new API");
$editLinkTip = $this->translate("Select to edit API");
$deleteConfirmTitle = $this->translate("Are you sure?");
$deleteConfirmMessage = $this->translate("Click again to confirm");
$deleteConfirmOk = $this->translate("OK");
$deleteConfirmCancel = $this->translate("Cancel");

?>
<div class="container">
    <div class="hero-unit">
        <h1>APIs</h1>
        <p><? echo $this->translate("Choose an API from the list below to edit")?></p>
    </div>
    <? if(!empty($this->messages)): ?>
    <div class="control-group success">
            <span id="messages" class="help-block">
                <? foreach ($this->messages as $message): ?>
                <?=$message?><br/>
                <? endforeach ?>
            </span>
    </div>
    <? endif ?>
    <div class="well">

        <div id="list">
            <div class="listItem">
                <div class="item-div pull-left"><label class="item1"><strong><? echo $this->translate("API Name")?></strong></label></div>
                <div class="item-div pull-left"><span class="item2"><strong><? echo $this->translate("Endpoint")?></strong></div>
                <div class="item-div pull-left"><span class="item3"><strong>Call</strong></span></div>
                <div class="item-div pull-left"><span class="item4"><a href="/api/create" class="btn btn-success"
                                                                       rel="tooltip" title="<?=$addButtonTip?>" data-placement="right"><i class="icon-plus icon-white"></i></a></div>

                <span class="clear"></span>
            </div>
            <?          foreach($this->apis as $api):
            /**
             * @var Api $api
             */
            $name = $api->getDisplayName();
            $endpoint = $api->getEndpoint();
            $id = $api->getId(); ?>
            <div class="listItem">
                <div class="item-div pull-left">
                    <label class="item1" rel="tooltip" title="<?=$editLinkTip?>"><p>
                        <a id="edit-<?=$endpoint?>" href="api/<?=$id?>"><strong><?if(strlen($name) > 15){ echo substr($name, 0, 15) . "...";}else{ echo $name;} ;?></strong></a>
                    </p></label>
                </div>
                <div class="item-div pull-left"><span class="item2"><p><?if(strlen($endpoint) > 15){ echo substr($endpoint, 0, 15) . "...";}else{ echo $endpoint;} ;?></p></span></div>
                <div class="item-div pull-left">
                        <span class="item4">
                            <a href="/api/<?=$api->getId()?>/call" class="btn btn-info" id="callApi-<?=$api->getId()?>">Call This Api</a>
                        </span>
                </div>
                <div class="item-div pull-left">
                        <span class="item5">
                            <a href="/api/<?=$api->getId()?>/delete" class="btn btn-danger delete" id="delete-<?=$endpoint?>"
                               confirm-title="<?=$deleteConfirmTitle?>" confirm-content="<?=$deleteConfirmMessage?>"
                               confirm-ok="<?=$deleteConfirmOk?>" confirm-cancel="<?=$deleteConfirmCancel?>"><? echo $this->translate("Delete")?></a>
                        </span>
                </div>
            </div>
            <? endforeach ?>
        </div>
    </div>
</div> <!-- /container -->
