Loading public/app.js +56 −56 Original line number Diff line number Diff line Loading @@ -114,6 +114,62 @@ function IndexFilter(name, closed, special, healthy, asc, timestamp) { } function NodeFilter(name, data, master, client, timestamp) { this.name = name; this.data = data; this.master = master; this.client = client; this.timestamp = timestamp; this.clone = function() { return new NodeFilter(this.name, this.data, this.master, this.client); }; this.getSorting = function() { return undefined; }; this.equals = function(other) { return ( other !== null && this.name == other.name && this.data == other.data && this.master == other.master && this.client == other.client && this.timestamp == other.timestamp ); }; this.isBlank = function() { return !this.name && (this.data && this.master && this.client); }; this.matches = function(node) { if (this.isBlank()) { return true; } else { return this.matchesName(node.name) && this.matchesType(node); } }; this.matchesType = function(node) { return ( node.data && this.data || node.master && this.master || node.client && this.client ); }; this.matchesName = function(name) { if (this.name) { return name.toLowerCase().indexOf(this.name.toLowerCase()) != -1; } else { return true; } }; } function Page(elements, total, first, last, next, previous) { this.elements = elements; this.total = total; Loading Loading @@ -636,62 +692,6 @@ angular.module('cerebro').filter('bytes', function() { }); function NodeFilter(name, data, master, client, timestamp) { this.name = name; this.data = data; this.master = master; this.client = client; this.timestamp = timestamp; this.clone = function() { return new NodeFilter(this.name, this.data, this.master, this.client); }; this.getSorting = function() { return undefined; }; this.equals = function(other) { return ( other !== null && this.name == other.name && this.data == other.data && this.master == other.master && this.client == other.client && this.timestamp == other.timestamp ); }; this.isBlank = function() { return !this.name && (this.data && this.master && this.client); }; this.matches = function(node) { if (this.isBlank()) { return true; } else { return this.matchesName(node.name) && this.matchesType(node); } }; this.matchesType = function(node) { return ( node.data && this.data || node.master && this.master || node.client && this.client ); }; this.matchesName = function(name) { if (this.name) { return name.toLowerCase().indexOf(this.name.toLowerCase()) != -1; } else { return true; } }; } var Alert = function(message, response, level, _class, icon) { var currentDate = new Date(); this.message = message; Loading src/overview/node_filter.js→src/common/node_filter.js +0 −0 File moved. View file tests/all.html +1 −0 Original line number Diff line number Diff line Loading @@ -18,5 +18,6 @@ <!-- TESTS --> <script src="./common/paginator.js"></script> <script src="./common/index_filter.js"></script> <script src="./common/node_filter.js"></script> </body> </html> tests/common/node_filter.js 0 → 100644 +67 −0 Original line number Diff line number Diff line test("Blank node filter", function() { var filter = new NodeFilter("", true, true, true, 0); var node = { name: 'a', master: true, client: false, data: true }; ok(filter.matches(node), "Matches any node if filter is blank"); }) test("Only master node filter x non master node", function() { var filter = new NodeFilter("", false, true, false, 0); var node = { name: 'a', master: false, client: false, data: true }; ok(!filter.matches(node),"Doesnt match a non master node"); }) test("Only master node filter x master node", function() { var filter = new NodeFilter("", false, true, false, 0); var node = { name: 'a', master: true, client: false, data: true }; ok(filter.matches(node),"Matches a master node"); }) test("Only data node filter x non data node", function() { var filter = new NodeFilter("", true, false, false, 0); var node = { name: 'a', master: false, client: true, data: false }; ok(!filter.matches(node),"Doesnt match a non data node"); }) test("Only data node filter x data node", function() { var filter = new NodeFilter("", true, false, false, 0); var node = { name: 'a', master: false, client: false, data: true }; ok(filter.matches(node),"Match a data node"); }) test("Only client node filter x non client node", function() { var filter = new NodeFilter("", false, false, true, 0); var node = { name: 'a', master: false, client: false, data: true }; ok(!filter.matches(node), "Doesnt match a non client node"); }) test("Only client node filter x client node", function() { var filter = new NodeFilter("", false, false, true, 0); var node = { name: 'a', master: false, client: true, data: false }; ok(filter.matches(node),"Match a client node"); }) test("Master or client node filter x data node", function() { var filter = new NodeFilter("", false, true, true, 0); var node = { name: 'a', master: false, client: false, data: true }; ok(!filter.matches(node), "Doesnt match a non master/client node"); }) test("Master or client node filter x client node x master node", function() { var filter = new NodeFilter("", false, true, true, 0); var node = { name: 'a', master: false, client: true, data: false }; var node2 = { name: 'a', master: true, client: false, data: false }; ok(filter.matches(node),"Match a client node"); ok(filter.matches(node2),"Match a master node"); }) test("node filter with name x non matching name", function() { var filter = new NodeFilter("moli", true, true, true, 0); var node = { name: 'milo_id', master: true, client: false, data: true }; ok(!filter.matches(node),"Doesnt match if name is not a substring"); }) test("node filter with name x matching name", function() { var filter = new NodeFilter("moli", true, true, true, 0); var node = { name: 'moliware', master: true, client: false, data: true }; ok(filter.matches(node),"Matches if name is not a substring"); }) Loading
public/app.js +56 −56 Original line number Diff line number Diff line Loading @@ -114,6 +114,62 @@ function IndexFilter(name, closed, special, healthy, asc, timestamp) { } function NodeFilter(name, data, master, client, timestamp) { this.name = name; this.data = data; this.master = master; this.client = client; this.timestamp = timestamp; this.clone = function() { return new NodeFilter(this.name, this.data, this.master, this.client); }; this.getSorting = function() { return undefined; }; this.equals = function(other) { return ( other !== null && this.name == other.name && this.data == other.data && this.master == other.master && this.client == other.client && this.timestamp == other.timestamp ); }; this.isBlank = function() { return !this.name && (this.data && this.master && this.client); }; this.matches = function(node) { if (this.isBlank()) { return true; } else { return this.matchesName(node.name) && this.matchesType(node); } }; this.matchesType = function(node) { return ( node.data && this.data || node.master && this.master || node.client && this.client ); }; this.matchesName = function(name) { if (this.name) { return name.toLowerCase().indexOf(this.name.toLowerCase()) != -1; } else { return true; } }; } function Page(elements, total, first, last, next, previous) { this.elements = elements; this.total = total; Loading Loading @@ -636,62 +692,6 @@ angular.module('cerebro').filter('bytes', function() { }); function NodeFilter(name, data, master, client, timestamp) { this.name = name; this.data = data; this.master = master; this.client = client; this.timestamp = timestamp; this.clone = function() { return new NodeFilter(this.name, this.data, this.master, this.client); }; this.getSorting = function() { return undefined; }; this.equals = function(other) { return ( other !== null && this.name == other.name && this.data == other.data && this.master == other.master && this.client == other.client && this.timestamp == other.timestamp ); }; this.isBlank = function() { return !this.name && (this.data && this.master && this.client); }; this.matches = function(node) { if (this.isBlank()) { return true; } else { return this.matchesName(node.name) && this.matchesType(node); } }; this.matchesType = function(node) { return ( node.data && this.data || node.master && this.master || node.client && this.client ); }; this.matchesName = function(name) { if (this.name) { return name.toLowerCase().indexOf(this.name.toLowerCase()) != -1; } else { return true; } }; } var Alert = function(message, response, level, _class, icon) { var currentDate = new Date(); this.message = message; Loading
tests/all.html +1 −0 Original line number Diff line number Diff line Loading @@ -18,5 +18,6 @@ <!-- TESTS --> <script src="./common/paginator.js"></script> <script src="./common/index_filter.js"></script> <script src="./common/node_filter.js"></script> </body> </html>
tests/common/node_filter.js 0 → 100644 +67 −0 Original line number Diff line number Diff line test("Blank node filter", function() { var filter = new NodeFilter("", true, true, true, 0); var node = { name: 'a', master: true, client: false, data: true }; ok(filter.matches(node), "Matches any node if filter is blank"); }) test("Only master node filter x non master node", function() { var filter = new NodeFilter("", false, true, false, 0); var node = { name: 'a', master: false, client: false, data: true }; ok(!filter.matches(node),"Doesnt match a non master node"); }) test("Only master node filter x master node", function() { var filter = new NodeFilter("", false, true, false, 0); var node = { name: 'a', master: true, client: false, data: true }; ok(filter.matches(node),"Matches a master node"); }) test("Only data node filter x non data node", function() { var filter = new NodeFilter("", true, false, false, 0); var node = { name: 'a', master: false, client: true, data: false }; ok(!filter.matches(node),"Doesnt match a non data node"); }) test("Only data node filter x data node", function() { var filter = new NodeFilter("", true, false, false, 0); var node = { name: 'a', master: false, client: false, data: true }; ok(filter.matches(node),"Match a data node"); }) test("Only client node filter x non client node", function() { var filter = new NodeFilter("", false, false, true, 0); var node = { name: 'a', master: false, client: false, data: true }; ok(!filter.matches(node), "Doesnt match a non client node"); }) test("Only client node filter x client node", function() { var filter = new NodeFilter("", false, false, true, 0); var node = { name: 'a', master: false, client: true, data: false }; ok(filter.matches(node),"Match a client node"); }) test("Master or client node filter x data node", function() { var filter = new NodeFilter("", false, true, true, 0); var node = { name: 'a', master: false, client: false, data: true }; ok(!filter.matches(node), "Doesnt match a non master/client node"); }) test("Master or client node filter x client node x master node", function() { var filter = new NodeFilter("", false, true, true, 0); var node = { name: 'a', master: false, client: true, data: false }; var node2 = { name: 'a', master: true, client: false, data: false }; ok(filter.matches(node),"Match a client node"); ok(filter.matches(node2),"Match a master node"); }) test("node filter with name x non matching name", function() { var filter = new NodeFilter("moli", true, true, true, 0); var node = { name: 'milo_id', master: true, client: false, data: true }; ok(!filter.matches(node),"Doesnt match if name is not a substring"); }) test("node filter with name x matching name", function() { var filter = new NodeFilter("moli", true, true, true, 0); var node = { name: 'moliware', master: true, client: false, data: true }; ok(filter.matches(node),"Matches if name is not a substring"); })