From 4bbe692548165e32aac4db19a3e42f1014e5a6d8 Mon Sep 17 00:00:00 2001 From: Sander Vocke Date: Sun, 26 Jan 2020 00:12:52 +0059 Subject: [PATCH] Got layout and simplification of query filters working. --- public/test_many_photos_db/digikam4.db | Bin 335872 -> 335872 bytes public/test_many_photos_db/recognition.db | Bin 0 -> 36864 bytes public/test_many_photos_db/similarity.db | Bin 0 -> 24576 bytes .../test_many_photos_db/thumbnails-digikam.db | Bin 4710400 -> 4710400 bytes src/groupingbox.js | 67 ------------------ src/queries.js | 49 ++++++++++--- src/userquerywidget.js | 45 +++++++----- 7 files changed, 67 insertions(+), 94 deletions(-) create mode 100644 public/test_many_photos_db/recognition.db create mode 100644 public/test_many_photos_db/similarity.db delete mode 100644 src/groupingbox.js diff --git a/public/test_many_photos_db/digikam4.db b/public/test_many_photos_db/digikam4.db index 9fcf62b69d1b8d24b10151a0346c6d5cac097609..57856f8dd6b40038522856f91f1ec1f8726e698d 100644 GIT binary patch delta 183 zcmZoTAkuI^WP&u~wuv&%tlJp$OcWYZwx%%d+0VnXn`bpI7tbf2cAkvQf&w-?in3zN z(#FBbiFtXcDMkiH2D%1@x<;lUMn+bq7FGt9N}|&{&oC-78ckn)hS5V(gjrwE#VIVc zs5mn}FDSLJG_xo*#n6CHcstKo#!Nw0F(qbC#_2t0808p6r_a2{Xecbg%Ph|b*CH&( c?8rD>{w$+Z`}cc{K+FWh%-g@;W8riJ0FcZ$?*IS* delta 183 zcmZoTAkuI^WP&u~=7}=SteYA1tUorUY)xU@v!92Ti{}&1Zl2XV?K~Nq1qEz)6lH~& zrHzA=6Z7&?Q;ZCZ40H_)b&ZTd3=FIc%&bgIlmw@Do?%pEG@QQr45No6AG5xoi&I!? zQE_H|UQlXbX=YJsilG4??{=QEjG2P0LQ2e@jMID0Fv>9sPM>*?(NLI=msy?>u7y{Q c*^zO&{8>h+_V4!?ftU%1nYVwx$HM6d00fIUi2wiq diff --git a/public/test_many_photos_db/recognition.db b/public/test_many_photos_db/recognition.db new file mode 100644 index 0000000000000000000000000000000000000000..b311ff1711643e3f81fdab0645a0bd40ebe21db2 GIT binary patch literal 36864 zcmeI)Z%@-e90%}r1G=F&d|(!0NR9^t7Y&3=!UJNIu>%&z24yIin5C@eY#b}JH((|{ z*uni1EFo+qL(*?(TE9Zdb^*x6&48?XM`wFwxnmWJ%rRMsahA7CR^}GBn44%N z*4C&_E=7_gO;Zt&&5(AbQ6fnRx|YgFOB%t=)2!;*4gW;dWiHycU*XKXvf9gas#8gY zS<56(NH(1mnI&m$nn|+INc7>n`oSuj?9}jIEbr|$JJZpIaFZgHNzz?%A)Isobkrda zEHhSrrD@UWY4z-c8~Y`;Y82RpA$nF|Zf8E^Q!gjdlysIz+b_;cQkfiWjLN2-+E~{2 z$aA{)NE+N6*{WYd9#yc*oSkx#qq{kI1g{>l-sf=a6SsFn!7lZQFb!^yL^_+0H{zHT zS`o4O$%qz>$JI~wJlyOdE3dprCpOnDm)k|hIB+G0v@U8%fE4kc#2r?!i)HIQbK2u1 z@6I(Hn^=8mSc@(!sAm%wn9+p_IrBUjkBBmN)%m^rRxmwV4c$1tr*pP5)@R`Kn= z?eqyNib2kw_I^1pru7Dl)fR@d=={7|KcBakFE^Ku40p+0F7M|ipMI?iS&z5R+l+IoTy*{C zKvygLqw+SqW7QMeF})s=Og2X{JLxpp$)vV+s9dc>WG*lgU71uB?_XB* literal 0 HcmV?d00001 diff --git a/public/test_many_photos_db/similarity.db b/public/test_many_photos_db/similarity.db new file mode 100644 index 0000000000000000000000000000000000000000..d7183d25be8857244d1181ac29897d60aab8551a GIT binary patch literal 24576 zcmeI)-)_=S90%|g7@Je|!9(9Oh05PaZMHky5iLvWMQmS;XZb@6h&eOSGId zGdF@vG)kAdHQi%Uw_F51s;Wr<<8L^8^I)NHHiIu)@kak5U+F5WSHo5X9|CfBzu6w0Y={-C%h>k@u# zJ#ir|K5Ey(kK0^$+6Yf55P$##AOHafKmY;|fB*y_009WxRe|*|Fg*X?)$K)G5P$## zAOHafKmY;|fB*y_0D(vVfB#1!KmY;|fB*y_009U<00Izz00i#7K=}Nh(tax1Z*f9_ z00bZa0SG_<0uX=z1Rwwb2teQ#3v8y+HO;8bz7yds^T*6*IaHvp+8>C!z(`#;q&ls*6e literal 0 HcmV?d00001 diff --git a/public/test_many_photos_db/thumbnails-digikam.db b/public/test_many_photos_db/thumbnails-digikam.db index 83a4588b6d47bf1a60322ef15fb6e7319f06dd68..07430bc637a720b15791a88fcefae48d2070f082 100644 GIT binary patch delta 403 zcmZw7IZgsm0D$2)^FWkQABZ|As3YQrg3I8(A)sEs*lRSAL@|+2OJZTEgaf>a157MT ztf)vhiLsbF_#eRH>%K-un+<#<46B(e1uc=wJKk;kMRwKCXSDOJTHW_lT1r=yiGxAR&iUp#y?ZGdfEvHA?#OQzxmpL35fuL=tBto z7(f^n1~G(TC`1s&2x1t;7{*~EjtNX6fh49djTtzYMGA9BV;&1w#1fW~!3tK9MGk9N n#|AdxB9AR>V+Xs~!#)mhh$9^11O=R;h!V;;!}*u5FJgs1V{66s delta 378 zcmWN{%Sr-K0D$2$Gg>)WCo|2`%FM2sU8YjAi+Sq>qP;K@>kmIZ`rd|)D<)=Puo!)M`_Suzy&u(Fp4pFU}79z zOkffcQ}AILe#{_%AZ8K59Oe;51PfTi5~5f}3@eCZ6>C_>1~##U1d`ZB3Om@v9`<43 i0Eak28X079j2upIiZh%ej|&t~L ({ - groupingboxtitle: { - - }, -})); - -export function GroupingBoxTitle(props) { - const { children } = props; - return children; -} - -export function GroupingBoxItem(props) { - const { children } = props; - return children; -} - -export function GroupingBox(props) { - const classes = useStyles(); - const { children } = props; - - var title_elem = false; - var content_elems = []; - - children.forEach(child => { - if (child.type == GroupingBoxItem) { - content_elems.push(child); - } else if (child.type == GroupingBoxTitle) { - if (title_elem) { - throw new Error("A GroupingBox may only have one GroupingBoxTitle child."); - } - title_elem = child; - } - }); - - if (!title_elem) { - throw new Error("A GroupingBox must have at least one GroupingBoxTitle."); - } - - return ( - - - - - {title_elem} - - {content_elems} - - - - ) -} \ No newline at end of file diff --git a/src/queries.js b/src/queries.js index 1ba2c70..7ed4fef 100644 --- a/src/queries.js +++ b/src/queries.js @@ -84,6 +84,9 @@ export class ResultFilter { result_type = ResultTypeEnum.IMAGE; to_sql_where() { return "(1=1)"; } + is_true() { return false; } + is_false() { return false; } + simplify() { return this; } } export class ConstFilter extends ResultFilter { @@ -93,6 +96,10 @@ export class ConstFilter extends ResultFilter { to_sql_where() { return this.constval ? "(1=1)" : "(1=0)"; } + + is_true() { return this.constval; } + is_false() { return !this.constval; } + simplify() { return this; } } export class MatchingFilter extends ResultFilter { @@ -134,6 +141,7 @@ export class MatchingFilter extends ResultFilter { return "(" + (this.negate ? "NOT " : "") + match_against + match_type_str + match_from + ")"; } + simplify() { return this; } } export const LogicalOperatorEnum = { @@ -160,6 +168,29 @@ export class LogicalOperatorFilter extends ResultFilter { } return "(" + where1 + operator_str + where2 + ")"; } + + simplify() { + var a = this.sub_filter_a.simplify(); + var b = this.sub_filter_b.simplify(); + + if(this.operator == LogicalOperatorEnum.OR) { + if(a.is_true() || b.is_true()) { + return new ConstFilter(this.return_type, true); + } + if(a.is_false()) { return b; } + if(b.is_false()) { return a; } + } + + if(this.operator == LogicalOperatorEnum.AND) { + if(a.is_false() || b.is_false()) { + return new ConstFilter(this.return_type, false); + } + if(a.is_true()) { return b; } + if(b.is_true()) { return a; } + } + + return this; + } } export class UserQuery { @@ -263,7 +294,7 @@ function filter_from_text_segment(result_type, segment) { filter = name_filter; } - return filter; + return filter.simplify(); } export function user_query_from_search_string(search_string) { @@ -277,11 +308,11 @@ export function user_query_from_search_string(search_string) { texts.forEach(text => { r.image_filter = new LogicalOperatorFilter(ResultTypeEnum.IMAGE, r.image_filter, - filter_from_text_segment(ResultTypeEnum.IMAGE, text), LogicalOperatorEnum.AND); + filter_from_text_segment(ResultTypeEnum.IMAGE, text), LogicalOperatorEnum.AND).simplify(); r.album_filter = new LogicalOperatorFilter(ResultTypeEnum.ALBUM, r.album_filter, - filter_from_text_segment(ResultTypeEnum.ALBUM, text), LogicalOperatorEnum.AND); + filter_from_text_segment(ResultTypeEnum.ALBUM, text), LogicalOperatorEnum.AND).simplify(); r.tag_filter = new LogicalOperatorFilter(ResultTypeEnum.TAG, r.tag_filter, - filter_from_text_segment(ResultTypeEnum.TAG, text), LogicalOperatorEnum.AND); + filter_from_text_segment(ResultTypeEnum.TAG, text), LogicalOperatorEnum.AND).simplify(); }); return r; @@ -292,8 +323,8 @@ export function user_query_from_browsed_album(album_path) { var match_type = MatchTypeEnum.MATCH_REGEXP_CASEINSENSITIVE; var match_text = '"' + escape_regex(album_path) + '(\/[^\/]+)*' + '"'; var match_against = "Albums.relativePath"; - r.image_filter = new MatchingFilter(ResultTypeEnum.IMAGE, match_against, match_text, match_type, false); - r.album_filter = new ConstFilter(ResultTypeEnum.ALBUM, false); + r.image_filter = new MatchingFilter(ResultTypeEnum.IMAGE, match_against, match_text, match_type, false).simplify(); + r.album_filter = new ConstFilter(ResultTypeEnum.ALBUM, false).simplify(); return r; } @@ -303,9 +334,9 @@ export function user_query_from_browsed_tag(name) { var match_type = MatchTypeEnum.MATCH_EQUALS; var match_text = '"' + name + '"'; var match_against = "Tags.name"; - r.image_filter = new MatchingFilter(ResultTypeEnum.IMAGE, match_against, match_text, match_type, false); - r.album_filter = new ConstFilter(ResultTypeEnum.ALBUM, false); - r.tag_filter = new ConstFilter(ResultTypeEnum.TAG, false); + r.image_filter = new MatchingFilter(ResultTypeEnum.IMAGE, match_against, match_text, match_type, false).simplify(); + r.album_filter = new ConstFilter(ResultTypeEnum.ALBUM, false).simplify(); + r.tag_filter = new ConstFilter(ResultTypeEnum.TAG, false).simplify(); return r; } \ No newline at end of file diff --git a/src/userquerywidget.js b/src/userquerywidget.js index 424ed42..543e235 100644 --- a/src/userquerywidget.js +++ b/src/userquerywidget.js @@ -9,8 +9,6 @@ import Button from '@material-ui/core/Button'; import { makeStyles } from '@material-ui/core/styles'; -import { GroupingBox, GroupingBoxItem, GroupingBoxTitle } from './groupingbox.js'; - import { filter_is_const_false, ConstFilter, LogicalOperatorFilter, MatchingFilter, ResultTypeEnum, LogicalOperatorEnum, MatchTypeEnum @@ -18,12 +16,15 @@ import { const useStyles = makeStyles(theme => ({ root: {}, - treebox: { - display: "block", - margin: "auto", + filterexpcontrol: {}, + logic_op_outer: { + display: "flex", + }, + logic_op_sbs: { + "box-sizing": "border-box", }, - filterexpcontrol: { - margin: "10px", + logic_op_subexpr: { + float: "right", }, })); @@ -59,19 +60,27 @@ export function LogicalOperatorFilterExpressionControl(props) { } return ( - - - - - - - - - - - + + ) }