In Rally, is it possible to dynamically change script source so that I can load multiple apps? - sdk

I would like to have a drop down of app Names (or url parameter) and load the app on select: Something like:
Ext.define('TestPage', {
extend: 'Rally.app.App',
items: [{
xtype: 'container',
id: "appDiv"
}],
launch: function () {
var me = this;
me.add({
xtype: 'box',
autoEl: {
tag: 'iframe',
src: 'https://rally-apps.com/Test.CFD.html',
width: 1020,
height: 1000
}
});
}
});
But I get error: Blocked a frame with origin https://rally-apps.com" from accessing a cross-origin frame. Is there any other way I can achieve this?

That error is a standard browser security limitation, where code in one domain cannot access code in another one. You may be able to work around it by instead making an ajax request to that url to load the app content and then injecting it into your current app. Hard to say.
The other idea that comes to mind is just adding these apps to your subscription app catalog, so anyone can add them to any pages they like...

Related

Set up opt-in Highcharts Alerts?

I would like to setup a method for sending users an alert via email if a critical value is crossed in highcharts (I'd also like them to have to opt in to this feature rather than it being compulsory). Is there any built in functionality for this? Could anyone recommend the best way to go about solving this issue? Thanks.
If you want to have a reaction to what is happening on the chart, you need to connect to chart.events. There you will be able to plug in an external function that will send an email, in Higcharts there is no such option built in.
In this case use event render fire after each redraw, as your data changes dynamically.
chart: {
events: {
render: function() {
let data = this.series[0].data;
data.forEach(function(point) {
console.log(point.y);
if (point.y > 40) {
window.alert("you have point above 40");
}
})
}
},
},
https://api.highcharts.com/highcharts/chart.events.render
https://api.highcharts.com/class-reference/Highcharts.Series#addPoint
Demo: https://jsfiddle.net/BlackLabel/jpcz7xu2/1/

"Not allowed to load local resource" with file image URL in Electron app

I am working on a note taking Electron app that uses Markdown. Currently, I'm working on inserting images into notes (using the Markdown syntax).
When inserting an image, my main process copies the image into the notes directory, then returns a file:/// URL to the image file. However, when I try to render the image, it doesn't load - and I get the error Not allowed to load local resource: file:///Users/joe/notes/images/foo.jpg.
Is there a way I can configure Electron to allow these local image URLs?
Option 1
Turning the web security off
mainWindow = new BrowserWindow({
height: 563,
useContentSize: true,
width: 1000,
webPreferences: {
webSecurity: false
}
});
Option 2
You can create your own protocol like this answer
Also here is the user that answered that question
You need register a file protocol to remove the file:/// prefix.
import { protocol } from "electron";
app.whenReady().then(() => {
protocol.registerFileProtocol('file', (request, callback) => {
const pathname = decodeURI(request.url.replace('file:///', ''));
callback(pathname);
});
});
https://github.com/electron/electron/issues/23757#issuecomment-640146333

Can't recieve port message from main.js in content script

I am trying to send a message via port from my main.js to my content script for my panel. I've tried many things without luck, however sending a message from the content script to main.js works perfectly.
Here is what my main.js looks like:
var data = require("self").data;
var setting = require("panel").Panel({
width: 250,
height: 130,
contentURL: data.url("www.google.com"),
contentScriptFile: data.url("script.js")
});
require("widget").Widget({
id: "sorter1",
label: "Search Result Sorting",
contentURL: data.url("icon.ico"),
panel: setting
});
setting.port.emit("message");
And here is my content script:
self.on("message", function(addonMessage) {
document.innerHTML = "Got Message"
});
I had this figured out a few days ago, just haven't had the time to post here.
A few things to keep in mind when using panels:
Pannel page is loaded when extension is loaded, not when it is shown.
Content script of the panel page is injected into the panel page when the page is shown.(when contentScriptWhen property is default)
Content scripts dont have access to add-on SDK resources.
This is how I implemented it
In main.js
panel.on("show", function() {
panel.port.emit("message");
});
In panel content script
self.port.on("message", function() {
//doThings
});
port.emit() doesn't need a second argument, though second argument is what will be passed to the content script for
function(secondArg) {
}
[Update] Sorry, I didn't fully read the code.
First off, you actually need to send the panel a message, eg
setting.port.emit('message', someData);
For the second part: I think you want:
self.port.on("message", function(addonMessage) {
document.innerHTML = "Got Message"
});
The relevant docs are here:
https://addons.mozilla.org/en-US/developers/docs/sdk/latest/dev-guide/guides/content-scripts/using-port.html

trigger.io - Embed external website

I would like to embed an external website in my app, so I tried it with the tag here:
<iframe src="http://www.uniteich.at" frameborder="0" width="420" height="315"></iframe>
But I get the following error: "Unsafe JavaScript attempt to access frame with URL content://io.trigger.forge2dd999d0f14b11e1bc8612313d1adcbe/src/index.html from frame with URL http://www.uniteich.at/. Domains, protocols and ports must match."
So is there a good solution to embed a website in ios/android app with trigger.io?
Thanks in advance,
enne
EDIT: Ok, to make it more clear what I want: I would just like to load an external website as soon as a user clicks on a specific tabbar button at the bottom. I made this event-handler:
var dessertButton = forge.tabbar.addButton({
text: "Uniteich",
icon: "img/strawberry.png",
index: 2
}, function (button) {
button.onPressed.addListener(function () {
//LOAD EXTERNAL WEBSITE IN CONTENT CONTAINER HERE
});
});
Is that possible somehow?
This issue is cross domain requests. For more information read the same origin policy.
To get around this you will need to utilize forge.request. After adding www.uniteich.at to your config permissions first try the simple forge.get like this:
button.onPressed.addListener(function () {
var mainElement = document.getElementById("main");
forge.request.get("http://www.uniteich.at/index.html", function(content) {
mainElement.innerHTML = content;
},
function(error) {
mainElement.innerHTML = "<b>Error</b>" + error.message;
});
});
And if that does not work or not enough (I am not at my dev computer right now) you can utilize more options with forge.request.ajax.

jQuery UI AutoComplete Plugin - Questions

I have an ASP.NET MVC 3 Web Application (Razor), and a particular View with the jQuery UI AutoComplete plugin (v1.8).
Here's the setup i currently have:
$('#query').autocomplete({
source: function (request, response) {
$.ajax({
url: "/Search/FindLocations",
type: "POST",
dataType: "json",
data: { searchText: request.term },
success: function (data) {
response($.map(data, function (item) {
return { name: item.id, value: item.name, type: item.type }
}))
},
error: function (xmlHttpRequest, textStatus, errorThrown) {
// don't know what i should do here...
}
})
},
select: function (event, ui) {
$.get('/Search/RenderLocation', { id: ui.item.name }, function (data) {
$('#location-info').html(data);
});
},
delay: 300, minLength: 3
});
The AutoComplete returns locations in the world, basically identical to Google Maps auto complete.
Here are my questions:
1) What are the recommended settings for delay and minLength? Leave as default?
2) I thought about putting [OutputCache] on the Controller action, but i looks as though the plugin automatically does caching? How does this work? Does it store the results in a cookie? If so when does it expire? Is any additional caching recommended?
3) I've noticed if i type something, and whilst the AJAX request is fired off, if i type something else, the dialog shows the first result momentarily, then the second result. I can understand why, but it's confusing to the user (given the AJAX request can take 1-2 seconds) but i'm thinking about using async: false in the $.ajax options to prevent multiple requests - is this bad design/UX?
4) Can you recommend any other changes on my above settings for improving performance/usability?
1) It really depends on your usage and your data.
2) You should use [OutputCache]. If there's any caching happening on the plugin, it's only going to be for each user, if you use caching at the controller action level, it'll cache one for all users. (again, this might actually be bad depending on your usage, but usually this is good to do)
3) This questions kind of hard too because of the lack of context. If ajax requests are 1-2 seconds and there's no way to make this shorter, you really should be a pretty big delay in so that users aren't sending off many requests while typing out a long word (if they type slow).
4) sounds like you need to look at your /search/FindLocations method and see where you can do caching or pref improvements. Give us a look at your code in here and I can try to suggest more.

Resources