Skip to content

Commit

Permalink
#2055 Make alert tags and description editable
Browse files Browse the repository at this point in the history
  • Loading branch information
nadouani committed Jun 3, 2021
1 parent 89da745 commit 482adaa
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 16 deletions.
16 changes: 15 additions & 1 deletion frontend/app/scripts/controllers/alert/AlertEventCtrl.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(function () {
'use strict';
angular.module('theHiveControllers')
.controller('AlertEventCtrl', function ($scope, $rootScope, $state, $uibModal, $uibModalInstance, ModalUtilsSrv, AuthenticationSrv, CustomFieldsSrv, CaseResolutionStatus, AlertingSrv, NotificationSrv, UiSettingsSrv, clipboard, event, templates, readonly) {
.controller('AlertEventCtrl', function ($scope, $rootScope, $state, $uibModal, $uibModalInstance, ModalUtilsSrv, TagSrv, AuthenticationSrv, CustomFieldsSrv, CaseResolutionStatus, AlertingSrv, NotificationSrv, UiSettingsSrv, clipboard, event, templates, readonly) {
var self = this;
var eventId = event._id;

Expand Down Expand Up @@ -35,6 +35,20 @@
return 'customFields.' + fieldDef.reference + '.' + fieldDef.type;
};

self.getTags = function (selection) {
var tags = [];

angular.forEach(selection, function (tag) {
tags.push(tag.text);
});

return tags;
};

self.getAlertTags = function (query) {
return TagSrv.autoComplete(query);
};

self.load = function () {
AlertingSrv.get(eventId).then(function (data) {
self.event = data;
Expand Down
23 changes: 15 additions & 8 deletions frontend/app/views/directives/flow/alert.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="flow-alert "ng-switch="base.operation">
<div class="flow-alert">
<div class="flow-item-title wrap">
<i class="fa fa-download"></i>
<span ng-show="bulk">Alert updates</span>
Expand All @@ -7,23 +7,27 @@

<div class="flow-item-updates wrap" ng-show="bulk">
<div class="flow-item-bulk" ng-show="summary.alert.Creation">
<ng-pluralize count="summary.alert.Creation" when="{'one': '{} new alert has been added', 'other': '{} new alerts have been added'}"></ng-pluralize>
<ng-pluralize count="summary.alert.Creation"
when="{'one': '{} new alert has been added', 'other': '{} new alerts have been added'}"></ng-pluralize>
</div>
<div class="flow-item-bulk" ng-show="summary.alert.Update">
<ng-pluralize count="summary.alert.Update" when="{'one': '{} existing alert has been updated', 'other': '{} existing alerts have been updated'}"></ng-pluralize>
<ng-pluralize count="summary.alert.Update"
when="{'one': '{} existing alert has been updated', 'other': '{} existing alerts have been updated'}">
</ng-pluralize>
</div>
<div class="flow-item-bulk" ng-show="summary.alert.Delete">
<ng-pluralize count="summary.alert.Delete" when="{'one': '{} existing alert has been permanently deleted', 'other': '{} existing alerts have been permanently deleted'}"></ng-pluralize>
<ng-pluralize count="summary.alert.Delete"
when="{'one': '{} existing alert has been permanently deleted', 'other': '{} existing alerts have been permanently deleted'}">
</ng-pluralize>
</div>
<div>
<a class="small" href ng-click="openState('app.alert-list')">See all</a>
</div>
</div>

<div class="flow-item-updates wrap" ng-hide="bulk" ng-switch-default>
<span ng-repeat="(k,v) in base.details"
ng-switch="k"
ng-if="['description', 'caseTemplate', 'title', 'follow', 'lastSyncDate'].indexOf(k) === -1">
<div class="flow-item-updates wrap" ng-hide="bulk">
<span ng-repeat="(k,v) in base.details" ng-switch="k"
ng-if="['caseTemplate', 'title', 'follow', 'lastSyncDate'].indexOf(k) === -1">
<div ng-switch-when="artifacts">
{{k}}:
<em>{{v.length}}</em>
Expand All @@ -39,6 +43,9 @@
<div ng-switch-when="case">
{{k}}: <a href ui-sref="app.case.details({caseId: v})">{{v}}</a>
</div>
<div ng-switch-when="description">
description: <em>{{v | limitTo: 250}}</em>
</div>
<div ng-switch-when="tags">
{{k}}:
<span ng-repeat="tag in v">
Expand Down
8 changes: 5 additions & 3 deletions frontend/app/views/directives/updatable-tag-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@

<span ng-show="updatable.updating">
<div class="form-group">
<tags-input class="ti-input-sm ti-tag-selector" min-length="2" ng-model="value" placeholder="Add labels" replace-spaces-with-dashes="false"
template="views/directives/tag-input-item.html" tag-class="label-primary">
<auto-complete ng-if="source" min-length="3" debounce-delay="400" source="source($query)"></auto-complete>
<tags-input class="ti-input-sm ti-tag-selector" min-length="2" ng-model="value" placeholder="Add tags"
replace-spaces-with-dashes="false" template="views/directives/tag-input-item.html"
tag-class="label-primary">
<auto-complete ng-if="source" min-length="3" debounce-delay="400" source="source($query)">
</auto-complete>
</tags-input>
</div>
<div class="btn-group btn-group-sm">
Expand Down
29 changes: 25 additions & 4 deletions frontend/app/views/partials/alert/event.dialog.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,44 @@ <h4 class="text-primary">
<span>{{dialog.event.source}}</span>
</span>
</div>
<div class="case-tags flexwrap mt-xxs">
<!-- <div class="case-tags flexwrap mt-xxs">
<strong><i class="fa fa-tags mr-xxxs"></i></strong>
<strong class="text-muted mr-xxxs"
ng-if="!dialog.event.tags || dialog.event.tags.length === 0">None</strong>
<tag-item ng-repeat="tag in dialog.event.tags track by $index" value="tag"></tag-item>
</div> -->

<div class="mt-xs">
<h4 class="vpad10 text-primary">
Basic Information
</h4>
<dl class="dl-horizontal">
<dt class="pull-left">Tags</dt>
<dd ng-if="dialog.canEdit">
<updatable-tag-list on-update="dialog.updateField('tags', dialog.getTags(newValue))"
value="dialog.event.tags" source="dialog.getAlertTags"></updatable-tag-list>
</dd>
<dd ng-if="!dialog.canEdit">
<tag-list data="caze.tags"></tag-list>
</dd>
</dl>
</div>

<div class="mt-xs" ng-if="dialog.event.description">
<div class="mt-xs">
<h4 class="vpad10 text-primary">
Description
</h4>
<div class="description-pane">
<div class="description-pane" ng-if="!dialog.canEdit">
<div marked="dialog.event.description" class="markdown"></div>
</div>

<div class="description-pane" ng-if="dialog.canEdit">
<updatable-text on-update="dialog.updateField('description', newValue)"
value="dialog.event.description"></updatable-text>
</div>
</div>

<div class="mt-xs" ng-if="dialog.event.description">
<div class="mt-xs">
<h4 class="vpad10 text-primary">
Additional fields

Expand Down

0 comments on commit 482adaa

Please sign in to comment.