In our web application, we are integrating spotfire reports using "TIBCO Spotfire JavascriptAPI"
We need to display reports from multiple spotfire servers. for example we have one visualization report in "spotfire.cloud.tibco.com" and another report is in "spotfire-next.cloud.tibco.com"
In order to load report from these two servers, i need to include two SF servers like below
<script src="https://spotfire-next.cloud.tibco.com/spotfire/js-api/loader.js"></script>
<script src="https://spotfire.cloud.tibco.com/spotfire/wp/GetJavaScriptApi.ashx"></script>
so if i instantiate report using spotfire instance like "spotfire.webPlayer" which spotfire server will get trigger ?
var serverUrl = "https://spotfire-next.cloud.tibco.com/spotfire/wp/";
var analysisPath = "/Samples/Expense Analyzer Dashboard";
var customizationInfo = new spotfire.webPlayer.Customization();
var app = new spotfire.webPlayer.Application(serverUrl, customizationInfo,analysisPath);
var doc=app.openDocument("container");
var serverUrl2 = "https://spotfire.cloud.tibco.com/spotfire/wp/";
var analysisPath2 = "/Samples/Expense Analyzer Dashboard2";
var customizationInfo2 = new spotfire.webPlayer.Customization();
var app2 = new spotfire.webPlayer.Application(serverUrl2, customizationInfo2, analysisPath2);
var doc2=app2.openDocument("container2");
In order to load report from two different Spotfire server how can i achive this?
so if i instantiate report using spotfire instance like
"spotfire.webPlayer" which spotfire server will get trigger ?
Spotfire 7.6 and above uses Spotfire Server as a Load balance for Webplayers installed as Nodes. So based on Spotfire server request will go to Webplayer nodes managed by that server.
If you want to run your reports on specific Server/Webplayer Instances follow these steps:
create 2 resource pool Named: "Dashboard" and "Dashboard1"
assign some Webplayer instances from "server 1" to "Dashboard" pool
assign some Webplayer instances from "server 2" to "Dashboard1" pool
now you can assign reports to appropriate resource pool
I don't know if it would work but what if you staggered the scripts.
<script src="https://spotfire-next.cloud.tibco.com/spotfire/js-api/loader.js"></script>
<script>
var serverUrl = "https://spotfire-next.cloud.tibco.com/spotfire/wp/";
var analysisPath = "/Samples/Expense Analyzer Dashboard";
var customizationInfo = new spotfire.webPlayer.Customization();
var app = new spotfire.webPlayer.Application(serverUrl, customizationInfo,analysisPath);
var doc=app.openDocument("container");
</script>
<script src="https://spotfire.cloud.tibco.com/spotfire/wp/GetJavaScriptApi.ashx"></script>
<script>
var serverUrl2 = "https://spotfire.cloud.tibco.com/spotfire/wp/";
var analysisPath2 = "/Samples/Expense Analyzer Dashboard2";
var customizationInfo2 = new spotfire.webPlayer.Customization();
var app2 = new spotfire.webPlayer.Application(serverUrl2, customizationInfo2, analysisPath2);
var doc2=app2.openDocument("container2");
</script>
Could you download one of the loader.js and append a prefix manually and load that to your site and reference it.
You could build them in separate pages and then pull them in iframes if not overly complicated pages.
It's definitely a problem as JavaScript overrides same named functions with the last one.
Related
When I try to get the time of creation of a file in Google Drive with the built in function getDateCreated() in the apps script, it returns the time an hour after the creation.
My code is as follows
var folder = DriveApp.getFolderById(myFolderId);
var contents = folder.getFiles();
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var var_file;
var var_name;
var var_link;
var var_owner;
var var_time;
while(contents.hasNext()){
var_file = contents.next();
var_name = var_file.getName();
var_link = var_file.getUrl();
var_owner = var_file.getOwner().getName();
var_time = var_file.getDateCreated();
sheet.appendRow([var_name,var_link,var_owner, var_time]);
}
If time of creation of a file is 25/06/2022 22:48:39
The output of my code returns 25/06/2022 23:48:39 which is an error.
Note: My time zone is UTC-5
I did some research on different built-in methods in Javascript and the .toLocaleTimeString() seems to work fine returning the actual time the file was created.
var_time = var_file.getDateCreated().toLocaleTimeString();
It's also quite important to check the appsscript.json file which can be accesed by going to Project Settings and toggling on the option Show the appsscripts.json file
The only reason could be the time zone setup of your script file. You can check out bi going to File > Project properties in the script editor.
Google developers docs
Also you can review this setting running this:
var timeZone = Session.getScriptTimeZone();
Logger.log(timeZone);
I want to use data from the api from Mixcloud (audio hosting service like soundcloud) such that a new subpage(is it called deeplink?) is created when a new post is posted to Mixcloud.
My project is a website for a podcast. I am imagining the index.html featuring every podcast episode in a list, with subpages each dedicated to a single episode. mockup
I'm very new to web development so please bear with me. I would therefore love references/material to read.
I have figured out how to get data from the JSON api parse it into Javascript strings and change the innerHTML of elements in the index.html.
I'm having difficulty understanding how you might go about generating the new subpages whenever a new post is posted to Mixcloud.
I'm also having difficulty searching for the right material to read about this, probably because I don't know the right words and terms to search for.
Here's a snippet of my code so far. And the API / JSON file that I'm using.
<div class="episode">
<div class="episode-title">Loading episode...</div>
</div>
<div class="episode">
<div class="episode-title">Loading episode...</div>
</div>
<div class="episode">
<div class="episode-title">Loading episode...</div>
</div>
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
//parse JSON to javascript objects
var response = JSON.parse(xhttp.responseText);
//array of the first 3 podcast episodes
var episodes = document.getElementsByClassName("episode");
//array of the first 3 podcast episode titles
var episodeTitles = document.getElementsByClassName("episode-title");
//loop to update innerHTML
for(var i = 0; i < episodes.length; i++) {
var episodeTitle = response.data[i].name;
episodeTitles[i].innerHTML = episodeTitle;
}
}
};
xhttp.open("GET", "https://api.mixcloud.com/radiomodem/cloudcasts/", true);
xhttp.send();
It seems like you are expecting to be able to create a hierarchical structure of pages with client side code. I suggest starting some reading around client vs server. This link being the first google search result.
If you plan on doing this in javascript as client side code, the pages you create will not physically exist. You would be creating a Single Page Application that references resources that look like pages but are only stored in memory. Delivery of those pages would be made through a client side router, without a web request to a server resource being made. With a Single Page Application approach, you would not be able to present the same cached version of a Mixcloud post to multiple users; the in-memory pages you create would only exist in an individual users browser.
You need to split your code into separate server and client code bases for this to work properly.
Your server would make the requests to https://api.mixcloud.com/radiomodem/cloudcasts/ and create a new physical subpage file for each child page. Your home page could read the contents of the subpage directory and present these as navigateable choices.
On the client side all you have is html.
If you want to stick with only learning 1 language I suggest using Node with Express. This would allow you to run JavaScript on the server.
I am trying to scan a folder for all .shp files and add them to my leaflet map as a layer. The problem I'm having is that AJAX doesn't appear to be able to scan a folder, rather it is only capable of searching for specific files. I need it to be able to scan the folder because the .shp files will be overwritten periodically with new file names and I don't know how many files will be there at a given time. If there are no files in the folder, I need a popup to notify that maps are unavailable (this works in the current website). The code for this section is provided below. I've tried using PHP, but I can't figure out how to incorporate that with JavaScript.
I'm not a programmer, but I have stumbled through developing our website on my own. You can view it here: http://hsvfms.azurewebsites.net/map.html
If I haven't provided enough information or have given this information out of context, please let me know. Also, check out the website and let me know what you think.
var noMaps = L.control ();
var profile01 = new L.LayerGroup();
var profile02 = new L.LayerGroup();
$.ajax({
type:"GET",
url:"Aldridge_Unet/",
success: function(data) {
$(data).find("a:contains(.shp)").each(function(){
var mapList=[];
var profile0 = new L.Shapefile(mapList[0],{color:'DarkCyan',fillOpacity:'0.5', opacity:'5', weight:'1'}).addTo(profile01);
var profile1 = new L.Shapefile(mapList[1],{color:'DarkCyan',fillOpacity:'0.5', opacity:'5', weight:'1'}).addTo(profile02);
})
},
error: function (xhr, status, error) {
if(xhr.status==404){
noMaps = L.control ({position:'bottomleft'});
noMaps.onAdd = function(map) { var div = L.DomUtil.create('div', 'info legend');
div.innerHTML += '<img src="Images/map_not_available.png" alt="legend" style="width:275px;height:75px;background-color:white">';
return div;};
}
}
});
var overlays = [{groupName:"Inundation Boundaries", expanded:false, layers:{"Max Value":profile01}},];
Cannot be done. JavaScript code cannot access the filesystem of the computer the browser is running in (let alone watch a path for changes).
AJAX (and fetch and similar techniques) are just ways of fetching information from another computer (the web server). If your question really is "when something changes in the web server, how can I update the clients?" then the answer is probably WebSockets, socket.io, and similar techniques.
I have a huge file of data points, and I would like to load them. I am using Leaflet(Front-End)/Node.Js(Back-end)
I wanted to load the data that is inside borders.
I have two choices:
Using Node.Js
Using Leaflet (this is bad idea, 'cause the file is two huge to be
processed)
Now I want to load data whenever I move browser, The confusing part to me is, how can I load file every time from every move in front end
Move/Zoom Page (front End) ----> get Bounds --> On Node.JS Side (Back-end) --> Load data from PostGis by querying it using ORM --> write it on geojson file ---> plot data using on front-end part
main.js
1- Detect Movement / Zoom on
...
map.on('dragend', getPins);
map.on('zoomend', getPins);
...
function getPins(e){
bounds = map.getBounds();
var latMax = map.getBounds().getNorthEast().lat();
var lngMax = map.getBounds().getNorthEast().lng();
var latMin = map.getBounds().getSouthWest().lat();
var lngMin = map.getBounds().getSouthWest().lng();
var centerLATT = map.getCenter().lat();
var centerLON = map.getCenter().lng();
var centerZOOM = map.getZoom();
}
Node.Js / Express
var express = require('express');
var app = new express();
app.use(express.json());
app.use(express.static(__dirname + '/public'));
var port = Number(process.env.PORT || 5000);
app.listen(port);
2- Node module for returning PostGIS queries from this thread
I would like to update the point by loading from Postgis
var postgeo = require("postgeo");
postgeo.connect("postgres://user#host:port/database");
postgeo.query(
'SELECT gid,name,ST_X(the_geom) as longitude,ST_Y(the_geom) as latitude FROM GeoDataTable WHERE ST_Intersects( ST_MakeEnvelope('+latMax+", "+lngMax+", "+latMin+", "+lngMin" ', function(data) {
for(i=0; i<data.rows.length; i++){
var feature = new Feature();
feature.geometry = JSON.parse(result.rows[i].locale);
feature.properties = {"TTL", result.rows[i].ttl};
featureCollection.features.push(feature);
}
});
The problem is how can I pass latMax,lngMax,latMin,lngMin from front-end to backend and pass json file loaded from data base from back-end to front end automatically.
You can use socket.io to communicate with the node.js server in real time with the browser.
Your question is very generic, so it would take a lot of coding here to solve your problem, but basically you can use the socket.emit function from the socket.io library to send data from the browser to the server, and server back to the browser.
Warning: I'm a novice programmer (more of sysadmin). We were given an node js application that's using MongoDB. From what I can tell, the mongo.js file is using mongojs and monq java classes. It was setup with only one MongoDB and I'm trying to setup a new HA environment to use a replica set. Here is what they provided:
var mongojs = require('mongojs');
var monq = require('monq');
var dbName = 'exampledb';
var db = mongojs(dbName, ['collections']);
var client = monq('mongodb://127.0.0.1/exampledb', { w: 1 });
exports.db = db;
exports.ObjectId = mongojs.ObjectId;
exports.monqClient = client;
Now for a replica set, according to this article, I need to make the following change:
var db = mongojs('replset0.com, replset1.com, replset2.com/mydb?slaveOK=true?', ['collections']);
I'm not entirely sure what I need to do for the line after that. I'm guessing I would have to create an array that would contain the host name and port # for each member of the replica set (setup is primary, secondary, arbiter) such as:
var replSet = new replSet();
var replSet[0] = "server0:port0"
var replSet[1] = "server1.:port1"
var replSet[2] = "server2.:port2"
How would I go about detecting which node is the primary? Also if the primary were to fail, I would have to restart the node js application (using forever)?
I found the answer as it's calling MongoDB's URI
http://docs.mongodb.org/manual/reference/connection-string/
Should be something like:
var client = monq('mongodb://server0:port0,server1:port1,server2:port2/[dbname]?replicaSet=[replicaSet Name]
First question: As long as you give it all of the members in the connection string, the mongojs driver should be able to figure out which one is primary. No need to figure it out yourself.
Second question: No, you don't have to restart the node app. The other members in the set will elect a new primary, although it takes time for mongo to detect failure and run the election.
For more information, see the mongodb docs on replica sets.