diff --git a/frontend/app/index.html b/frontend/app/index.html index a69b9fbf07..58448256be 100644 --- a/frontend/app/index.html +++ b/frontend/app/index.html @@ -149,6 +149,7 @@ + diff --git a/frontend/app/scripts/components/organisation/OrgCustomTagsListCmp.js b/frontend/app/scripts/components/organisation/OrgCustomTagsListCmp.js new file mode 100644 index 0000000000..306008d0a9 --- /dev/null +++ b/frontend/app/scripts/components/organisation/OrgCustomTagsListCmp.js @@ -0,0 +1,233 @@ +(function() { + 'use strict'; + + angular.module('theHiveComponents') + .component('orgCustomTagsList', { + controller: function($uibModal, $scope, PaginatedQuerySrv, FilteringSrv, UserSrv, NotificationSrv, ModalUtilsSrv) { + var self = this; + + self.tags = []; + self.getUserInfo = UserSrv.getCache; + + this.$onInit = function() { + // TODO: FIXME + self.filtering = new FilteringSrv('taxonomy', 'custom-tags.list', { + version: 'v1', + defaults: { + showFilters: true, + showStats: false, + pageSize: 15, + sort: ['+predicate'] + }, + defaultFilter: [] + }); + + self.filtering.initContext(self.organisation.name) + .then(function() { + self.load(); + + $scope.$watch('$vm.list.pageSize', function (newValue) { + self.filtering.setPageSize(newValue); + }); + }); + }; + + this.load = function() { + + self.list = new PaginatedQuerySrv({ + name: 'organisation-custom-tags', + version: 'v1', + skipStream: true, + sort: self.filtering.context.sort, + loadAll: false, + pageSize: self.filtering.context.pageSize, + filter: this.filtering.buildQuery(), + operations: [ + { + '_name': 'listTag' + }, + { + '_name': 'freetags' + } + ], + onFailure: function(err) { + if(err && err.status === 400) { + self.filtering.resetContext(); + self.load(); + } + } + }); + }; + + // Filtering + this.toggleFilters = function () { + this.filtering.toggleFilters(); + }; + + this.filter = function () { + self.filtering.filter().then(this.applyFilters); + }; + + this.clearFilters = function () { + this.filtering.clearFilters() + .then(self.search); + }; + + this.removeFilter = function (index) { + self.filtering.removeFilter(index) + .then(self.search); + }; + + this.search = function () { + self.load(); + self.filtering.storeContext(); + }; + this.addFilterValue = function (field, value) { + this.filtering.addFilterValue(field, value); + this.search(); + }; + + this.filterBy = function(field, value) { + self.filtering.clearFilters() + .then(function(){ + self.addFilterValue(field, value); + }); + }; + + this.sortBy = function(sort) { + self.list.sort = sort; + self.list.update(); + self.filtering.setSort(sort); + }; + + this.sortByField = function(field) { + var context = this.filtering.context; + var currentSort = Array.isArray(context.sort) ? context.sort[0] : context.sort; + var sort = null; + + if(currentSort.substr(1) !== field) { + sort = ['+' + field]; + } else { + sort = [(currentSort === '+' + field) ? '-'+field : '+'+field]; + } + + self.list.sort = sort; + 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', + bindings: { + organisation: '<', + templates: '=', + fields: '<', + onReload: '&', + onEdit: '&' + } + }); +})(); diff --git a/frontend/app/views/components/org/case-template/case-templates.html b/frontend/app/views/components/org/case-template/case-templates.html index 7df3821857..cfb55ea068 100644 --- a/frontend/app/views/components/org/case-template/case-templates.html +++ b/frontend/app/views/components/org/case-template/case-templates.html @@ -62,13 +62,20 @@

Custom Fields By - - - Creation Date - - - - + + Dates + + C. + + + + + + U. + + + + Actions @@ -108,10 +115,11 @@

-
- - {{template._createdAt | shortDate}} - +
+ C. {{template._createdAt | shortDate}} +
+
+ U. {{template._updatedAt | shortDate}}
diff --git a/frontend/app/views/components/org/custom-tags/filters.html b/frontend/app/views/components/org/custom-tags/filters.html new file mode 100644 index 0000000000..12c948d197 --- /dev/null +++ b/frontend/app/views/components/org/custom-tags/filters.html @@ -0,0 +1,39 @@ +
+
+

Filters

+ +
+
+
+
+ + + + +
+
+
+ +
+
+
+ +
+
+ +
+
diff --git a/frontend/app/views/components/org/custom-tags/tag-list.html b/frontend/app/views/components/org/custom-tags/tag-list.html new file mode 100644 index 0000000000..90048464ac --- /dev/null +++ b/frontend/app/views/components/org/custom-tags/tag-list.html @@ -0,0 +1,98 @@ +
+ +
+ + +
+
+
+

+ Custom tags List ({{$vm.list.values.length || 0}} of {{$vm.list.total}}) +

+
+ + +
+
+ + +
+
+
No records
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
+ + Name + + + + + + Colour + By + Dates + + + C. + + + + + + U. + + + + + Actions
+ {{tag.predicate}} + + {{tag.colour}} + + + + + + + + + + + + +
+ + +
+
diff --git a/frontend/app/views/components/org/custom-tags/toolbar.html b/frontend/app/views/components/org/custom-tags/toolbar.html new file mode 100644 index 0000000000..aaf3ea782e --- /dev/null +++ b/frontend/app/views/components/org/custom-tags/toolbar.html @@ -0,0 +1,16 @@ +
+
+ +
+
diff --git a/frontend/app/views/partials/admin/organisation/details.html b/frontend/app/views/partials/admin/organisation/details.html index 2407dc9dda..6859dd9a96 100644 --- a/frontend/app/views/partials/admin/organisation/details.html +++ b/frontend/app/views/partials/admin/organisation/details.html @@ -125,7 +125,18 @@

- + + + + + Custom Tags + + +
+ +
+
+