2010-10-20 20:11:15 +02:00
|
|
|
/*
|
|
|
|
|
|
|
|
Copyright 2010, Google Inc.
|
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
modification, are permitted provided that the following conditions are
|
|
|
|
met:
|
|
|
|
|
2011-08-04 22:37:14 +02:00
|
|
|
* Redistributions of source code must retain the above copyright
|
2010-10-20 20:11:15 +02:00
|
|
|
notice, this list of conditions and the following disclaimer.
|
2011-08-04 22:37:14 +02:00
|
|
|
* Redistributions in binary form must reproduce the above
|
2010-10-20 20:11:15 +02:00
|
|
|
copyright notice, this list of conditions and the following disclaimer
|
|
|
|
in the documentation and/or other materials provided with the
|
|
|
|
distribution.
|
2011-08-04 22:37:14 +02:00
|
|
|
* Neither the name of Google Inc. nor the names of its
|
2010-10-20 20:11:15 +02:00
|
|
|
contributors may be used to endorse or promote products derived from
|
|
|
|
this software without specific prior written permission.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
2011-08-04 22:37:14 +02:00
|
|
|
*/
|
2010-10-20 20:11:15 +02:00
|
|
|
|
2010-08-09 03:13:57 +02:00
|
|
|
DataTableColumnHeaderUI.extendMenu(function(column, columnHeaderUI, menu) {
|
2011-08-04 22:37:14 +02:00
|
|
|
var doFilterByExpressionPrompt = function(expression, type) {
|
|
|
|
DataTableView.promptExpressionOnVisibleRows(
|
|
|
|
column,
|
2018-11-21 16:24:57 +01:00
|
|
|
(type == "list" ? $.i18n._('core-views/custom-facet') : $.i18n._('core-views/custom-numeric-label')) +" "+ column.name,
|
2011-08-04 22:37:14 +02:00
|
|
|
expression,
|
|
|
|
function(expression) {
|
|
|
|
var config = {
|
|
|
|
"name" : column.name,
|
|
|
|
"columnName" : column.name,
|
|
|
|
"expression" : expression
|
|
|
|
};
|
|
|
|
if (type == "range") {
|
|
|
|
config.mode = "range";
|
|
|
|
}
|
|
|
|
|
|
|
|
ui.browsingEngine.addFacet(type, config);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
};
|
2010-08-09 03:13:57 +02:00
|
|
|
|
2011-08-04 22:37:14 +02:00
|
|
|
MenuSystem.appendTo(menu, [ "core/facet" ], [
|
|
|
|
{
|
|
|
|
id: "core/text-facet",
|
2018-11-21 16:24:57 +01:00
|
|
|
label: $.i18n._('core-views/text-facet'),
|
2011-08-04 22:37:14 +02:00
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"list",
|
|
|
|
{
|
|
|
|
"name": column.name,
|
|
|
|
"columnName": column.name,
|
|
|
|
"expression": "value"
|
2010-08-09 03:13:57 +02:00
|
|
|
}
|
|
|
|
);
|
2011-08-04 22:37:14 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "core/numeric-facet",
|
2018-11-21 16:24:57 +01:00
|
|
|
label: $.i18n._('core-views/numeric-facet'),
|
2011-08-04 22:37:14 +02:00
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"range",
|
|
|
|
{
|
|
|
|
"name": column.name,
|
|
|
|
"columnName": column.name,
|
|
|
|
"expression": "value",
|
|
|
|
"mode": "range"
|
2010-08-09 03:13:57 +02:00
|
|
|
}
|
2011-08-04 22:37:14 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "core/time-facet",
|
2018-11-21 16:24:57 +01:00
|
|
|
label: $.i18n._('core-views/timeline-facet'),
|
2011-08-04 22:37:14 +02:00
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"timerange",
|
|
|
|
{
|
|
|
|
"name": column.name,
|
|
|
|
"columnName": column.name,
|
|
|
|
"expression": "value",
|
|
|
|
"mode": "range"
|
2010-08-31 19:57:54 +02:00
|
|
|
}
|
2011-08-04 22:37:14 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "core/scatterplot-facet",
|
2018-11-21 16:24:57 +01:00
|
|
|
label: $.i18n._('core-views/scatterplot-facet'),
|
2011-08-04 22:37:14 +02:00
|
|
|
click: function() {
|
|
|
|
new ScatterplotDialog(column.name);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
id: "core/custom-text-facet",
|
2018-11-21 16:24:57 +01:00
|
|
|
label: $.i18n._('core-views/custom-text-facet')+'...',
|
2011-08-04 22:37:14 +02:00
|
|
|
click: function() {
|
|
|
|
doFilterByExpressionPrompt(null, "list");
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "core/custom-numeric-facet",
|
2018-11-21 16:24:57 +01:00
|
|
|
label: $.i18n._('core-views/custom-numeric')+'...',
|
2011-08-04 22:37:14 +02:00
|
|
|
click: function() {
|
|
|
|
doFilterByExpressionPrompt(null, "range");
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "core/customized-facets",
|
2018-11-21 16:24:57 +01:00
|
|
|
label: $.i18n._('core-views/custom-facets'),
|
2011-08-04 22:37:14 +02:00
|
|
|
submenu: [
|
2010-08-31 19:57:54 +02:00
|
|
|
{
|
2011-08-04 22:37:14 +02:00
|
|
|
id: "core/word-facet",
|
2018-11-21 16:24:57 +01:00
|
|
|
label: $.i18n._('core-views/word-facet'),
|
2011-08-04 22:37:14 +02:00
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"list",
|
|
|
|
{
|
|
|
|
"name": column.name,
|
|
|
|
"columnName": column.name,
|
|
|
|
"expression": "value.split(' ')"
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2010-08-09 03:13:57 +02:00
|
|
|
},
|
2011-08-04 22:37:14 +02:00
|
|
|
{},
|
2010-08-09 03:13:57 +02:00
|
|
|
{
|
2011-08-04 22:37:14 +02:00
|
|
|
id: "core/duplicates-facet",
|
2018-11-21 16:24:57 +01:00
|
|
|
label: $.i18n._('core-views/duplicates-facet'),
|
2011-08-04 22:37:14 +02:00
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"list",
|
|
|
|
{
|
|
|
|
"name": column.name,
|
|
|
|
"columnName": column.name,
|
|
|
|
"expression": "facetCount(value, 'value', '" +
|
|
|
|
column.name + "') > 1"
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2010-08-09 03:13:57 +02:00
|
|
|
},
|
|
|
|
{},
|
|
|
|
{
|
2011-08-04 22:37:14 +02:00
|
|
|
id: "core/numeric-log-facet",
|
2018-11-21 16:24:57 +01:00
|
|
|
label: $.i18n._('core-views/numeric-log-facet'),
|
2011-08-04 22:37:14 +02:00
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"range",
|
|
|
|
{
|
|
|
|
"name": column.name,
|
|
|
|
"columnName": column.name,
|
|
|
|
"expression": "value.log()",
|
|
|
|
"mode": "range"
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2010-08-09 03:13:57 +02:00
|
|
|
},
|
|
|
|
{
|
2011-08-04 22:37:14 +02:00
|
|
|
id: "core/bounded-numeric-log-facet",
|
2018-11-21 16:24:57 +01:00
|
|
|
label: $.i18n._('core-views/bounded-log-facet'),
|
2011-08-04 22:37:14 +02:00
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"range",
|
|
|
|
{
|
|
|
|
"name": column.name,
|
|
|
|
"columnName": column.name,
|
|
|
|
"expression": "log(max(1, value))",
|
|
|
|
"mode": "range"
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2010-08-09 03:13:57 +02:00
|
|
|
},
|
2011-08-04 22:37:14 +02:00
|
|
|
{},
|
2010-08-09 03:13:57 +02:00
|
|
|
{
|
2011-08-04 22:37:14 +02:00
|
|
|
id: "core/text-length-facet",
|
2018-11-21 16:24:57 +01:00
|
|
|
label: $.i18n._('core-views/text-length-facet'),
|
2011-08-04 22:37:14 +02:00
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"range",
|
2010-08-09 03:13:57 +02:00
|
|
|
{
|
2011-08-04 22:37:14 +02:00
|
|
|
"name": column.name,
|
|
|
|
"columnName": column.name,
|
|
|
|
"expression": "value.length()",
|
|
|
|
"mode": "range"
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "core/log-text-length-facet",
|
2018-11-21 16:24:57 +01:00
|
|
|
label: $.i18n._('core-views/log-length-facet'),
|
2011-08-04 22:37:14 +02:00
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"range",
|
2010-08-09 03:13:57 +02:00
|
|
|
{
|
2011-08-04 22:37:14 +02:00
|
|
|
"name": column.name,
|
|
|
|
"columnName": column.name,
|
|
|
|
"expression": "value.length().log()",
|
|
|
|
"mode": "range"
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "core/unicode-charcode-facet",
|
2018-11-21 16:24:57 +01:00
|
|
|
label: $.i18n._('core-views/unicode-facet'),
|
2011-08-04 22:37:14 +02:00
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"range",
|
2010-08-09 03:13:57 +02:00
|
|
|
{
|
2011-08-04 22:37:14 +02:00
|
|
|
"name": column.name,
|
|
|
|
"columnName": column.name,
|
|
|
|
"expression": "value.unicode()",
|
|
|
|
"mode": "range"
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
id: "core/error-facet",
|
2018-11-21 16:24:57 +01:00
|
|
|
label: $.i18n._('core-views/facet-error'),
|
2011-08-04 22:37:14 +02:00
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"list",
|
2010-08-09 03:13:57 +02:00
|
|
|
{
|
2011-08-04 22:37:14 +02:00
|
|
|
"name": column.name,
|
|
|
|
"columnName": column.name,
|
|
|
|
"expression": "isError(value)"
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2018-03-16 16:05:00 +01:00
|
|
|
id: "core/null-facet",
|
2018-11-21 16:24:57 +01:00
|
|
|
label: $.i18n._('core-views/facet-null'),
|
2011-08-04 22:37:14 +02:00
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"list",
|
2010-08-09 03:13:57 +02:00
|
|
|
{
|
2011-08-04 22:37:14 +02:00
|
|
|
"name": column.name,
|
|
|
|
"columnName": column.name,
|
2018-03-16 16:05:00 +01:00
|
|
|
"expression": "isNull(value)"
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "core/empty-string-facet",
|
2018-11-21 16:24:57 +01:00
|
|
|
label: $.i18n._('core-views/facet-empty-string'),
|
2018-03-16 16:05:00 +01:00
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"list",
|
|
|
|
{
|
|
|
|
"name": column.name,
|
|
|
|
"columnName": column.name,
|
|
|
|
"expression": "isEmptyString(value)"
|
2010-08-09 03:13:57 +02:00
|
|
|
}
|
2011-08-04 22:37:14 +02:00
|
|
|
);
|
|
|
|
}
|
2018-03-17 15:28:38 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "core/blank-facet",
|
2018-11-21 16:24:57 +01:00
|
|
|
label: $.i18n._('core-views/facet-blank'),
|
2018-03-17 15:28:38 +01:00
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"list",
|
|
|
|
{
|
|
|
|
"name": column.name,
|
|
|
|
"columnName": column.name,
|
|
|
|
"expression": "isBlank(value)"
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2010-08-09 03:13:57 +02:00
|
|
|
}
|
2011-08-04 22:37:14 +02:00
|
|
|
]
|
|
|
|
}
|
|
|
|
]);
|
|
|
|
|
|
|
|
MenuSystem.insertAfter(menu, [ "core/facet" ], [
|
|
|
|
{
|
2018-11-21 16:24:57 +01:00
|
|
|
label: $.i18n._('core-views/text-filter'),
|
2011-08-04 22:37:14 +02:00
|
|
|
click: function() {
|
|
|
|
ui.browsingEngine.addFacet(
|
|
|
|
"text",
|
|
|
|
{
|
|
|
|
"name" : column.name,
|
|
|
|
"columnName" : column.name,
|
|
|
|
"mode" : "text",
|
|
|
|
"caseSensitive" : false
|
2010-08-09 03:13:57 +02:00
|
|
|
}
|
2011-08-04 22:37:14 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]);
|
2010-08-09 03:13:57 +02:00
|
|
|
});
|