We're trying to pass an unique ID into Fineuploader (4.2.2, JQUERY) and reuse that into the fineuploader.js to set the foldername of where the upload is stored.
We basicly found two option:
Set the request option uuidName, which should be a string. Passing this one will result in "null" in console and doesn't do the trick.
Create a params request option where we define a variable with a value.
Option 2 get passed though we've got no idea how we get this value and process it into fineuploader.js (and alter the qq.getUniqueId-function with this new var for example).
Anyone know how we can get this done?
Thanks so much!
EDIT:
Underneath the code which initiates the uploader, how do I get the fileID inside the fineuploader.js?
$(".fine-uploader").fineUploader({
request: {
endpoint: 'server/endpoint',
params: {
fileID: '12345'
}
}
If you would like to override the UUID Fine Uploader creates for a file, you can do so either by passing your new UUID client-side via the setUuid method, or your server can return a newUuid property with its value set to the new UUID in its JSON response.
Related
I would like to setup axios to delete a record using a resource route:
axios.delete('/job-management', this.deletedata).then((res)=>{
console.log(res);
})
For my routes I have:
Route::resource('job-management', "PositionsController", [ 'as' => 'jobs']);
Now, in my PositionsController I have:
public function destroy(Positions $positions) {
return $positions;
}
But the above always returns "method not allowed". How can I handle a delete request with the axios delete() method?
Laravel throws the MethodNotAllowedHttpException when we attempt to send a request to a route using an HTTP verb that the route doesn't support. In the case of this question, we see this error because the JavaScript code sends a DELETE request to a URL with the path of /job‑management, which is handled by a route that only supports GET and POST requests. We need to change the URL to the conventional format Laravel expects for resourceful controllers.
The error is confusing because it hides the fact that we're sending the request to the wrong URL. To understand why, let's take a look at the routes created by Route::resource() (from the documentation):
Verb URI Action Route Name
GET /job-management index job-management.index
GET /job-management/create create job-management.create
POST /job-management store job-management.store
GET /job-management/{position} show job-management.show
GET /job-management/{position}/edit edit job-management.edit
PUT/PATCH /job-management/{position} update job-management.update
DELETE /job-management/{position} destroy job-management.destroy
As shown above, URLs with a path component of /job-management are passed to the controller's index() and store() methods which don't handle DELETE requests. This is why we see the exception.
To perform a DELETE request as shown in the question, we need to send the request to a URL with a path like /job-management/{position}, where {position} is the ID of the position model we want to delete. The JavaScript code might look something like:
axios.delete('/job-management/5', this.deletedata).then((res) => { ... })
I've hardcoded the position ID into the URL to clearly illustrate the concept. However, we likely want to use a variable for the this ID:
let positionId = // get the position ID somehow
axios.delete(`/job-management/${positionId}`, this.deletedata).then((res) => { ... })
The URL in this form enables Laravel to route the DELETE request to the controller's destroy() method. The example above uses ES6 template string literals because the code in the question suggests that we're using a version of JavaScript that supports this feature. Note the placement of backticks (`) around the template string instead of standard quotation marks.
as I can see in your code above, you pass Positionseloquent as a parameter to destroy method but in your vueJS you don't pass this object. for that you would pass it like this :
axios.delete('/job-management/${id}').then((res)=>{
console.log(res);
})
and the id param inside the url of ur axios delete, it can object of data or any think.
i hope this help you
I have profile resource which has
profileName,
firstName ,
Lastname and
id
here profileName is unique and used as resource identifier and id is just a count.
To modify resource it accept put request on
http://localhost:9090/messanger/api/[profileName]
Now problem is whenever I'm making put request, it replace profile name with id. I am unable to make restangular put request on profileName.
Code is as follows.
$scope.editUser=function(id){
var profile=$scope.profiles[id];
$scope.profile=profile;
profile.save().then(function(res){
console.log(res);
});
}
It turn out that there was a problem with method which was handling put request at backend. Object I was passing has 4 properties in java code but when I was passing it from front end I was passing only 3. Previously I was trying
var items=Restanular.all("profiles").getList();
var item=items[i];
item.propertyName=New Value;
item.save();
This should have ideally work but I think it require some thing more as when I called save method it made a request on http://localhost:9090/messanger/api/
rather than making request on http://localhost:9090/messanger/api/[profileName]
When autocomplete sends the query string it contains a parameter of term. See here:
Started GET "/nodes/autocomplete_user_first_name?term=Mi" for 127.0.0.1
Processing by NodesController#autocomplete_user_first_name as JSON
Parameters: {"term"=>"Mi"}
I need to add a parameter to a value that's available in my view to yield something like this, using node as the parameter and 27 as the value:
Started GET "/nodes/autocomplete_user_first_name?term=Mi&node=27"
Processing by NodesController#autocomplete_user_first_name as JSON
Parameters: {"term"=>"Mi", "node" => 27}
If I have to add via jQuery is a javascript file, please tell me where it should go. I'm new to js/JQuery, but I understand it. Thanks!
EDIT
The reason I need the node param is because I need to restrict the scope based on its value.
def get_autocomplete_items(parameters)
items = active_record_get_autocomplete_items(parameters)
items = items.where(:id => current_user.family_tree.memberships.pluck(:user_id))
.where.not(:full_name => node.user_tags.pluck(:name))
end
I am using django-jsignature in my django project. After making the post request, the form returns "type 'instance'". I'm trying to save this as an image, but I get the above error.
Even better would be to save the form data as a vector image as suggested in the docs.
My function:
def signature(request):
form = SignatureForm(request.POST or None)
if form.is_valid():
signature = form.cleaned_data.get('signature')
if signature:
# as an image
signature_picture = draw_signature(signature)
signature_file_path = draw_signature(signature, as_file=True)
with open(signature_file_path), 'wb') as f:
f.write(signature_picture)
(signature_file_path == '/tmp/tmpB71Wft.PNG')
I think the docs are a bit unclear, but you should be using either draw_signature(data, as_file=False) (default) OR draw_signature(data, as_file=True), no need for both.
Passing a True value to as_file makes the package dump the image content to a file, while False makes it return the PIL.Image instance.
The raw data is still available in your signature variable (as JSON string or list, so you could also use that vector directly.
Can draw_signature() take one or two arguments? Your code has it taking one argument in one location, and a two arguments in a second location.
I want to pass a parameter to my Store proxy to retrieve the right data from the server. I need to pass the parameter without the name prefix and just the value.
Instead of this kind of url :
myAppUrl/collections/units?collectionId=54
which can be done like this:
myStore.getProxy().extraParams.collectionId = 54;
I want to have a call like this:
myAppUrl/collections/54/units
My web service is adapted for both calls I just need the correct client code to pass the parameter.
Please help and advise.
An old question, but I write for anyone with this problem. I implemented the idea of #Saki in this package (for ExtJS 6) because of my own needs:
https://bitbucket.org/alfonsonishikawa/extjspackages/wiki/Server%20URL%20Placeholders
The idea is being able to use an URL like:
proxy: {
type: 'rest',
url: 'myAppUrl/collections/${collectionId}/units',
appendId: false
}
With that package, you just have to configure your proxy like above and call #load() with params:
store.load({
params: {
collectionId: 54
}
});
(getProxy().extraParams can be used as default value)
This is the source code as example that you asked #Saki about.
It looks almost like REST request but not exactly as REST places indexes at the end of url. You could solve it by implementing a custom buildUrl of Ajax or Rest proxy. In any case, see how is this method implemented in Rest proxy.
you can set your url dynamically and then call load method of store using below code.
store.getProxy().setUrl('your new url');
store.load();
but if you gonna use this method then you have to set correct url every time other-vice may be you will get wrong data.