Extjs 4 - How can I get the complete url with params from a currently loaded grid's store? - url

I have a grid loaded, I want to get the current stores URL which loaded the json data to it , and pass an extra param to it, and load this URL as a pdf, or xls. But how can I get the url?

Get the proxy and ExtraParams:
var url = grid.getStore().getProxy().url;
var params = grid.getStore().getProxy().extraParams;
Then, build the url:
var newUrl = url + '?' + Ext.Object.toQueryString (params);
And the newUrl will be something like this:
your_url_data.json?param1=value1&param2=value2
I don't think that exists a proxy method that do this but you can extend an existing proxy, as follows:
Ext.define ('MyProxy', {
extend: 'Ext.data.proxy.Ajax' ,
buildInternalUrl: function () {
return this.url + '?' + Ext.Object.toQueryString (this.extraParams);
}
});
And then:
var newUrl = grid.getStore().getProxy().buildInternalUrl ();
Result is the same ;)
Here's you can find the doc of proxies: Ajax Proxy

you can get the stores url by yourGrid.getStore().getProxy().url

Related

URL redirect from one domain to another using cloudflare

I haaave been trying to set up a cloudflare worker to redirecet an URL to another (SOURCE.ie/... -> DESTINATION.com/...).
The destination URL is set up within cloudflare the source-URL however is purchased via Onlydomains.
I have been using the code given in the documentation:
const base = "https://DESTINATION.com"
const statusCode = 301
async function handleRequest(request) {
const url = new URL(request.url)
const { pathname, search } = url
const destinationURL = base + pathname + search
return Response.redirect(destinationURL, statusCode)
}
addEventListener("fetch", async event => {
event.respondWith(handleRequest(event.request))
})
What I think have to do now is to aadd a route but is does not want to do that:
Although I added the nameservers to the Onlydomains URL.
Am I missing something? I just want a simple redirect that replaces SOURCE with DESTINATION :|

How to resolve path issues in asp.net mvc

In the view I am getting the JSON data from the controller. Path is working in my local but not working in the other servers.
$.get('../TestController/GetTestResultById?Id=' + s.GetValue(), function (data) {
some data
}
It is in this format I am getting the data in local but in different server the path should be appname/controllername/.... but getting as controllername/....
How to resolve this issue.
var myUrl = '#Url.Action("GetTestResultById","Test")';
//It will create your url where you want to call ajax.
//then append Id with url and your value.
$.get(myUrl + "?Id=" + s.GetValue(), function (data) {
// Use `data` here
});

How can we pass requests from one page to another in electron

How can we pass requests from one page to another in electron, like do we do in html or php.
For Eg: In html or php, we can pass them like test.html?name=jaydev
I want this in my electron app.
For example, i am loading index page in the main window using
mainWindow.loadURL('file://' + __dirname + '/index.html');
Then i load machines.html in the same main window using
mainWindow.loadURL('file://' + __dirname + '/machines.html');
Now how can i pass some requests from index.html to machines.html?
Can any suggest a solution for this? Any help will be appreciated.
I use that convention for passing values to an iFrame loading within Electron – I don't know if it will work in your case, The script below is called when the page has loaded. It gets params which were passed to the src of the iFrame:
video.html?videoSrc=clark-8.mp4&poster=clark-8.png
I don't know what you are trying to do or what data you are trying to pass between webcontent – but it seems like there are a variety of ways to go about it.
Pass the data back to the main process and have the new webcontent request it - or push it to the new webcontent once it has loaded.
Use cookies and local storage
<script>
function getParamValue(paramName) {
var url = window.location.search.substring(1);
var qArray = url.split('&');
for (var i = 0; i < qArray.length; i++) {
var pArr = qArray[i].split('=');
if (pArr[0] == paramName)
return pArr[1];
}
}
// grap the video & poster frame refs from url
var videoSrc = getParamValue('videoSrc');
videoSrc = "assets/videos/" + videoSrc;
var poster = getParamValue('poster');
poster = "assets/images/" + poster;
videojs("videoPlayer", {}, function () {
this.src(videoSrc);
this.poster(poster);
this.load();
});
</script>

Change prefix of URL in GET request

I'm making a get with a relative URL with YAHOO.util.Connect.asyncRequest.
Example:
var myurl = "newpagetotest?something="something");
var myCallback = {
success: function(data) {
console.log("success");
},
};
var transaction =
YAHOO.util.Connect.asyncRequest('GET', myurl, callback);
And this makes, for example, get to the
localhost:8080/share/page/newpagetotest
But if I want to change the "localhost:8080/share/page", i.e., the prefix of URL absolute. How can I change? It's possible? Or how can I get this prefix for example, for one variable?
Thanks in advance.
I made this by using location.pathname.
It solves the problem.

How to add campaign tracking data to any url automatically?

I get a bunch of different URL from my sources and what I would like is to redirect to the same URL, but with campaign data added to URL (to track the referred clicks).
For example I have these URLs:
www.example.com/category/product/name.html
www.example.com/id_product=5
I want to add at the end the following: utm_source=SOURCE&utm_medium=MEDIUM&utm_campaign=CAMPAIGN
And the URLs to become
www.example.com/category/product/name.html?utm_source=SOURCE&utm_medium=MEDIUM&utm_campaign=CAMPAIGN
www.example.com/id_product=5&utm_source=SOURCE&utm_medium=MEDIUM&utm_campaign=CAMPAIGN
How to I correctly check and cover all the cases if a URL string has parameters, and add mine?
I want to do it in node.js
Thank you
Elaborating on #snkashis, a similar but arguably more elegant solution, again using node's url module, is:
var addQueryParams = function (cleanUrl) {
var obj = url.parse(cleanUrl, true, false);
obj.query['utm_source'] = 'SOURCE';
obj.query['utm_medium'] = 'MEDIUM';
obj.query['utm_campaign'] = 'CAMPAIGN';
delete obj.search; // this makes format compose the search string out of the query object
var trackedUrl = url.format(obj);
return trackedUrl;
};
This works, because url.format first looks for search and, if it can't find it, it composes the query string from the query object
(taken from node url module documentation http://nodejs.org/api/url.html#url_url_format_urlobj )
search will be used in place of query
query (object; see querystring) will only be used if search is absent.
Here is a example showing different scenarios using Node's URL module.
var url = require('url');
var exurls = ["www.example.com/category/product/name.html","www.example.com/id_product=5?hasparam=yes"]
var to_append = "utm_source=SOURCE&utm_medium=MEDIUM&utm_campaign=CAMPAIGN";
for (i=0;i<exurls.length;i++) {
var parsedobj = url.parse(exurls[i],true,false);
//Below checks if param obj is empty.
if (Object.keys(parsedobj.query).length!==0) {
var newpath = parsedobj.href+"&"+to_append;
}
else {
var newpath = parsedobj.href+"?"+to_append;
}
console.log(newpath);
}
Connect will help you:
var connect = require('connect');
var app = connect();
app.use(connect.query());
app.use(function (req, res, next) {
console.log(req.query);
res.end(JSON.stringify(req.query));
});
app.listen(3000);

Resources