From 2b9b207e2d966a4400a6dbda20875f4dc96804e8 Mon Sep 17 00:00:00 2001 From: andrewlalis Date: Sat, 28 Dec 2024 12:28:07 -0500 Subject: [PATCH] Added bulk import. --- api/source/app.d | 9 +++- app/.env.production | 1 + .../apps/classroom_compliance/ClassView.vue | 2 + .../ImportStudentsView.vue | 51 +++++++++++++++++++ app/src/router/index.ts | 5 ++ deploy.sh | 23 +++++++++ teacher-tools-api.service | 14 +++++ 7 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 app/.env.production create mode 100644 app/src/apps/classroom_compliance/ImportStudentsView.vue create mode 100755 deploy.sh create mode 100644 teacher-tools-api.service diff --git a/api/source/app.d b/api/source/app.d index 3b66c27..308d93f 100644 --- a/api/source/app.d +++ b/api/source/app.d @@ -1,13 +1,15 @@ import handy_httpd; import handy_httpd.handlers.path_handler; -import std.stdio; import d2sqlite3; +import std.process; import db; import api_modules.auth; static import api_modules.classroom_compliance; void main() { + string env = environment.get("TEACHER_TOOLS_API_ENV", "DEV"); + // Initialize the database on startup. auto db = getDb(); db.close(); @@ -22,6 +24,11 @@ void main() { config.defaultHeaders["Access-Control-Request-Method"] = "*"; config.defaultHeaders["Access-Control-Allow-Headers"] = "Authorization, Content-Length, Content-Type"; + if (env == "PROD") { + config.port = 8107; + config.workerPoolSize = 5; + } + PathHandler handler = new PathHandler(); handler.addMapping(Method.OPTIONS, "/api/**", &optionsEndpoint); diff --git a/app/.env.production b/app/.env.production new file mode 100644 index 0000000..ce34da5 --- /dev/null +++ b/app/.env.production @@ -0,0 +1 @@ +VITE_API_URL=https://teacher-tools.andrewlalis.com/api \ No newline at end of file diff --git a/app/src/apps/classroom_compliance/ClassView.vue b/app/src/apps/classroom_compliance/ClassView.vue index 1cd48a7..7a03211 100644 --- a/app/src/apps/classroom_compliance/ClassView.vue +++ b/app/src/apps/classroom_compliance/ClassView.vue @@ -37,6 +37,8 @@ async function deleteThisClass() {
+
diff --git a/app/src/apps/classroom_compliance/ImportStudentsView.vue b/app/src/apps/classroom_compliance/ImportStudentsView.vue new file mode 100644 index 0000000..e7e60d1 --- /dev/null +++ b/app/src/apps/classroom_compliance/ImportStudentsView.vue @@ -0,0 +1,51 @@ + + diff --git a/app/src/router/index.ts b/app/src/router/index.ts index 252ebbb..6db4a96 100644 --- a/app/src/router/index.ts +++ b/app/src/router/index.ts @@ -54,6 +54,11 @@ const router = createRouter({ component: () => import('@/apps/classroom_compliance/EditStudentView.vue'), props: true, }, + { + path: 'classes/:classId/import-students', + component: () => import('@/apps/classroom_compliance/ImportStudentsView.vue'), + props: true, + }, ], }, ], diff --git a/deploy.sh b/deploy.sh new file mode 100755 index 0000000..a787e98 --- /dev/null +++ b/deploy.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +set -e +set -o pipefail + +# Script for deploying the application to teacher-tools.andrewlalis.com. + +echo "Building app" +cd app +rm -rf dist +npm run build +cd .. + +echo "Building API" +cd api +dub clean +dub build --build=release --compiler=/opt/ldc2/ldc2-1.36.0-linux-x86_64/bin/ldc2 +cd .. + +ssh -f root@andrewlalis.com 'systemctl stop teacher-tools-api.service' +scp api/teacher-tools-api root@andrewlalis.com:/opt/teacher-tools/ +rsync -rav -e ssh --delete app/dist/* root@andrewlalis.com:/opt/teacher-tools/app-content +ssh -f root@andrewlalis.com 'systemctl start teacher-tools-api.service' diff --git a/teacher-tools-api.service b/teacher-tools-api.service new file mode 100644 index 0000000..5c8ee7f --- /dev/null +++ b/teacher-tools-api.service @@ -0,0 +1,14 @@ +[Unit] +Description=teacher-tools-api +After=network.target + +[Service] +Type=simple +User=root +WorkingDirectory=/opt/teacher-tools +Environment="TEACHER_TOOLS_API_ENV=PROD" +ExecStart=/opt/teacher-tools/teacher-tools-api +Restart=always + +[Install] +WantedBy=multi-user.target \ No newline at end of file