ExtJS-Activity-Monitor snippet by arthurakay - extjs

Good day guys can anyone give an example how to use this snippet https://github.com/arthurakay/ExtJS-Activity-Monitor.
I searched this snippet because i want to catch how long the user has been idle then i saw this snippet i think it can help me what i want to achieve but i dont know how to use it i just try to insert this Ext.Loader.setPath('Ext.ux', 'extjs/examples/ux') to my app.js then i dont know where and how to insert this code :Ext.ux.ActivityMonitor.init({ verbose : true }); Ext.ux.ActivityMonitor.start();.
now can anyone help or give me an example like alert message when idle of 1 min so that i can include this to my work Thanks in advance

Ext.ux.ActivityMonitor.init({
verbose: true
});
Ext.ux.ActivityMonitor.start();
Ext.ux.ActivityMonitor.isActive = function() {
Ext.Msg.alert('Monitor', 'User is active!');
}
Ext.ux.ActivityMonitor.isInactive = function() {
Ext.Msg.alert('Monitor', 'User is inactive!');
}
Something like this. I add more messages for console log, just move mouse in ACTIVITY AREA window, or change chrome tabs for reset invactive counter

Related

$timeout function not working inside if statement

I am setting up a web form using angular whereby users will complete the form, get a response from the server, and then get redirected to another page.
angular.module('discountController', ['discServices'])
.controller('discCtrl', function(Discount, $timeout, $location){
var app = this;
app.reqDiscount = function(discountData) {
Discount.reqDiscount(app.discountData).then(function(data) {
if (data.data.success) {
app.successMsg = data.data.message ; // Create Success Message
$timeout(function(){
console.log('timeout fired');
$location.path('/discountoutcome');
} , 3000);
} else {
app.errorMsg = data.data.message; // Create an error message
}
});
};
});
In the above code I call the app.reqDiscount function and I successfully get a response from the server which populates the app.successMsg variable. But the $timeout function does not then work. However, if I place the $timeout function outside of the if-else statement it does work. This is not what I want, because if there is an error I want to stay on the page.
In other areas of my code I have placed a $timeout function in a nested position like this and it works, so I don't understand why it would not work here.
Any help you can give me would be great. Even if you can not answer this question if you can give me some tips on debugging that would be helpful as console.log() is my only method of debugging currently. I am using Visual Studio Code.
Chrome console:
Chrome console screen shot
Visual Studio Console:
VSC console
I got it. I had coded the API incorrectly. data.data.success was returning false instead of true. Thanks for your help.

how to handle unexpected 'alert' in selenium webdriver

PS: driver.switchTo().alert().accept(); is not working
Well , I want to automate testing of webpage which shows random alerts*
*random alerts :JavaScript Alert which are not controlled and can appear any time
so I dont know where to put driver.switchTo().alert().accept()because the occurrence of alert is not known in advance.
So kindly help me.. Here is simple mocha selenium test... I have commented out the alert.accept() part..
I want to know how to handle
UnexpectedAlertOpenError: unexpected alert open: {Alert text :}
once in for all....
I read the selenium docs but couldn't find any...
here is my code
describe( 'handling alerts' , function(done){
after(function(done){
return driver.quit();
done();
});
it( 'should check title ', function(done){
driver.get("https://www.google.in");
driver.findElement(By.id("q"));
driver.get("https://jsfiddle.net/cwthh0y7/");
// driver.switchTo().alert().accept();
driver.getTitle().then(function(title){
assert.equal(title, "Edit fiddle - JSFiddle");
done();
});
});
});
You can set capabilities while defining your driver object.
https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/ie/InternetExplorerDriver.html#UNEXPECTED_ALERT_BEHAVIOR
Refer this link on how to set Capabilities. This will help you define a generic behavior when your alerts are intermittent.

JSON post, browser and application different times

Before i start eating my keyboard, maybe someone can help me out here...
Im using Angular Bootstrap to set a time. After posting the time, and checking my console, i see that the selected time is posted. But after checking my log file, i see that the time is posted minus 1 hour. I've set my app => timezone to Europe/Amsterdam (ECT if im right) but still cant find what is going wrong.
Can someone help me please?
Controller:
public function update( EventRequest $request, $eventGuid )
{
Log::info($request->all());
$this->event->updateById($request, $eventGuid);
}
Angular post will be done as: 2016-01-27 03:45:39
Console log: 2016-01-27 03:45:39
Laravel log: 2016-01-27 02:45:39

Get the current browser name in Protractor test

I'm creating users in some test. Since it is connected to the backend and create real users I need fixtures. I was thinking of using the browser name to create unique user. However, It has proven to be quite difficult to get to it...
Anyone can point me in the right direction?
Another case of rubber ducking :)
The answer was actually quite simple.
in my onPrepare function I added the following function and it works flawlessly.
browser.getCapabilities().then(function (cap) {
browser.browserName = cap.caps_.browserName;
});
I can get access the name in my test using browser.browserName.
This has changed in version of protractor starting from 3.2 (selenium webdriver 2.52)
Now one should call:
browser.driver.getCapabilities().then(function(caps){
browser.browserName = caps.get('browserName');
}
If you want to avoid the a browser, you may want to do this:
it('User should see a message that he has already been added to the campaing when entering the same email twice', function () {
browser.getCapabilities().then(function (capabilities) {
browserName = capabilities.caps_.browserName;
platform = capabilities.caps_.platform;
}).then(function () {
console.log('Browser:', browserName, 'on platform', platform);
if (browserName === 'internet explorer') {
console.log('IE Was avoided for this test.');
} else {
basePage.email.sendKeys('bruno#test.com');
console.log('Mande el mail');
basePage.subscribe.click().then(function () {
basePage.confirmMessage('Contact already added to target campaign');
});
}
});
});

CakePHP how to display related information

My order table includes customer filed , When add new order, after choose the customer name from dropdown list, I want the same page to display the information of customer, for example, address, phone number from customer table
How to do?
Thanks in advance...
Could you give me an example or related links? I don't know anything about AJAX, have no idea where to start.
Maybe this link: http://www.w3schools.com/ajax/ajax_database.asp, but it uses php not cakephp...
the code in example is : xmlhttp.open("GET","getuser.php?q="+str,true);
I don't know how to pass customer_id(q=str) to orderscontroller/getuser function.need help
You can use JsHelper to achieve the same you mentioned. Kindly try at your end, and provide some raw code so that peers can help you to do that.
Your code should be like this
function showCustomer(str)
{
var xmlhttp;
if (str=="")
{
document.getElementById("divtoDisplayInfo").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("divtoDisplayInfo").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","/yoursite/controllername/action/str,true); //if you use redirect and windows environment
xmlhttp.send();
}
you should expect the view of that action so do the normal cake processing, get data in the controller, render view, if there is an error set the actions autorender to false.
but i will just advice you to download Jquery add to your cakephp framework this simple line
$("divToDisplayInfo's_ID").load("Controllername/action")
solves your problem.

Resources