Skip to content

Commit 04e4126

Browse files
authored
Add MTR module. (#50)
* Semi working * Semi working * Working jobs * Working output in html * Working table * Add data to table * Add packet loss * Small fixes to CSS and renames * Working ( but ugly ) dependency installer. * Update CSS * Dependency dialouge license fix * Update title * Fix quotation * Fix quotation again * Disable button on load * Change module icon
1 parent d35f8c9 commit 04e4126

30 files changed

Lines changed: 33683 additions & 0 deletions

mtr/.editorconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Editor configuration, see https://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
indent_style = space
7+
indent_size = 4
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
max_line_length = off
13+
trim_trailing_whitespace = false

mtr/.gitignore

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# See http://help.github.com/ignore-files/ for more about ignoring files.
2+
3+
build2.sh
4+
# compiled output
5+
/dist
6+
/tmp
7+
/out-tsc
8+
# Only exists if Bazel was run
9+
/bazel-out
10+
11+
# dependencies
12+
/node_modules
13+
14+
# profiling files
15+
chrome-profiler-events*.json
16+
speed-measure-plugin*.json
17+
18+
# IDEs and editors
19+
/.idea
20+
.project
21+
.classpath
22+
.c9/
23+
*.launch
24+
.settings/
25+
*.sublime-workspace
26+
27+
# IDE - VSCode
28+
.vscode/*
29+
!.vscode/settings.json
30+
!.vscode/tasks.json
31+
!.vscode/launch.json
32+
!.vscode/extensions.json
33+
.history/*
34+
35+
# misc
36+
/.sass-cache
37+
/connect.lock
38+
/coverage
39+
/libpeerconnection.log
40+
npm-debug.log
41+
yarn-error.log
42+
testem.log
43+
/typings
44+
45+
# System Files
46+
.DS_Store
47+
Thumbs.db

mtr/angular.json

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3+
"version": 1,
4+
"newProjectRoot": "projects",
5+
"projects": {
6+
"mtr": {
7+
"projectType": "library",
8+
"root": "projects/mtr",
9+
"sourceRoot": "projects/mtr/src",
10+
"prefix": "lib",
11+
"architect": {
12+
"build": {
13+
"builder": "@angular-devkit/build-ng-packagr:build",
14+
"options": {
15+
"tsConfig": "projects/mtr/tsconfig.lib.json",
16+
"project": "projects/mtr/ng-package.json"
17+
},
18+
"configurations": {
19+
"production": {
20+
"tsConfig": "projects/mtr/tsconfig.lib.prod.json"
21+
}
22+
}
23+
},
24+
"test": {
25+
"builder": "@angular-devkit/build-angular:karma",
26+
"options": {
27+
"main": "projects/mtr/src/test.ts",
28+
"tsConfig": "projects/mtr/tsconfig.spec.json",
29+
"karmaConfig": "projects/mtr/karma.conf.js"
30+
}
31+
},
32+
"lint": {
33+
"builder": "@angular-devkit/build-angular:tslint",
34+
"options": {
35+
"tsConfig": [
36+
"projects/mtr/tsconfig.lib.json",
37+
"projects/mtr/tsconfig.spec.json"
38+
],
39+
"exclude": [
40+
"**/node_modules/**"
41+
]
42+
}
43+
}
44+
}
45+
}},
46+
"defaultProject": "mtr"
47+
}

mtr/build.sh

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#!/bin/bash
2+
3+
MODULENAME=$(basename $PWD)
4+
5+
check_workspace() {
6+
if [[ ! -d "node_modules" ]]; then
7+
while true; do
8+
read -p "[!!] The Angular workspace has not been prepared. Would you like to do it now? [Y\n] " yn
9+
case $yn in
10+
[Yy]* ) prepare_workspace; break;;
11+
[Nn]* ) exit 1;;
12+
* ) prepare_workspace; break;;
13+
esac
14+
done
15+
fi
16+
}
17+
18+
prepare_workspace() {
19+
echo "[*] Preparing the Angular workspace."
20+
21+
if ! command -v npm &> /dev/null; then
22+
echo "[!] NPM does not appear to be installed on this system. Failed to create workspace."
23+
return
24+
fi
25+
26+
if ! npm install &> /dev/null; then
27+
echo "[!] Failed to prepare workspace. Run npm install to see why."
28+
return
29+
fi
30+
31+
echo "[*] Prepared the Angular workspace successfully."
32+
}
33+
34+
build_module() {
35+
ng build --prod > /dev/null 2>&1
36+
RET=$?
37+
38+
if [[ $RET -ne 0 ]]; then
39+
echo "[!] Angular Build Failed: Run 'ng build --prod' to figure out why."
40+
exit 1
41+
else
42+
echo "[*] Angular Build Succeeded"
43+
fi
44+
45+
# Step 2: Copy the required files to the build output
46+
cp -r projects/$MODULENAME/src/module.svg dist/$MODULENAME/bundles/
47+
cp -r projects/$MODULENAME/src/module.json dist/$MODULENAME/bundles/
48+
cp -r projects/$MODULENAME/src/module.py dist/$MODULENAME/bundles/ > /dev/null 2>&1
49+
cp -r projects/$MODULENAME/src/module.php dist/$MODULENAME/bundles/ > /dev/null 2>&1
50+
cp -r projects/$MODULENAME/src/assets/ dist/$MODULENAME/bundles/ > /dev/null 2>&1
51+
52+
# Step 3: Clean up
53+
rm -rf dist/$MODULENAME/bundles/*.map
54+
rm -rf dist/$MODULENAME/bundles/*.min*
55+
rm -rf bundletmp
56+
mv dist/$MODULENAME/bundles/ bundletmp
57+
rm -rf dist/$MODULENAME/*
58+
mv bundletmp/* dist/$MODULENAME/
59+
rm -rf bundletmp
60+
}
61+
62+
package() {
63+
VERS=$(cat dist/$MODULENAME/module.json | grep "version" | awk '{split($0, a, ": "); gsub("\"", "", a[2]); gsub(",", "", a[2]); print a[2]}')
64+
rm -rf $MODULENAME-$VERS.tar.gz
65+
echo "[*] Packaging $MODULENAME (Version $VERS)"
66+
cd dist/
67+
tar -pczf $MODULENAME-$VERS.tar.gz $MODULENAME
68+
mv $MODULENAME-$VERS.tar.gz ../
69+
cd ../
70+
}
71+
72+
copy_to_device() {
73+
echo "[*] Copying module to WiFi Pineapple via SCP"
74+
scp -r dist/$MODULENAME root@172.16.42.1:/pineapple/modules
75+
}
76+
77+
main() {
78+
check_workspace
79+
build_module
80+
81+
if [[ $1 == "package" ]]; then
82+
package
83+
elif [[ $1 == "copy" ]]; then
84+
copy_to_device
85+
fi
86+
87+
echo "[*] Success!"
88+
}
89+
90+
main $1

0 commit comments

Comments
 (0)