attemp to capture grafana screen without open browser, fail

This commit is contained in:
Ryan Tang 2023-03-30 18:01:54 -04:00
parent aacac712ca
commit 23367d5ac4
6 changed files with 101 additions and 65 deletions

1
.gitignore vendored
View File

@ -10,6 +10,7 @@ screenshot.*
*settings*.dat
*.dat
Logs
*.png
*~
*.autosave

View File

@ -966,7 +966,6 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
{//@============== Trigger Mask/Map tab
//TODO==========================
triggerMapTab[iDigi] = new QTabWidget(tab);
chTabWidget->addTab(triggerMapTab[iDigi], "Trigger Map");

View File

@ -1,61 +0,0 @@
#!/bin/bash
#url=http://localhost:3000/dashboard/snapshot/qHdJjri9Uk7DPbwnFh0fIBDEELMn4nzP
#url="http://localhost:3000/d/iXH6cG-Vz/test-dashboard?orgId=1&refresh=5s&from=1678824051707&to=1678827651708"
#firefox -screenshot http://solarisdaq:3000/dashboard/snapshot/qHdJjri9Uk7DPbwnFh0fIBDEELMn4nzP haha.png
#cutycapt --url=${url} --out=haha.png
#wget --output-document="haha.png" ${url}
usr=GeneralSOLARIS
pwd='gam$hippie'
APIKEY=eyJrIjoid25Bc3U3NEdxVDZYV2xrdEJ0QTlxNTdFM25JcXVTTlAiLCJuIjoiYWRtaW5LRVkiLCJpZCI6MX0=
url=http://localhost:3000/
#curl http://${usr}:${pwd}@localhost:3000/api/search
#curl http://${usr}:${pwd}@localhost:3000/api/admin/settings
#curl -v -H "Accept: application/json" -H "Content-Type: application/json" http://${usr}:${pwd}@localhost:3000/api/dashboard/snapshots
#get list of snapshot
#curl -v http://${usr}:${pwd}@localhost:3000/api/dashboard/snapshots
#delet snapshot
#curl -X DELETE http://${usr}:${pwd}@localhost:3000/api/snapshots/HzQd70cK1NhqZ7lDV7bSU4GkmNMezacs
#curl -v -X -d ${msg} http://${usr}:${pwd}@localhost:3000/api/snapshots
#curl -X DELETE -H "Authorization: Bearer ${APIKEY}" ${url}api/snapshots/Yn7MnDIzXsOL3VoRS617N17K5ojTsnOk
# curl -X POST -H "Authorization: Bearer ${APIKEY}" -H "Accept: application/json" -H "Content-Type: application/json" -d '{
# "dashboard": {
# "editable":false,
# "nav":[{"enable":false, "type":"timepicker"}],
# "rows": [ {} ],
# "style":"dark",
# "tags":[],
# "templating":{ "list":[]},
# "time":{ },
# "timezone":"browser",
# "title":"Home",
# "version":5
# },
# "expires": 2
# }' ${url}/api/snapshots
#curl -v -X GET -H "Authorization: Bearer ${APIKEY}" -H "Accept: application/json" ${url}api/dashboard/snapshots
#curl -v -X GET -H "Authorization: Bearer ${APIKEY}" -H "Accept: application/json" ${url}api/search
#successfull single panel
#curl 'http://localhost:3000/render/d-solo/iXH6cG-Vz/test-dashboard?orgId=1&refresh=5s&from=now-6h&to=now&panelId=2&width=1000&height=500&tz=America%2FNew_York' -H "Authorization: Bearer ${APIKEY}" --compressed > haha.png
curl 'http://localhost:3000/render/d-solo/iXH6cG-Vz/test-dashboard?orgId=1&refresh=5s&from=now-6h&to=now&panelId=2' -H "Authorization: Bearer ${APIKEY}" --compressed > haha.png
eog haha.png

View File

@ -321,9 +321,6 @@ MainWindow::~MainWindow(){
delete influx;
}
//TODO --- printf("----- Save Log File");
printf("--- end of %s\n", __func__);
}
@ -522,6 +519,7 @@ void MainWindow::StopACQ(){
+ "======================";
AppendElog(msg, chromeWindowID);
LogMsg("Run " + settingFilePath + "/scripts/endRunScript.sh" );
QProcess::startDetached(settingFilePath + "/scripts/endRunScript.sh");
}else{
@ -1984,6 +1982,8 @@ void MainWindow::AppendElog(QString appendHtmlText, int screenID){
}
}
//TODO ========= add elog bash script to tell mac, capture screenshot and send it back.
elogBash.start("elog", arg);
elogBash.waitForFinished();

68
scripts/grafanaScreenShot.sh Executable file
View File

@ -0,0 +1,68 @@
#!/bin/bash
APIKEY=eyJrIjoid25Bc3U3NEdxVDZYV2xrdEJ0QTlxNTdFM25JcXVTTlAiLCJuIjoiYWRtaW5LRVkiLCJpZCI6MX0=
url=http://localhost:3000
############# successfull single panel screenshot
#dashboardID=solaris-main-dashoard
#panelID=2
#curl "$url/render/d-solo/iXH6cG-Vz/$dashboardID?orgId=1&refresh=5s&from=now-6h&to=now&panelId=$panelID" -H "Authorization: Bearer ${APIKEY}" --compressed > haha.png
############# get list of snapshot
SNAPSHOT_LIST=$(curl -X GET -H "Authorization: Bearer ${APIKEY}" $url/api/dashboard/snapshots)
############ list the key
SNAPSHOT_KEYS=$(echo $SNAPSHOT_LIST | jq -r '.[].key')
#echo $SNAPSHOT_KEYS
echo "========== list of key"
for haha in $SNAPSHOT_KEYS
do
echo $haha
done
echo "============================="
############# delete snapshot
for haha in $SNAPSHOT_KEYS
do
echo "Deleting snapshot $haha"
curl -s -X DELETE -H "Authorization: Bearer $APIKEY" "$url/api/snapshots/$haha"
done
echo ""
echo "==========================="
curl -X GET -H "Authorization: Bearer ${APIKEY}" $url/api/dashboard/snapshots
############ reset the snapshot count
# # Set the new snapshot count
# NEW_SNAPSHOT_COUNT=0
# DASHBOARD_UID="iXH6cG-Vz"
# # Get the current dashboard settings
# DASHBOARD_SETTINGS=$(curl -s -H "Authorization: Bearer $APIKEY" "$url/api/dashboards/uid/$DASHBOARD_UID")
# # Update the snapshot count in the dashboard settings
# UPDATED_DASHBOARD_SETTINGS=$(echo "$DASHBOARD_SETTINGS" | jq ".dashboard.snapshotData.snapshotCount = $NEW_SNAPSHOT_COUNT")
# # Send the updated dashboard settings back to Grafana
# curl -s -X POST -H "Authorization: Bearer $APIKEY" -H "Content-Type: application/json" -d "$UPDATED_DASHBOARD_SETTINGS" "$url/api/dashboards/db"
############ get snapshot by key
#curl -X GET -H "Authorization: Bearer ${APIKEY}" $url/api/snapshots/gH0GK86ExXR0zr5rNhSUaweyxVH607BH
############ Generate snapshot [FAIL!!!!!!!!!!]
# SNAPSHOT_FILE=haha.png
# SNAPSHOT_RESULT=$(curl -s -X POST -H "Authorization: Bearer $APIKEY" -H "Content-Type: application/json" -d "@snapshot-data.json" "$url/api/snapshots")
# echo "========================"
# echo $SNAPSHOT_RESULT
# SNAPSHOT_URL=$(echo $SNAPSHOT_RESULT | jq -r '.url')
# echo "========================"
# echo $SNAPSHOT_URL
# #microsoft-edge $SNAPSHOT_URL
# microsoft-edge --headless --window-size=2000,1000 --screenshot=$SNAPSHOT_FILE $SNAPSHOT_URL
# #echo "Snapshot saved to $SNAPSHOT_FILE"
# #eog $SNAPSHOT_FILE
echo ""

View File

@ -0,0 +1,29 @@
{
"dashboard": {
"uid": "iXH6cG-Vz",
"editable":false,
"nav":[
{
"enable":false,
"type":"timepicker"
}
],
"rows": [
{
}
],
"style":"dark",
"tags":[],
"templating":{
"list":[
]
},
"time":{
},
"timezone":"browser",
"title":"haha",
"version":5
},
"expires": 10
}