From 23367d5ac432797cda36156e3dcdb92005f01faa Mon Sep 17 00:00:00 2001 From: "Ryan@SOLARIS-DAQ" Date: Thu, 30 Mar 2023 18:01:54 -0400 Subject: [PATCH] attemp to capture grafana screen without open browser, fail --- .gitignore | 1 + digiSettingsPanel.cpp | 1 - grafanaScreenShot.sh | 61 -------------------------------- mainwindow.cpp | 6 ++-- scripts/grafanaScreenShot.sh | 68 ++++++++++++++++++++++++++++++++++++ scripts/snapshot-data.json | 29 +++++++++++++++ 6 files changed, 101 insertions(+), 65 deletions(-) delete mode 100755 grafanaScreenShot.sh create mode 100755 scripts/grafanaScreenShot.sh create mode 100644 scripts/snapshot-data.json diff --git a/.gitignore b/.gitignore index b0c1293..d6a7efd 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ screenshot.* *settings*.dat *.dat Logs +*.png *~ *.autosave diff --git a/digiSettingsPanel.cpp b/digiSettingsPanel.cpp index f573d84..927cd4e 100644 --- a/digiSettingsPanel.cpp +++ b/digiSettingsPanel.cpp @@ -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"); diff --git a/grafanaScreenShot.sh b/grafanaScreenShot.sh deleted file mode 100755 index f5ffa1d..0000000 --- a/grafanaScreenShot.sh +++ /dev/null @@ -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 \ No newline at end of file diff --git a/mainwindow.cpp b/mainwindow.cpp index 60fe52d..3163b62 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -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(); diff --git a/scripts/grafanaScreenShot.sh b/scripts/grafanaScreenShot.sh new file mode 100755 index 0000000..f747edb --- /dev/null +++ b/scripts/grafanaScreenShot.sh @@ -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 "" \ No newline at end of file diff --git a/scripts/snapshot-data.json b/scripts/snapshot-data.json new file mode 100644 index 0000000..8f120fb --- /dev/null +++ b/scripts/snapshot-data.json @@ -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 +}