New electron app

This commit is contained in:
barwie2@st.amu.edu.pl 2020-01-13 17:29:37 +01:00
parent 48b4e2e5c5
commit b13f83ba2a
4 changed files with 127 additions and 67 deletions

View File

@ -3,12 +3,12 @@
<head> <head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-beta/css/materialize.min.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-beta/css/materialize.min.css">
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>@ATCHECK</title> <title>Student counter</title>
</head> </head>
<body> <body>
<nav> <nav>
<div class="nav-wrapper"> <div class="nav-wrapper">
<a class="brand-logo center">@ATCHECK</a> <a class="brand-logo center">Student counter</a>
</div> </div>
</nav> </nav>

View File

@ -7,6 +7,9 @@ const asn1js = require('asn1js');
const util = require('util'); const util = require('util');
const notifier = require('node-notifier'); const notifier = require('node-notifier');
const smartcard = require('smartcard'); const smartcard = require('smartcard');
const axios = require('axios')
let class_code = "";
let counter = 0; let counter = 0;
@ -33,7 +36,7 @@ app.on('ready', function () {
//Load html into window //Load html into window
mainWindow.loadURL(url.format({ mainWindow.loadURL(url.format({
pathname: path.join(__dirname, "index.html"), pathname: path.join(__dirname, "classcode.html"),
protocol: "file:", protocol: "file:",
slashes: true slashes: true
})); }));
@ -293,6 +296,21 @@ function printStudent(item) {
icon: path.join(__dirname, 'ok.png') icon: path.join(__dirname, 'ok.png')
}); });
axios.post('http://127.0.0.1:8889', JSON.stringify({
classes_code: class_code,
student_index: item[2],
student_name: item[0],
student_surname: item[1]
}))
.then((res) => {
console.log(`statusCode: ${res.statusCode}`)
console.log(res)
})
.catch((error) => {
console.error(error)
})
} }
//Catch //Catch
@ -307,6 +325,16 @@ ipcMain.on("card:read", function (e) {
card_read(); card_read();
}) })
ipcMain.on("set:classcode", function (e,classcode) {
class_code = classcode;
mainWindow.loadURL(url.format({
pathname: path.join(__dirname, "index.html"),
protocol: "file:",
slashes: true
}));
})
//Menu template //Menu template
const mainMenuTemplate = [{ const mainMenuTemplate = [{
label: "Student", label: "Student",

View File

@ -5,9 +5,9 @@
"requires": true, "requires": true,
"dependencies": { "dependencies": {
"@electron/get": { "@electron/get": {
"version": "1.7.2", "version": "1.7.0",
"resolved": "https://registry.npmjs.org/@electron/get/-/get-1.7.2.tgz", "resolved": "https://registry.npmjs.org/@electron/get/-/get-1.7.0.tgz",
"integrity": "sha512-LSE4LZGMjGS9TloDx0yO44D2UTbaeKRk+QjlhWLiQlikV6J4spgDCjb6z4YIcqmPAwNzlNCnWF4dubytwI+ATA==", "integrity": "sha512-Xzo+xLQ+gwmGywFnFuG7HNIALPVJOCkvKagGxSXU1LC3s/j3h2Nku9OdwJ4KDkITeUuXfvAO5KS8rLGcmAunNQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"debug": "^4.1.1", "debug": "^4.1.1",
@ -17,7 +17,7 @@
"global-tunnel-ng": "^2.7.1", "global-tunnel-ng": "^2.7.1",
"got": "^9.6.0", "got": "^9.6.0",
"sanitize-filename": "^1.6.2", "sanitize-filename": "^1.6.2",
"sumchecker": "^3.0.1" "sumchecker": "^3.0.0"
} }
}, },
"@sindresorhus/is": { "@sindresorhus/is": {
@ -36,9 +36,9 @@
} }
}, },
"@types/node": { "@types/node": {
"version": "12.12.17", "version": "12.12.11",
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.17.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.11.tgz",
"integrity": "sha512-Is+l3mcHvs47sKy+afn2O1rV4ldZFU7W8101cNlOd+MRbjM4Onida8jSZnJdTe/0Pcf25g9BNIUsuugmE6puHA==", "integrity": "sha512-O+x6uIpa6oMNTkPuHDa9MhMMehlxLAd5QcOvKRjAFsBVpeFWTOPnXbDvILvFgFFZfQ1xh1EZi1FbXxUix+zpsQ==",
"dev": true "dev": true
}, },
"abbrev": { "abbrev": {
@ -126,11 +126,20 @@
"dev": true "dev": true
}, },
"aws4": { "aws4": {
"version": "1.9.0", "version": "1.8.0",
"resolved": "https://registry.npmjs.org/aws4/-/aws4-1.9.0.tgz", "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz",
"integrity": "sha512-Uvq6hVe90D0B2WEnUqtdgY1bATGz3mw33nH9Y+dmA+w5DHvUmBgkr5rM/KCHpCsiFNRUfokW/szpPPgMK2hm4A==", "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==",
"dev": true "dev": true
}, },
"axios": {
"version": "0.19.0",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.19.0.tgz",
"integrity": "sha512-1uvKqKQta3KBxIz14F2v06AEHZ/dIoeKfbTRkK1E5oqjDnuEerLmYTgJB5AiQZHJcljpg1TuRzdjDR06qNk0DQ==",
"requires": {
"follow-redirects": "1.5.10",
"is-buffer": "^2.0.2"
}
},
"balanced-match": { "balanced-match": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
@ -393,9 +402,9 @@
"dev": true "dev": true
}, },
"core-js": { "core-js": {
"version": "3.5.0", "version": "3.4.2",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-3.5.0.tgz", "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.4.2.tgz",
"integrity": "sha512-Ifh3kj78gzQ7NAoJXeTu+XwzDld0QRIwjBLRqAMhuLhP3d2Av5wmgE9ycfnvK6NAEjTkQ1sDPeoEZAWO3Hx1Uw==", "integrity": "sha512-bUTfqFWtNKWp73oNIfRkqwYZJeNT3lstzZcAkhhiuvDraRSgOH1/+F9ZklbpR4zpdKuo4cpXN8tKP7s61yjX+g==",
"dev": true, "dev": true,
"optional": true "optional": true
}, },
@ -448,9 +457,9 @@
} }
}, },
"defer-to-connect": { "defer-to-connect": {
"version": "1.1.1", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-1.1.1.tgz", "resolved": "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-1.1.0.tgz",
"integrity": "sha512-J7thop4u3mRTkYRQ+Vpfwy2G5Ehoy82I14+14W4YMDLKdWloI9gSzRbV30s/NckQGVJtPkWNcW4oMAUigTdqiQ==", "integrity": "sha512-WE2sZoctWm/v4smfCAdjYbrfS55JiMRdlY9ZubFhsYbteCK9+BvAx4YV7nPjYM6ZnX5BcoVKwfmyx9sIFTgQMQ==",
"dev": true "dev": true
}, },
"define-properties": { "define-properties": {
@ -505,9 +514,9 @@
} }
}, },
"electron": { "electron": {
"version": "7.1.5", "version": "7.1.2",
"resolved": "https://registry.npmjs.org/electron/-/electron-7.1.5.tgz", "resolved": "https://registry.npmjs.org/electron/-/electron-7.1.2.tgz",
"integrity": "sha512-jagsvNz6Axu2Lsp5PqDgkcR+4BwoPP9YyLgMu9lhpFNRNKpNgfsEqUbtNolkFN/TtmWjxGO+iioWRrGqZHmJ8w==", "integrity": "sha512-7hjONYt2GlQfKuKgQrhhUL1P9lbGWLBfMUq+2QFU3yeLtCvM0ROfPJCRP4OF5pVp3KDyfFp4DtmhuVzAnxV3jA==",
"dev": true, "dev": true,
"requires": { "requires": {
"@electron/get": "^1.0.1", "@electron/get": "^1.0.1",
@ -635,9 +644,9 @@
"dev": true "dev": true
}, },
"fast-json-stable-stringify": { "fast-json-stable-stringify": {
"version": "2.1.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz",
"integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=",
"dev": true "dev": true
}, },
"fd-slicer": { "fd-slicer": {
@ -663,6 +672,29 @@
"locate-path": "^3.0.0" "locate-path": "^3.0.0"
} }
}, },
"follow-redirects": {
"version": "1.5.10",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz",
"integrity": "sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==",
"requires": {
"debug": "=3.1.0"
},
"dependencies": {
"debug": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
"requires": {
"ms": "2.0.0"
}
},
"ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
}
}
},
"forever-agent": { "forever-agent": {
"version": "0.6.1", "version": "0.6.1",
"resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz",
@ -916,6 +948,11 @@
"dev": true, "dev": true,
"optional": true "optional": true
}, },
"is-buffer": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.4.tgz",
"integrity": "sha512-Kq1rokWXOPXWuaMAqZiJW4XxsmD9zGx9q4aePabbn3qCRGedtH7Cm+zV8WETitMfu1wdh+Rvd6w5egwSngUX2A=="
},
"is-fullwidth-code-point": { "is-fullwidth-code-point": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz",
@ -1143,9 +1180,9 @@
"integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==" "integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg=="
}, },
"node-abi": { "node-abi": {
"version": "2.13.0", "version": "2.12.0",
"resolved": "https://registry.npmjs.org/node-abi/-/node-abi-2.13.0.tgz", "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-2.12.0.tgz",
"integrity": "sha512-9HrZGFVTR5SOu3PZAnAY2hLO36aW1wmA+FDsVkr85BTST32TLCA1H/AEcatVRAsWLyXS3bqUDYCAjq5/QGuSTA==", "integrity": "sha512-VhPBXCIcvmo/5K8HPmnWJyyhvgKxnHTUMXR/XwGHV68+wrgkzST4UmQrY/XszSWA5dtnXpNp528zkcyJ/pzVcw==",
"dev": true, "dev": true,
"requires": { "requires": {
"semver": "^5.4.1" "semver": "^5.4.1"
@ -1220,9 +1257,9 @@
"dev": true "dev": true
}, },
"npm": { "npm": {
"version": "6.13.4", "version": "6.13.1",
"resolved": "https://registry.npmjs.org/npm/-/npm-6.13.4.tgz", "resolved": "https://registry.npmjs.org/npm/-/npm-6.13.1.tgz",
"integrity": "sha512-vTcUL4SCg3AzwInWTbqg1OIaOXlzKSS8Mb8kc5avwrJpcvevDA5J9BhYSuei+fNs3pwOp4lzA5x2FVDXACvoXA==", "integrity": "sha512-2awiDZ9JuV/UoF4oXGhekCURC2X+eLLRz9/e58AGrPDlpzyn7e4oCaZmkzyEaisxM7jSoFKNnZhzB4xbmbM0Yw==",
"requires": { "requires": {
"JSONStream": "^1.3.5", "JSONStream": "^1.3.5",
"abbrev": "~1.1.1", "abbrev": "~1.1.1",
@ -1230,7 +1267,7 @@
"ansistyles": "~0.1.3", "ansistyles": "~0.1.3",
"aproba": "^2.0.0", "aproba": "^2.0.0",
"archy": "~1.0.0", "archy": "~1.0.0",
"bin-links": "^1.1.6", "bin-links": "^1.1.3",
"bluebird": "^3.5.5", "bluebird": "^3.5.5",
"byte-size": "^5.0.1", "byte-size": "^5.0.1",
"cacache": "^12.0.3", "cacache": "^12.0.3",
@ -1251,7 +1288,7 @@
"find-npm-prefix": "^1.0.2", "find-npm-prefix": "^1.0.2",
"fs-vacuum": "~1.2.10", "fs-vacuum": "~1.2.10",
"fs-write-stream-atomic": "~1.0.10", "fs-write-stream-atomic": "~1.0.10",
"gentle-fs": "^2.3.0", "gentle-fs": "^2.2.1",
"glob": "^7.1.4", "glob": "^7.1.4",
"graceful-fs": "^4.2.3", "graceful-fs": "^4.2.3",
"has-unicode": "~2.0.1", "has-unicode": "~2.0.1",
@ -1300,7 +1337,7 @@
"npm-install-checks": "^3.0.2", "npm-install-checks": "^3.0.2",
"npm-lifecycle": "^3.1.4", "npm-lifecycle": "^3.1.4",
"npm-package-arg": "^6.1.1", "npm-package-arg": "^6.1.1",
"npm-packlist": "^1.4.7", "npm-packlist": "^1.4.6",
"npm-pick-manifest": "^3.0.2", "npm-pick-manifest": "^3.0.2",
"npm-profile": "^4.0.2", "npm-profile": "^4.0.2",
"npm-registry-fetch": "^4.0.2", "npm-registry-fetch": "^4.0.2",
@ -1309,7 +1346,7 @@
"once": "~1.4.0", "once": "~1.4.0",
"opener": "^1.5.1", "opener": "^1.5.1",
"osenv": "^0.1.5", "osenv": "^0.1.5",
"pacote": "^9.5.11", "pacote": "^9.5.9",
"path-is-inside": "~1.0.2", "path-is-inside": "~1.0.2",
"promise-inflight": "~1.0.1", "promise-inflight": "~1.0.1",
"qrcode-terminal": "^0.12.0", "qrcode-terminal": "^0.12.0",
@ -1318,7 +1355,7 @@
"read": "~1.0.7", "read": "~1.0.7",
"read-cmd-shim": "^1.0.5", "read-cmd-shim": "^1.0.5",
"read-installed": "~4.0.3", "read-installed": "~4.0.3",
"read-package-json": "^2.1.1", "read-package-json": "^2.1.0",
"read-package-tree": "^5.3.1", "read-package-tree": "^5.3.1",
"readable-stream": "^3.4.0", "readable-stream": "^3.4.0",
"readdir-scoped-modules": "^1.1.0", "readdir-scoped-modules": "^1.1.0",
@ -1489,14 +1526,13 @@
} }
}, },
"bin-links": { "bin-links": {
"version": "1.1.6", "version": "1.1.3",
"bundled": true, "bundled": true,
"requires": { "requires": {
"bluebird": "^3.5.3", "bluebird": "^3.5.3",
"cmd-shim": "^3.0.0", "cmd-shim": "^3.0.0",
"gentle-fs": "^2.3.0", "gentle-fs": "^2.0.1",
"graceful-fs": "^4.1.15", "graceful-fs": "^4.1.15",
"npm-normalize-package-bin": "^1.0.0",
"write-file-atomic": "^2.3.0" "write-file-atomic": "^2.3.0"
} }
}, },
@ -2245,12 +2281,11 @@
"bundled": true "bundled": true
}, },
"gentle-fs": { "gentle-fs": {
"version": "2.3.0", "version": "2.2.1",
"bundled": true, "bundled": true,
"requires": { "requires": {
"aproba": "^1.1.2", "aproba": "^1.1.2",
"chownr": "^1.1.2", "chownr": "^1.1.2",
"cmd-shim": "^3.0.3",
"fs-vacuum": "^1.2.10", "fs-vacuum": "^1.2.10",
"graceful-fs": "^4.1.11", "graceful-fs": "^4.1.11",
"iferr": "^0.1.5", "iferr": "^0.1.5",
@ -3095,11 +3130,8 @@
} }
}, },
"npm-bundled": { "npm-bundled": {
"version": "1.1.1", "version": "1.0.6",
"bundled": true, "bundled": true
"requires": {
"npm-normalize-package-bin": "^1.0.1"
}
}, },
"npm-cache-filename": { "npm-cache-filename": {
"version": "1.0.2", "version": "1.0.2",
@ -3130,10 +3162,6 @@
"version": "1.2.1", "version": "1.2.1",
"bundled": true "bundled": true
}, },
"npm-normalize-package-bin": {
"version": "1.0.1",
"bundled": true
},
"npm-package-arg": { "npm-package-arg": {
"version": "6.1.1", "version": "6.1.1",
"bundled": true, "bundled": true,
@ -3145,7 +3173,7 @@
} }
}, },
"npm-packlist": { "npm-packlist": {
"version": "1.4.7", "version": "1.4.6",
"bundled": true, "bundled": true,
"requires": { "requires": {
"ignore-walk": "^3.0.1", "ignore-walk": "^3.0.1",
@ -3303,7 +3331,7 @@
} }
}, },
"pacote": { "pacote": {
"version": "9.5.11", "version": "9.5.9",
"bundled": true, "bundled": true,
"requires": { "requires": {
"bluebird": "^3.5.3", "bluebird": "^3.5.3",
@ -3320,7 +3348,6 @@
"mississippi": "^3.0.0", "mississippi": "^3.0.0",
"mkdirp": "^0.5.1", "mkdirp": "^0.5.1",
"normalize-package-data": "^2.4.0", "normalize-package-data": "^2.4.0",
"npm-normalize-package-bin": "^1.0.0",
"npm-package-arg": "^6.1.0", "npm-package-arg": "^6.1.0",
"npm-packlist": "^1.1.12", "npm-packlist": "^1.1.12",
"npm-pick-manifest": "^3.0.0", "npm-pick-manifest": "^3.0.0",
@ -3559,14 +3586,14 @@
} }
}, },
"read-package-json": { "read-package-json": {
"version": "2.1.1", "version": "2.1.0",
"bundled": true, "bundled": true,
"requires": { "requires": {
"glob": "^7.1.1", "glob": "^7.1.1",
"graceful-fs": "^4.1.2", "graceful-fs": "^4.1.2",
"json-parse-better-errors": "^1.0.1", "json-parse-better-errors": "^1.0.1",
"normalize-package-data": "^2.0.0", "normalize-package-data": "^2.0.0",
"npm-normalize-package-bin": "^1.0.0" "slash": "^1.0.0"
} }
}, },
"read-package-tree": { "read-package-tree": {
@ -3719,6 +3746,10 @@
"version": "3.0.2", "version": "3.0.2",
"bundled": true "bundled": true
}, },
"slash": {
"version": "1.0.0",
"bundled": true
},
"slide": { "slide": {
"version": "1.1.6", "version": "1.1.6",
"bundled": true "bundled": true
@ -4489,9 +4520,9 @@
"optional": true "optional": true
}, },
"psl": { "psl": {
"version": "1.6.0", "version": "1.4.0",
"resolved": "https://registry.npmjs.org/psl/-/psl-1.6.0.tgz", "resolved": "https://registry.npmjs.org/psl/-/psl-1.4.0.tgz",
"integrity": "sha512-SYKKmVel98NCOYXpkwUqZqh0ahZeeKfmisiLIcEZdsb+WbLv02g/dI5BUmZnIyOe7RzZtLax81nnb2HbvC2tzA==", "integrity": "sha512-HZzqCGPecFLyoRj5HLfuDSKYTJkAfB5thKBIkRHtGjWwY7p1dAyveIbXIq4tO0KYfDF2tHqPUgY9SDnGm00uFw==",
"dev": true "dev": true
}, },
"pump": { "pump": {
@ -4779,9 +4810,9 @@
} }
}, },
"sumchecker": { "sumchecker": {
"version": "3.0.1", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/sumchecker/-/sumchecker-3.0.1.tgz", "resolved": "https://registry.npmjs.org/sumchecker/-/sumchecker-3.0.0.tgz",
"integrity": "sha512-MvjXzkz/BOfyVDkG0oFOtBxHX2u3gKbMHIF/dXblZsgD3BWOFLmHovIpZY7BykJdAjcqRCBi1WYBNdEC9yI7vg==", "integrity": "sha512-yreseuC/z4iaodVoq07XULEOO9p4jnQazO7mbrnDSvWAU/y2cbyIKs+gWJptfcGu9R+1l27K8Rkj0bfvqnBpgQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"debug": "^4.1.0" "debug": "^4.1.0"

View File

@ -10,15 +10,16 @@
"author": "Me", "author": "Me",
"license": "ISC", "license": "ISC",
"devDependencies": { "devDependencies": {
"electron": "^7.1.5", "electron": "^7.1.2",
"electron-rebuild": "^1.8.8" "electron-rebuild": "^1.8.8"
}, },
"dependencies": { "dependencies": {
"asn1js": "^2.0.26", "asn1js": "^2.0.26",
"axios": "^0.19.0",
"fs": "0.0.1-security", "fs": "0.0.1-security",
"node-datetime": "^2.1.2", "node-datetime": "^2.1.2",
"node-notifier": "^6.0.0", "node-notifier": "^6.0.0",
"npm": "^6.13.4", "npm": "^6.13.1",
"pcsclite": "^1.0.0", "pcsclite": "^1.0.0",
"smartcard": "^1.0.32" "smartcard": "^1.0.32"
} }