From 8ffe780ab2c326404b4e190f95c42370af6848ef Mon Sep 17 00:00:00 2001 From: simon987 Date: Thu, 25 Jun 2020 20:11:30 -0400 Subject: [PATCH] Tag tree fix for #64, validate required argument in exec-script --- src/cli.c | 5 +++ src/index/elastic.c | 7 +---- src/main.c | 2 +- src/static/css/dark.css | 4 +++ src/static/css/light.css | 4 +++ src/static/js/5_inspire-tree.min.js | 2 +- src/static/js/dom.js | 2 +- src/static/js/search.js | 47 +++++++++++++++++++++++++++-- src/static/search.html | 2 +- src/static/stats.html | 2 +- src/web/static_generated.c | 12 ++++---- 11 files changed, 70 insertions(+), 19 deletions(-) diff --git a/src/cli.c b/src/cli.c index 8c24f5a..e597a31 100644 --- a/src/cli.c +++ b/src/cli.c @@ -367,6 +367,11 @@ web_args_t *web_args_create() { int exec_args_validate(exec_args_t *args, int argc, const char **argv) { + if (argc < 2) { + fprintf(stderr, "Required positional argument: PATH.\n"); + return 1; + } + char *index_path = abspath(argv[1]); if (index_path == NULL) { fprintf(stderr, "File not found: %s\n", argv[1]); diff --git a/src/index/elastic.c b/src/index/elastic.c index 1e5e776..dc1ea17 100644 --- a/src/index/elastic.c +++ b/src/index/elastic.c @@ -261,18 +261,13 @@ void destroy_indexer(char *script, char index_id[UUID_STR_LEN]) { char url[4096]; - snprintf(url, sizeof(url), "%s/sist2/_refresh", IndexCtx.es_url); - response_t *r = web_post(url, ""); - LOG_INFOF("elastic.c", "Refresh index <%d>", r->status_code); - free_response(r); - if (script != NULL) { execute_update_script(script, index_id); free(script); } snprintf(url, sizeof(url), "%s/sist2/_refresh", IndexCtx.es_url); - r = web_post(url, ""); + response_t *r = web_post(url, ""); LOG_INFOF("elastic.c", "Refresh index <%d>", r->status_code); free_response(r); diff --git a/src/main.c b/src/main.c index a851022..1dd9add 100644 --- a/src/main.c +++ b/src/main.c @@ -21,7 +21,7 @@ #define EPILOG "Made by simon987 . Released under GPL-3.0" -static const char *const Version = "2.5.0"; +static const char *const Version = "2.5.1"; static const char *const usage[] = { "sist2 scan [OPTION]... PATH", "sist2 index [OPTION]... INDEX", diff --git a/src/static/css/dark.css b/src/static/css/dark.css index b947bb3..301e135 100644 --- a/src/static/css/dark.css +++ b/src/static/css/dark.css @@ -512,3 +512,7 @@ svg { #graphs-card svg text { fill: #eee; } + +.wholerow { + outline: none !important; +} diff --git a/src/static/css/light.css b/src/static/css/light.css index fa9e1e4..68a3dbf 100644 --- a/src/static/css/light.css +++ b/src/static/css/light.css @@ -375,3 +375,7 @@ mark { float: right; margin-bottom: 10px; } + +.wholerow { + outline: none !important; +} diff --git a/src/static/js/5_inspire-tree.min.js b/src/static/js/5_inspire-tree.min.js index f8e29d0..a4fa764 100644 --- a/src/static/js/5_inspire-tree.min.js +++ b/src/static/js/5_inspire-tree.min.js @@ -13,4 +13,4 @@ * See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE * @version v4.2.8+1e68dce6 */ - e.exports=function(){function c(e){return"function"==typeof e}var n=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},i=0,t=void 0,r=void 0,o=function(e,t){d[i]=e,d[i+1]=t,2===(i+=2)&&(r?r(f):v())};var e="undefined"!=typeof window?window:void 0,s=e||{},a=s.MutationObserver||s.WebKitMutationObserver,u="undefined"==typeof self&&"undefined"!=typeof process&&"[object process]"==={}.toString.call(process),l="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function h(){var e=setTimeout;return function(){return e(f,1)}}var d=new Array(1e3);function f(){for(var e=0;ee.length&&(o.children._pagination.total=c.parseInt(t)),"checkbox"===o._tree.config.selection.mode&&o.selected()&&o.children.select(),o.markDirty(),o.context().end(),i(o.children),o._tree.emit("children.loaded",o)}function t(e){o.state("loading",!1),o.children=new g(o._tree),(o.children._context=o).markDirty(),o.context().applyChanges(),r(e),o._tree.emit("tree.loaderror",e)}var n=o._tree.constructor.isTreeNodes(o.children)?o.children.pagination():null,s=o._tree.config.data(o,e,t,n);c.isObject(s)&&m(s).then(e).catch(t)})}},{key:"loading",value:function(){return this.state("loading")}},{key:"loadMore",value:function(){return this.children&&!0!==this.children?this.children.loadMore():f.reject(new Error("Children have not yet been loaded."))}},{key:"markDirty",value:function(){return this.itree.dirty||(this.itree.dirty=!0,this.hasParent()&&this.getParent().markDirty()),this}},{key:"matched",value:function(){return this.state("matched")}},{key:"nextVisibleAncestralSiblingNode",value:function(){var e;if(this.hasParent()){var t=this.getParent();e=(e=t.nextVisibleSiblingNode())||t.nextVisibleAncestralSiblingNode()}return e}},{key:"nextVisibleChildNode",value:function(){var e;return this.hasChildren()&&(e=c.find(this.children,function(e){return e.visible()})),e}},{key:"nextVisibleNode",value:function(){return this.nextVisibleChildNode()||this.nextVisibleSiblingNode()||this.nextVisibleAncestralSiblingNode()}},{key:"nextVisibleSiblingNode",value:function(){var e=this.hasParent()?this.getParent().children:this._tree.nodes(),t=c.findIndex(e,{id:this.id});return c.find(c.slice(e,t+1),function(e){return e.visible()})}},{key:"pagination",value:function(){return c.get(this,"children._pagination")}},{key:"previousVisibleNode",value:function(){var e;return(e=this.previousVisibleSiblingNode())&&e.hasChildren()&&!e.collapsed()&&(e=e.lastDeepestVisibleChild()),!e&&this.hasParent()&&(e=this.getParent()),e}},{key:"previousVisibleSiblingNode",value:function(){var e=this.hasParent()?this.getParent().children:this._tree.nodes(),t=c.findIndex(e,{id:this.id});return c.findLast(c.slice(e,0,t),function(e){return e.visible()})}},{key:"recurseDown",value:function(e){return _(this,e),this}},{key:"recurseUp",value:function(e){return!1!==e(this)&&this.hasParent()&&this.getParent().recurseUp(e),this}},{key:"refreshIndeterminateState",value:function(){var e=this.indeterminate();if(this.state("indeterminate",!1),this.hasChildren()){var t=this.children.length,n=0,i=0;this.children.each(function(e){e.checked()&&i++,e.indeterminate()&&n++}),i===t?o("checked",!0,"checked",this):o("checked",!1,"unchecked",this),this.checked()||this.state("indeterminate",0>>((3&t)<<3)&255;return i}}}),D=[],A=0;A<256;++A)D[A]=(A+256).toString(16).substr(1);var L=function(e,t){var n=t||0,i=D;return[i[e[n++]],i[e[n++]],i[e[n++]],i[e[n++]],"-",i[e[n++]],i[e[n++]],"-",i[e[n++]],i[e[n++]],"-",i[e[n++]],i[e[n++]],"-",i[e[n++]],i[e[n++]],i[e[n++]],i[e[n++]],i[e[n++]],i[e[n++]]].join("")};var P=function(e,t,n){var i=t&&n||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var r=(e=e||{}).random||(e.rng||x)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t)for(var s=0;s<16;++s)t[i+s]=r[s];return t||L(r)};function C(t,n,e){n.id=n.id||P(),"string"!=typeof n.id&&"number"!=typeof n.id&&(n.id=n.id.toString());var i=n.itree=n.itree||{};i.icon=i.icon||!1,i.dirty=!1;var r=i.li=i.li||{};r.attributes=r.attributes||{};var s=i.a=i.a||{};s.attributes=s.attributes||{};var o=i.state=i.state||{};return o.collapsed="boolean"==typeof o.collapsed?o.collapsed:t.defaultState.collapsed,o.selectable="boolean"==typeof o.selectable?o.selectable:t.defaultState.selectable,o.draggable="boolean"==typeof o.draggable?o.draggable:t.defaultState.draggable,o["drop-target"]="boolean"==typeof o["drop-target"]?o["drop-target"]:t.defaultState["drop-target"],o.checked="boolean"==typeof o.checked&&o.checked,o.editable="boolean"==typeof o.editable?o.editable:t.defaultState.editable,o.editing="boolean"==typeof o.editing?o.editing:t.defaultState.editing,o.focused=o.focused||t.defaultState.focused,o.hidden=o.hidden||t.defaultState.hidden,o.indeterminate=o.indeterminate||t.defaultState.indeterminate,o.loading=o.loading||t.defaultState.loading,o.removed=o.removed||t.defaultState.removed,o.rendered=o.rendered||t.defaultState.rendered,o.selected=o.selected||t.defaultState.selected,n.itree.parent=e,n=c.assign(new w(t),n),c.isArrayLike(n.children)&&(n.children=S(t,n.children,n)),t.allowsLoadEvents&&c.each(t.config.allowLoadEvents,function(e){o[e]&&t.emit("node."+e,n,!0)}),n}function S(t,e,n){var i=new g(t,null,{calculateRenderablePositions:!0});return i.batch(),t.config.sort&&(e=c.sortBy(e,t.config.sort)),c.each(e,function(e){i.push(C(t,e,n))}),i._context=n,i.end(),i}var O=d(function(e,t){function u(){this._events={},this._conf&&n.call(this,this._conf)}function n(e){e?((this._conf=e).delimiter&&(this.delimiter=e.delimiter),this._maxListeners=e.maxListeners!==l?e.maxListeners:r,e.wildcard&&(this.wildcard=e.wildcard),e.newListener&&(this._newListener=e.newListener),e.removeListener&&(this._removeListener=e.removeListener),e.verboseMemoryLeak&&(this.verboseMemoryLeak=e.verboseMemoryLeak),this.wildcard&&(this.listenerTree={})):this._maxListeners=r}function o(e,t){var n="(node) warning: possible EventEmitter memory leak detected. "+e+" listeners added. Use emitter.setMaxListeners() to increase limit.";if(this.verboseMemoryLeak&&(n+=" Event name: "+t+"."),"undefined"!=typeof process&&process.emitWarning){var i=new Error(n);i.name="MaxListenersExceededWarning",i.emitter=this,i.count=e,process.emitWarning(i)}else console.error(n),console.trace&&console.trace()}function i(e){this._events={},this._newListener=!1,this._removeListener=!1,this.verboseMemoryLeak=!1,n.call(this,e)}function y(e,t,n,i){if(!n)return[];var r,s,o,a,c,u,l,h=[],d=t.length,f=t[i],v=t[i+1];if(i===d&&n._listeners){if("function"==typeof n._listeners)return e&&e.push(n._listeners),[n];for(r=0,s=n._listeners.length;rthis._maxListeners&&(r._listeners.warned=!0,o.call(this,r._listeners.length,s))):r._listeners=t,!0;s=e.shift()}return!0}.call(this,e,t):this._events[e]?("function"==typeof this._events[e]&&(this._events[e]=[this._events[e]]),n?this._events[e].unshift(t):this._events[e].push(t),!this._events[e].warned&&0this._maxListeners&&(this._events[e].warned=!0,o.call(this,this._events[e].length,e))):this._events[e]=t,this},i.prototype.off=function(e,t){if("function"!=typeof t)throw new Error("removeListener only takes instances of Function");var n,i=[];if(this.wildcard){var r="string"==typeof e?e.split(this.delimiter):e.slice();i=y.call(this,null,r,this.listenerTree,0)}else{if(!this._events[e])return this;n=this._events[e],i.push({_listeners:n})}for(var s=0;se.length&&(o.model._pagination.total=c.parseInt(t)),t||o.model.recurseDown(function(e){e.hasChildren()&&(e.children._pagination.total=e.children.length)}),o.config.selection.require&&!o.selected().length&&o.selectFirstAvailableNode(),!o.initialized&&c.isArray(e)?setTimeout(i):i()}if(c.isArrayLike(n))e(n);else if(c.isFunction(n)){var t=n(null,e,s,o.pagination());t&&(n=t)}c.isObject(n)?m(n).then(e).catch(s):s(new Error("Invalid data loader."))});return e.catch(function(e){o.emit("data.loaderror",e)}),this._loader={promise:e},e}},{key:"loading",value:function(){return N(this,"loading",arguments)}},{key:"loadMore",value:function(){return N(this,"loadMore",arguments)}},{key:"map",value:function(){return N(this,"map",arguments)}},{key:"matched",value:function(){return N(this,"matched",arguments)}},{key:"move",value:function(){return N(this,"move",arguments)}},{key:"mute",value:function(e){return c.isString(e)||c.isArray(e)?this._muted=c.castArray(e):this._muted=!0,this}},{key:"muted",value:function(){return this._muted}},{key:"node",value:function(){return N(this,"node",arguments)}},{key:"nodes",value:function(){return N(this,"nodes",arguments)}},{key:"pagination",value:function(){return N(this,"pagination",arguments)}},{key:"pop",value:function(){return N(this,"pop",arguments)}},{key:"push",value:function(){return N(this,"push",arguments)}},{key:"recurseDown",value:function(){return N(this,"recurseDown",arguments)}},{key:"reduce",value:function(){return N(this,"reduce",arguments)}},{key:"reduceRight",value:function(){return N(this,"reduceRight",arguments)}},{key:"reload",value:function(){return this.reset(),this.load(this.opts.data||this.config.data)}},{key:"remove",value:function(){return N(this,"remove",arguments)}},{key:"removeAll",value:function(){return this.reset().applyChanges(),this}},{key:"removed",value:function(){return N(this,"removed",arguments)}},{key:"reset",value:function(){return this.model=new g(this),this}},{key:"restore",value:function(){return N(this,"restore",arguments)}},{key:"restoreDeep",value:function(){return N(this,"restoreDeep",arguments)}},{key:"reverse",value:function(){return N(this,"reverse",arguments)}},{key:"search",value:function(n){var r=this,e=this.config.search,i=e.matcher,s=e.matchProcessor;return!n||c.isString(n)&&c.isEmpty(n)?f.resolve(this.clearSearch()):(this.batch(),this.recurseDown(function(e){e.state("hidden",!0),e.state("matched",!1)}),this.end(),i=c.isFunction(i)?i:function(t,e){var n,i=new g(r);c.isString(t)&&(t=new RegExp(t,"i")),n=c.isRegExp(t)?function(e){return t.test(e.text)}:t,r.model.recurseDown(function(e){e.removed()||n(e)&&i.push(e)}),e(i)},s=c.isFunction(s)?s:function(e){e.each(function(e){e.show().state("matched",!0),e.expandParents().collapse(),e.hasChildren()&&e.children.showDeep()})},new f(function(t,e){i(n,function(e){o.isTreeNodes(e)||(e=r.nodes(c.map(e,"id"))),r.batch(),s(e),r.end(),t(e)},e)}))}},{key:"select",value:function(){return N(this,"select",arguments)}},{key:"selectable",value:function(){return N(this,"selectable",arguments)}},{key:"selectBetween",value:function(e,t){this.batch();for(var n=e.nextVisibleNode();n.id!==t.id;)n.select(),n=n.nextVisibleNode();return this.end(),this}},{key:"selectDeep",value:function(){return N(this,"selectDeep",arguments)}},{key:"selected",value:function(){return N(this,"selected",arguments)}},{key:"selectFirstAvailableNode",value:function(){var e=this.model.filterBy("available").get(0);return e&&e.select(),e}},{key:"shift",value:function(){return N(this,"shift",arguments)}},{key:"show",value:function(){return N(this,"show",arguments)}},{key:"showDeep",value:function(){return N(this,"showDeep",arguments)}},{key:"slice",value:function(){return N(this,"slice",arguments)}},{key:"softRemove",value:function(){return N(this,"softRemove",arguments)}},{key:"some",value:function(){return N(this,"some",arguments)}},{key:"sort",value:function(){return N(this,"sort",arguments)}},{key:"sortBy",value:function(){return N(this,"sortBy",arguments)}},{key:"sortDeep",value:function(){return N(this,"sortDeep",arguments)}},{key:"splice",value:function(){return N(this,"slice",arguments)}},{key:"state",value:function(){return N(this,"state",arguments)}},{key:"stateDeep",value:function(){return N(this,"stateDeep",arguments)}},{key:"swap",value:function(){return N(this,"swap",arguments)}},{key:"toArray",value:function(){return N(this,"toArray",arguments)}},{key:"toString",value:function(){return N(this,"toString",arguments)}},{key:"unmute",value:function(e){return c.isString(e)||c.isArray(e)?(this._muted=c.difference(this._muted,c.castArray(e)),this._muted.length||(this._muted=!1)):this._muted=!1,this}},{key:"unshift",value:function(){return N(this,"unshift",arguments)}},{key:"visible",value:function(){return N(this,"visible",arguments)}}],[{key:"isTreeNode",value:function(e){return e instanceof w}},{key:"isTreeNodes",value:function(e){return e instanceof g}}]),o}()}); + e.exports=function(){function c(e){return"function"==typeof e}var n=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},i=0,t=void 0,r=void 0,o=function(e,t){d[i]=e,d[i+1]=t,2===(i+=2)&&(r?r(f):v())};var e="undefined"!=typeof window?window:void 0,s=e||{},a=s.MutationObserver||s.WebKitMutationObserver,u="undefined"==typeof self&&"undefined"!=typeof process&&"[object process]"==={}.toString.call(process),l="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function h(){var e=setTimeout;return function(){return e(f,1)}}var d=new Array(1e3);function f(){for(var e=0;ee.length&&(o.children._pagination.total=c.parseInt(t)),"checkbox"===o._tree.config.selection.mode&&o.selected()&&o.children.select(),o.markDirty(),o.context().end(),i(o.children),o._tree.emit("children.loaded",o)}function t(e){o.state("loading",!1),o.children=new g(o._tree),(o.children._context=o).markDirty(),o.context().applyChanges(),r(e),o._tree.emit("tree.loaderror",e)}var n=o._tree.constructor.isTreeNodes(o.children)?o.children.pagination():null,s=o._tree.config.data(o,e,t,n);c.isObject(s)&&m(s).then(e).catch(t)})}},{key:"loading",value:function(){return this.state("loading")}},{key:"loadMore",value:function(){return this.children&&!0!==this.children?this.children.loadMore():f.reject(new Error("Children have not yet been loaded."))}},{key:"markDirty",value:function(){return this.itree.dirty||(this.itree.dirty=!0,this.hasParent()&&this.getParent().markDirty()),this}},{key:"matched",value:function(){return this.state("matched")}},{key:"nextVisibleAncestralSiblingNode",value:function(){var e;if(this.hasParent()){var t=this.getParent();e=(e=t.nextVisibleSiblingNode())||t.nextVisibleAncestralSiblingNode()}return e}},{key:"nextVisibleChildNode",value:function(){var e;return this.hasChildren()&&(e=c.find(this.children,function(e){return e.visible()})),e}},{key:"nextVisibleNode",value:function(){return this.nextVisibleChildNode()||this.nextVisibleSiblingNode()||this.nextVisibleAncestralSiblingNode()}},{key:"nextVisibleSiblingNode",value:function(){var e=this.hasParent()?this.getParent().children:this._tree.nodes(),t=c.findIndex(e,{id:this.id});return c.find(c.slice(e,t+1),function(e){return e.visible()})}},{key:"pagination",value:function(){return c.get(this,"children._pagination")}},{key:"previousVisibleNode",value:function(){var e;return(e=this.previousVisibleSiblingNode())&&e.hasChildren()&&!e.collapsed()&&(e=e.lastDeepestVisibleChild()),!e&&this.hasParent()&&(e=this.getParent()),e}},{key:"previousVisibleSiblingNode",value:function(){var e=this.hasParent()?this.getParent().children:this._tree.nodes(),t=c.findIndex(e,{id:this.id});return c.findLast(c.slice(e,0,t),function(e){return e.visible()})}},{key:"recurseDown",value:function(e){return _(this,e),this}},{key:"recurseUp",value:function(e){return!1!==e(this)&&this.hasParent()&&this.getParent().recurseUp(e),this}},{key:"refreshIndeterminateState",value:function(){var e=this.indeterminate();if(this.state("indeterminate",!1),this.hasChildren()){var t=this.children.length,n=0,i=0;this.children.each(function(e){e.checked()&&i++,e.indeterminate()&&n++}),i===t?o("checked",!0,"checked",this):o("checked",!1,"unchecked",this),this.checked()||this.state("indeterminate",0>>((3&t)<<3)&255;return i}}}),D=[],A=0;A<256;++A)D[A]=(A+256).toString(16).substr(1);var L=function(e,t){var n=t||0,i=D;return[i[e[n++]],i[e[n++]],i[e[n++]],i[e[n++]],"-",i[e[n++]],i[e[n++]],"-",i[e[n++]],i[e[n++]],"-",i[e[n++]],i[e[n++]],"-",i[e[n++]],i[e[n++]],i[e[n++]],i[e[n++]],i[e[n++]],i[e[n++]]].join("")};var P=function(e,t,n){var i=t&&n||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var r=(e=e||{}).random||(e.rng||x)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t)for(var s=0;s<16;++s)t[i+s]=r[s];return t||L(r)};function C(t,n,e){n.id=n.id||P(),"string"!=typeof n.id&&"number"!=typeof n.id&&(n.id=n.id.toString());var i=n.itree=n.itree||{};i.icon=i.icon||!1,i.dirty=!1;var r=i.li=i.li||{};r.attributes=r.attributes||{};var s=i.a=i.a||{};s.attributes=s.attributes||{};var o=i.state=i.state||{};return o.collapsed="boolean"==typeof o.collapsed?o.collapsed:t.defaultState.collapsed,o.selectable="boolean"==typeof o.selectable?o.selectable:t.defaultState.selectable,o.draggable="boolean"==typeof o.draggable?o.draggable:t.defaultState.draggable,o["drop-target"]="boolean"==typeof o["drop-target"]?o["drop-target"]:t.defaultState["drop-target"],o.checked="boolean"==typeof o.checked&&o.checked,o.editable="boolean"==typeof o.editable?o.editable:t.defaultState.editable,o.editing="boolean"==typeof o.editing?o.editing:t.defaultState.editing,o.focused=o.focused||t.defaultState.focused,o.hidden=o.hidden||t.defaultState.hidden,o.indeterminate=o.indeterminate||t.defaultState.indeterminate,o.loading=o.loading||t.defaultState.loading,o.removed=o.removed||t.defaultState.removed,o.rendered=o.rendered||t.defaultState.rendered,o.selected=o.selected||t.defaultState.selected,n.itree.parent=e,n=c.assign(new w(t),n),c.isArrayLike(n.children)&&(n.children=S(t,n.children,n)),t.allowsLoadEvents&&c.each(t.config.allowLoadEvents,function(e){o[e]&&t.emit("node."+e,n,!0)}),n}function S(t,e,n){var i=new g(t,null,{calculateRenderablePositions:!0});return i.batch(),t.config.sort&&(e=c.sortBy(e,t.config.sort)),c.each(e,function(e){i.push(C(t,e,n))}),i._context=n,i.end(),i}var O=d(function(e,t){function u(){this._events={},this._conf&&n.call(this,this._conf)}function n(e){e?((this._conf=e).delimiter&&(this.delimiter=e.delimiter),this._maxListeners=e.maxListeners!==l?e.maxListeners:r,e.wildcard&&(this.wildcard=e.wildcard),e.newListener&&(this._newListener=e.newListener),e.removeListener&&(this._removeListener=e.removeListener),e.verboseMemoryLeak&&(this.verboseMemoryLeak=e.verboseMemoryLeak),this.wildcard&&(this.listenerTree={})):this._maxListeners=r}function o(e,t){var n="(node) warning: possible EventEmitter memory leak detected. "+e+" listeners added. Use emitter.setMaxListeners() to increase limit.";if(this.verboseMemoryLeak&&(n+=" Event name: "+t+"."),"undefined"!=typeof process&&process.emitWarning){var i=new Error(n);i.name="MaxListenersExceededWarning",i.emitter=this,i.count=e,process.emitWarning(i)}else console.error(n),console.trace&&console.trace()}function i(e){this._events={},this._newListener=!1,this._removeListener=!1,this.verboseMemoryLeak=!1,n.call(this,e)}function y(e,t,n,i){if(!n)return[];var r,s,o,a,c,u,l,h=[],d=t.length,f=t[i],v=t[i+1];if(i===d&&n._listeners){if("function"==typeof n._listeners)return e&&e.push(n._listeners),[n];for(r=0,s=n._listeners.length;rthis._maxListeners&&(r._listeners.warned=!0,o.call(this,r._listeners.length,s))):r._listeners=t,!0;s=e.shift()}return!0}.call(this,e,t):this._events[e]?("function"==typeof this._events[e]&&(this._events[e]=[this._events[e]]),n?this._events[e].unshift(t):this._events[e].push(t),!this._events[e].warned&&0this._maxListeners&&(this._events[e].warned=!0,o.call(this,this._events[e].length,e))):this._events[e]=t,this},i.prototype.off=function(e,t){if("function"!=typeof t)throw new Error("removeListener only takes instances of Function");var n,i=[];if(this.wildcard){var r="string"==typeof e?e.split(this.delimiter):e.slice();i=y.call(this,null,r,this.listenerTree,0)}else{if(!this._events[e])return this;n=this._events[e],i.push({_listeners:n})}for(var s=0;se.length&&(o.model._pagination.total=c.parseInt(t)),t||o.model.recurseDown(function(e){e.hasChildren()&&(e.children._pagination.total=e.children.length)}),o.config.selection.require&&!o.selected().length&&o.selectFirstAvailableNode(),!o.initialized&&c.isArray(e)?setTimeout(i):i()}if(c.isArrayLike(n))e(n);else if(c.isFunction(n)){var t=n(null,e,s,o.pagination());t&&(n=t)}c.isObject(n)?m(n).then(e).catch(s):s(new Error("Invalid data loader."))});return e.catch(function(e){o.emit("data.loaderror",e)}),this._loader={promise:e},e}},{key:"loading",value:function(){return N(this,"loading",arguments)}},{key:"loadMore",value:function(){return N(this,"loadMore",arguments)}},{key:"map",value:function(){return N(this,"map",arguments)}},{key:"matched",value:function(){return N(this,"matched",arguments)}},{key:"move",value:function(){return N(this,"move",arguments)}},{key:"mute",value:function(e){return c.isString(e)||c.isArray(e)?this._muted=c.castArray(e):this._muted=!0,this}},{key:"muted",value:function(){return this._muted}},{key:"node",value:function(){return N(this,"node",arguments)}},{key:"nodes",value:function(){return N(this,"nodes",arguments)}},{key:"pagination",value:function(){return N(this,"pagination",arguments)}},{key:"pop",value:function(){return N(this,"pop",arguments)}},{key:"push",value:function(){return N(this,"push",arguments)}},{key:"recurseDown",value:function(){return N(this,"recurseDown",arguments)}},{key:"reduce",value:function(){return N(this,"reduce",arguments)}},{key:"reduceRight",value:function(){return N(this,"reduceRight",arguments)}},{key:"reload",value:function(){return this.reset(),this.load(this.opts.data||this.config.data)}},{key:"remove",value:function(){return N(this,"remove",arguments)}},{key:"removeAll",value:function(){return this.reset().applyChanges(),this}},{key:"removed",value:function(){return N(this,"removed",arguments)}},{key:"reset",value:function(){return this.model=new g(this),this}},{key:"restore",value:function(){return N(this,"restore",arguments)}},{key:"restoreDeep",value:function(){return N(this,"restoreDeep",arguments)}},{key:"reverse",value:function(){return N(this,"reverse",arguments)}},{key:"search",value:function(n){var r=this,e=this.config.search,i=e.matcher,s=e.matchProcessor;return!n||c.isString(n)&&c.isEmpty(n)?f.resolve(this.clearSearch()):(this.batch(),this.recurseDown(function(e){e.state("hidden",!0),e.state("matched",!1)}),this.end(),i=c.isFunction(i)?i:function(t,e){var n,i=new g(r);c.isString(t)&&(t=new RegExp(t,"i")),n=c.isRegExp(t)?function(e){return t.test(e.text)}:t,r.model.recurseDown(function(e){e.removed()||n(e)&&i.push(e)}),e(i)},s=c.isFunction(s)?s:function(e){e.each(function(e){e.show().state("matched",!0),e.expandParents().collapse(),e.hasChildren()&&e.children.showDeep()})},new f(function(t,e){i(n,function(e){o.isTreeNodes(e)||(e=r.nodes(c.map(e,"id"))),r.batch(),s(e),r.end(),t(e)},e)}))}},{key:"select",value:function(){return N(this,"select",arguments)}},{key:"selectable",value:function(){return N(this,"selectable",arguments)}},{key:"selectBetween",value:function(e,t){this.batch();for(var n=e.nextVisibleNode();n.id!==t.id;)n.select(),n=n.nextVisibleNode();return this.end(),this}},{key:"selectDeep",value:function(){return N(this,"selectDeep",arguments)}},{key:"selected",value:function(){return N(this,"selected",arguments)}},{key:"selectFirstAvailableNode",value:function(){var e=this.model.filterBy("available").get(0);return e&&e.select(),e}},{key:"shift",value:function(){return N(this,"shift",arguments)}},{key:"show",value:function(){return N(this,"show",arguments)}},{key:"showDeep",value:function(){return N(this,"showDeep",arguments)}},{key:"slice",value:function(){return N(this,"slice",arguments)}},{key:"softRemove",value:function(){return N(this,"softRemove",arguments)}},{key:"some",value:function(){return N(this,"some",arguments)}},{key:"sort",value:function(){return N(this,"sort",arguments)}},{key:"sortBy",value:function(){return N(this,"sortBy",arguments)}},{key:"sortDeep",value:function(){return N(this,"sortDeep",arguments)}},{key:"splice",value:function(){return N(this,"slice",arguments)}},{key:"state",value:function(){return N(this,"state",arguments)}},{key:"stateDeep",value:function(){return N(this,"stateDeep",arguments)}},{key:"swap",value:function(){return N(this,"swap",arguments)}},{key:"toArray",value:function(){return N(this,"toArray",arguments)}},{key:"toString",value:function(){return N(this,"toString",arguments)}},{key:"unmute",value:function(e){return c.isString(e)||c.isArray(e)?(this._muted=c.difference(this._muted,c.castArray(e)),this._muted.length||(this._muted=!1)):this._muted=!1,this}},{key:"unshift",value:function(){return N(this,"unshift",arguments)}},{key:"visible",value:function(){return N(this,"visible",arguments)}}],[{key:"isTreeNode",value:function(e){return e instanceof w}},{key:"isTreeNodes",value:function(e){return e instanceof g}}]),o}()});function baseStateChange(prop, value, verb, node, deep) { if (node.state(prop) !== value) { node.context().batch(); if (node._tree.config.nodes.resetStateOnRestore && verb === 'restored') { resetState(node); } if (value && prop === 'checked') { node.state('indeterminate', false); } node.state(prop, value); node._tree.emit('node.' + verb, node, false); if (deep && node.hasChildren()) { node.children.recurseDown(child => { baseStateChange(prop, value, verb, child); }); } if (prop === 'hidden' || prop === 'removed') { node.context().indicesDirty = true; node.context().calculateRenderablePositions(); } node.markDirty(); node.context().end(); } return node; } \ No newline at end of file diff --git a/src/static/js/dom.js b/src/static/js/dom.js index 2cf0ef1..9dcbc0a 100644 --- a/src/static/js/dom.js +++ b/src/static/js/dom.js @@ -160,7 +160,7 @@ function getTags(hit, mimeCategory) { if (tokens.length > 1) { const bg = "#" + tokens[1]; - const fg = lum(tokens[1]) > 40 ? "#000" : "#fff"; + const fg = lum(tokens[1]) > 50 ? "#000" : "#fff"; userTag.setAttribute("style", `background-color: ${bg}; color: ${fg}`); } diff --git a/src/static/js/search.js b/src/static/js/search.js index 910b4d7..264e1a1 100644 --- a/src/static/js/search.js +++ b/src/static/js/search.js @@ -234,6 +234,9 @@ $.jsonPost("es", { selection: { mode: 'checkbox' }, + checkbox: { + autoCheckChildren: false + }, data: tagMap }); new InspireTreeDOM(tagTree, { @@ -251,7 +254,47 @@ function addTag(map, tag, id, count) { id: id, text: tags.length !== 1 ? tags[0] : `${tags[0]} (${count})`, name: tags[0], - children: [] + children: [], + isLeaf: tags.length === 1, + //Overwrite base functions + blur: function() {}, + select: function() { + this.state("selected", true); + return this.check() + }, + deselect: function() { + this.state("selected", false); + return this.uncheck() + }, + uncheck: function () { + if (!this.isLeaf) { + return; + } + + baseStateChange('checked', false, 'unchecked', this, false); + this.state('indeterminate', false); + + if (this.hasParent()) { + this.getParent().refreshIndeterminateState(); + } + + this._tree.end(); + return this; + }, + check: function () { + if (!this.isLeaf) { + return; + } + + baseStateChange('checked', true, 'checked', this, false); + + if (this.hasParent()) { + this.getParent().refreshIndeterminateState(); + } + + this._tree.end(); + return this; + } }; let found = false; @@ -374,7 +417,7 @@ function search(after = null) { let tags = getSelectedNodes(tagTree); if (!tags.includes("any")) { - filters.push({terms: {"tag": tags}}); + tags.forEach(term => filters.push({term: {"tag": term}})) } if (date_min && date_max) { diff --git a/src/static/search.html b/src/static/search.html index 1352a41..facd8bf 100644 --- a/src/static/search.html +++ b/src/static/search.html @@ -11,7 +11,7 @@