max-mapper / max-mapper/elementary-electron
Works with this code, but still get fn undefined error
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 231
- Forks
- 43
- PR merge metrics
- No merged PRs in 30d
Description
I had issues every step of the way. Needed to add node support to app.js and made changes to index.js too. I don't know why replacing the callback way of doing it with a promise way worked, but with the following code getting the cat pic, annotating and printing on 'p' press all work.
However, still getting error messages in the console, similar to https://github.com/maxogden/elementary-electron/issues/32
Tracked them to here:
https://github.com/visionmedia/superagent/issues/676
https://github.com/visionmedia/superagent/issues/714
but I couldn't figure out where it's being included from to test if upgrading the version fixes it or such.
app.js
var electron = require('electron');
electron.app.on('ready', function () {
var mainWindow = new electron.BrowserWindow({
width: 600,
height: 800,
webPreferences: {
nodeIntegration: true
}});
mainWindow.loadURL('file://' + __dirname + '/index.html');
})
index.js
// Get cat pic src
var catpicture = require('cat-picture');
var src = catpicture.src;
catpicture.remove();
// Get annotation
var image = require('lightning-image-poly');
var viz = new image('#visualization', null, [src], {hullAlgorithm: 'convex'});
// Save pdf
var fs = require('fs');
var remote = require('electron').remote;
function save () {
remote.getCurrentWebContents().printToPDF({portrait: true})
.then( data => {
fs.writeFile('annotation.pdf', data, function (err) {
if (err) {
alert('error generating pdf! ' + err.message);
} else {
alert('pdf saved!');
}
})
})
.catch (err => {
console.log('test');
})
}
window.addEventListener('keydown', function (e) {
if (e.keyCode == 80) save()
})
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing app.js and index.js, then trace which dependency brings superagent into the application. Compare the reported console errors with superagent issues #676 and #714 and investigate the dependency version. Done means identifying the source of the errors and confirming whether an available dependency update removes them without breaking the working cat-picture, annotation, and PDF behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- electron, javascript
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100