Skip to content

Commit

Permalink
Merge pull request #147 from google/54-hide-event
Browse files Browse the repository at this point in the history
54 hide event
  • Loading branch information
berggren committed Nov 25, 2015
2 parents 12ef9f7 + 44a2f18 commit f9461b0
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 5 deletions.
2 changes: 1 addition & 1 deletion timesketch/api/v1/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ def post(self, sketch_id):
if annotation not in event.labels:
event.labels.append(annotation)
toggle = False
if u'__ts_star' in form.annotation.data:
if u'__ts_star' or u'__ts_hidden' in form.annotation.data:
toggle = True
self.datastore.set_label(
searchindex_id, event_id, event_type, sketch.id,
Expand Down
22 changes: 22 additions & 0 deletions timesketch/ui/static/components/explore/explore-event-directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,20 @@ limitations under the License.
$scope.event).success(function(data) {})
};

$scope.toggleHidden = function() {
timesketchApi.saveEventAnnotation(
$scope.sketchId,
'label',
'__ts_hidden',
$scope.event).success(function(data) {
if ($scope.event.hidden) {
$scope.meta.numHiddenEvents++
} else {
$scope.meta.numHiddenEvents--
}
})
};

$scope.getDetail = function() {
if ($scope.eventdetail) {return}
timesketchApi.getEvent(
Expand All @@ -182,6 +196,7 @@ limitations under the License.
$scope.$watch('event', function(value) {
$scope.star = false;
$scope.comment = false;

if ($scope.event._source.label.indexOf('__ts_star') > -1) {
$scope.event.star = true;
} else {
Expand All @@ -192,6 +207,13 @@ limitations under the License.
$scope.comment = true;
}

if ($scope.event._source.label.indexOf('__ts_hidden') > -1) {
$scope.event.hidden = true;
$scope.meta.numHiddenEvents++;
} else {
$scope.event.hidden = false;
}

});

},
Expand Down
12 changes: 10 additions & 2 deletions timesketch/ui/static/components/explore/explore-event-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,20 @@
<i class="fa fa-circle-o-notch fa-spin"></i> Searching..
</span>
<span ng-show="events.length || meta.es_total_count == 0">
{{ meta.es_total_count }} events ({{ meta.es_time/1000 }}s)
{{ meta.es_total_count }} events <span ng-show="meta.numHiddenEvents > 0 && !meta.showHiddenEvents" style="color:red;">({{ meta.numHiddenEvents }} hidden)</span> ({{ meta.es_time/1000 }}s)
<span ng-show="meta.noisy" style="margin-left:10px;color:red;font-weight:bold;">
<i class="fa fa-warning"></i> Wow, that is a lot of events! I will only show you 500 of them.
</span>
</span>
</div>
<div class="pull-right">

<button style="min-width:200px;" class="btn btn-danger" ng-show="meta.numHiddenEvents > 0" ng-click="meta.showHiddenEvents = !meta.showHiddenEvents">
<span ng-show="!meta.showHiddenEvents"><i class="fa fa-eye"></i> Show </span>
<span ng-show="meta.showHiddenEvents"><i class="fa fa-eye-slash"></i> Hide </span>
{{ meta.numHiddenEvents }} hidden events
</button>

<div class="btn-group" style="margin-left:10px;">
<button class="btn btn-default" ng-click="filter.order = { 'asc': 'desc', 'desc': 'asc'}[filter.order];applyOrder()"><i ng-class="{'asc': 'fa fa-sort-asc', 'desc': 'fa fa-sort-desc'}[filter.order]"></i> Sort</button>
<a class="btn btn-default" href="/sketch/{{ sketchId }}/explore/export/" download="export.csv"><i class="fa fa-cloud-download"></i> Export</a>
Expand All @@ -20,7 +27,8 @@
</div>
</div>
<br><br><br>

<div ng-repeat="event in events">
<ts-event event="::event" meta="::meta" sketch-id="::sketchId" prev-timestamp="::events[$index-1]['_source'].timestamp" next-timestamp="::events[$index+1]['_source'].timestamp" index="::$index" order="::filter.order"></ts-event>
<ts-event ng-hide="event.hidden && !meta.showHiddenEvents" event="::event" meta="::meta" sketch-id="::sketchId" prev-timestamp="::events[$index-1]['_source'].timestamp" next-timestamp="::events[$index+1]['_source'].timestamp" index="::$index" order="::filter.order"></ts-event>
</div>
</div>
11 changes: 9 additions & 2 deletions timesketch/ui/static/components/explore/explore-event.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,24 @@
<input type="checkbox" ng-click="toggleSelected()" ng-checked="event.selected">
</td>

<td width="35px;">
<td width="25px;">
<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 width="35px;">
<i ng-click="event.hidden = !event.hidden;toggleHidden()" ng-class="{true: 'fa fa-lg fa-eye-slash', false: 'fa fa-lg fa-eye-slash icon-grey'}[event.hidden]"></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>
<i ng-if="::event._source.tag" ng-repeat="tag in ::event._source.tag" class="label label-primary">{{::tag}}</i>
[{{ event._source.timestamp_desc }}] {{ event._source.message|limitTo:500 }}

<span ng-class="{true: 'message-hidden'}[event.hidden]">[{{ event._source.timestamp_desc }}] {{ event._source.message|limitTo:500 }}</span>

<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;">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ limitations under the License.
if (data.meta.es_total_count > 500) {
$scope.meta.noisy = true
}
$scope.meta.numHiddenEvents = 0;
})
};

Expand Down
5 changes: 5 additions & 0 deletions timesketch/ui/static/css/ts.css
Original file line number Diff line number Diff line change
Expand Up @@ -489,3 +489,8 @@ rect.bordered {
stroke: #000;
shape-rendering: crispEdges;
}

.message-hidden {
color:#666;
font-style: italic;
}

0 comments on commit f9461b0

Please sign in to comment.