diff --git a/frontend/app/scripts/components/organisation/OrgCustomTagsListCmp.js b/frontend/app/scripts/components/organisation/OrgCustomTagsListCmp.js index a4b691f371..6c677676e3 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($scope, PaginatedQuerySrv, FilteringSrv, TagSrv, UserSrv, NotificationSrv) { + controller: function($scope, PaginatedQuerySrv, FilteringSrv, TagSrv, UserSrv, ModalUtilsSrv, NotificationSrv) { var self = this; self.tags = []; @@ -50,6 +50,7 @@ '_name': 'freetags' } ], + extraData: ['usage'], onFailure: function(err) { if(err && err.status === 400) { self.filtering.resetContext(); @@ -59,6 +60,23 @@ }); }; + self.deleteTag = function (tag) { + ModalUtilsSrv.confirm('Remove free tag', 'Are you sure you want to delete this tag?', { + okText: 'Yes, remove it', + flavor: 'danger' + }) + .then(function () { + return TagSrv.removeTag(tag._id); + }) + .then(function () { + NotificationSrv.success('Tag list', 'Tag removed successfully'); + + self.load(); + + $scope.$emit('freetags:refresh'); + }); + }; + self.updateColour = function(id, colour) { TagSrv.updateTag(id, {colour: colour}) .then(function(/*response*/) { @@ -125,110 +143,6 @@ self.list.update(); self.filtering.setSort(sort); }; - - - // this.showTemplate = function(template) { - - // var promise = template._id ? CaseTemplateSrv.get(template._id) : $q.resolve(template); - - // promise - // .then(function(response) { - // var modalInstance = $uibModal.open({ - // animation: true, - // keyboard: false, - // backdrop: 'static', - // templateUrl: 'views/components/org/case-template/details.modal.html', - // controller: 'OrgCaseTemplateModalCtrl', - // controllerAs: '$vm', - // size: 'max', - // resolve: { - // template: function() { - // return response; - // }, - // fields: function() { - // return self.fields; - // } - // } - // }); - - // return modalInstance.result; - // }) - // .then(function() { - // self.load(); - // }) - // .catch(function(err) { - // if(err && !_.isString(err)) { - // NotificationSrv.error('Case Template Admin', err.data, err.status); - // } - // }) - // } - - // self.createTemplate = function(template) { - // return CaseTemplateSrv.create(template).then( - // function(/*response*/) { - // self.load(); - - // $scope.$emit('templates:refresh'); - - // NotificationSrv.log('The template [' + template.name + '] has been successfully created', 'success'); - // }, - // function(response) { - // NotificationSrv.error('TemplateCtrl', response.data, response.status); - // } - // ); - // }; - - // self.importTemplate = function() { - // var modalInstance = $uibModal.open({ - // animation: true, - // templateUrl: 'views/components/org/case-template/import.html', - // controller: 'AdminCaseTemplateImportCtrl', - // controllerAs: 'vm', - // size: 'lg' - // }); - - // modalInstance.result - // .then(function(template) { - // return self.createTemplate(template); - // }) - // .catch(function(err) { - // if (err && err.status) { - // NotificationSrv.error('TemplateCtrl', err.data, err.status); - // } - // }); - // }; - - // self.deleteTemplate = function (template) { - // ModalUtilsSrv.confirm('Remove case template', 'Are you sure you want to delete this case template?', { - // okText: 'Yes, remove it', - // flavor: 'danger' - // }) - // .then(function () { - // return CaseTemplateSrv.delete(template._id); - // }) - // .then(function () { - // self.load(); - - // $scope.$emit('templates:refresh'); - // }); - // }; - - // self.exportTemplate = function (template) { - // CaseTemplateSrv.get(template._id) - // .then(function(response) { - // var fileName = 'Case-Template__' + response.name.replace(/\s/gi, '_') + '.json'; - - // // Create a blob of the data - // var fileToSave = new Blob([angular.toJson(_.omit(response, 'id'))], { - // type: 'application/json', - // name: fileName - // }); - - // // Save the file - // saveAs(fileToSave, fileName); - // }) - - // }; }, controllerAs: '$vm', templateUrl: 'views/components/org/custom-tags/tag-list.html', diff --git a/frontend/app/scripts/directives/tag-colour.js b/frontend/app/scripts/directives/tag-colour.js index 10e62b5ad7..c6fb358884 100644 --- a/frontend/app/scripts/directives/tag-colour.js +++ b/frontend/app/scripts/directives/tag-colour.js @@ -11,7 +11,7 @@ return; } - scope.bgColour = TaxonomyCacheSrv.getColour(scope.tag) || '#3c8dbc'; + scope.bgColour = TaxonomyCacheSrv.getColour(scope.tag) || TaxonomyCacheSrv.getColour('_freetags_:' + scope.tag) || '#3c8dbc'; $timeout(function() { angular.element(element[0]).attr('style', 'background-color:' + scope.bgColour); diff --git a/frontend/app/scripts/services/api/TagSrv.js b/frontend/app/scripts/services/api/TagSrv.js index 42016d5482..83a6057a21 100644 --- a/frontend/app/scripts/services/api/TagSrv.js +++ b/frontend/app/scripts/services/api/TagSrv.js @@ -26,6 +26,10 @@ return $http.patch('./api/v1/tag/' + id, patch); } + this.removeTag = function(id) { + return $http.delete('./api/v1/tag/' + id); + } + this.autoComplete = function(term) { var defer = $q.defer(); diff --git a/frontend/app/scripts/services/api/TaxonomyCacheSrv.js b/frontend/app/scripts/services/api/TaxonomyCacheSrv.js index 3fd425a248..9a72d87700 100644 --- a/frontend/app/scripts/services/api/TaxonomyCacheSrv.js +++ b/frontend/app/scripts/services/api/TaxonomyCacheSrv.js @@ -65,8 +65,6 @@ .then(function(freeTags) { self.cacheTagColors(freeTags); - console.log(self.cache); - deferred.resolve(self.cache); }); } else { diff --git a/frontend/app/views/components/org/custom-tags/tag-list.html b/frontend/app/views/components/org/custom-tags/tag-list.html index 83a0dd1cf2..d7f12704e7 100644 --- a/frontend/app/views/components/org/custom-tags/tag-list.html +++ b/frontend/app/views/components/org/custom-tags/tag-list.html @@ -29,7 +29,6 @@
ID |
Name
@@ -41,6 +40,9 @@
| ||||||||
---|---|---|---|---|---|---|---|---|---|
{{tag._id}} |
|
|
-
+ {{tag.extraData.usage.case}} | +{{tag.extraData.usage.alert}} | +{{tag.extraData.usage.observable}} |
|
@@ -84,10 +87,10 @@ - + + | diff --git a/frontend/app/views/partials/case/case.links.html b/frontend/app/views/partials/case/case.links.html index ff419bcfa3..5d9f9c89ea 100644 --- a/frontend/app/views/partials/case/case.links.html +++ b/frontend/app/views/partials/case/case.links.html @@ -61,7 +61,7 @@