diff --git a/frontend/app/index.html b/frontend/app/index.html index 58448256be..3dba14c63f 100644 --- a/frontend/app/index.html +++ b/frontend/app/index.html @@ -261,6 +261,7 @@ + diff --git a/frontend/app/scripts/components/organisation/OrgCustomTagsListCmp.js b/frontend/app/scripts/components/organisation/OrgCustomTagsListCmp.js index 306008d0a9..a4b691f371 100644 --- a/frontend/app/scripts/components/organisation/OrgCustomTagsListCmp.js +++ b/frontend/app/scripts/components/organisation/OrgCustomTagsListCmp.js @@ -3,7 +3,7 @@ angular.module('theHiveComponents') .component('orgCustomTagsList', { - controller: function($uibModal, $scope, PaginatedQuerySrv, FilteringSrv, UserSrv, NotificationSrv, ModalUtilsSrv) { + controller: function($scope, PaginatedQuerySrv, FilteringSrv, TagSrv, UserSrv, NotificationSrv) { var self = this; self.tags = []; @@ -11,7 +11,7 @@ this.$onInit = function() { // TODO: FIXME - self.filtering = new FilteringSrv('taxonomy', 'custom-tags.list', { + self.filtering = new FilteringSrv('tag', 'custom-tags.list', { version: 'v1', defaults: { showFilters: true, @@ -59,6 +59,16 @@ }); }; + self.updateColour = function(id, colour) { + TagSrv.updateTag(id, {colour: colour}) + .then(function(/*response*/) { + NotificationSrv.success('Tag list', 'Tag colour updated successfully'); + }) + .catch(function(err) { + NotificationSrv.error('Tag list', err.data, err.status); + }) + } + // Filtering this.toggleFilters = function () { this.filtering.toggleFilters(); diff --git a/frontend/app/scripts/directives/tag-item.js b/frontend/app/scripts/directives/tag-item.js index 598bc7facc..c868207b61 100644 --- a/frontend/app/scripts/directives/tag-item.js +++ b/frontend/app/scripts/directives/tag-item.js @@ -5,7 +5,8 @@ restrict: 'E', replace: true, scope: { - value: '=' + value: '=', + colour: '=' }, templateUrl: 'views/directives/tag-item.html', link: function(scope/*, element, attrs*/) { @@ -14,7 +15,10 @@ } if(_.isString(scope.value)) { scope.tag = scope.value; - scope.bgColor = TaxonomyCacheSrv.getColour(scope.value) || '#3c8dbc'; + scope.bgColor = scope.colour || + TaxonomyCacheSrv.getColour(scope.value) || + TaxonomyCacheSrv.getColour('_freetags_:' + scope.value) || + '#3c8dbc'; } else { scope.tag = _.without([ scope.value.namespace, @@ -22,8 +26,15 @@ scope.value.predicate, scope.value.value ? ("=\"" + scope.value.value + "\"") : null ], null).join(''); - scope.bgColor = scope.value.colour || '#3c8dbc'; + scope.bgColor = scope.value.colour || scope.colour || '#3c8dbc'; } + + scope.$watch('colour', function(value) { + if(!value) { + return; + } + scope.bgColor = value; + }); } }; }); diff --git a/frontend/app/scripts/directives/updatableColour.js b/frontend/app/scripts/directives/updatableColour.js new file mode 100644 index 0000000000..1ffbda4fae --- /dev/null +++ b/frontend/app/scripts/directives/updatableColour.js @@ -0,0 +1,18 @@ +(function() { + 'use strict'; + angular.module('theHiveDirectives') + .directive('updatableColour', function(UtilsSrv) { + return { + 'restrict': 'E', + 'link': UtilsSrv.updatableLink, + 'templateUrl': 'views/directives/updatable-colour.html', + 'scope': { + 'value': '=?', + 'onUpdate': '&', + 'active': '=?', + 'placeholder': '@', + 'clearable': ' - + Colour By @@ -66,10 +66,10 @@

{{tag._id}} - + - {{tag.colour}} + diff --git a/frontend/app/views/directives/updatable-colour.html b/frontend/app/views/directives/updatable-colour.html new file mode 100644 index 0000000000..3b450087c2 --- /dev/null +++ b/frontend/app/views/directives/updatable-colour.html @@ -0,0 +1,31 @@ +
+ + {{value}} + Not Specified + + + + + + +
+
+ + + + + + + + +
+
+