How to include OR condition in HTTP request to an API? - angularjs

I am wondering if it was possible to include a "OR" condition in a URL request.
In my case, I would like to have the list of items which have been created or updated between two dates. (Assuming that items that have been created before these dates but updated during these dates interest me!).
I tired lot of syntax but can't find the right way to do so..
I wrote the following code to make my problem more understandable.
api/items/search/?query=(created_on_from=2015-05-09&created_on_to=2015-10-
09)OR(updated_on_from=2015-05-09&updated_on_to=2015-10-09)
Thanks a lot !

Related

ReferenceInput with nested CheckBoxGroupInput behaving strangely

I have looked around for many hours and tried various things but alot of the examples i see for CheckBoxGroupInput simply have a hardcoded list of choices associated which is a bit useless... My scenario here is that i have a list of tags that i want to be able to associate with a product, pretty common stuff..
i need that list to be fetched from the postgres database... and that part all seems to work and my list looks normal when first rendered on the create screens for react-admin... The control looks like below
<ReferenceInput reference="ProductRealBenefit" source="realbenefits" sort={{ field: 'name', order: 'ASC' }}>
<CheckboxGroupInput source="name" />
</ReferenceInput>
This all well and good so far..
it renders my list as expected.. i have my schema all set up according to the format for ra_data_graphql_simple... Thing that is unexpected, is that as soon as i click on one of the tags, it immediately sends off a request to the server for the allProductRealBenefit query with a filter value equal to the clicked id and it adds a duplicate of that clicked tag to the list which breaks the control with a duplicate key error... i don't see why it would be sending off a request after i click anyway, i am not trying to save anything just assemble which tags would be sent off with the form data to create the link records, and i already have all that data after the initial populating of the control..
i am guessing maybe this should not be nested in ReferenceInput but i don't see any other way to populate my choices with database query result. I know this is ridiculously common functionality & I'll need to figure out a way to use this in multiple spots because this tagging functionality should be available in multiple resources.. I also tried this with AutocompleteArrayInput and it had similar issues so i know the problem is i must be missing an important step.... Be great if someone can point be in the right direction. i am going back to the docs for now to see what i can dig up!
OK, i am gonna answer another one of my questions in case anyone lands here equally as upsidedown as i was when i asked it... I simply didn't realize what some of the behind the scenes magic was doing therefore i was using this wrong... And i find the docs confusing
In my example above... my ProductRealBenefits in the reference was a one to many relationship represented in my schema with realbenefits: [ProductRealBenefits]... Therefore i needed the following components.
<ReferenceArrayInput label="Real Benefit Tags" source="realbenefitsIds" reference="ProductRealBenefit">
<CheckboxGroupInput optionValue="id" optionText="name" allowEmpty />
</ReferenceArrayInput>
There is a little magic in the ra_data_graphql_simple dataProvider that creates an item for you in state called realbenefitsIds, which is what you use as the source for the ReferenceArrayInput, i was trying to use the actual realbenefits array object, and that was not gonna work. I could not find any good examples out there or any decent explanations on how to get this to work... So ultimately it was Redux Dev Tools that saved my bacon here. I had to jump through some hoops in the graph server to get all this working with the dataprovider sending back diff things for GET_MANY and GET_REFERENCE_MANY filter values, but that was just a matter of parsing the filter args to match what sequelize was expecting. I'll end up writing a dataProvider eventually but this fit the bill for now..
PS.. i was seeing some strange behaviour in my CheckboxGroupInput, when i clicked something it duplicated whatever box was clicked... The reason for that was an error in object type in my schema... There was an Int mixed in with ID, and luckily that showed up in Redux Dev Tools and led me to the problem.
Lastly.. I'm putting together a sample project in Github that will use React-Admin, GraphQL, RA_DATA_GRAPHQL_SIMPLE, Sequelize, and a Postgres Database and i will comment it alot to take some of the confusion out of it for anyone like myself... Cheers!!

Active Directory search query for nested groups with wildcard pattern in search filter

I am trying to allow the users from nested groups in Active Directory to login to my spring boot/security based application. I have figured how to provide the search query through spring-security configuration, but I am having trouble with the search query itself.
Here is the search query that is currently working as expected:
(&(objectCategory=Person)(userPrincipalName=user1#domain.local)
(memberOf:1.2.840.113556.1.4.1941:=CN=parent_group1,OU=Another Group,OU=Groups,OU=Company,DC=Company-Domain,DC=local))
This is working as expected as user1 belongs to parent_group1 or one of its sub groups. But I have more than one parent_group, with constant prefix. So I am trying to provide wildcard in that query as CN=parent_group*, but its not working.
I have seen a variation here where each parent_group can be added with an OR like this:
(&(objectCategory=Person)(userPrincipalName=user1#domain.local)
(|(memberOf:1.2.840.113556.1.4.1941:=CN=parent_group1,OU=Another Group,OU=Groups,OU=Company,DC=Company-Domain,DC=local)
(memberOf:1.2.840.113556.1.4.1941:=CN=parent_group2,OU=Another Group,OU=Groups,OU=Company,DC=Company-Domain,DC=local)
(memberOf:1.2.840.113556.1.4.1941:=CN=parent_group3,OU=Another Group,OU=Groups,OU=Company,DC=Company-Domain,DC=local)
And this works too. But the problem with this is, every time a new new parent group is added this needs to be updated. I have gone through the link specified in the answer to the above question, but nothing from there works.
Ideally, I was hoping something like this would work (wildcard pattern for parent_group):
(&(objectCategory=Person)(userPrincipalName=user1#domain.local)
(memberOf:1.2.840.113556.1.4.1941:=CN=parent_group*,OU=Another Group,OU=Groups,OU=Company,DC=Company-Domain,DC=local))
But its not working. It doesn't return any results. Can someone help me if there is a better way of doing this?
Also, is it possible not to mention the entire hierarchy like this?
CN=parent_group*,OU=Another Group,OU=Groups,OU=Company,DC=Company-Domain,DC=local
I have been researching on this for a couple of days now and gone through most of the articles provided online or on SO, but nothing with the wildcard pattern with the chain command works so far.
It is not possible to do what you describe. You'd be well served by having one parent group which all your "other" parent groups are nested in. Anytime a new parent group is created, you would nest it in your master group so that it's granted access. This is a pretty common model.

paginate an union in Cakephp 3

I'm trying to paginate a union in cakephp 3. I have already found and read How do you modify a UNION query in CakePHP 3?, but am probably too new to cakephp to understand properly what is meant by "use a custom finder". I have read the relevant section in the cakephp book, but still fail to see how this helps to apply the epilog() to the query. Maybe someone could show a complete example?
I have two models Customers and Suppliers. I am trying to builds a search function that returns matching entries from both models, including pagination and sorting.
public function index($q=null) {
$this->loadmodel('Suppliers');
$this->loadmodel('Customers');
$customers=$this->Customers->find('all')->select(['type'=>"'Customers'",'id'=>'id','name'=>'name','phone'=>'phone'])
->where(['name like'=>'%'.$q.'%']);
$suppliers=$this->Suppliers->find('all')->select(['type'=>"'Suppliers'",'id'=>'id','name'=>'name','phone'=>'phone'])
->where(['name like'=>'%'.$q.'%']);
$customers->union($suppliers);
$results=$this->paginate($customers);
$this->set(compact(['q','results']));
}
As detailed in How do you modify a UNION query in CakePHP 3?, this results in the order,limit and offset only being applied to the first select.
Removing the paginate() and applying order,limit and offset manually via epilog() works, but than I'd have to recreate the whole pagination mechanism in my code. While this is my current plan in case I can't find a better solution, I don't believe this would be the right way to do it.
Could someone (#PhantomWatson, #ndm) show an example, how the suggested custom finder can solve this?

Angular ui.grid getting filtered dataset

I m actually trying to developp a little application using de ui.grid library and I m facing problems when getting the data result set on a filter.
In fact, everything works great, I can filter, I can make opération on each line, but I cant get the full result set of a filter using :
http://ui-grid.info/docs/#/tutorial/103_filtering
Can you help ?
I repeat : everything works great, I can sort and filter, but I cant get my resultset
Thanks for advance & have a nice day ! :D
What do you mean by "get my resultset"?
I'm assuming this means you want to programmatically get at the filtered list of rows. ui-grid doesn't provide an API for doing that, but you can get it from gridApi.grid.renderContainers.body.visibleRowCache. This will give you a list of the current visible rows.
You can extract the original entities from your data array from those rows, the entity is typically in row.entity.

Issues on a select with AngularJS and Google Spreadsheet

I want to create a small web app which would display a list of movies, with a Google spreadsheet set as a database. So far, I was able to connect my spreadsheet to my app and I also added some filters to it. (As a side note, this thread really helped me in the process.)
Here is a very simplified version of my app: http://plnkr.co/edit/BtbSCVOh7KJsMHjANxMP?p=preview
I still have 3 problems with my <select>, which I can't fix despite trying for hours:
I can't sort my <options> alphabetically. Trying with orderBy didn't return anything.
I can't figure out a way to split my categories when there are more than one for a movie.
If the "categorie" field in my spreadsheet is empty, it will return a blank <option> which I would like to remove or hide.
My guess is that I'll need to update my function one way or another, but I'm a bit lost at the moment.
Any help on this would be really appreciated!

Resources