Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query search development #6

Open
JulioJu opened this issue Feb 3, 2018 · 8 comments
Open

Query search development #6

JulioJu opened this issue Feb 3, 2018 · 8 comments

Comments

@JulioJu
Copy link

JulioJu commented Feb 3, 2018

Hi

Thanks for your work. What is your plan for the future development ?

I believe a good feature who was in Norwell was the query search, especially the « - » operator. Example: « history -google ». It's a very good feature, not implemented in the built-in Firefox history.

Do you think implement this soon ?

@GabLeRoux
Copy link
Owner

GabLeRoux commented Feb 3, 2018

For future development, I plan to do what I listed in ReadMe's todo.

For improved search, I wonder if there's some query language that could be easily included to do exactly this. I did a quick search in npm registry, but I'm not sure what keyword I should use. I'm not sure yet how I could implement - search yet.

I could quickly include datatables multi-filter which adds search fields to all columns.

My personal use case when I started the plugin was to have a date range picker to quickly see history based on a date range (ex: 1 week). I created the following feature/date-range-picker branch which I will update with master shortly.

@JulioJu
Copy link
Author

JulioJu commented Feb 4, 2018

Yes, I've seen your ReadME, but I only ask if you plan to continue the dev and when ? When do you think to implement Query search ?

I've read the Norvell source code. If I know the Trumpai code, he uses Regex. To answer to your question posted 8 month ago at https://addons.mozilla.org/en-US/firefox/addon/norwell/reviews/, to see source code simply download the extension and unzip it. As Trumpai says, this code is already Open Source. If you want reuse portions of his code, you must ask him to place it under MIT licence.

There is no dependencies in the Trumpai plugin. It's cool, because I think it's lightweight. Maybe it's not necessary to search in npm registry

If I understand the Norwell plugin, it pushes only the results who matches the regex.

  • For search « history -google »:
    • retrieve all history who matches « history » and who doesn't match « google ».
    • i.e. result = /^.+history.+$/ - /^+google.+$/
  • For search « "history google" » (surround by double quotes or simple quotes)
    • retrieve all history who matches /^.+history google.+$/.

For the date, if I understand the Norwell plugin, he uses the javascript Date Object. Each raw is associated to a Date. It displays only raw with Date => minDate && Date <= maxDate.

Maybe (it's not sure) in one month I'll could try to help you. But I'm not really sure to have any time. There is not emergency, actually we have Firefox ESR for legacy plugins ;-), or Waterfox (but I don't know if it is very secure).

@JulioJu
Copy link
Author

JulioJu commented Feb 4, 2018

For query search I think something like

    const result = [];
    const regexAdd = "/^.+history.+$/" // Or "/^.+history google.+$/"  if in the search string there is /^".+"$/ or /^'.+'$/
    const regexMinus = "/^+google.+$/" // (deduce from search terms « history -google ».  null if there  isn't $/^-\S$/  in the search string. 
    const dateMin =  new Date('2016-12-17T03:24:00'); // retrieve from UI
    const dateMax =  new Date('2017-12-17T03:24:00'); // retrieve from UI
    allHistory.forEach(function(item){
        const date = retrieveDate(item);
        if (date >= dateMin && date <= dateMax && isMatch(regexAdd) && ! isMatch(regexMinus)){
            result.push[item];
        }
    })

I don't know if it's possible to do something like that, or exactly like that. But there is the idea in this algorithm ;-).

Obviously, it could be cool to could have an infinite number of regex… i.e. in the search bar have several « -term1 », « -term2 », « "term 3" », « "term 4" »…

@JulioJu
Copy link
Author

JulioJu commented Feb 4, 2018

I try to write a pull request ;-)

@GabLeRoux
Copy link
Owner

GabLeRoux commented Feb 4, 2018

I like the idea. Maybe we could have a enable regex search checkbox so one could search using a regex string directly.

I also plan to add some unit tests to the project just to make additions keep working on the long term. Project is already set to run them automatically in travis.

@JulioJu JulioJu changed the title [Question] futur development Query search development Feb 4, 2018
@JulioJu
Copy link
Author

JulioJu commented Feb 4, 2018

I've had not a much time this afternoon. The next week, I will not have lot of time too, but probably some hour the next week-end.

I believe we must customize https://datatables.net/plug-ins/filtering/row-based/range_dates#Example .
(see example at https://github.com/DataTables/DataTables/blob/master/examples/plug-ins/range_filtering.html).

Could wait until the next week-end?

@GabLeRoux
Copy link
Owner

GabLeRoux commented Feb 4, 2018

Sure, we can have a look next weekend. I did find the same links and examples as you. I also found vedmack/yadcf (Yet Another DataTables Column Filter) which has a few filters. It does support daterange, see server side source example.

Its date range filter uses jquery-ui and it feels old, but it could be a first working step for the date range.

Thanks for investigating this, have an awesome week.

If we go the acdf way, implementation should look something like that:

yadcf.init(oTable, [{
    column_number: 3, // date column numer, not sure if its the right one
    filter_type: "range_date",
    date_format: "mm/dd/yyyy",
    filter_delay: 500
}])

@vedmack
Copy link

vedmack commented Feb 8, 2018

yadcf also support bootstrap datetimepicker with moment, read more in the docs - datepicker_type and here is the link to a relevant showcase page. In addition, I hope to finish the integration of another bootstrap plugin soon vedmack/yadcf#435

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants