Jelajahi Sumber

feat: configure globals from environment file

Sean 1 tahun lalu
induk
melakukan
7b23b72c20

+ 7 - 0
.env.development

@@ -0,0 +1,7 @@
+VITE_GITLAB_REPO=https://gitlab.com/example/repo
+VITE_GITLAB_REPO_TICKET=https://gitlab.com/example/ticket
+VITE_MODULE_SIGNUP=https://example.com/signup
+VITE_STUDENTHUB=https://example.com/studenthub
+VITE_ALL_TIMETABLES=https://example.com/timetables
+VITE_ADDITIONAL_MODULE_INFORMATION=https://example.com/module-info
+VITE_SCHOOL_NAME=MySchoolName

+ 6 - 0
README.md

@@ -1 +1,7 @@
 # Modulplaner
+
+## Customization
+
+The `.env.development` file contains some default environment variables that may be
+customized during the building process by including a `.env.production` file with custom
+values.

+ 39 - 37
cspell.config.yaml

@@ -14,15 +14,22 @@ ignorePaths:
   - .vscode/launch.json
   - node_modules
 dictionaryDefinitions: []
-ignoreWords:
+ignoreWords: []
+dictionaries: []
+import:
+  - "@cspell/dict-de-ch/cspell-ext.json"
+  - "@cspell/dict-en-gb/cspell-ext.json"
+words:
   - .gitlab-ci.yml
   - adresse1
   - adresse2
+  - adxd
   - anlass
   - anlassbezeichnung
   - anlassleitungen
   - anlassnummer
   - anmeldungsDatum
+  - annot
   - anrechnungEcts
   - anzahl
   - Ausb
@@ -45,17 +52,27 @@ ignoreWords:
   - blockmodules
   - Bridgekeeper
   - brotli
+  - bsys
   - bverI
   - bverl
   - camelot
   - changenotes
   - clsss
   - dataframe
+  - derotation
   - distributin'
+  - dnet
   - Dozentenkürzel
+  - Dozierendenanpassungen
+  - dtds
   - dumpable
+  - eana
+  - ecae
+  - ecpe
   - ects
   - edbs
+  - einschr
+  - Elektro
   - ELEKTRO
   - english
   - evenodd
@@ -70,22 +87,30 @@ ignoreWords:
   - fortawesome
   - gidx
   - GITLAB
+  - gles
+  - goek
   - Heeeeeelp
   - HISTORIZED
+  - Ieng
   - iloc
   - isna
   - iterrows
   - Jorj
   - klassen
+  - konami
   - korr
   - kurse
   - kürzel
+  - lalg
   - lect
   - linecap
   - linejoin
   - lyin'
+  - matomo
+  - Matomo
   - maxsplit
   - mediabox
+  - mgli
   - miterlimit
   - mmdc
   - modul
@@ -93,6 +118,7 @@ ignoreWords:
   - MODULEGROUPS
   - moduleset
   - nachname
+  - nochecks
   - notiz
   - notna
   - nummer
@@ -102,6 +128,7 @@ ignoreWords:
   - parent_modulegroup_id
   - pdfs
   - pinia
+  - Planänderungen
   - präsenz
   - proi
   - prov
@@ -111,54 +138,29 @@ ignoreWords:
   - rects
   - resp
   - ruleset
+  - Semesternote
+  - SIGNUP
+  - simag
   - Smits
+  - sprx
+  - stqm
   - studenthub
+  - Studenthub
+  - Stundenplanänderung
+  - Stundenplanänderungen
   - telefon
   - TIMEBOX
   - timecell
   - titlebar
   - Upgrader
+  - vars
   - vers
   - Vetur
+  - VITE
   - volar
   - Volar
   - vue-toastification
+  - Whyyyyy
   - wifi
   - xlink
   - Xmark
-dictionaries: []
-words:
-  - adxd
-  - annot
-  - bsys
-  - derotation
-  - dnet
-  - Dozierendenanpassungen
-  - dtds
-  - eana
-  - ecae
-  - ecpe
-  - einschr
-  - Elektro
-  - gles
-  - goek
-  - Ieng
-  - konami
-  - lalg
-  - matomo
-  - Matomo
-  - mgli
-  - nochecks
-  - Planänderungen
-  - Semesternote
-  - simag
-  - sprx
-  - stqm
-  - Studenthub
-  - Stundenplanänderung
-  - Stundenplanänderungen
-  - vars
-  - Whyyyyy
-import:
-  - "@cspell/dict-de-ch/cspell-ext.json"
-  - "@cspell/dict-en-gb/cspell-ext.json"

+ 3 - 3
src/components/general/ClassInfo.vue

@@ -201,7 +201,7 @@ import { useStudenthubStore } from "../../stores/studenthub";
 import { Module, TaughtClass, Lecturer, TeachingType } from "../../types";
 import CurrentModuleExecutions from "./CurrentModuleExecutions.vue";
 import TeachingTypeIcon from "./TeachingTypeIcon.vue";
-import { URLS, SCHOOL_NAME } from "../../helpers";
+import { URLS, SCHOOL_NAME } from "../../globals";
 
 export default {
   name: "ClassInfo",
@@ -241,7 +241,7 @@ export default {
     },
     hasCompletedModule(): boolean {
       return this.studenthubStore.hasCompletedModule(
-        this.module?.module_id ?? null,
+        this.module?.module_id ?? null
       );
     },
     module(): Module | null {
@@ -252,7 +252,7 @@ export default {
       return (
         Object.values(this.module.dependencies).reduce(
           (sum, dep) => sum + dep.length,
-          0,
+          0
         ) > 0
       );
     },

+ 2 - 1
src/components/general/DependencyTree.vue

@@ -90,7 +90,8 @@ import { PropType } from "vue";
 import { useModulesStore } from "../../stores/modules";
 import { useStateStore } from "../../stores/state";
 import { Module, ModuleLanguages } from "../../types";
-import { rowStyling, SCHOOL_NAME } from "../../helpers";
+import { rowStyling } from "../../helpers";
+import { SCHOOL_NAME } from "../../globals";
 
 function availableLanguages(module: Module): string[] {
   const deps = module.dependencies;

+ 3 - 3
src/components/general/ModuleInfo.vue

@@ -181,7 +181,7 @@ import { useStudenthubStore } from "../../stores/studenthub";
 import { HistoricClassEntry, Module, TaughtClass } from "../../types";
 import CurrentModuleExecutions from "./CurrentModuleExecutions.vue";
 import PreviousModuleExecutions from "./PreviousModuleExecutions.vue";
-import { URLS, SCHOOL_NAME } from "../../helpers";
+import { URLS, SCHOOL_NAME } from "../../globals";
 
 export default {
   name: "ModuleInfo",
@@ -222,7 +222,7 @@ export default {
   computed: {
     hasCompletedModule(): boolean {
       return this.studenthubStore.hasCompletedModule(
-        this.module?.module_id ?? null,
+        this.module?.module_id ?? null
       );
     },
     hasModuleDeps(): boolean {
@@ -230,7 +230,7 @@ export default {
       return (
         Object.values(this.module.dependencies).reduce(
           (sum, dep) => sum + dep.length,
-          0,
+          0
         ) > 0
       );
     },

+ 1 - 1
src/components/layout/HeaderBar.vue

@@ -107,7 +107,7 @@ import Popper from "vue3-popper";
 import AdditionalInfo from "../modals/AdditionalInfo.vue";
 import { useClassVersionStore } from "../../stores/ClassVersion";
 import { useStateStore } from "../../stores/state";
-import { URLS, SCHOOL_NAME } from "../../helpers";
+import { URLS, SCHOOL_NAME } from "../../globals";
 
 export default {
   name: "HeaderBar",

+ 1 - 1
src/components/modals/AdditionalInfo.vue

@@ -241,7 +241,7 @@
 
 <script lang="ts">
 import RightDrawer from "./RightDrawer.vue";
-import { URLS } from "../../helpers";
+import { URLS } from "../../globals";
 import { useClassVersionStore } from "../../stores/ClassVersion";
 import { MainView, TimetableChangelogEntry } from "../../types";
 import { useStateStore } from "../../stores/state";

+ 1 - 1
src/components/modals/ClassModuleDetails.vue

@@ -54,7 +54,7 @@ import ClassInfo from "../general/ClassInfo.vue";
 import ModuleInfo from "../general/ModuleInfo.vue";
 import DependencyTree from "../general/DependencyTree.vue";
 import BaseModal from "./BaseModal.vue";
-import { URLS } from "../../helpers";
+import { URLS } from "../../globals";
 
 export default {
   name: "ClassModuleDetails",

+ 11 - 0
src/globals.ts

@@ -0,0 +1,11 @@
+export const URLS = {
+  GITLAB_REPO: import.meta.env.VITE_GITLAB_REPO,
+  GITLAB_REPO_TICKET: import.meta.env.VITE_GITLAB_REPO_TICKET,
+  MODULE_SIGNUP: import.meta.env.VITE_MODULE_SIGNUP,
+  STUDENTHUB: import.meta.env.VITE_STUDENTHUB,
+  ALL_TIMETABLES: import.meta.env.VITE_ALL_TIMETABLES,
+  ADDITIONAL_MODULE_INFORMATION: import.meta.env
+    .VITE_ADDITIONAL_MODULE_INFORMATION,
+};
+
+export const SCHOOL_NAME = import.meta.env.VITE_SCHOOL_NAME;

+ 7 - 20
src/helpers.ts

@@ -12,7 +12,7 @@ export function toTime(t: number): string {
   const minutes = (t - 3600 * hours) / 60;
   return `${String(hours).padStart(2, "0")}:${String(minutes).padStart(
     2,
-    "0",
+    "0"
   )}`;
 }
 
@@ -47,7 +47,7 @@ export function openURLInNewWindow(url: string) {
   window.open(
     url,
     "_blank",
-    "resizable=yes, scrollbars=yes, titlebar=yes, width=800, height=600",
+    "resizable=yes, scrollbars=yes, titlebar=yes, width=800, height=600"
   );
 }
 
@@ -59,7 +59,7 @@ export const contextClassRe = /^\dK/;
 export function classesPDFLink(
   cls: TaughtClass | HistoricClassEntry,
   semester: string | null = null,
-  version: string | null = null,
+  version: string | null = null
 ): string {
   let semesterFolder;
   let semVerFolder;
@@ -92,7 +92,7 @@ export function getSemVerFolder(semester: string, version: string): string {
 
 export function addRemoveClassTitle(
   module: Module | null,
-  isChosen: boolean,
+  isChosen: boolean
 ): string {
   if (module?.hasCompleted) return "Modul bereits bestanden";
   if (module?.maxAttemptsReached)
@@ -120,19 +120,6 @@ export function matchesOneOf(list1: any[], list2: any[]): boolean {
 }
 
 export const MAX_ATTEMPT_COUNT = 2;
-
-// TODO: Set externally
-export const URLS = {
-  GITLAB_REPO: "https://example.com",
-  GITLAB_REPO_TICKET: "https://example.com",
-  MODULE_SIGNUP: "https://example.com",
-  STUDENTHUB: "https://example.com",
-  ALL_TIMETABLES: "https://example.com",
-  ADDITIONAL_MODULE_INFORMATION: "https://example.com",
-};
-
-export const SCHOOL_NAME = "<TODO>";
-
 export const MinFullNameSearchLength = 4;
 
 /**
@@ -168,7 +155,7 @@ export function parsePDFVersion(versionStr: string | null): {
 
 export function samePDFVersion(
   vers1: string | null,
-  vers2: string | null,
+  vers2: string | null
 ): boolean {
   const parsed1 = parsePDFVersion(vers1);
   const parsed2 = parsePDFVersion(vers2);
@@ -180,14 +167,14 @@ export function samePDFVersion(
 
 export function semesterVersionString(
   semester: string,
-  version: string,
+  version: string
 ): string {
   return `${semester}|${version}`;
 }
 
 export function semesterVersionStringC(
   semVer: SemesterVersion | null,
-  versionIdx = 0,
+  versionIdx = 0
 ): string | null {
   if (semVer == null) return null;
   return `${semVer.semester}|${semVer.versions[versionIdx]}`;