Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

CISE Space Size

Floor plans of the building with every room outlined, for recording which unit stewards each room and what it's used for.

Editing stewards and labels

In the Controls panel, pick a steward (replaces the room's steward) or a label (toggles it on the room), and click rooms on the plan or in a floor's table. Stewards, labels and their colours come from public/assets/config.json.

Unsaved changes are kept in the browser. The Save & Sync tab saves them:

  • GitHub: saves are committed to a branch for that user, edits/<login>, on the upstream repository (github.upstream in config.json), credited to them with a Co-authored-by line. Users can also attach files to propose, such as a newer floor plan image or a space.json with updated room shapes. After saving, the app offers to share the changes, which opens a pull request for the maintainers to review. Later saves are added to that pull request. Once it's merged, the next save starts the branch afresh from the default branch.
  • Solid pod: signs in with the user's identity provider (OIDC with PKCE) and stores every room's stewards and labels in cise-space-size/annotations.json in their pod (solid.path in config.json).
  • Download space.json: the current data, to commit by hand.

When you sign in, the app loads what you last saved there.

Setting up GitHub sign-in

Signing in only proves who the user is: it asks for no permissions, so GitHub shows just "verify your identity" and the user's token can't change anything. All writing is done by a GitHub App installed on the upstream repository alone, with only Contents and Pull requests access. A small backend (server/) checks who the user is on every request and then writes with the app's credentials. The same code runs in the Vite dev server (npm run dev) and as a Cloudflare Worker (server/worker.ts).

  1. Create the GitHub App (your organization's Settings → Developer settings → GitHub Apps → New GitHub App, so it can be installed on the organization's repository):
    • Callback URLs: add both http://localhost:5173/ and https://cise.mhciael.com/ (a GitHub App can have several).
    • Expire user authorization tokens: on. Request user authorization (OAuth) during installation: off.
    • Webhook: untick Active.
    • Repository permissions: Contents: Read and write, Pull requests: Read and write (Metadata: Read-only is added automatically). Account permissions: none.
    • Where can this GitHub App be installed: only on this account.
  2. On the app's page, note the App ID and Client ID, generate a client secret, and generate a private key (a .pem file; keep it outside the repository).
  3. Install the app (Install App → the organization → Only select repositories → cise-space-size).
  4. Set github.upstream in public/assets/config.json, e.g. "JMU-CS/cise-space-size".
  5. Local development: copy .env.example to .env.development.local and fill it in. Restart npm run dev.
  6. Deployment: the frontend and the backend are deployed separately.
    • Frontend (GitHub Pages): .github/workflows/pages.yml builds the app and publishes it on every push to main, so merged pull requests go live within a few minutes. In the repository settings, set Pages → Source to GitHub Actions, and add the Actions variable VITE_GITHUB_CLIENT_ID (and VITE_API_BASE if the backend isn't at https://cise-api.mhciael.com). public/CNAME sets the custom domain, which needs a DNS CNAME record pointing cise.mhciael.com at jmu-cs.github.io.
    • Backend (Docker): the Dockerfile runs server/bun-server.ts, which serves /api/* with the same code as the worker (it also serves the built app, so one container can host everything). Run it with GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET, GITHUB_APP_ID, GITHUB_APP_PRIVATE_KEY_FILE (or GITHUB_APP_PRIVATE_KEY) and ALLOWED_ORIGIN=https://cise.mhciael.com, behind a reverse proxy with HTTPS at cise-api.mhciael.com. For example:
      docker build -t cise-space-size .
      docker run -p 8080:8080 --env-file .env -e ALLOWED_ORIGIN=https://cise.mhciael.com \
        -e GITHUB_APP_PRIVATE_KEY_FILE=/key.pem -v "$PWD/app.private-key.pem:/key.pem:ro" cise-space-size
      Saves can be up to 50 MB, so allow request bodies that large in the proxy.
    • Alternatively, a Cloudflare Worker: fill in the [vars] in server/wrangler.toml, then
      npx wrangler deploy --config server/wrangler.toml
      npx wrangler secret put GITHUB_CLIENT_SECRET --config server/wrangler.toml
      npx wrangler secret put GITHUB_APP_PRIVATE_KEY --config server/wrangler.toml < path/to/app.private-key.pem
      Routed on the app's own domain at /api/*, the app needs no extra settings beyond VITE_GITHUB_CLIENT_ID at build time. On another origin, set ALLOWED_ORIGIN on it and VITE_API_BASE in the build.

Anyone with a GitHub account can propose changes; set ALLOWED_USERS (comma-separated logins) on the server to limit who can. Proposals can touch any file in the repository but only ever land on edits/<login> branches, so nothing reaches the default branch without a maintainer merging a pull request. The app has no Workflows permission, so GitHub rejects changes to .github/workflows.

The user's token is kept in the browser's local storage until they sign out or it expires (8 hours), after which they sign in again.

Solid

Nothing to configure: users type or pick their identity provider (the list is solid.issuers in config.json).

Room outlines

scripts/extract_rooms.py and scripts/build_space.py generate the room polygons in space.json from the plan images. Rebuilding keeps each room's stewards, labels and notes.


React + TypeScript + Vite

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

Currently, two official plugins are available:

React Compiler

The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see this documentation.

Expanding the ESLint configuration

If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:

export default defineConfig([
  globalIgnores(['dist']),
  {
    files: ['**/*.{ts,tsx}'],
    extends: [
      // Other configs...

      // Remove tseslint.configs.recommended and replace with this
      tseslint.configs.recommendedTypeChecked,
      // Alternatively, use this for stricter rules
      tseslint.configs.strictTypeChecked,
      // Optionally, add this for stylistic rules
      tseslint.configs.stylisticTypeChecked,

      // Other configs...
    ],
    languageOptions: {
      parserOptions: {
        project: ['./tsconfig.node.json', './tsconfig.app.json'],
        tsconfigRootDir: import.meta.dirname,
      },
      // other options...
    },
  },
])

You can also install eslint-plugin-react-x and eslint-plugin-react-dom for React-specific lint rules:

// eslint.config.js
import reactX from 'eslint-plugin-react-x'
import reactDom from 'eslint-plugin-react-dom'

export default defineConfig([
  globalIgnores(['dist']),
  {
    files: ['**/*.{ts,tsx}'],
    extends: [
      // Other configs...
      // Enable lint rules for React
      reactX.configs['recommended-typescript'],
      // Enable lint rules for React DOM
      reactDom.configs.recommended,
    ],
    languageOptions: {
      parserOptions: {
        project: ['./tsconfig.node.json', './tsconfig.app.json'],
        tsconfigRootDir: import.meta.dirname,
      },
      // other options...
    },
  },
])

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages