Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Projets-INFO4
20-21
18
chirpstack-monitoring
Commits
caa21791
Commit
caa21791
authored
Mar 16, 2021
by
Kevin Yung
Browse files
Intégration de momentjs pour changer les dates pour plus de lisibilité
parent
bcc77d22
Changes
5
Show whitespace changes
Inline
Side-by-side
reports/ChirpstackMonitoring.token.json
View file @
caa21791
{
"jwt"
:
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJjaGlycHN0YWNrLWFwcGxpY2F0aW9uLXNlcnZlciIsImV4cCI6MTYxNTkxMDIxMiwiaXNzIjoiY2hpcnBzdGFjay1hcHBsaWNhdGlvbi1zZXJ2ZXIiLCJuYmYiOjE2MTU4MjM4MTIsInN1YiI6InVzZXIiLCJ1c2VybmFtZSI6IkNoaXJwc3RhY2tNb25pdG9yaW5nIn0.WMcgbg-Mi4QecWM-MkZ4WImwycGyHuH2Rvqj1tXsGPo"
}
\ No newline at end of file
{
"jwt"
:
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJjaGlycHN0YWNrLWFwcGxpY2F0aW9uLXNlcnZlciIsImV4cCI6MTYxNTk5NTIxMiwiaXNzIjoiY2hpcnBzdGFjay1hcHBsaWNhdGlvbi1zZXJ2ZXIiLCJuYmYiOjE2MTU5MDg4MTIsInN1YiI6InVzZXIiLCJ1c2VybmFtZSI6IkNoaXJwc3RhY2tNb25pdG9yaW5nIn0.xFYJP6kBVTKT83xe_T2U25p96N3OQvFA1HWVqEmNUqA"
}
\ No newline at end of file
reports/changeDateMomentjs.js
0 → 100644
View file @
caa21791
const
moment
=
require
(
'
moment
'
);
var
argv
=
process
.
argv
;
// store the argument given
process
.
argv
.
shift
();
// skip path of node file
process
.
argv
.
shift
();
// skip path of js file
argv
=
process
.
argv
.
join
(
"
"
)
// parse to keep only the string
function
f
(
lastSeenAt
)
{
//console.log(lastSeenAt);
lastSeenAt
=
new
Date
(
lastSeenAt
);
return
moment
(
lastSeenAt
).
fromNow
();
}
console
.
log
(
f
(
argv
))
\ No newline at end of file
reports/get_id_gatewaysChange.sh
View file @
caa21791
...
...
@@ -91,6 +91,13 @@ do
fi
fi
done
if
[[
${
date
[
$i
]
}
!=
"null"
]]
then
tmp
=
$(
grep
${
id
[
$i
]
}
< .gateways.html
)
dateFromNow
=
$(
node changeDateMomentjs.js
${
date
[
$i
]
}
)
replacement
=
${
tmp
/
${
date
[
$i
]
}
/
"
$dateFromNow
"
}
sed
-i
"/
${
id
[
$i
]
}
/c
$replacement
"
.gateways.html
fi
done
#On met à jour les states des gateways pour le prochain jour
...
...
@@ -112,62 +119,3 @@ echo " {
}
]
}"
>>
lastGatewaysStates.json
\ No newline at end of file
#jq --raw-output -f gateways_to_html.jq .gateways.json | grep "0000024b0805031a"
#jq --raw-output ".result" .gateways.json
#jq -c ".result | sort_by(.lastSeenAt, .id) | reverse []" .gateways.json
#data=()
#objects=()
#id=()
#lastSeenAt=()
#i=0
#while read x
#do
# data[$i]=$(echo $x | tr "," "\n")
# i=$((i+1))
#done <data.txt
#
#echo ${data[1]}
#echo "---"
#j=0
#cpt=$((${#data[@]}-1))
#for (( j=0; j<=$cpt; j++ ))
#do
# echo ${data[$j]}
# echo "---"
#
# #On récupère toutes les id dans le tableau id
# tmp=$(echo ${data[$j]} | tr [:space:] "_" | sed -e 's,"id":,\n,g')
# k=0
# for d in $tmp
# do
# objects[$k]=$d
# k=$((k+1))
# done
# tmp=$(echo ${objects[1]} | tr "_" "\n")
# for a in $tmp
# do
# id[$j]=$a
# break
# done
#
# #On récupère toutes les dates lastSeenAt dans un tableau (qui représentera le champ pour chaque id)
# #tmp
#done
#
#echo ${id[0]}
#echo ${id[1]}
#echo ${id[2]}
#echo ${id[3]}
##echo $test
##echo ${objects[1]}
\ No newline at end of file
reports/test.js
0 → 100644
View file @
caa21791
#!/usr/bin/env node
const
moment
=
require
(
'
moment
'
);
var
argv
=
process
.
argv
;
// store the argument given
process
.
argv
.
shift
();
// skip path of node file
process
.
argv
.
shift
();
// skip path of js file
argv
=
process
.
argv
.
join
(
"
"
)
// parse to keep only the string
function
f
(
lastSeenAt
)
{
//console.log(lastSeenAt);
lastSeenAt
=
new
Date
(
lastSeenAt
);
return
moment
(
lastSeenAt
).
fromNow
();
}
console
.
log
(
f
(
argv
))
\ No newline at end of file
reports/test.sh
0 → 100755
View file @
caa21791
#!/bin/bash
var
=
"2021-03-16T14:20:40.327687Z"
a
=
$(
node test.js
$var
)
echo
"
$a
"
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment