New to ember and ember cli, and not having any JS based framework experience apart from jQuery (which is not a framework)
I find my self stuck at the very beginning compared to work done in Angular,
I have a static list of groups which are on REST api `http://localhost:8000/api/groups' and it is only 8 items there, I needed to show them as dropdown for a search criteria. Nothing fancy
I started with creating a route and model with the name of groups but app stopped working and I had to create a model for group which is identical to groups model, only having 2 items for dropdown
Now i have a url in my ember app http://localhost:4200/groups which I dont need and i dont want it to be there,
But I ignored it and had to create a dropdown of the cities, api is
http://localhost:8000/api/cities <-- All cities list, needed for admin
http://localhost:8000/api/cities/active <-- For clients to show active cities so they can add their records
http://localhost:8000/api/cities/filled <-- For users, to show them where clients are available
So in ember, I created a route and model for cities, and same model is copied as city just to show the list of cities in dropdown, I needed to show cities which are filled, I had created ember g route city/filled and it created folders, but its model is also same like other two models.
Ajax call is not being sent to city/filled url and now I ended up having
http://localhost:4200/cities // useless for me
http://localhost:4200/cities/filled //useless for me
and in filled i see that ajax call is made but to the http://localhost:8000/api/cities two times, loading same data. I tried adding a dropdown on my application and opened http://localhost:4200/cities/filled in browswer, and woosh, it send ajax call to the same url 3 times, one for application.hbs and one for cities.hbs and one for city/filled. Why load the same data 3 times if it is already fetched from same url within single request?
in angular I just call a custom url and I can get the data, but for ember its really hard to get grip on these small things and there is no help around
active and filled are filters for your cities resource and these are not standalone resources, so you should try to use them as query parameters. like
http://localhost:8000/api/cities?type=filled
http://localhost:8000/api/cities?type=active
Facebook uses this style for query params. You can also use query params for getting paginated data of a resource, like for 1st page and 25 records per page, the request will look like:
http://localhost:8000/api/cities?page=1&records=25
Related
I am designing an application that will expose a REST API.
URLs for the resources themselves will look fairly standard, like below:
GET /orders //Get all orders
GET /orders?somefilter=somecriteria //search for orders
GET /orders/<orderid> //specific order
PUT /orders/<orderid> //update a specific order
POST /orders //create an order
My question is regarding resources related to these. I expect the resources will mainly be accessed through an app, but still would like want to provide basic web entry forms, as well as schemas for various resources. What url should they have?
Possible urls
//Option1
GET /forms/orders //new order
GET /forms/orders/<orderid> //edit existing order
GET /schemas/orders
//Option2
GET /orders/form //new order
GET /orders/<orderid>/form //edit existing order
GET /orders/schema
//Option3
GET /orderform //new order
GET /orderform/<orderid> //edit existing order
GET /orderschema
Option 2 doesn't seem right to me, I don't think that the form resource should share the same location on a URL as the order ID. Option 1 looks the best, but would increase the organisational complexity of the app as I couldn't keep the schemas with the rest of the code dealing with a particular resource (but that is a problem that can be solved).
Is there any accepted best practice for these? It does not have to be one of the three options above, any and all pointers would be appreciated.
I'm using one of the two datasources:
marcusolsson-json-datasource
yesoreyeram-infinity-datasource
Both can call HTTP API endpoints.
The problem is the endpoint returns paginated response (JSON)..
My panel will be a very simple table that just shows the endpoint's response to the query (HTTP Request).
What I want to achieve is making Grafana grab the paginated data..
Example: When I click on page 1 in table it make a request with page_size=X&page_number=1 and so on.. Is that possible ?
If not possible.. what is the best thing to do here?
Should I use some kind of caching ? What cache suits best with my case and how to implement it?
I've been digging but I didn't really come to something useful.
The workaround I could come up with is by using a dashboard variable..
We create a variable that fills its value from a request to the endpoint and refreshes with the dashboard reload.
We then use that as a dropdown variable starting from 1 to number of pages.. When a page number is selected, it makes a new request to the endpoint to load the data. (By including variable value as a query parameter.)
The thing with this approach is that it doesn't look nice like Grafana's table pagination pane. Instead, the user will have to choose a page number from a dropdown list.
situation: Lets's think about basic process of object creation on a client (with CRUD backend).
Let's imagine that we have two "Create" buttons on a page.
first case:
Clicking on the first button will cause to redirect to /create route, where our form located.
After we fill the form with data, we post it to a backend and it retrieves an id of a newly created object.
second case:
Clicking on the second button will cause to send creation request to the backend, then after we got a new object id, we will be redirected to /edit/:id, where our form located (same form).
After we fill the form with data, we send it to a backend and save already existed object (post by id).
question:
What's the pros and cons of those two cases, when to use each of them?
In the first case you can include the validation of the fields in the time of creation
and you only need to create an insert so one database call.
In the second case you are creating an empty entry that will appear in the grids of an application with no data.
Also if your database has required fields, you have to fill them with default data.
Validation will be more difficult since you need to allow empty ex Mobile in data entry
while phone might be required.
Another problem with this is that that you are basically doing two operations. One if for the Insert of the row and one is for the update of the row
However this methodology is easier to implement the live update of text when typing so any disconnects etc will not lose any data. This methodology is also good for collaboration between two clients using websockets ex inserting the row at the same time.
I'm trying to come up to speed on the Square API. I have been able to successfully create a post call to CreateCustomer() and a get call to ListCustomers(). In both cases, the customer objects come through fine but the custom fields I have added to extend the customer object are not present. When I add, view and edit Customers using the Square Dashboard they show up as expected. They are also present if I export Customers from the Dashboard.
Is there a way to get the custom fields to be included in Square's Rest API calls?
At this time Square's APIs will not return custom fields.
Is there a way to load multiple adinterests by IDs in a single API call?
Here's situation:
We have multiple adinterests for ads targeting campaign. For example, we are targeting users that are interested in:
music (ID=111)
arts (ID=222)
museums (ID=333)
We are listing all interests to a user, but in the database we store only IDs.
Currently we can only load single interest per request, e.g.:
https://graph.facebook.com/v2.3/111?access_token=___
https://graph.facebook.com/v2.3/222?access_token=___
https://graph.facebook.com/v2.3/333?access_token=___
or
https://graph.facebook.com/v2.3/?access_token=___&type=adinterest&id=111
This works. However, I would like to load all interests in a single call to speed up page load, for example:
https://graph.facebook.com/v2.3/?type=adinterest&id[0]=111&id[1]=222&id[2]=333&access_token=___
This, unfortunatelly, does not work.
So, is there any way to load ad interests list by list of supplied IDs?
You can use the Batch request framework to make a single HTTP request to multiple endpoints. See
https://developers.facebook.com/docs/marketing-api/batch-requests