Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit ea573161 authored by Antoine Blanquet's avatar Antoine Blanquet
Browse files

grosses modif generation sparkline en piece jointe mail, capture ecran...

grosses modif generation sparkline en piece jointe mail, capture ecran sparkline en JS via phantomJS
parent c03a3638
images/operators.png

171 KB | W: | H:

images/operators.png

224 KB | W: | H:

images/operators.png
images/operators.png
images/operators.png
images/operators.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -6,3 +6,4 @@ admin.token.json
.DS_Store
*.bak
*.old
data/images/*
#!/bin/bash
# -------------------------------------------------
# Description: Generate HTML report of gateways
# List Command: x
# Usage: runned by get_gateways.sh (à détailler)
# Create by: CampusIoT Dev Team, 2021 - Copyright (C) CampusIoT, - All Rights Reserved
# Since: 09/09/2560 (DD/MM/YYYY)
# -------------------------------------------------
# Version: 1.0
# -------------------------------------------------
# Bug:
# -------------------------------------------------
# DATA REPOSITORY
DATA_APP_FOLDER="data/applications/"
DATA_GAT_FOLDER="data/gateways/"
# 1 .Save Picture of Sparkline File
#todo
const webshot = require('webshot');
webshot('file:///home/blanquan/Bureau/2019-2022_Polytech/2emeAnnee/Tronc_Info/projet_campus_iot/chirpstack-monitoring/reports/.gateways.html',
'data/images/sparkline_report.png', function(err) {
if (!err) {
console.log("Screenshot taken!")
} else {
console.log("Bug when generating screeenshot")
}
});
{
"requires": true,
"lockfileVersion": 1,
"dependencies": {
"moment": {
"version": "2.29.1",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz",
"integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ=="
}
}
}
......@@ -6,16 +6,45 @@
# crontab entry
# TODO /bin/bash
# ./decompose_gateways_sparkline.sh
# DATA REPOSITORY
DATA_CONFIG_FOLDER="data/configuration/"
DATA_IMAGES_FOLDER="data/images/"
TO=$(jq --raw-output ".report_email_to" ${DATA_CONFIG_FOLDER}.config.json)
SUBJECT="Monitoring Report"
CONTENT_TYPE="Content-type: text/html"
CONTENT_TYPE_HTML="Content-type: text/html"
CONTENT_TYPE_MUL="Content-Type: multipart/mixed; boundary=\"GvXjxJ+pjyke8COw\""
CONTENT_TYPE_IMG="Content-type: image/png"
# CONTENT_TYPE="Content-type: multipart/mixed"
ATTACHMENT="../images/operators.png"
mail -a "$CONTENT_TYPE" -s "$SUBJECT" -u monitoring $TO <.gateways.html
mail -a "$CONTENT_TYPE" -s "$SUBJECT" -u monitoring $TO <.devices.html
# mail -a "$CONTENT_TYPE" -s "$SUBJECT" -u monitoring $TO <.gateways.html #généré avec pièce jointe
mail -a "$CONTENT_TYPE_HTML" -s "$SUBJECT" -u monitoring $TO <.devices.html
# mailx -a "$CONTENT_TYPE" -s "$SUBJECT" <.gateways.html "$TO"
IMAGE="sparkline_report.png"
IMAGE_LOC="${DATA_IMAGES_FOLDER}${IMAGE}"
echo "mail sended"
\ No newline at end of file
outputFile=".gateways.html"
(
echo "To: $TO"
echo "Subject: $SUBJECT"
echo "Mime-Version: 1.0"
echo "$CONTENT_TYPE_MUL"
echo "Content-Disposition: inline"
echo ""
echo "--GvXjxJ+pjyke8COw"
echo "$CONTENT_TYPE_HTML"
echo "Content-Disposition: inline"
cat $outputFile
echo ""
echo "--GvXjxJ+pjyke8COw"
echo "$CONTENT_TYPE_IMG"
echo "Content-Transfer-Encoding: BASE64"
echo "Content-ID: <envoie sparkline>"
echo "Content-Disposition: attachement; filename=${IMAGE}"
echo ""
cat $IMAGE_LOC | base64
) | mail -t
\ No newline at end of file
# Training Sparkline.
```
Envoyer un mail avec un résumé très précis . (Sparkline)
PB : envoyer par mail, possiblement pas possible avec du javascript. Alternative : Générer Sparkline, générer image et générer doc en svg.
```
TODO :
* Step1 : Produire des faux rapports (HTML) avec des éléments Sparkline. (entrainement utilisation de sparkline)
* Step2 : Générer image du rapport HTML en SVG
* Step3 : Produire les rapports HTML avec les véritables informations des gateways.
\ No newline at end of file
This diff is collapsed.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"></html>
<head>
<script type="text/javascript" src="jQuery_Sparklines_Simple_Example_fichiers/jquery-1.js"></script>
<script type="text/javascript" src="jQuery_Sparklines_Simple_Example_fichiers/jquery.js"></script>
<script type="text/javascript">
$(function() {
/** This code runs when everything has been loaded on the page */
/* Inline sparklines take their values from the contents of the tag */
$('.inlinesparkline').sparkline();
/* Sparklines can also take their values from the first argument
passed to the sparkline() function */
var myvalues = [10,8,5,7,4,4,1];
$('.dynamicsparkline').sparkline(myvalues);
/* The second argument gives options such as chart type */
$('.dynamicbar').sparkline(myvalues, {type: 'bar', barColor: 'green'} );
/* Use 'html' instead of an array of values to pass options
to a sparkline with data in the tag */
$('.inlinebar').sparkline('html', {type: 'bar', barColor: 'red'} );
});
</script>
</head>
<body>
<p>
Inline Sparkline: <span class="inlinesparkline">1,4,4,7,5,9,10</span>.
</p>
<p>
Sparkline with dynamic data: <span class="dynamicsparkline">Loading..</span>
</p>
<p>
Bar chart with dynamic data: <span class="dynamicbar">Loading..</span>
</p>
<p>
Bar chart with inline data: <span class="inlinebar">1,3,4,5,3,5</span>
</p>
</body>
</html>
\ No newline at end of file
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"></html>
<head>
<title>jQuery Sparklines Simple Example</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<style type="text/css">
body { font-family: helvetica, arial, san-serif; background-color: #fff; text-align: left; font-size: 0.9em; margin: 10em }
</style>
<script type="text/javascript" src="jQuery_Sparklines_Simple_Example_fichiers/jquery-1.js"></script>
<script type="text/javascript" src="jQuery_Sparklines_Simple_Example_fichiers/jquery.js"></script>
<script type="text/javascript" src="html2canvas.js"></script>
<script type="text/javascript">
$(function() {
/** This code runs when everything has been loaded on the page */
/* Inline sparklines take their values from the contents of the tag */
$('.inlinesparkline').sparkline();
/* Sparklines can also take their values from the first argument
passed to the sparkline() function */
var myvalues = [10,8,5,7,4,4,1];
$('.dynamicsparkline').sparkline(myvalues);
/* The second argument gives options such as chart type */
$('.dynamicbar').sparkline(myvalues, {type: 'bar', barColor: 'green'} );
/* Use 'html' instead of an array of values to pass options
to a sparkline with data in the tag */
$('.inlinebar').sparkline('html', {type: 'bar', barColor: 'red'} );
$.sparkline_display_visible();
/* To download as an image
AS TO BE IN THE CURRENT FUNCTION (sparline generating function)*/
html2canvas(document.querySelector("#capture")).then(canvas => {
//document.body.appendChild(canvas)
saveAs(canvas.toDataURL(), 'screenshot.png');
});
});
/* Function to download without having to click somewhere */
function saveAs(uri, filename) {
var link = document.createElement('a');
if (typeof link.download === 'string') {
link.href = uri;
link.download = filename;
//Firefox requires the link to be in the body
document.body.appendChild(link);
//simulate click
link.click();
//remove the link when done
document.body.removeChild(link);
} else {
window.open(uri);
}
};
</script>
</head>
<body id="capture">
<div style="padding: 10px; background: #f5da55">
<h4 style="color: #000; ">Hello world!</h4>
</div>
<p>
Inline Sparkline: <span class="inlinesparkline">1,4,4,7,5,9,10</span>.
</p>
<p>
Sparkline with dynamic data: <span class="dynamicsparkline">Loading..</span>
</p>
<p>
Bar chart with dynamic data: <span class="dynamicbar">Loading..</span>
</p>
<p>
Bar chart with inline data: <span class="inlinebar">1,3,4,5,3,5</span>
</p>
</body>
</html>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment