<!--
Copyright 2015 Google Inc. All rights reserved.

Licensed 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.
-->

<table id="search-result-table" width="100%">
    <tr>
        <td style="background: #{{ ::meta.timeline_colors[event._index] }}" width="210px">
            {{ event._source.datetime }}
        </td>

        <td width="20px;" ng-hide="isContextEvent">
            <input type="checkbox" ng-click="toggleSelected()" ng-checked="event.selected">
        </td>

        <td width="35px;" ng-hide="isContextEvent">
            <i ng-click="event.star = !event.star;toggleStar()" ng-class="{true: 'fa fa-lg fa-star icon-yellow', false: 'fa fa-lg fa-star-o icon-grey'}[event.star]"></i>
        </td>

        <td class="event-message" ng-class="{true:'event-message-selected'}[event.selected]" ng-click="getDetail();showDetails = !showDetails">
            <span ng-show="comment">
                <i class="fa fa-comments"></i>
            </span>
            [{{ event._source.timestamp_desc }}] {{ event._source.message|limitTo:500 }}
            <div style="width:20px;height:20px;cursor: pointer;" class="pull-right tooltips"><span>Details</span><i ng-class="{true: 'fa fa-minus-square-o', false: 'fa fa-plus-square-o'}[showDetails]" style="color:#999;"></i></div>

        </td>

        <td width="150px" style="text-align: right;background: #f1f1f1;">
            <span class="label ts-name-label">{{ ::meta.timeline_names[event._index] }}</span>
            <div ng-hide="isContextEvent" style="width:20px;height:20px;cursor: pointer;" class="pull-right tooltips" ng-click="getContext(event)"><span>Context query</span><i class="fa fa-search-plus" style="color:#777;"></i></div>
        </td>

    </tr>
</table>

<div ng-show="showDetails" class="event-detail">
    <br>
    <div class="event-detail-container">
        <div class="container">
            <div class="row">
                <div class="col-md-8">
                    <table class="table table-bordered table-hover">
                        <tr ng-repeat="(key, value) in eventdetail">
                            <td width="150px">{{ key }}</td>
                            <td>{{ value }}</td>
                        </tr>
                    </table>
                </div>
                <div class="col-md-4">
                    <div ng-repeat="comment in comments">
                        <div class="comment-bubble">
                            <div class="comment-name">{{ comment.user.username }}</div>
                            <div class="comment-body">{{ comment.comment }}</div>
                            <div class="comment-timestamp"><i class="fa fa-clock-o"></i> {{ comment.created_at }}</div>
                        </div>
                    </div>
                    <form name="commentForm" ng-submit="postComment()">
                        <div class="form-group">
                            <textarea ng-model="formData.comment" class="form-control" rows="3" placeholder="What's on your mind?" required></textarea>
                        </div>
                        <div class="form-group">
                            <input type="submit" class="btn btn-primary" value="Post comment" />
                            <input type="reset" class="btn btn-default" value="Cancel" />
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
