Loading Gruntfile.js +3 −3 Original line number Diff line number Diff line Loading @@ -48,8 +48,8 @@ module.exports = function(grunt) { } }, qunit: { all: [] } all: ['./tests/all.html'] }, }); grunt.loadNpmTasks('grunt-contrib-clean'); grunt.loadNpmTasks('grunt-contrib-concat'); Loading @@ -61,5 +61,5 @@ module.exports = function(grunt) { grunt.loadNpmTasks("grunt-jscs"); grunt.registerTask('dev', ['watch']) grunt.registerTask('build', ['clean', 'copy', 'concat' ]); ['clean', 'copy', 'concat', 'qunit' ]); }; public/app.js +91 −92 Original line number Diff line number Diff line Loading @@ -14,6 +14,97 @@ angular.module('cerebro', ['ngRoute']).config(['$routeProvider', otherwise({redirectTo: '/connect'}); }]); function Page(elements, total, first, last, next, previous) { this.elements = elements; this.total = total; this.first = first; this.last = last; this.next = next; this.previous = previous; } function Paginator(page, pageSize, collection, filter) { this.filter = filter; this.page = page; this.pageSize = pageSize; this.$collection = collection ? collection : []; this.nextPage = function() { this.page += 1; }; this.previousPage = function() { this.page -= 1; }; this.setPageSize = function(newSize) { this.pageSize = newSize; }; this.getPageSize = function() { return this.pageSize; }; this.getCurrentPage = function() { return this.page; }; this.getPage = function() { var results = this.getResults(); var total = results.length; var first = total > 0 ? ((this.page - 1) * this.pageSize) + 1 : 0; while (total < first) { this.previousPage(); first = (this.page - 1) * this.pageSize + 1; } var lastPage = this.page * this.pageSize > total; var last = lastPage ? total : this.page * this.pageSize; var elements = total > 0 ? results.slice(first - 1, last) : []; var next = this.pageSize * this.page < total; var previous = this.page > 1; while (elements.length < this.pageSize) { elements.push(null); } return new Page(elements, total, first, last, next, previous); }; this.setCollection = function(collection) { if (this.filter.getSorting()) { this.$collection = collection.sort(this.filter.getSorting()); } else { this.$collection = collection; } }; this.getResults = function() { var filter = this.filter; var collection = this.$collection; if (filter.isBlank()) { return collection; } else { var filtered = []; collection.forEach(function(item) { if (filter.matches(item)) { filtered.push(item); } }); return filtered; } }; this.getCollection = function() { return this.$collection; }; } angular.module('cerebro').controller('AlertsController', ['$scope', 'AlertService', function($scope, AlertService) { Loading Loading @@ -390,98 +481,6 @@ angular.module('cerebro').directive('ngPagination', ['$document', function($docu }; }]); function Paginator(page, pageSize, collection, filter) { this.filter = filter; this.page = page; this.pageSize = pageSize; this.$collection = collection ? collection : []; this.nextPage = function() { this.page += 1; }; this.previousPage = function() { this.page -= 1; }; this.setPageSize = function(newSize) { this.pageSize = newSize; }; this.getPageSize = function() { return this.pageSize; }; this.getCurrentPage = function() { return this.page; }; this.getPage = function() { var results = this.getResults(); var total = results.length; var first = total > 0 ? ((this.page - 1) * this.pageSize) + 1 : 0; while (total < first) { this.previousPage(); first = (this.page - 1) * this.pageSize + 1; } var lastPage = this.page * this.pageSize > total; var last = lastPage ? total : this.page * this.pageSize; var elements = total > 0 ? results.slice(first - 1, last) : []; var next = this.pageSize * this.page < total; var previous = this.page > 1; while (elements.length < this.pageSize) { elements.push(null); } return new Page(elements, total, first, last, next, previous); }; this.setCollection = function(collection) { if (this.filter.getSorting()) { this.$collection = collection.sort(this.filter.getSorting()); } else { this.$collection = collection; } }; this.getResults = function() { var filter = this.filter; var collection = this.$collection; if (filter.isBlank()) { return collection; } else { var filtered = []; collection.forEach(function(item) { if (filter.matches(item)) { filtered.push(item); } }); return filtered; } }; this.getCollection = function() { return this.$collection; }; } function Page(elements, total, first, last, next, previous) { this.elements = elements; this.total = total; this.first = first; this.last = last; this.next = next; this.previous = previous; } angular.module('cerebro').directive('ngProgress', function () { Loading src/common/page.js 0 → 100644 +8 −0 Original line number Diff line number Diff line function Page(elements, total, first, last, next, previous) { this.elements = elements; this.total = total; this.first = first; this.last = last; this.next = next; this.previous = previous; } src/common/paginator.js 0 → 100644 +81 −0 Original line number Diff line number Diff line function Paginator(page, pageSize, collection, filter) { this.filter = filter; this.page = page; this.pageSize = pageSize; this.$collection = collection ? collection : []; this.nextPage = function() { this.page += 1; }; this.previousPage = function() { this.page -= 1; }; this.setPageSize = function(newSize) { this.pageSize = newSize; }; this.getPageSize = function() { return this.pageSize; }; this.getCurrentPage = function() { return this.page; }; this.getPage = function() { var results = this.getResults(); var total = results.length; var first = total > 0 ? ((this.page - 1) * this.pageSize) + 1 : 0; while (total < first) { this.previousPage(); first = (this.page - 1) * this.pageSize + 1; } var lastPage = this.page * this.pageSize > total; var last = lastPage ? total : this.page * this.pageSize; var elements = total > 0 ? results.slice(first - 1, last) : []; var next = this.pageSize * this.page < total; var previous = this.page > 1; while (elements.length < this.pageSize) { elements.push(null); } return new Page(elements, total, first, last, next, previous); }; this.setCollection = function(collection) { if (this.filter.getSorting()) { this.$collection = collection.sort(this.filter.getSorting()); } else { this.$collection = collection; } }; this.getResults = function() { var filter = this.filter; var collection = this.$collection; if (filter.isBlank()) { return collection; } else { var filtered = []; collection.forEach(function(item) { if (filter.matches(item)) { filtered.push(item); } }); return filtered; } }; this.getCollection = function() { return this.$collection; }; } src/directives/pagination.js +0 −92 Original line number Diff line number Diff line Loading @@ -34,95 +34,3 @@ angular.module('cerebro').directive('ngPagination', ['$document', function($docu } }; }]); function Paginator(page, pageSize, collection, filter) { this.filter = filter; this.page = page; this.pageSize = pageSize; this.$collection = collection ? collection : []; this.nextPage = function() { this.page += 1; }; this.previousPage = function() { this.page -= 1; }; this.setPageSize = function(newSize) { this.pageSize = newSize; }; this.getPageSize = function() { return this.pageSize; }; this.getCurrentPage = function() { return this.page; }; this.getPage = function() { var results = this.getResults(); var total = results.length; var first = total > 0 ? ((this.page - 1) * this.pageSize) + 1 : 0; while (total < first) { this.previousPage(); first = (this.page - 1) * this.pageSize + 1; } var lastPage = this.page * this.pageSize > total; var last = lastPage ? total : this.page * this.pageSize; var elements = total > 0 ? results.slice(first - 1, last) : []; var next = this.pageSize * this.page < total; var previous = this.page > 1; while (elements.length < this.pageSize) { elements.push(null); } return new Page(elements, total, first, last, next, previous); }; this.setCollection = function(collection) { if (this.filter.getSorting()) { this.$collection = collection.sort(this.filter.getSorting()); } else { this.$collection = collection; } }; this.getResults = function() { var filter = this.filter; var collection = this.$collection; if (filter.isBlank()) { return collection; } else { var filtered = []; collection.forEach(function(item) { if (filter.matches(item)) { filtered.push(item); } }); return filtered; } }; this.getCollection = function() { return this.$collection; }; } function Page(elements, total, first, last, next, previous) { this.elements = elements; this.total = total; this.first = first; this.last = last; this.next = next; this.previous = previous; } Loading
Gruntfile.js +3 −3 Original line number Diff line number Diff line Loading @@ -48,8 +48,8 @@ module.exports = function(grunt) { } }, qunit: { all: [] } all: ['./tests/all.html'] }, }); grunt.loadNpmTasks('grunt-contrib-clean'); grunt.loadNpmTasks('grunt-contrib-concat'); Loading @@ -61,5 +61,5 @@ module.exports = function(grunt) { grunt.loadNpmTasks("grunt-jscs"); grunt.registerTask('dev', ['watch']) grunt.registerTask('build', ['clean', 'copy', 'concat' ]); ['clean', 'copy', 'concat', 'qunit' ]); };
public/app.js +91 −92 Original line number Diff line number Diff line Loading @@ -14,6 +14,97 @@ angular.module('cerebro', ['ngRoute']).config(['$routeProvider', otherwise({redirectTo: '/connect'}); }]); function Page(elements, total, first, last, next, previous) { this.elements = elements; this.total = total; this.first = first; this.last = last; this.next = next; this.previous = previous; } function Paginator(page, pageSize, collection, filter) { this.filter = filter; this.page = page; this.pageSize = pageSize; this.$collection = collection ? collection : []; this.nextPage = function() { this.page += 1; }; this.previousPage = function() { this.page -= 1; }; this.setPageSize = function(newSize) { this.pageSize = newSize; }; this.getPageSize = function() { return this.pageSize; }; this.getCurrentPage = function() { return this.page; }; this.getPage = function() { var results = this.getResults(); var total = results.length; var first = total > 0 ? ((this.page - 1) * this.pageSize) + 1 : 0; while (total < first) { this.previousPage(); first = (this.page - 1) * this.pageSize + 1; } var lastPage = this.page * this.pageSize > total; var last = lastPage ? total : this.page * this.pageSize; var elements = total > 0 ? results.slice(first - 1, last) : []; var next = this.pageSize * this.page < total; var previous = this.page > 1; while (elements.length < this.pageSize) { elements.push(null); } return new Page(elements, total, first, last, next, previous); }; this.setCollection = function(collection) { if (this.filter.getSorting()) { this.$collection = collection.sort(this.filter.getSorting()); } else { this.$collection = collection; } }; this.getResults = function() { var filter = this.filter; var collection = this.$collection; if (filter.isBlank()) { return collection; } else { var filtered = []; collection.forEach(function(item) { if (filter.matches(item)) { filtered.push(item); } }); return filtered; } }; this.getCollection = function() { return this.$collection; }; } angular.module('cerebro').controller('AlertsController', ['$scope', 'AlertService', function($scope, AlertService) { Loading Loading @@ -390,98 +481,6 @@ angular.module('cerebro').directive('ngPagination', ['$document', function($docu }; }]); function Paginator(page, pageSize, collection, filter) { this.filter = filter; this.page = page; this.pageSize = pageSize; this.$collection = collection ? collection : []; this.nextPage = function() { this.page += 1; }; this.previousPage = function() { this.page -= 1; }; this.setPageSize = function(newSize) { this.pageSize = newSize; }; this.getPageSize = function() { return this.pageSize; }; this.getCurrentPage = function() { return this.page; }; this.getPage = function() { var results = this.getResults(); var total = results.length; var first = total > 0 ? ((this.page - 1) * this.pageSize) + 1 : 0; while (total < first) { this.previousPage(); first = (this.page - 1) * this.pageSize + 1; } var lastPage = this.page * this.pageSize > total; var last = lastPage ? total : this.page * this.pageSize; var elements = total > 0 ? results.slice(first - 1, last) : []; var next = this.pageSize * this.page < total; var previous = this.page > 1; while (elements.length < this.pageSize) { elements.push(null); } return new Page(elements, total, first, last, next, previous); }; this.setCollection = function(collection) { if (this.filter.getSorting()) { this.$collection = collection.sort(this.filter.getSorting()); } else { this.$collection = collection; } }; this.getResults = function() { var filter = this.filter; var collection = this.$collection; if (filter.isBlank()) { return collection; } else { var filtered = []; collection.forEach(function(item) { if (filter.matches(item)) { filtered.push(item); } }); return filtered; } }; this.getCollection = function() { return this.$collection; }; } function Page(elements, total, first, last, next, previous) { this.elements = elements; this.total = total; this.first = first; this.last = last; this.next = next; this.previous = previous; } angular.module('cerebro').directive('ngProgress', function () { Loading
src/common/page.js 0 → 100644 +8 −0 Original line number Diff line number Diff line function Page(elements, total, first, last, next, previous) { this.elements = elements; this.total = total; this.first = first; this.last = last; this.next = next; this.previous = previous; }
src/common/paginator.js 0 → 100644 +81 −0 Original line number Diff line number Diff line function Paginator(page, pageSize, collection, filter) { this.filter = filter; this.page = page; this.pageSize = pageSize; this.$collection = collection ? collection : []; this.nextPage = function() { this.page += 1; }; this.previousPage = function() { this.page -= 1; }; this.setPageSize = function(newSize) { this.pageSize = newSize; }; this.getPageSize = function() { return this.pageSize; }; this.getCurrentPage = function() { return this.page; }; this.getPage = function() { var results = this.getResults(); var total = results.length; var first = total > 0 ? ((this.page - 1) * this.pageSize) + 1 : 0; while (total < first) { this.previousPage(); first = (this.page - 1) * this.pageSize + 1; } var lastPage = this.page * this.pageSize > total; var last = lastPage ? total : this.page * this.pageSize; var elements = total > 0 ? results.slice(first - 1, last) : []; var next = this.pageSize * this.page < total; var previous = this.page > 1; while (elements.length < this.pageSize) { elements.push(null); } return new Page(elements, total, first, last, next, previous); }; this.setCollection = function(collection) { if (this.filter.getSorting()) { this.$collection = collection.sort(this.filter.getSorting()); } else { this.$collection = collection; } }; this.getResults = function() { var filter = this.filter; var collection = this.$collection; if (filter.isBlank()) { return collection; } else { var filtered = []; collection.forEach(function(item) { if (filter.matches(item)) { filtered.push(item); } }); return filtered; } }; this.getCollection = function() { return this.$collection; }; }
src/directives/pagination.js +0 −92 Original line number Diff line number Diff line Loading @@ -34,95 +34,3 @@ angular.module('cerebro').directive('ngPagination', ['$document', function($docu } }; }]); function Paginator(page, pageSize, collection, filter) { this.filter = filter; this.page = page; this.pageSize = pageSize; this.$collection = collection ? collection : []; this.nextPage = function() { this.page += 1; }; this.previousPage = function() { this.page -= 1; }; this.setPageSize = function(newSize) { this.pageSize = newSize; }; this.getPageSize = function() { return this.pageSize; }; this.getCurrentPage = function() { return this.page; }; this.getPage = function() { var results = this.getResults(); var total = results.length; var first = total > 0 ? ((this.page - 1) * this.pageSize) + 1 : 0; while (total < first) { this.previousPage(); first = (this.page - 1) * this.pageSize + 1; } var lastPage = this.page * this.pageSize > total; var last = lastPage ? total : this.page * this.pageSize; var elements = total > 0 ? results.slice(first - 1, last) : []; var next = this.pageSize * this.page < total; var previous = this.page > 1; while (elements.length < this.pageSize) { elements.push(null); } return new Page(elements, total, first, last, next, previous); }; this.setCollection = function(collection) { if (this.filter.getSorting()) { this.$collection = collection.sort(this.filter.getSorting()); } else { this.$collection = collection; } }; this.getResults = function() { var filter = this.filter; var collection = this.$collection; if (filter.isBlank()) { return collection; } else { var filtered = []; collection.forEach(function(item) { if (filter.matches(item)) { filtered.push(item); } }); return filtered; } }; this.getCollection = function() { return this.$collection; }; } function Page(elements, total, first, last, next, previous) { this.elements = elements; this.total = total; this.first = first; this.last = last; this.next = next; this.previous = previous; }