I can't seem to get the Alasql to become defined, i have installed it via node and I'm fairly certain that it is installed proplery however whenever i load my front end. i'm not 100% sure where it's going wrong, any help would be greatly appreciated!
require is not defined at Scope.$scope.exportData
$scope.exportData = function () {
var mystyle = {
sheetid: 'Account sheet',
headers: true,
caption: {
title:'My Big Table',
},
style:'background:#00FF00',
column: {
style:'font-size:30px'
},
columns: [
{columnid:'Date'},
{columnid:'Description'},
{columnid:'Due'},
{columnid:'Charged £'},
{columnid:'Received £'},
{columnid:'Balanced £'},
{
columnid:'name',
title: 'Number of letters in name',
width: '300px',
cell: {
value: function(value){return value.length}
}
},
],
row: {
style: function(sheet,row,rowidx){
return 'background:'+(rowidx%2?'red':'yellow');
}
},
rows: {
},
cells: {
2:{
2:{
}
}
}
};
$scope.exportData = function () {
var alasql = require('alasql');
alasql('SELECT * INTO XLS("report.xls",?) FROM ?',[mystyle,records]);
};
1 - From their own angularjs readme:
Please include the file normally and not via requireJS. Please include alasql before requireJS to avoid issue of "Mismatched anonymous define() module". This issue is with requireJS.
2 - I had "alasql is undefined" when using grunt to build my project. So I had to include alasql in my jshint file under "globals" section:
{
.
.
.
"globals": {
"angular": false,
"confirm": false,
"console": false,
"alert": false,
"alasql": false
}
}
PS: I recommend you exporting to ".xlsx" instead of ".xls". Microsoft is now refusing to open those files.
Related
I have integrated powerbi-embedded with Angular 9 web app also add code for custom layut but it's not working.
I want to customize operations menu /context and custom layout.
Configuration object -
const config: any = {
type: 'report',
uniqueId: 'report-id',
permissions: this.model.Permissions.All,
embedUrl: 'embed-url',
accessToken: 'access-token',
settings: {
layoutType: this.models.LayoutType.Custom,
customLayout: {
pageSize: {
type: this.models.PageSizeType.Custom,
width: 1600,
height: 1200
},
displayOption: this.models.DisplayOption.ActualSize,
pagesLayout: {
"MyReportSection007" : {
defaultLayout: {
displayState: {
mode: this.models.VisualContainerDisplayMode.Hidden
}
},
visualsLayout: {
"VisualContainer1": {
x: 1,
y: 1,
z: 1,
width: 400,
height: 300,
displayState: {
mode: this.models.VisualContainerDisplayMode.Visible
}
},
"VisualContainer2": {
displayState: {
mode: this.models.VisualContainerDisplayMode.Visible
}
},
}
}
}
}
}
};
Above config. not working. any idea how can i achived customization in menu operation and layout.
I'm following below docs -
https://microsoft.github.io/PowerBI-JavaScript/demo/v2-demo/index.html#
https://github.com/microsoft/PowerBI-JavaScript/wiki/Custom-Layout
Thanks,
Your query is not clear since you have not shared any error message.
Though, code snippet that you shared offers a correct solution but, it might be possible that you are using wrong names for visual containers (i.e. VisualContainer1 or VisualContainer2) or the report page name (i.e. MyReportSection007). Ensure that you are providing correct names.
And if possible, please share the error message as well.
my Configuration file is not able to find the spec file even though it is present in the path that i provided in the cucumberOpts..i tried all the resolutions but none of them is worked.
Config File
const log4js = require('log4js');
var fs=require('fs');
global.screenshots = require('protractor-take-screenshots-on-demand');
global.browser2;
var propertiesReader=require('properties-reader');
var env=require("../../env.js");
const {Given, Then, When, Before} = require('cucumber');
exports.config = {
//seleniumAddress: 'http://localhost:4444/wd/hub',
directConnect:true,
framework: 'custom',
// path relative to the current config file
frameworkPath: require.resolve('protractor-cucumber-framework'),
capabilities: {
'browserName': 'chrome',
metadata: {
browser: {
name: 'chrome',
version: '79'
},
device: 'MacBook Pro 15',
platform: {
name: 'OSX',
version: '10.12.6'
},
disableLog:true,
durationInMS:true,
openReportInBrowser:true
}
},
ignoreUncaughtExceptions:false,
// Spec patterns are relative to this directory.
specs: [
'../../Test_modules/features/'
],
beforeLaunch:function(){
if (fs.existsSync('./logs/ExecutionLog.log')) {
fs.unlink('./logs/ExecutionLog.log')
}
log4js.configure({
appenders: {
out: { type: 'console' },
info:{ type: 'dateFile', filename: "../Reports/logs/info", "pattern":"-dd.log",alwaysIncludePattern:false},
"console" : {
"type": "console",
"category": "console"
},
"file" : {
"category": "test-file-appender",
"type": "file",
"filename": "../../Reports/logs/log_file.log",
"maxLogSize": 10240,
// "backups": 3,
// "pattern": "%d{dd/MM hh:mm} %-5p %m"
}
},
categories: {
"info" :{"appenders": ["console"], "level": "info"},
"default" :{"appenders": ["console", "file"], "level": "DEBUG"},
//"file" : {"appenders": ["file"], "level": "DEBUG"}
}
});
},
cucumberOpts: {
require:['../../Test_modules/utilities/timeOutConfig.js','../../Test_modules/stepDefinition/spec.js'],
tags: false,
profile: false,
format:'json:../../Reports/jsonResult/results.json',
'no-source': true
},
onPrepare: function () {
const logDefault = log4js.getLogger('default');
const logInfo=log4js.getLogger('info');
screenshots.browserNameJoiner = ' - '; //this is the default
//folder of screenshot
screenshots.screenShotDirectory = '../../Screenshots';
global.openNewBrowser=require('../../Test_modules/utilities/newBrowserinstance.js');
global.testData=require('../../TestData/testData.json');
browser.logger = log4js.getLogger('protractorLog4js');
global.firstBrowser=browser;
global.properties=propertiesReader('../../TestData/propertyConfig.properties');
browser.waitForAngularEnabled(false);
browser.manage().window().maximize();
global.facebook=require('../../Test_modules/pages/fbPageObjects.js');
global.utility=require('../../Test_modules/utilities/testFile.js');
},
plugins: [{
package: 'H:/workspace/Proc-UI/node_modules/protractor-multiple-cucumber-html-reporter-plugin',
options:{
// read the options part for more options
automaticallyGenerateReport: true,
removeExistingJsonReportFile: true,
reportPath:'../../Reports/HtmlReports',
reportName:"test.html"
},
customData: {
title: 'Run info',
data: [
{label: 'Project', value: 'Framework Setup'},
{label: 'Release', value: '1.2.3'},
{label: 'Cycle', value: 'Test Cycle'}
]
},
}]
};
Spec File
var utilityInit,page2;//browser2;
page1=new facebook(firstBrowser);
module.exports=function(){
this.Given(/^Open the browser and Load the URL$/,async function(){
await firstBrowser.get(properties.get("url1"));
browser.logger.info("Title of the window is :"+await browser.getTitle());
//screenshots.takesScreenshot("filename");
});
this.When(/^User entered the text in the search box$/,async function(){
firstBrowser.sleep(3000);
await page1.email().sendKeys(testData.Login.CM[0].Username);
browser.sleep(3000);
await page1.password().sendKeys(testData.Login.CM[0].Password);
});
this.Then(/^click on login button$/,async function(){
browser.sleep(3000);
await facebook.submit().click();
});
this.Then(/^User tried to open in new browser instance$/,async function(){
browser2=await openNewBrowser.newBrowserInit(firstBrowser);
utilityInit=new utility(browser2);
utilityInit.ignoreSync(properties.get("url2"));
browser2.manage().window().maximize();
console.log(await utilityInit.title()+" title");
browser2.sleep(5000);
});
this.When(/^User entered the text in the email field$/,async function(){
page2=new facebook(browser2);
console.log(await page2.title()+" browser2");
await page2.search().sendKeys("testing");
browser2.sleep(3000);
page1=new facebook(firstBrowser);
console.log(await page1.title()+" browser1");
await page1.email().sendKeys(testData.Login.CM[0].Username);
screenshots.takeScreenshot("newScreenshot");
firstBrowser.sleep(5000);
});
};
Execution log
1) Scenario: Title of your scenario # ..\features\test.feature:24
? Given Open the browser and Load the URL
Undefined. Implement with the following snippet:
Given('Open the browser and Load the URL', function () {
// Write code here that turns the phrase above into concrete actions
return 'pending';
});
? Then User tried to open in new browser instance
Undefined. Implement with the following snippet:
Then('User tried to open in new browser instance', function () {
// Write code here that turns the phrase above into concrete actions
return 'pending';
});
? And User entered the text in the email field
Undefined. Implement with the following snippet:
Then('User entered the text in the email field', function () {
// Write code here that turns the phrase above into concrete actions
return 'pending';
});
√ After # ..\..\node_modules\protractor-cucumber-framework\lib\resultsCapturer.js:27
1 scenario (1 undefined)
3 steps (3 undefined)
0m00.004s
i tried by adding cucumber dependencies, updating from relative path to absolute path everything i did.. but none it is resolved.. previously it worked fine but in the process of updating it in to public framework file.. i updated the paths from absolute to relative path. that's it i lost my whole framework and it is continuesly saying undefined scenarios.
**For Just made me sure i ran the script by passing wrong spec file name in the cucumber opts and still it giving Undefined and that confirmed me that it is not even considering that spec file that i passed.
Simple installation makes my framework works
npm install cucumber#1.3.3 --save-dev
I'm having a hard time figuring out how to scrape this webpage to get this wedding list into my onepager. It doesn't seem complicated at first but when I get into the code, I just can't get any results.
I've tried ygrab.js, which was fairly simple and got me somewhere but then I can't seem to scrape the images and it only prints the output in the console (not much documentation to go on).
$(function() {
var $listResult = $('#list-result');
var kado = [];
var data = [
{
url: 'https://www.kadolog.com/fr/list/liste-de-mariage-laura-julien',
selector: '.kado-not-full',
loop: true,
result: [{
name: 'photo',
find: '.views-field-field-photo',
grab: {
by: 'attr',
value: 'src'
}
},
{
name: 'title',
find: '.views-field-title .field-content',
grab: {
by: 'text',
value: ''
}
},
{
name: 'description',
find: '.views-field-body .field-content',
grab: {
by: 'text',
value: ''
}
},
{
name: 'price',
find: '.price',
grab: {
by: 'text',
value: ''
}
},
{
name: 'remaining',
find: '.topinfo',
grab: {
by: 'text',
value: ''
}
},
{
name: 'link',
find: '.views-field-nothing .field-content .btn',
grab: {
by: 'attr',
value: 'href'
}
},
],
},
];
ygrab(data, function(result){
console.log(JSON.stringify(result, null, 2)); //photos = undefined
});
Then there's Node.js with Request and Cheerio (and I tried Crawler too), but I have no idea how node works.
var request = require("request");
This gives me an error in the console saying require is not defined. Fair enough, I added require.js to the scripts in my page. I got another error ("Uncaught Error: Mismatched anonymous define() module: ...").
My question is this: Is there a simple Javascript way (possibly without involving node?), to scrape the wedding list I'm trying to get? Or maybe a tutorial that resembles what I'm trying to do step by step ?
I'd be truly grateful for any help or advice.
i think your only issue is the img selector.
Change
{
name: 'photo',
find: '.views-field-field-photo',
grab: {
by: 'attr',
value: 'src'
}
},
To this
{
name: 'photo',
find: '.views-field-field-photo .field-content img',
grab: {
by: 'attr',
value: 'src'
}
},
I actually can't test this right now, but it should be working!!
Node.js is a seperate application that executes javascript independent of a web page.
require is Node's way of importing packages, and isn't defined by the browser, require.js is a javascript library for requiring packages, but it doesn't work the same way as Node's require function.
To use request and cheerio, you'd need to install Node.js from here, then install request and cheerio with the following commands:
npm install request --save
npm install cheerio --save
Then any code you write with Node.js in that directory will have access to the modules.
Here's a tutorial to web scraping in Node.js with cheerio.
I am developing a large enterprise application and I need to lazy load modules (another ExtJs applications) into a main application. I am trying to load app.js of other applications with Ext.Loader:
onTabChange: function (tabPanel, newCard, oldCard) {
Ext.Loader.loadScript({
url: 'SecondaryApp/app.js',
onLoad: function (obj) {
console.log('ok');
},
onError: function (obj) {
console.log('ko');
},
scope: this
});
newCard.add({ xtype: 'secondarylist' });
}
The callback it's ok but when I add the secondarylist component an exception of "Uncaught Error: [Ext.create] Unrecognized class name / alias: widget.secondarylist" is being thrown. The component is:
Ext.define('SecondaryApp.view.main.List', {
extend: 'Ext.grid.Panel',
xtype: 'secondarylist',
title: 'Personnel',
columns: [
{ text: 'Name', dataIndex: 'name' },
{ text: 'Email', dataIndex: 'email', flex: 1 },
{ text: 'Phone', dataIndex: 'phone', flex: 1 }
]
});
I tried to compile and load the List.js only but I have the same problem anyway.
Any suggestions?
EDIT:
I solved the issue (bad url '-_-) but now have another issue. If I load the js file it works properly but if I try to load the compiled js file (with Sencha Cmd) it fails because Ext.cmd is undefined. I need to load the compiled js and not the original js file. Any ideas?
I have a problem with a js script running in Internet Explorer.
Basically the script runs fine in Firefox, but I need to embed it into the webbrowser control in a silverlight application, for which it has to run error free in the Internet Explorer engine.
Running it in the IE produces an "Expected object" error in the following line:
$f("player", "player.swf", {
How could this be rewritten to also work in IE?
Here is the complete script:
$f("player", "player.swf", {
key: '##18a1aaa6552d45a2cfe',
log: { level: 'debug', filter: 'org.flowplayer.cluster.*' },
clip: {
url: 'live3',
live: true,
provider: 'rtmp',
autoBuffer:true,
bufferLength:10,
scale:'fit',
connectionProvider: 'cluster',
onStart: function(clip){ }
},
canvas: {backgroundImage: 'url(staytuned.jpg)'},
onError:function(err){canvas: {backgroundImage: 'url(taytuned.jpg)'}},
contextMenu: [
'player 1.1',
{'About ...' : function() {
location.href = "url/?page=aboutus";}},
{'Contact ...' : function() {
location.href = "url/?page=contactus";}},
{'More Casts ...' : function() {
location.href = "url/?page=casts";}},
],
plugins: {
overlay: {
url: 'overlay.swf',
top: 0,
right: 0,
width: 854,
height:450,
zIndex:3
},
rtmp: {
url: 'rtmp.swf'
},
cluster: {
url: 'cluster.swf',
netConnectionUrl: 'url',
hosts: [
{host:'url'},
{host:'url'}
]
},
controls: {
autoHide: false,
url:'url',
zIndex:5
},
gatracker: {
url: "analytics.swf",
trackingMode: "Bridge",
bridgeObject: "pageTracker"
}
}
});
Thanks,
Andrej
First answer was incorrect. See comments for details.
Edit
The problem is likely that $f is not defined at the time you're trying to call it. Place alert(typeof $f); on the line immediately before the line causing the error. If it doesn't alert function, them I'm right.
Make sure you're including the script that contains the definition for $f before you try to call it.
Goto www.jslint.com. Paste this entire script into the top window and click the "jslint" button below it.
You'll find that onError is malformed:
onError:function(err){canvas: {backgroundImage: 'url(taytuned.jpg)'}},
it should read more like:
onError:function(err) {
var canvas = {backgroundImage: 'url(taytuned.jpg)'};
return canvas;
},
There's a similar issue a few lines below.
And I suspect that "taytuned.jpg" needs to be enclosed within quotes, but it's not my script.