From 088076bbeaf671cc993f650d9b48c081f3024566 Mon Sep 17 00:00:00 2001 From: Florian Schmitt Date: Wed, 23 Oct 2024 13:32:12 +0300 Subject: [PATCH] feat(config): make timezone, locale, username and password editable --- .vitepress/theme/custom.css | 11 ++++++-- components/ConfigForm.vue | 51 +++++++++++++++++++++++++++++-------- package-lock.json | 8 ++++++ package.json | 3 +++ 4 files changed, 60 insertions(+), 13 deletions(-) diff --git a/.vitepress/theme/custom.css b/.vitepress/theme/custom.css index 73e5fcb..b44f4b6 100644 --- a/.vitepress/theme/custom.css +++ b/.vitepress/theme/custom.css @@ -15,14 +15,21 @@ margin-bottom: 1em; } -.form-cell input[type="text"] { +.form-cell input[type="text"], +.form-cell select { border: 1px solid rgb(60, 60, 67); display: block; padding: 0.25em 0.5em; border-radius: 0.25em; min-width: 40em; + max-width: 40em; + background: transparent; + appearance: auto; + -webkit-appearance: auto; } -.form-cell input[type="text"]:focus { + +.form-cell input[type="text"]:focus, +.form-cell select:focus { border: 1px solid #0c78fc; } .nix-code { diff --git a/components/ConfigForm.vue b/components/ConfigForm.vue index 761058b..0401b3e 100644 --- a/components/ConfigForm.vue +++ b/components/ConfigForm.vue @@ -2,7 +2,13 @@ import NixCode from "./NixCode.vue" import NixForm from "./NixForm.vue" import { provide, ref } from 'vue' +import { listTz, clientTz } from 'timezone-select-js'; +const availableLanguages = { + 'en_US.UTF-8': 'English', + 'fr_FR.UTF-8': 'Francais' +} +const availableTimezones = listTz() let nixin = { netconf: 'autoconfig', networkingHostname: '', @@ -66,12 +72,11 @@ let nixin = { }], bundles: [], services: [], - timezone: 'Etc/UTC', + timezone: 'Europe/Belfast', // default to UTC but could be found with clientTz(), locale: 'en_US.UTF-8', - user: 'operator', - userPassword: 'CHANGE ME !!!', + operatingUser: 'operator', + operatingUserPassword: 'CHANGE ME !!!', } - nixin.availableServices.forEach((s) => { s.inBundle = [] }) @@ -175,10 +180,34 @@ function selectServices(bundleId, services) {

Other configuration

- Operating UNIX user name
- Operating UNIX user password
- Timezone
- Locale
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+

Auto-generated configuration.nix file

@@ -205,15 +234,15 @@ function selectServices(bundleId, services) {
 
 
 
-  users.users.{{ nixin.user }} = {
+  users.users.{{ nixin.operatingUser }} = {
       isNormalUser = true;
       extraGroups = [ "wheel" ];
-      initialPassword = "{{ nixin.userPassword }}";
+      initialPassword = "{{ nixin.operatingUserPassword }}";
   };
 
   security.sudo.extraRules= [
     {
-      users = [ "{{ nixin.user }}" ];
+      users = [ "{{ nixin.operatingUser }}" ];
       commands = [
         { 
           command = "ALL" ;
diff --git a/package-lock.json b/package-lock.json
index 589fcf2..491270d 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -6,6 +6,9 @@
     "": {
       "name": "NixiN",
       "license": "AGPL-3.0",
+      "dependencies": {
+        "timezone-select-js": "^2.0.1"
+      },
       "devDependencies": {
         "vitepress": "^1.3.3"
       }
@@ -2262,6 +2265,11 @@
       "dev": true,
       "license": "MIT"
     },
+    "node_modules/timezone-select-js": {
+      "version": "2.0.1",
+      "resolved": "https://registry.npmjs.org/timezone-select-js/-/timezone-select-js-2.0.1.tgz",
+      "integrity": "sha512-alGTIkA0193yj+cE2oDa47VMrfYvJGgx6waZm1s0UnVF5hGYZGZkcfd2DtFqjf/v5Qs+Fl6hR7jeUrPMbfWLSg=="
+    },
     "node_modules/to-fast-properties": {
       "version": "2.0.0",
       "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz",
diff --git a/package.json b/package.json
index bc8c651..dbcfe0a 100644
--- a/package.json
+++ b/package.json
@@ -13,5 +13,8 @@
   },
   "devDependencies": {
     "vitepress": "^1.3.3"
+  },
+  "dependencies": {
+    "timezone-select-js": "^2.0.1"
   }
 }