Can you access a Modules Quick Settings from a scheduled task (class implementing SchedulerClient)? OR is there a way to select which Module you would like to retrieve the ModuleSettings for?
for example:
ActiveModule.ModuleSettings[FeatureController.SETTING_URL]
You can get the module settings with the ModuleController.
using DotNetNuke.Entities.Modules;
//get the module settings with the correct ModuleId and TabId
ModuleInfo mi = ModuleController.Instance.GetModule(ModuleId, TabId, false);
//change some settings
mi.ModuleTitle = "New Module Title";
//save the new module settings
ModuleController.Instance.UpdateModule(mi);
UPDATE
You can get all the Tabs or Modules like this
//get all tabs in the portal
var tabs = TabController.GetPortalTabs(PortalId, 0, true, false);
//get all modules in the portal
var modules = ModuleController.Instance.GetModules(PortalId);
//loop all individual modules
foreach (ModuleInfo module in modules)
{
Label1.Text += module.ModuleTitle + "<br>";
}
Related
$http.get('localhost:8080/myApp/Login).success(function() {.....
…..
…
});
I want to replace 'localhost:8080/myApp with the host where I will deploy my project with project name at that time …
What I am doing is that using angular I am mapping the URL to spring controller method . So I don't want it to be static I want 'localhost:8080/myApp to be taken dynamically where I am deploying my project with the project name …
While working
Projects name: myApp
Host:localhost:8080
When deployed
Projects name: myApplication
Host:www.xyz.com
So my
$http.get('www.xyz.com/myApplication/Login). success(function(){...
….
…});
Update:I also want my project name to be automatically taken in which my js and Java controller is there
The $location service does provide information from the url. So, you could construct something to then make the dynamic host:
// given URL http://example.com/#/some/path?foo=bar&baz=xoxo
var host = $location.host();
// => "example.com"
// given URL http://user:password#example.com:8080/#/some/path?foo=bar&baz=xoxo
host = $location.host();
// => "example.com"
host = location.host;
// => "example.com:8080"
First you need to declare $location in your service then you can extract dynamic location host port.
To know more about $location service please check angular api doc
Extract Project Name:
For Extract Projet name i make my custom method which get project name from $location.absUrl() use Following function:
var url= $location.absUrl();
url= getProjectName(url);
function getProjectName(url){
var index,int;
for (int = 0; int <3; int++) {
index = url.indexOf("/");
url= url.substring(index+1);
}
var index = url.indexOf("/");
url = url.slice(0, index);
return url;
}
I have an Angular.js application, and, because it is a single page application, I'm loading some scripts dynamically, depending on the user navigation, so I don't get an overload.
The problem is, some of these scripts are uglified and minified in a ASP.NET MVC Bundle, and when I update a source script, the imported bundle never gets updated.
Why that happens, and what can I do to force an update?
Why that happens
The ASP.NET bundle comes with a caching mechanism. When you add the bundle to the page using Scripts.Render, the engine automatically puts a v query string into the bundle URL.
#Scripts.Render("~/bundles/commands")
produces something like:
<script src="/bundles/commands?v=eiR2xO-xX5H5Jbn3dKjSxW7hNCH9DfgZHqGApCP3ARM1"></script>
If this parameter is not provided, the cached result will be returned. If you add the script tag manually, without it, you can face the same caching issue.
Info about the v query string is provided here ("Bundle Caching"), but is not very helpful.
What can I do
You can still load the bundled scripts dynamically, but you will have to add the v parameter. Note that it doesn't work if you try a randomly generated hash (I tried). Thanks to Frison B Alexander, this is possible using this approach:
private static string GetHashByBundlePath(string bundlePath)
{
BundleContext bundleContext = new BundleContext(new HttpContextWrapper(System.Web.HttpContext.Current), BundleTable.Bundles, bundlePath);
Bundle bundle = BundleTable.Bundles.GetBundleFor(bundlePath);
BundleResponse bundleResponse = bundle.GenerateBundleResponse(bundleContext);
Type bundleReflection = bundleResponse.GetType();
MethodInfo method = bundleReflection.GetMethod("GetContentHashCode", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
object contentHash = method.Invoke(bundleResponse, null);
return contentHash.ToString();
}
So what you can do is: Return the bundle hash from the ASP.NET view and get it when you need to load the script.
I my application, I created a JS object specific to it:
var appBundles = {
commands: "/bundles/commands?v=eiR2xO-xX5H5Jbn3dKjSxW7hNCH9DfgZHqGApCP3ARM1"
};
Hope this helps!
I had this problem with bundles not updating when I was loading bundles from one MVC app in another MVC app using GTM (sound messed up, but it actually makes sense in the context of multiple MVC apps sharing code between).
What I came up with is what Marcos Lima wrote in his answer, but taken a step further.
I've added a Bundle controller with following code:
public class BundleController : Controller
{
private static string GetHashByBundlePath(string bundlePath)
{
BundleContext bundleContext = new BundleContext(new HttpContextWrapper(System.Web.HttpContext.Current), BundleTable.Bundles, bundlePath);
Bundle bundle = BundleTable.Bundles.GetBundleFor(bundlePath);
BundleResponse bundleResponse = bundle.GenerateBundleResponse(bundleContext);
Type bundleReflection = bundleResponse.GetType();
MethodInfo method = bundleReflection.GetMethod("GetContentHashCode", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
object contentHash = method.Invoke(bundleResponse, null);
return contentHash.ToString();
}
public ActionResult Index(string bundleName)
{
string bundlePath = "~/bundles/" + bundleName;
var hash = GetHashByBundlePath(bundlePath);
return RedirectPermanent(bundlePath + "?v=" + hash);
}
}
Then I've added this route:
routes.MapRoute(
name: "Bundle",
url: "Bundle/{bundleName}",
defaults: new { controller = "Bundle", action = "Index" }
);
The end result is that I request the bundles through the controller, but because I do a 301 redirect the Index action is run only once per user and it returns the current version of the bundle and the bundle is then served from browser cache afterwards. When I actually update the bundle I add some query parameter in the request url (in GTM) and all users now get the updated bundle.
Of course, I assume that bundles are placed in ~/bundles/ path, but that should be easy enough to change if yours are placed elsewhere. In fact the route isn't even necessary.
I'm doing some studies using the Pixijs library, which I find amazing. I'll also have a look into Fabricjs, that seems to have a smaller footprint.
I've been working with Angularjs for some time now and I like conventions, instead of taking time in each project doing configuration and organizing code differently every time.
I would like to hear from some body who experienced Pixijs (or similar) with a framework to organise the code.
I understand that Angularjs is MVVM, but let me know about any tips or suggestion that you may think of?
I did some research this far and a few things came to my mind, such as Browserify (I do believe in convention instead of configuration like I've mentioned though and maybe this wouldn't be the best tool for me).
Kinda old question, but this is something I was looking for myself when starting out with PIXI, so I hope it could be of help to someone to get started.
I use the Revealing module pattern and separate the application into separate files/modules, and then use Browserify to create the application bundle. The HTML loads the app.js bundle which stems from the app.js source below.
index.html: Load your libs (PIXI et al) in <head> and then your app.js in the <body>.
app.js source example:
(function() {
// App.js is the "bootstrap" that loads dependencies, takes care of pre-loading etc.
// I have a template of this which I copy into any new project and use as a checklist.
var core = require("./core.js"); // Use a dummy module as application-wide namespace for easy access
// Any external modules (f eg node modules) could go here
core.utilityLib = require("node-lib");
// Application modules here
core.myModule = require("./myModule.js");
// core.myModule2 = require("./myModule2.js"); // .. you get the idea
// Our main application module
core.main = require("./main.js");
// Init function to run when DOM/scripts have loaded
var init = function() {
// I have a generic screen module which sets up PIXI renderer depending on device compatibility using Modernizr (or weapon of choice). To keep it simple for the sake of the example, lets just create our renderer directly:
core.renderer = PIXI.autoDetectRenderer(screen.innerWidth,screen.innerHeight,{resolution:window.devicePixelRatio});
// I also use a generic loader module that wraps PIXI.loader, taking a list of assets from a config file. Let's just call PIXI.loader directly for now:
PIXI.loader
.add({name:"myasset",url:"/myasset.png"})
.on('progress', loadProgressFunction)
.once('complete',loadCompleteFunction)
})
.load();
}
window.onload = init; // Tell browser to call init function when loaded
// Optional loading progress bar
var function = loadProgressCallback(e) {
}
// Call when mandatory assets has been loaded
var loadCompleteFunction = function() {
myModule.init(); // Init any mandatory modules, f eg to instantiate a player
main.init(); // Tell our main application/game module that we're ready to do fancy stuff
}
// Method to make things move
var animate = function() {
// Send juice to modules that needs to be juiced (or use a ticker module on per-module basis).
// core.main.animate();
requestAnimationFrame(animate);
}
requestAnimationFrame(animate); // See comment below
}());
Comment: PIXI has an built-in requestAnimationFrame alias that takes care of fallback. If not using PIXI, you could use Paul Irish' gist.
core.js:
module.exports = {}; // Just a dummy object to create a module scope that all the modules
// can use to communicate with each other, without running into circular reference problems
main.js:
// Main application/game module
module.exports = (function() {
// Dependencies
var core = require("./core.js"); // This way we can easily access all the necessary modules
// Exports
var exports = {}; // Everything put into this object will be "public"
// Vars
var stuff = 1; // Module vars
exports.init = function() {
// Application magic starts here :)
}
// Some other public method ...
exports.publicMethod = function() {
}
// Some private method
var privateMethod = function() {
}
return exports; // Expose public functions to other modules
}());
Any additional modules can be organized in pretty much the same way as main.js.
Run browserify dev/app.js > html_root/app.js each time you want to "compile" your bundle (or create a Makefile, gulp-, node-, or webpack-script - whichever you prefer).
Using protractor-net, Login page is non-angular, where as the home page is angular. hence cannot launch browser with url using NgWebDriver, probably since its looking for angular. tried angular.ignoreSynchronization="false". But same issue. If I use angDriver.WrappedDriver.FindElement to cross login, the angular objects in home page are not recognized-Asynchronous script error-timeout.
driver = new ChromeDriver("C:\\FTWork\\DriverFiles\\chromedriver_win32\\");
driver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(20));
angDriver = new NgWebDriver(driver,"[ng-app='Phoenix']");
string root=angDriver.RootElement;
angDriver.WrappedDriver.Navigate().GoToUrl(url);
angDriver.WrappedDriver.Manage().Window.Maximize();
driver = angDriver.WrappedDriver;
driver.FindElement(By.Id("UserID")).Clear();
driver.FindElement(By.Id("UserID")).SendKeys("");
driver.FindElement(By.Id("Password")).SendKeys("");
driver.FindElement(By.Id("searchsubmit")).Click();
System.Threading.Thread.Sleep(10000);
string dolAmt = angDriver.FindElement(NgBy.Binding("activeValue")).Text;
I am hoping this will do it.
_driver = new ChromeDriver("C:\\FTWork\\DriverFiles\\chromedriver_win32\\");
_driver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(10));;
//Do whatever for log in with chrome driver
string url = "url for angular page";
_ngWebDriver = new NgWebDriver(_driver, "[ng-app='Phoenix']");
//You have to naviagate to url in order the _ngWebDriver to know the angular page NOT click and go to angular page
_ngWebDriver.Navigate().GoToUrl(url);
_ngWebDriver.Manage().Window.Maximize();
//The script timeout is almost essential since most of protractor mechanism are dependent of client side script.
//start finding elements with NgBy class
NgWebElement ngElement = _ngWebDriver.FindElement(NgBy.Model("model"));
ngElement.Clear();
EDIT
driver = new ChromeDriver("C:\\FTWork\\DriverFiles\\chromedriver_win32\\");
driver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(20));
driver.FindElement(By.Id("UserID")).Clear();
driver.FindElement(By.Id("UserID")).SendKeys("");
driver.FindElement(By.Id("Password")).SendKeys("");
driver.FindElement(By.Id("searchsubmit")).Click();
// Phoenix is the ng-app of the coming angular page
string url = "url for angular page containing [ng-app='Phoenix']"
NgWebDriver angDriver = new NgWebDriver(driver,"[ng-app='Phoenix']");
// don't switch to wrapper driver
angDriver.Navigate().GoToUrl(url);
angDriver.Manage().Window.Maximize();
driver = angDriver.WrappedDriver;
string dolAmt = angDriver.FindElement(NgBy.Binding("activeValue")).Text;
Due to multiple interactive browser setup during tests, I have to setup protractor manually. My setup is from protractor 0.19. After I upgraded to 1.3.1 'protractor/jasminewd' is missing.
Has the manual setup process changed? Can anyone point me in the right direction? The head of my setup script:
var protractor = require('protractor');
require('protractor/jasminewd');
var utils = require('./utils.js');
//needed for jenkins
require('jasmine-reporters');
jasmine.getEnv().addReporter(
new jasmine.JUnitXmlReporter('xmloutput', true, true));
var conf = utils.readConfig();
var host = conf['server:main'].host;
var port = conf['server:main'].port;
var testbrowser = utils.readConfig()['integrationtest'].browser;
//setup
var driver1 = new protractor.Builder().
usingServer('http://localhost:4444/wd/hub').
withCapabilities({'browserName': testbrowser}).build();
driver1.manage().timeouts().setScriptTimeout(15000);
var browser = protractor.wrapDriver(driver1);
protractor.setInstance(browser);
var by = protractor.By;
var element = browser.element;
jasminewd has been moved to its own npm module now: https://www.npmjs.org/package/jasminewd.
If you include jasminewd in your package.json and use
require('jasminewd');
instead of
require('protractor/jasminewd')
everything should just work