feat: redesign admin panel & profile page, optimize Dockerfile, remove rootless
- Completely redesign admin.html matching OxiCloud design system - Create standalone profile.html page with avatar, details & password change - Optimize Dockerfile: 3-stage build, non-root user, OCI labels, layer cache - Add .dockerignore to reduce build context - Remove redundant Dockerfile.rootless & rootless-compose.yml - Redesign login language selector as compact dropdown with search - Fix CI/CD workflows (ci.yml, docker-build.yml, docker-publish.yml) - Update app.js to navigate to profile page instead of modal
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
# Build artifacts
|
||||
target/
|
||||
|
||||
# Git
|
||||
.git/
|
||||
.gitignore
|
||||
|
||||
# IDE
|
||||
.vscode/
|
||||
.idea/
|
||||
*.swp
|
||||
*.swo
|
||||
|
||||
# Docker
|
||||
Dockerfile
|
||||
Dockerfile.rootless
|
||||
docker-compose.yml
|
||||
rootless-compose.yml
|
||||
|
||||
# Runtime data (mapped via volumes)
|
||||
storage/
|
||||
|
||||
# Documentation
|
||||
doc/
|
||||
*.md
|
||||
LICENSE
|
||||
CODEOWNERS
|
||||
|
||||
# Miscellaneous
|
||||
.github/
|
||||
.env
|
||||
*.bak
|
||||
@@ -16,7 +16,7 @@ jobs:
|
||||
name: Rustfmt
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v6
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
components: rustfmt
|
||||
@@ -26,7 +26,7 @@ jobs:
|
||||
name: Clippy
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v6
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
components: clippy
|
||||
@@ -51,7 +51,7 @@ jobs:
|
||||
--health-timeout 5s
|
||||
--health-retries 5
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v6
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
|
||||
@@ -69,7 +69,7 @@ jobs:
|
||||
name: Security Audit
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v6
|
||||
- uses: rustsec/audit-check@v2.0.0
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -79,7 +79,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [fmt, clippy, test]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v6
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- run: cargo build --release
|
||||
|
||||
@@ -14,7 +14,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
@@ -30,7 +30,7 @@ jobs:
|
||||
type=sha
|
||||
|
||||
- name: Build Docker image
|
||||
uses: docker/build-push-action@v5
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
push: false
|
||||
|
||||
@@ -18,7 +18,7 @@ jobs:
|
||||
name: Pre-publish Tests
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v6
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- run: cargo test --workspace
|
||||
@@ -30,7 +30,7 @@ jobs:
|
||||
needs: test
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Set version tag
|
||||
id: version
|
||||
@@ -58,7 +58,7 @@ jobs:
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Build and Push Multi-Arch Image
|
||||
uses: docker/build-push-action@v5
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
platforms: linux/amd64,linux/arm64
|
||||
|
||||
+2
-2
@@ -10,7 +10,7 @@ tokio = { version = "1.49.0", features = ["full"] }
|
||||
tokio-util = { version = "0.7.18", features = ["io", "codec"] }
|
||||
tokio-stream = { version = "0.1.18", features = ["fs"] }
|
||||
bytes = "1.11.0"
|
||||
tempfile = "3.24.0"
|
||||
tempfile = "3.25.0"
|
||||
tower = "0.5.3"
|
||||
tower-http = { version = "0.6.8", features = ["fs", "compression-gzip", "trace", "cors", "add-extension", "request-id"] }
|
||||
flate2 = "1.1.9"
|
||||
@@ -32,7 +32,7 @@ sqlx = { version = "0.8.6", features = ["postgres", "runtime-tokio", "tls-rustls
|
||||
anyhow = "1.0.101"
|
||||
jsonwebtoken = { version = "10.1.0", features = ["rust_crypto"] }
|
||||
argon2 = "0.5.3"
|
||||
rand_core = { version = "0.6.4", features = ["std"] }
|
||||
rand_core = { version = "0.9.5", features = ["std"] }
|
||||
hyper = { version = "1.8.1", features = ["full"] }
|
||||
quick-xml = "0.39.0"
|
||||
dotenv = "0.15.0"
|
||||
|
||||
+30
-15
@@ -14,39 +14,54 @@ FROM rust:1.93.0-alpine3.23 AS builder
|
||||
WORKDIR /app
|
||||
RUN apk --no-cache upgrade && \
|
||||
apk add --no-cache musl-dev pkgconfig postgresql-dev gcc perl make
|
||||
# Copy cached dependencies
|
||||
# Copy cached dependencies (only target dir and cargo registry)
|
||||
COPY --from=cacher /app/target target
|
||||
COPY --from=cacher /usr/local/cargo /usr/local/cargo
|
||||
# Copy ALL files needed for compilation, including static files
|
||||
COPY src src
|
||||
COPY static static
|
||||
COPY db db
|
||||
COPY --from=cacher /usr/local/cargo/registry /usr/local/cargo/registry
|
||||
# Copy only what Cargo needs to compile (static/db are runtime-only, copied in final stage)
|
||||
COPY Cargo.toml Cargo.lock ./
|
||||
# Build with all optimizations
|
||||
ENV DATABASE_URL="postgres://postgres:postgres@postgres/oxicloud"
|
||||
RUN cargo build --release
|
||||
COPY src src
|
||||
# Build with all optimizations (DATABASE_URL only needed at compile-time for sqlx)
|
||||
ARG DATABASE_URL="postgres://postgres:postgres@localhost/oxicloud"
|
||||
RUN DATABASE_URL="${DATABASE_URL}" cargo build --release
|
||||
|
||||
# Stage 3: Create minimal final image
|
||||
FROM alpine:3.23.3
|
||||
|
||||
# OCI image metadata
|
||||
LABEL org.opencontainers.image.title="OxiCloud" \
|
||||
org.opencontainers.image.description="Ultra-fast, secure & lightweight self-hosted cloud storage built in Rust" \
|
||||
org.opencontainers.image.url="https://github.com/DioCrafts/OxiCloud" \
|
||||
org.opencontainers.image.source="https://github.com/DioCrafts/OxiCloud" \
|
||||
org.opencontainers.image.vendor="DioCrafts" \
|
||||
org.opencontainers.image.licenses="MIT"
|
||||
|
||||
# Install only necessary runtime dependencies and update packages
|
||||
RUN apk --no-cache upgrade && \
|
||||
apk add --no-cache libgcc ca-certificates libpq tzdata
|
||||
|
||||
# Create non-root user
|
||||
RUN addgroup -g 1001 -S oxicloud && \
|
||||
adduser -u 1001 -S oxicloud -G oxicloud
|
||||
|
||||
# Copy only the compiled binary
|
||||
COPY --from=builder /app/target/release/oxicloud /usr/local/bin/
|
||||
RUN chmod +x /usr/local/bin/oxicloud
|
||||
|
||||
# Copy static files and other resources needed at runtime
|
||||
COPY static /app/static
|
||||
COPY db /app/db
|
||||
COPY --chown=oxicloud:oxicloud static /app/static
|
||||
COPY --chown=oxicloud:oxicloud db /app/db
|
||||
|
||||
# Create storage directory with proper permissions
|
||||
RUN mkdir -p /app/storage && chmod 777 /app/storage
|
||||
|
||||
# Set proper permissions
|
||||
RUN chmod +x /usr/local/bin/oxicloud
|
||||
RUN mkdir -p /app/storage && chown oxicloud:oxicloud /app/storage
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Expose application port
|
||||
EXPOSE 8086
|
||||
|
||||
# Run as non-root user
|
||||
USER oxicloud
|
||||
|
||||
# Run the application
|
||||
CMD ["oxicloud"]
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
# Stage 1: Builder – compile the application
|
||||
FROM rust:1.93.0-alpine3.23 AS builder
|
||||
|
||||
# Install build dependencies
|
||||
RUN apk add --no-cache musl-dev pkgconfig openssl-dev postgresql-dev
|
||||
|
||||
# Create a non-root user with UID 10001 (we use the same UID across stages)
|
||||
RUN adduser -D -u 10001 oxicloud
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy dependency files first to leverage Docker cache for dependency compilation
|
||||
COPY Cargo.toml Cargo.lock ./
|
||||
|
||||
# Prepare dummy source to build dependencies (improves caching)
|
||||
RUN mkdir -p src && \
|
||||
echo "fn main() {}" > src/main.rs && \
|
||||
touch src/lib.rs && \
|
||||
cargo build --release && \
|
||||
rm -rf src
|
||||
|
||||
# Copy the actual source code and additional files
|
||||
COPY src ./src
|
||||
COPY static ./static
|
||||
COPY db ./db
|
||||
|
||||
# Build the actual application and strip debug symbols for a smaller binary
|
||||
RUN cargo build --release && \
|
||||
strip target/release/oxicloud
|
||||
|
||||
# Stage 2: Runtime – only include what is necessary to run the app
|
||||
FROM alpine:3.23
|
||||
|
||||
# Install runtime dependencies and clean up cache
|
||||
RUN apk add --no-cache libgcc openssl ca-certificates tzdata && \
|
||||
rm -rf /var/cache/apk/*
|
||||
|
||||
# Create a non-root user with the same UID (10001) for consistent file ownership
|
||||
RUN adduser -D -u 10001 oxicloud
|
||||
|
||||
# Create application directories, assign proper permissions
|
||||
WORKDIR /app
|
||||
RUN mkdir -p /app/static /app/storage /app/db && \
|
||||
chown -R oxicloud:oxicloud /app
|
||||
|
||||
# Copy the built binary from the builder stage and additional runtime files
|
||||
COPY --from=builder /app/target/release/oxicloud /app/oxicloud
|
||||
COPY --from=builder /app/static /app/static
|
||||
COPY --from=builder /app/db /app/db
|
||||
|
||||
# Ensure all files are owned by the non-root user
|
||||
RUN chown -R oxicloud:oxicloud /app
|
||||
|
||||
# Set the non-root user for running the application
|
||||
USER oxicloud
|
||||
|
||||
# Expose the port the application listens on
|
||||
EXPOSE 8086 8085
|
||||
|
||||
# Run the binary in release mode
|
||||
CMD ["./oxicloud", "--release"]
|
||||
@@ -1,48 +0,0 @@
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:17.4-alpine
|
||||
restart: always
|
||||
environment:
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD: postgres
|
||||
POSTGRES_DB: oxicloud
|
||||
# ports:
|
||||
# - "5432:5432"
|
||||
networks:
|
||||
- oxicloud
|
||||
volumes:
|
||||
- pg_data:/var/lib/postgresql/data
|
||||
- ./db/schema.sql:/docker-entrypoint-initdb.d/10-schema.sql
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
||||
oxicloud:
|
||||
image: oxicloud-rootless
|
||||
restart: always
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.rootless
|
||||
ports:
|
||||
- "8086:8086"
|
||||
- "8085:8085"
|
||||
networks:
|
||||
- oxicloud
|
||||
depends_on:
|
||||
- postgres
|
||||
environment:
|
||||
- "OXICLOUD_DB_CONNECTION_STRING=postgres://postgres:postgres@postgres/oxicloud"
|
||||
# Ensure the container runs with the non-root user (UID:GID 10001:10001)
|
||||
user: "10001:10001"
|
||||
volumes:
|
||||
- storage_data:/app/storage
|
||||
|
||||
networks:
|
||||
oxicloud:
|
||||
driver: bridge
|
||||
|
||||
volumes:
|
||||
pg_data:
|
||||
storage_data:
|
||||
+236
-162
@@ -4,185 +4,259 @@
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>OxiCloud — Admin Panel</title>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
|
||||
<style>
|
||||
*{box-sizing:border-box;margin:0;padding:0}
|
||||
body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;background:#f5f7fa;color:#1a1a2e;line-height:1.6}
|
||||
.container{max-width:960px;margin:0 auto;padding:20px}
|
||||
header{display:flex;align-items:center;justify-content:space-between;margin-bottom:24px}
|
||||
header h1{font-size:1.5rem;color:#1a1a2e}
|
||||
header a{color:#3b82f6;text-decoration:none;font-size:.9rem}
|
||||
header a:hover{text-decoration:underline}
|
||||
*{box-sizing:border-box;margin:0;padding:0;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Oxygen,Ubuntu,Cantarell,'Open Sans','Helvetica Neue',sans-serif}
|
||||
body{background:#f5f7fa;color:#1e293b;min-height:100vh;display:flex;flex-direction:column}
|
||||
|
||||
/* Tabs */
|
||||
.tabs{display:flex;gap:4px;margin-bottom:24px;border-bottom:2px solid #e5e7eb;padding-bottom:0}
|
||||
.tab{padding:10px 20px;cursor:pointer;font-weight:600;font-size:.9rem;color:#6b7280;border:none;background:none;
|
||||
border-bottom:2px solid transparent;margin-bottom:-2px;transition:all .2s}
|
||||
.tab:hover{color:#3b82f6}
|
||||
.tab.active{color:#3b82f6;border-bottom-color:#3b82f6}
|
||||
/* ── Scrollbar ── */
|
||||
::-webkit-scrollbar{width:8px}
|
||||
::-webkit-scrollbar-track{background:transparent}
|
||||
::-webkit-scrollbar-thumb{background:rgba(0,0,0,.15);border-radius:4px}
|
||||
::-webkit-scrollbar-thumb:hover{background:rgba(0,0,0,.25)}
|
||||
*{scrollbar-width:thin;scrollbar-color:rgba(0,0,0,.15) transparent}
|
||||
|
||||
/* ── Top Header Bar ── */
|
||||
.admin-header{
|
||||
background:linear-gradient(135deg,#2a3042 0%,#232838 100%);
|
||||
padding:0 32px;height:64px;display:flex;align-items:center;justify-content:space-between;
|
||||
box-shadow:0 2px 12px rgba(0,0,0,.15);position:sticky;top:0;z-index:100;
|
||||
}
|
||||
.admin-header-left{display:flex;align-items:center;gap:14px}
|
||||
.admin-logo{
|
||||
width:38px;height:38px;background:linear-gradient(135deg,#ff5e3a,#ff2d55);border-radius:11px;
|
||||
display:flex;align-items:center;justify-content:center;
|
||||
box-shadow:0 3px 10px rgba(255,94,58,.35);
|
||||
}
|
||||
.admin-logo svg{width:20px;height:20px;fill:#fff}
|
||||
.admin-title{font-size:17px;font-weight:700;color:#fff;letter-spacing:.3px}
|
||||
.admin-title span{color:rgba(255,255,255,.5);font-weight:400;margin-left:6px}
|
||||
.admin-header-right a{
|
||||
color:rgba(255,255,255,.65);text-decoration:none;font-size:13px;font-weight:500;
|
||||
display:flex;align-items:center;gap:6px;transition:color .2s;
|
||||
}
|
||||
.admin-header-right a:hover{color:#fff}
|
||||
|
||||
/* ── Container ── */
|
||||
.admin-container{max-width:1080px;margin:0 auto;padding:28px 24px 60px;width:100%}
|
||||
|
||||
/* ── Tabs ── */
|
||||
.admin-tabs{display:flex;gap:6px;margin-bottom:28px;background:#fff;border-radius:14px;padding:6px;box-shadow:0 1px 4px rgba(0,0,0,.06)}
|
||||
.admin-tab{
|
||||
padding:10px 22px;cursor:pointer;font-weight:600;font-size:13.5px;color:#64748b;
|
||||
border:none;background:none;border-radius:10px;transition:all .2s;display:flex;align-items:center;gap:8px;
|
||||
}
|
||||
.admin-tab:hover{color:#1e293b;background:#f8fafc}
|
||||
.admin-tab.active{color:#fff;background:linear-gradient(135deg,#ff5e3a,#ff2d55);box-shadow:0 3px 12px rgba(255,94,58,.25)}
|
||||
.admin-tab.active i{color:#fff}
|
||||
.admin-tab i{font-size:14px;width:16px;text-align:center}
|
||||
.tab-content{display:none}
|
||||
.tab-content.active{display:block}
|
||||
|
||||
/* Cards */
|
||||
.card{background:#fff;border-radius:12px;box-shadow:0 1px 3px rgba(0,0,0,.1);padding:24px;margin-bottom:20px}
|
||||
.card h2{font-size:1.1rem;margin-bottom:16px;color:#1a1a2e;display:flex;align-items:center;gap:8px}
|
||||
.card h3{font-size:.95rem;margin:16px 0 10px;color:#374151}
|
||||
/* ── Cards ── */
|
||||
.admin-card{background:#fff;border-radius:16px;box-shadow:0 1px 4px rgba(0,0,0,.06),0 0 0 1px rgba(0,0,0,.03);padding:28px;margin-bottom:22px}
|
||||
.admin-card h2{font-size:16px;font-weight:700;margin-bottom:20px;color:#1e293b;display:flex;align-items:center;gap:10px}
|
||||
.admin-card h2 i{color:#ff5e3a;font-size:17px}
|
||||
|
||||
/* Stats Grid */
|
||||
.stats-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:12px;margin-bottom:20px}
|
||||
.stat-card{padding:16px;background:#f9fafb;border-radius:10px;text-align:center;border:1px solid #e5e7eb}
|
||||
.stat-value{font-size:1.6rem;font-weight:700;color:#1a1a2e}
|
||||
.stat-label{font-size:.75rem;color:#6b7280;text-transform:uppercase;letter-spacing:.05em;margin-top:2px}
|
||||
/* ── Stats Grid ── */
|
||||
.stats-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:14px;margin-bottom:22px}
|
||||
.stat-card{
|
||||
padding:20px;background:#f8fafc;border-radius:14px;text-align:center;
|
||||
border:1px solid #e2e8f0;transition:transform .15s,box-shadow .15s;
|
||||
}
|
||||
.stat-card:hover{transform:translateY(-2px);box-shadow:0 4px 12px rgba(0,0,0,.06)}
|
||||
.stat-value{font-size:1.75rem;font-weight:800;color:#1e293b}
|
||||
.stat-label{font-size:11.5px;color:#94a3b8;text-transform:uppercase;letter-spacing:.06em;margin-top:4px;font-weight:600}
|
||||
.stat-card.warn{border-color:#fbbf24;background:#fffbeb}
|
||||
.stat-card.danger{border-color:#ef4444;background:#fef2f2}
|
||||
.stat-card .stat-value.text-blue{color:#3b82f6}
|
||||
.stat-card .stat-value.text-green{color:#059669}
|
||||
.stat-card .stat-value.text-orange{color:#d97706}
|
||||
.stat-card .stat-value.text-red{color:#dc2626}
|
||||
.text-blue{color:#3b82f6!important}
|
||||
.text-green{color:#059669!important}
|
||||
.text-orange{color:#d97706!important}
|
||||
.text-red{color:#dc2626!important}
|
||||
|
||||
/* Progress bar */
|
||||
.progress-bar{width:100%;height:8px;background:#e5e7eb;border-radius:4px;overflow:hidden;margin-top:6px}
|
||||
.progress-fill{height:100%;border-radius:4px;transition:width .5s}
|
||||
.progress-fill.green{background:#059669}
|
||||
.progress-fill.orange{background:#d97706}
|
||||
.progress-fill.red{background:#dc2626}
|
||||
/* ── Progress bar ── */
|
||||
.progress-bar{width:100%;height:8px;background:#e2e8f0;border-radius:4px;overflow:hidden}
|
||||
.progress-fill{height:100%;border-radius:4px;transition:width .5s ease}
|
||||
.progress-fill.green{background:linear-gradient(90deg,#059669,#10b981)}
|
||||
.progress-fill.orange{background:linear-gradient(90deg,#d97706,#f59e0b)}
|
||||
.progress-fill.red{background:linear-gradient(90deg,#dc2626,#ef4444)}
|
||||
|
||||
/* Table */
|
||||
.table-wrap{overflow-x:auto}
|
||||
table{width:100%;border-collapse:collapse;font-size:.85rem}
|
||||
th{text-align:left;padding:10px 12px;border-bottom:2px solid #e5e7eb;color:#6b7280;font-size:.75rem;
|
||||
text-transform:uppercase;letter-spacing:.05em;white-space:nowrap}
|
||||
td{padding:10px 12px;border-bottom:1px solid #f3f4f6;vertical-align:middle}
|
||||
tr:hover{background:#f9fafb}
|
||||
.user-info{display:flex;flex-direction:column;gap:1px}
|
||||
.user-name{font-weight:600;color:#1a1a2e}
|
||||
.user-email{font-size:.8rem;color:#6b7280}
|
||||
/* ── Table ── */
|
||||
.table-wrap{overflow-x:auto;border-radius:12px;border:1px solid #e2e8f0}
|
||||
table{width:100%;border-collapse:collapse;font-size:13.5px}
|
||||
th{text-align:left;padding:12px 16px;background:#f8fafc;color:#94a3b8;font-size:11px;text-transform:uppercase;letter-spacing:.06em;font-weight:700;white-space:nowrap;border-bottom:1px solid #e2e8f0}
|
||||
td{padding:14px 16px;border-bottom:1px solid #f1f5f9;vertical-align:middle}
|
||||
tr:last-child td{border-bottom:none}
|
||||
tr:hover{background:#fafbfd}
|
||||
.user-info{display:flex;flex-direction:column;gap:2px}
|
||||
.user-name{font-weight:600;color:#1e293b}
|
||||
.user-email{font-size:12px;color:#94a3b8}
|
||||
|
||||
/* Badges */
|
||||
.badge{display:inline-block;font-size:.7rem;padding:2px 8px;border-radius:10px;font-weight:600}
|
||||
/* ── Badges ── */
|
||||
.badge{display:inline-flex;align-items:center;gap:4px;font-size:11px;padding:3px 10px;border-radius:20px;font-weight:600}
|
||||
.badge-admin{background:#dbeafe;color:#1d4ed8}
|
||||
.badge-user{background:#f3f4f6;color:#6b7280}
|
||||
.badge-user{background:#f1f5f9;color:#64748b}
|
||||
.badge-active{background:#d1fae5;color:#065f46}
|
||||
.badge-inactive{background:#fee2e2;color:#991b1b}
|
||||
.badge-oidc{background:#ede9fe;color:#6d28d9}
|
||||
.badge-env{background:#fef3c7;color:#92400e;font-size:.65rem;margin-left:4px}
|
||||
.badge-env{background:#fef3c7;color:#92400e;font-size:10px;padding:1px 6px;margin-left:4px}
|
||||
|
||||
/* Buttons */
|
||||
.btn{padding:6px 14px;border:none;border-radius:6px;font-size:.8rem;font-weight:600;cursor:pointer;transition:all .15s;white-space:nowrap}
|
||||
.btn-sm{padding:4px 10px;font-size:.75rem}
|
||||
.btn-primary{background:#3b82f6;color:#fff}
|
||||
.btn-primary:hover{background:#2563eb}
|
||||
.btn-secondary{background:#fff;color:#374151;border:1px solid #d1d5db}
|
||||
.btn-secondary:hover{background:#f9fafb}
|
||||
.btn-danger{background:#fee2e2;color:#991b1b;border:1px solid #fecaca}
|
||||
.btn-danger:hover{background:#fecaca}
|
||||
.btn-success{background:#d1fae5;color:#065f46;border:1px solid #a7f3d0}
|
||||
.btn-success:hover{background:#a7f3d0}
|
||||
.btn:disabled{opacity:.5;cursor:not-allowed}
|
||||
/* ── Buttons ── */
|
||||
.btn{
|
||||
padding:8px 18px;border:none;border-radius:10px;font-size:13px;font-weight:600;
|
||||
cursor:pointer;transition:all .15s;white-space:nowrap;display:inline-flex;align-items:center;gap:6px;
|
||||
}
|
||||
.btn-sm{padding:6px 12px;font-size:12px;border-radius:8px}
|
||||
.btn-primary{background:linear-gradient(135deg,#ff5e3a,#ff2d55);color:#fff;box-shadow:0 2px 8px rgba(255,94,58,.25)}
|
||||
.btn-primary:hover{box-shadow:0 4px 14px rgba(255,94,58,.35);transform:translateY(-1px)}
|
||||
.btn-secondary{background:#fff;color:#334155;border:1px solid #e2e8f0}
|
||||
.btn-secondary:hover{background:#f8fafc;border-color:#cbd5e1}
|
||||
.btn-danger{background:#fef2f2;color:#991b1b;border:1px solid #fecaca}
|
||||
.btn-danger:hover{background:#fee2e2}
|
||||
.btn-success{background:#ecfdf5;color:#065f46;border:1px solid #a7f3d0}
|
||||
.btn-success:hover{background:#d1fae5}
|
||||
.btn:disabled{opacity:.4;cursor:not-allowed;transform:none!important}
|
||||
.actions-row{display:flex;gap:6px;flex-wrap:wrap}
|
||||
|
||||
/* Forms */
|
||||
.form-group{margin-bottom:14px}
|
||||
.form-group label{display:block;font-size:.82rem;font-weight:600;margin-bottom:3px;color:#374151}
|
||||
/* ── Forms ── */
|
||||
.form-group{margin-bottom:16px}
|
||||
.form-group label{display:block;font-size:13px;font-weight:600;margin-bottom:4px;color:#334155}
|
||||
.form-group input[type="text"],.form-group input[type="password"],.form-group input[type="url"],.form-group input[type="number"],.form-group select{
|
||||
width:100%;padding:8px 12px;border:1px solid #d1d5db;border-radius:6px;font-size:.85rem;transition:border .2s}
|
||||
.form-group input:focus,.form-group select:focus{outline:none;border-color:#3b82f6;box-shadow:0 0 0 3px rgba(59,130,246,.1)}
|
||||
.form-group small{color:#6b7280;font-size:.75rem;display:block;margin-top:2px}
|
||||
.toggle-row{display:flex;align-items:center;justify-content:space-between;padding:8px 0}
|
||||
.toggle-row label{font-size:.85rem;font-weight:500}
|
||||
.switch{position:relative;width:40px;height:22px;flex-shrink:0}
|
||||
.switch input{opacity:0;width:0;height:0}
|
||||
.slider{position:absolute;cursor:pointer;inset:0;background:#d1d5db;border-radius:22px;transition:.3s}
|
||||
.slider:before{content:"";position:absolute;height:16px;width:16px;left:3px;bottom:3px;background:#fff;border-radius:50%;transition:.3s}
|
||||
.switch input:checked+.slider{background:#3b82f6}
|
||||
.switch input:checked+.slider:before{transform:translateX(18px)}
|
||||
.readonly-field{display:flex;align-items:center;gap:6px;background:#f9fafb;border:1px solid #e5e7eb;border-radius:6px;padding:6px 12px;font-family:monospace;font-size:.82rem;word-break:break-all}
|
||||
.readonly-field button{flex-shrink:0;padding:3px 8px;border:1px solid #d1d5db;border-radius:4px;background:#fff;cursor:pointer;font-size:.75rem}
|
||||
width:100%;padding:10px 14px;border:2px solid #e2e8f0;border-radius:10px;font-size:14px;
|
||||
background:#f8fafc;transition:all .2s;font-family:inherit;color:#1e293b;
|
||||
}
|
||||
.form-group input:focus,.form-group select:focus{outline:none;border-color:#ff5e3a;background:#fff;box-shadow:0 0 0 3px rgba(255,94,58,.1)}
|
||||
.form-group small{color:#94a3b8;font-size:12px;display:block;margin-top:3px}
|
||||
|
||||
/* Alerts */
|
||||
.alert{padding:10px 14px;border-radius:8px;font-size:.82rem;margin-top:12px;display:none}
|
||||
.toggle-row{display:flex;align-items:center;justify-content:space-between;padding:10px 0}
|
||||
.toggle-row label{font-size:14px;font-weight:500;color:#334155}
|
||||
.switch{position:relative;width:44px;height:24px;flex-shrink:0}
|
||||
.switch input{opacity:0;width:0;height:0}
|
||||
.slider{position:absolute;cursor:pointer;inset:0;background:#d1d5db;border-radius:24px;transition:.3s}
|
||||
.slider:before{content:"";position:absolute;height:18px;width:18px;left:3px;bottom:3px;background:#fff;border-radius:50%;transition:.3s;box-shadow:0 1px 3px rgba(0,0,0,.15)}
|
||||
.switch input:checked+.slider{background:linear-gradient(135deg,#ff5e3a,#ff2d55)}
|
||||
.switch input:checked+.slider:before{transform:translateX(20px)}
|
||||
|
||||
.readonly-field{
|
||||
display:flex;align-items:center;gap:8px;background:#f8fafc;border:2px solid #e2e8f0;border-radius:10px;
|
||||
padding:10px 14px;font-family:'SF Mono',Monaco,Consolas,monospace;font-size:13px;word-break:break-all;color:#334155;
|
||||
}
|
||||
.readonly-field button{
|
||||
flex-shrink:0;padding:6px 10px;border:1px solid #e2e8f0;border-radius:8px;background:#fff;cursor:pointer;
|
||||
font-size:12px;transition:all .15s;color:#64748b;
|
||||
}
|
||||
.readonly-field button:hover{background:#f1f5f9;color:#334155}
|
||||
|
||||
/* ── Alerts ── */
|
||||
.alert{padding:12px 16px;border-radius:10px;font-size:13px;margin-top:14px;display:none;font-weight:500}
|
||||
.alert-success{background:#ecfdf5;color:#065f46;border:1px solid #a7f3d0;display:block}
|
||||
.alert-error{background:#fef2f2;color:#991b1b;border:1px solid #fecaca;display:block}
|
||||
.alert-info{background:#eff6ff;color:#1e40af;border:1px solid #bfdbfe;display:block}
|
||||
.warning{background:#fffbeb;border:1px solid #fde68a;border-radius:8px;padding:8px 12px;font-size:.8rem;color:#92400e;margin-top:6px;display:flex;align-items:baseline;gap:4px}
|
||||
.warning{background:#fffbeb;border:1px solid #fde68a;border-radius:10px;padding:10px 14px;font-size:13px;color:#92400e;margin-top:8px;display:flex;align-items:center;gap:6px;font-weight:500}
|
||||
|
||||
/* Discovery */
|
||||
.discovery-result{margin:10px 0;padding:10px;border-radius:8px;font-size:.8rem}
|
||||
/* ── Discovery ── */
|
||||
.discovery-result{margin:12px 0;padding:14px;border-radius:10px;font-size:13px}
|
||||
.discovery-result.ok{background:#ecfdf5;border:1px solid #a7f3d0;color:#065f46}
|
||||
.discovery-result.fail{background:#fef2f2;border:1px solid #fecaca;color:#991b1b}
|
||||
.discovery-result dt{font-weight:600;margin-top:4px}
|
||||
.discovery-result dt{font-weight:700;margin-top:6px}
|
||||
.discovery-result dd{margin-left:0;word-break:break-all}
|
||||
|
||||
/* Details */
|
||||
details{margin-top:12px;border-top:1px solid #e5e7eb;padding-top:10px}
|
||||
details summary{cursor:pointer;font-weight:600;font-size:.85rem;color:#6b7280;padding:4px 0;user-select:none}
|
||||
details[open] summary{margin-bottom:10px}
|
||||
/* ── Details ── */
|
||||
details{margin-top:14px;border-top:1px solid #e2e8f0;padding-top:12px}
|
||||
details summary{cursor:pointer;font-weight:600;font-size:14px;color:#64748b;padding:6px 0;user-select:none;transition:color .2s}
|
||||
details summary:hover{color:#ff5e3a}
|
||||
details[open] summary{margin-bottom:14px;color:#ff5e3a}
|
||||
|
||||
/* Modal */
|
||||
.modal-overlay{position:fixed;inset:0;background:rgba(0,0,0,.4);display:flex;align-items:center;justify-content:center;z-index:1000}
|
||||
.modal{background:#fff;border-radius:12px;padding:24px;width:400px;max-width:90vw;box-shadow:0 10px 40px rgba(0,0,0,.2)}
|
||||
.modal h3{margin-bottom:16px}
|
||||
.modal-actions{display:flex;gap:8px;justify-content:flex-end;margin-top:16px}
|
||||
/* ── Modal ── */
|
||||
.modal-overlay{position:fixed;inset:0;background:rgba(0,0,0,.45);backdrop-filter:blur(4px);display:flex;align-items:center;justify-content:center;z-index:1000}
|
||||
.modal{background:#fff;border-radius:20px;padding:28px;width:420px;max-width:90vw;box-shadow:0 20px 60px rgba(0,0,0,.2);animation:modalIn .2s ease-out}
|
||||
@keyframes modalIn{from{opacity:0;transform:scale(.95) translateY(10px)}to{opacity:1;transform:scale(1) translateY(0)}}
|
||||
.modal h3{margin-bottom:18px;font-size:17px;color:#1e293b;display:flex;align-items:center}
|
||||
.modal-actions{display:flex;gap:8px;justify-content:flex-end;margin-top:18px}
|
||||
|
||||
/* Quota bar inline */
|
||||
.quota-bar{display:flex;align-items:center;gap:8px}
|
||||
/* ── Quota bar inline ── */
|
||||
.quota-bar{display:flex;align-items:center;gap:10px}
|
||||
.quota-bar .progress-bar{flex:1;height:6px}
|
||||
.quota-text{font-size:.75rem;color:#6b7280;white-space:nowrap}
|
||||
.quota-text{font-size:12px;color:#94a3b8;white-space:nowrap}
|
||||
|
||||
/* Access / loading */
|
||||
#access-denied{display:none;text-align:center;padding:60px 20px}
|
||||
#access-denied h2{color:#991b1b;margin-bottom:8px}
|
||||
#loading{text-align:center;padding:60px;color:#6b7280}
|
||||
/* ── Access / Loading ── */
|
||||
#access-denied{display:none;text-align:center;padding:80px 20px}
|
||||
#access-denied .access-icon{width:80px;height:80px;background:#fef2f2;border-radius:50%;display:flex;align-items:center;justify-content:center;margin:0 auto 20px}
|
||||
#access-denied .access-icon i{font-size:32px;color:#ef4444}
|
||||
#access-denied h2{color:#991b1b;margin-bottom:8px;font-size:20px}
|
||||
#access-denied p{color:#64748b;margin-bottom:20px;font-size:14px}
|
||||
#access-denied a{display:inline-flex;align-items:center;gap:6px;padding:10px 24px;background:linear-gradient(135deg,#ff5e3a,#ff2d55);color:#fff;text-decoration:none;border-radius:10px;font-weight:600;font-size:14px;box-shadow:0 3px 12px rgba(255,94,58,.3);transition:all .2s}
|
||||
#access-denied a:hover{transform:translateY(-1px);box-shadow:0 5px 18px rgba(255,94,58,.4)}
|
||||
#loading{text-align:center;padding:80px;color:#94a3b8;font-size:15px}
|
||||
#loading i{font-size:32px;color:#ff5e3a;display:block;margin-bottom:12px;animation:spin 1s linear infinite}
|
||||
@keyframes spin{to{transform:rotate(360deg)}}
|
||||
|
||||
/* Pagination */
|
||||
.pagination{display:flex;align-items:center;justify-content:space-between;margin-top:12px;font-size:.82rem;color:#6b7280}
|
||||
.pagination button{padding:4px 12px}
|
||||
/* ── Pagination ── */
|
||||
.pagination{display:flex;align-items:center;justify-content:space-between;margin-top:14px;font-size:13px;color:#94a3b8;padding:0 4px}
|
||||
.pagination button{padding:6px 14px}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<header>
|
||||
<h1>⚙️ Admin Panel</h1>
|
||||
<a href="/">← Back to OxiCloud</a>
|
||||
</header>
|
||||
|
||||
<div id="loading">Loading…</div>
|
||||
<div id="access-denied"><h2>Access Denied</h2><p>Administrator privileges required.</p><a href="/login.html">Sign in</a></div>
|
||||
<!-- Header -->
|
||||
<div class="admin-header">
|
||||
<div class="admin-header-left">
|
||||
<div class="admin-logo">
|
||||
<svg viewBox="0 0 500 500">
|
||||
<path d="M345 310c32 0 58-26 58-58s-26-58-58-58c-6.2 0-12 0.9-17.5 2.7C318 166 289 143 255 143c-34.3 0-63.1 22.6-73 53.7C176.9 195.7 171 195 165 195c-32 0-58 26-58 58s26 58 58 58h180z"/>
|
||||
</svg>
|
||||
</div>
|
||||
<div class="admin-title">OxiCloud <span>· Admin</span></div>
|
||||
</div>
|
||||
<div class="admin-header-right">
|
||||
<a href="/"><i class="fas fa-arrow-left"></i> Back to OxiCloud</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="admin-container">
|
||||
<div id="loading"><i class="fas fa-circle-notch"></i> Loading…</div>
|
||||
<div id="access-denied">
|
||||
<div class="access-icon"><i class="fas fa-lock"></i></div>
|
||||
<h2>Access Denied</h2>
|
||||
<p>Administrator privileges required to access this panel.</p>
|
||||
<a href="/login.html"><i class="fas fa-sign-in-alt"></i> Sign in</a>
|
||||
</div>
|
||||
|
||||
<div id="main-content" style="display:none">
|
||||
<!-- Tabs -->
|
||||
<div class="tabs">
|
||||
<button class="tab active" onclick="switchTab('dashboard')">📊 Dashboard</button>
|
||||
<button class="tab" onclick="switchTab('users')">👥 Users</button>
|
||||
<button class="tab" onclick="switchTab('oidc')">🔐 SSO / OIDC</button>
|
||||
<div class="admin-tabs">
|
||||
<button class="admin-tab active" onclick="switchTab('dashboard',this)"><i class="fas fa-chart-pie"></i> Dashboard</button>
|
||||
<button class="admin-tab" onclick="switchTab('users',this)"><i class="fas fa-users"></i> Users</button>
|
||||
<button class="admin-tab" onclick="switchTab('oidc',this)"><i class="fas fa-key"></i> SSO / OIDC</button>
|
||||
</div>
|
||||
|
||||
<!-- ======== DASHBOARD TAB ======== -->
|
||||
<div id="tab-dashboard" class="tab-content active">
|
||||
<div class="stats-grid" id="dashboard-stats">
|
||||
<div class="stats-grid">
|
||||
<div class="stat-card"><div class="stat-value text-blue" id="ds-total-users">—</div><div class="stat-label">Total Users</div></div>
|
||||
<div class="stat-card"><div class="stat-value text-green" id="ds-active-users">—</div><div class="stat-label">Active Users</div></div>
|
||||
<div class="stat-card"><div class="stat-value text-blue" id="ds-admin-users">—</div><div class="stat-label">Admins</div></div>
|
||||
<div class="stat-card"><div class="stat-value" id="ds-version">—</div><div class="stat-label">Version</div></div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<h2>💾 Storage Overview</h2>
|
||||
<div class="admin-card">
|
||||
<h2><i class="fas fa-hdd"></i> Storage Overview</h2>
|
||||
<div class="stats-grid">
|
||||
<div class="stat-card"><div class="stat-value" id="ds-used">—</div><div class="stat-label">Used</div></div>
|
||||
<div class="stat-card"><div class="stat-value" id="ds-quota">—</div><div class="stat-label">Total Quota</div></div>
|
||||
<div class="stat-card"><div class="stat-value" id="ds-usage-pct">—</div><div class="stat-label">Usage %</div></div>
|
||||
</div>
|
||||
<div class="progress-bar"><div class="progress-fill green" id="ds-bar" style="width:0%"></div></div>
|
||||
<div style="margin-top:12px">
|
||||
<div style="margin-top:14px">
|
||||
<div class="stats-grid">
|
||||
<div class="stat-card warn" id="ds-warn-card" style="display:none"><div class="stat-value text-orange" id="ds-over80">0</div><div class="stat-label">Users >80% quota</div></div>
|
||||
<div class="stat-card warn" id="ds-warn-card" style="display:none"><div class="stat-value text-orange" id="ds-over80">0</div><div class="stat-label">Users >80% quota</div></div>
|
||||
<div class="stat-card danger" id="ds-danger-card" style="display:none"><div class="stat-value text-red" id="ds-overquota">0</div><div class="stat-label">Users over quota</div></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<h2>ℹ️ System</h2>
|
||||
<div class="admin-card">
|
||||
<h2><i class="fas fa-server"></i> System</h2>
|
||||
<div class="stats-grid">
|
||||
<div class="stat-card"><div class="stat-value" id="ds-auth">—</div><div class="stat-label">Auth</div></div>
|
||||
<div class="stat-card"><div class="stat-value" id="ds-oidc">—</div><div class="stat-label">OIDC</div></div>
|
||||
@@ -193,8 +267,8 @@ details[open] summary{margin-bottom:10px}
|
||||
|
||||
<!-- ======== USERS TAB ======== -->
|
||||
<div id="tab-users" class="tab-content">
|
||||
<div class="card">
|
||||
<h2>👥 User Management</h2>
|
||||
<div class="admin-card">
|
||||
<h2><i class="fas fa-users-cog"></i> User Management</h2>
|
||||
<div class="table-wrap">
|
||||
<table>
|
||||
<thead>
|
||||
@@ -207,14 +281,14 @@ details[open] summary{margin-bottom:10px}
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="users-tbody"><tr><td colspan="6" style="text-align:center;padding:20px;color:#6b7280">Loading users…</td></tr></tbody>
|
||||
<tbody id="users-tbody"><tr><td colspan="6" style="text-align:center;padding:28px;color:#94a3b8"><i class="fas fa-spinner fa-spin"></i> Loading users…</td></tr></tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="pagination">
|
||||
<span id="users-info">—</span>
|
||||
<div>
|
||||
<button class="btn btn-sm btn-secondary" id="prev-btn" onclick="prevPage()" disabled>← Prev</button>
|
||||
<button class="btn btn-sm btn-secondary" id="next-btn" onclick="nextPage()">Next →</button>
|
||||
<div style="display:flex;gap:6px">
|
||||
<button class="btn btn-sm btn-secondary" id="prev-btn" onclick="prevPage()" disabled><i class="fas fa-chevron-left"></i> Prev</button>
|
||||
<button class="btn btn-sm btn-secondary" id="next-btn" onclick="nextPage()">Next <i class="fas fa-chevron-right"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -222,8 +296,8 @@ details[open] summary{margin-bottom:10px}
|
||||
|
||||
<!-- ======== OIDC TAB ======== -->
|
||||
<div id="tab-oidc" class="tab-content">
|
||||
<div class="card">
|
||||
<h2>🔐 Single Sign-On (OIDC / SSO)</h2>
|
||||
<div class="admin-card">
|
||||
<h2><i class="fas fa-shield-alt"></i> Single Sign-On (OIDC / SSO)</h2>
|
||||
<div class="toggle-row">
|
||||
<label>Enable SSO Authentication</label>
|
||||
<label class="switch"><input type="checkbox" id="oidc-enabled"><span class="slider"></span></label>
|
||||
@@ -238,8 +312,8 @@ details[open] summary{margin-bottom:10px}
|
||||
<input type="url" id="issuer-url" placeholder="https://auth.example.com/application/o/oxicloud/">
|
||||
<small>OpenID Connect issuer URL of your identity provider</small>
|
||||
</div>
|
||||
<div style="margin-bottom:10px">
|
||||
<button class="btn btn-secondary btn-sm" id="discover-btn" onclick="testConnection()">🔍 Auto-discover</button>
|
||||
<div style="margin-bottom:12px">
|
||||
<button class="btn btn-secondary btn-sm" id="discover-btn" onclick="testConnection()"><i class="fas fa-search"></i> Auto-discover</button>
|
||||
</div>
|
||||
<div id="discovery-result"></div>
|
||||
<div class="form-group">
|
||||
@@ -249,14 +323,14 @@ details[open] summary{margin-bottom:10px}
|
||||
<div class="form-group">
|
||||
<label>Client Secret <span id="badge-client_secret"></span></label>
|
||||
<input type="password" id="client-secret" placeholder="Leave empty to keep current value">
|
||||
<small id="secret-hint" style="display:none">✓ A client secret is already configured</small>
|
||||
<small id="secret-hint" style="display:none"><i class="fas fa-check-circle" style="color:#059669"></i> A client secret is already configured</small>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Callback URL <small>(register in your IdP)</small></label>
|
||||
<div class="readonly-field"><span id="callback-url">—</span><button onclick="copyCallback()">📋</button></div>
|
||||
<label>Callback URL <small style="font-weight:400;color:#94a3b8">(register in your IdP)</small></label>
|
||||
<div class="readonly-field"><span id="callback-url">—</span><button onclick="copyCallback()" title="Copy"><i class="fas fa-copy"></i></button></div>
|
||||
</div>
|
||||
<details>
|
||||
<summary>Advanced Settings</summary>
|
||||
<summary><i class="fas fa-sliders-h" style="margin-right:6px"></i> Advanced Settings</summary>
|
||||
<div class="form-group">
|
||||
<label>Scopes <span id="badge-scopes"></span></label>
|
||||
<input type="text" id="scopes" placeholder="openid profile email">
|
||||
@@ -274,11 +348,11 @@ details[open] summary{margin-bottom:10px}
|
||||
<label>Disable password login (OIDC only)</label>
|
||||
<label class="switch"><input type="checkbox" id="disable-password"><span class="slider"></span></label>
|
||||
</div>
|
||||
<div class="warning" id="password-warning" style="display:none">⚠️ This will prevent ALL password-based logins!</div>
|
||||
<div class="warning" id="password-warning" style="display:none"><i class="fas fa-exclamation-triangle"></i> This will prevent ALL password-based logins!</div>
|
||||
</details>
|
||||
<div style="display:flex;gap:8px;margin-top:20px;justify-content:flex-end">
|
||||
<button class="btn btn-secondary" onclick="testConnection()">🧪 Test</button>
|
||||
<button class="btn btn-primary" id="save-btn" onclick="saveOidcSettings()">💾 Save</button>
|
||||
<div style="display:flex;gap:10px;margin-top:24px;justify-content:flex-end">
|
||||
<button class="btn btn-secondary" onclick="testConnection()"><i class="fas fa-vial"></i> Test</button>
|
||||
<button class="btn btn-primary" id="save-btn" onclick="saveOidcSettings()"><i class="fas fa-save"></i> Save</button>
|
||||
</div>
|
||||
<div id="oidc-status" class="alert"></div>
|
||||
</div>
|
||||
@@ -290,28 +364,28 @@ details[open] summary{margin-bottom:10px}
|
||||
<!-- Quota Modal -->
|
||||
<div id="quota-modal" class="modal-overlay" style="display:none">
|
||||
<div class="modal">
|
||||
<h3>Update Storage Quota</h3>
|
||||
<h3><i class="fas fa-box" style="color:#ff5e3a;margin-right:8px"></i> Update Storage Quota</h3>
|
||||
<div class="form-group">
|
||||
<label>User: <strong id="qm-username"></strong></label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>New Quota</label>
|
||||
<div style="display:flex;gap:8px;align-items:center">
|
||||
<div style="display:flex;gap:10px;align-items:center">
|
||||
<input type="number" id="qm-value" min="0" step="1" style="flex:1">
|
||||
<select id="qm-unit" style="width:80px"><option value="1073741824">GB</option><option value="1048576">MB</option><option value="1099511627776">TB</option></select>
|
||||
<select id="qm-unit" style="width:90px;padding:10px 14px;border:2px solid #e2e8f0;border-radius:10px;font-size:14px;background:#f8fafc"><option value="1073741824">GB</option><option value="1048576">MB</option><option value="1099511627776">TB</option></select>
|
||||
</div>
|
||||
<small>Set to 0 for unlimited</small>
|
||||
</div>
|
||||
<div class="modal-actions">
|
||||
<button class="btn btn-secondary" onclick="closeQuotaModal()">Cancel</button>
|
||||
<button class="btn btn-primary" onclick="saveQuota()">Save Quota</button>
|
||||
<button class="btn btn-primary" onclick="saveQuota()"><i class="fas fa-save"></i> Save</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const API = '/api';
|
||||
const token = localStorage.getItem('token') || localStorage.getItem('access_token');
|
||||
const token = localStorage.getItem('oxicloud_token') || localStorage.getItem('token') || localStorage.getItem('access_token');
|
||||
let currentAdminId = '';
|
||||
let usersPage = 0;
|
||||
const PAGE_SIZE = 50;
|
||||
@@ -341,11 +415,11 @@ function timeAgo(dateStr) {
|
||||
}
|
||||
|
||||
// ── Tab switching ──
|
||||
function switchTab(name) {
|
||||
document.querySelectorAll('.tab').forEach(t => t.classList.remove('active'));
|
||||
function switchTab(name, el) {
|
||||
document.querySelectorAll('.admin-tab').forEach(t => t.classList.remove('active'));
|
||||
document.querySelectorAll('.tab-content').forEach(t => t.classList.remove('active'));
|
||||
document.getElementById('tab-' + name).classList.add('active');
|
||||
event.target.classList.add('active');
|
||||
if (el) el.classList.add('active');
|
||||
if (name === 'users') loadUsers();
|
||||
if (name === 'dashboard') loadDashboard();
|
||||
}
|
||||
@@ -384,14 +458,14 @@ async function loadDashboard() {
|
||||
// ── Users ──
|
||||
async function loadUsers() {
|
||||
const tbody = document.getElementById('users-tbody');
|
||||
tbody.innerHTML = '<tr><td colspan="6" style="text-align:center;padding:20px;color:#6b7280">Loading…</td></tr>';
|
||||
tbody.innerHTML = '<tr><td colspan="6" style="text-align:center;padding:28px;color:#94a3b8"><i class="fas fa-spinner fa-spin"></i> Loading…</td></tr>';
|
||||
try {
|
||||
const resp = await fetch(API + '/admin/users?limit=' + PAGE_SIZE + '&offset=' + (usersPage * PAGE_SIZE), { headers: headers() });
|
||||
if (!resp.ok) { tbody.innerHTML = '<tr><td colspan="6" style="color:#991b1b">Failed to load users</td></tr>'; return; }
|
||||
if (!resp.ok) { tbody.innerHTML = '<tr><td colspan="6" style="color:#991b1b;padding:20px"><i class="fas fa-exclamation-circle"></i> Failed to load users</td></tr>'; return; }
|
||||
const data = await resp.json();
|
||||
totalUsers = data.total;
|
||||
const users = data.users;
|
||||
if (users.length === 0) { tbody.innerHTML = '<tr><td colspan="6" style="text-align:center;padding:20px">No users found</td></tr>'; return; }
|
||||
if (users.length === 0) { tbody.innerHTML = '<tr><td colspan="6" style="text-align:center;padding:28px;color:#94a3b8">No users found</td></tr>'; return; }
|
||||
|
||||
tbody.innerHTML = users.map(u => {
|
||||
const quotaPct = u.storage_quota_bytes > 0 ? ((u.storage_used_bytes / u.storage_quota_bytes) * 100) : 0;
|
||||
@@ -399,16 +473,16 @@ async function loadUsers() {
|
||||
const quotaText = u.storage_quota_bytes > 0 ? formatBytes(u.storage_used_bytes) + ' / ' + formatBytes(u.storage_quota_bytes) : formatBytes(u.storage_used_bytes) + ' / ∞';
|
||||
const isSelf = u.id === currentAdminId;
|
||||
return '<tr>' +
|
||||
'<td><div class="user-info"><span class="user-name">' + u.username + (isSelf ? ' (you)' : '') + '</span><span class="user-email">' + u.email + '</span></div></td>' +
|
||||
'<td><span class="badge badge-' + u.role + '">' + u.role + '</span></td>' +
|
||||
'<td><div class="user-info"><span class="user-name">' + u.username + (isSelf ? ' <span style="color:#94a3b8;font-weight:400">(you)</span>' : '') + '</span><span class="user-email">' + u.email + '</span></div></td>' +
|
||||
'<td><span class="badge badge-' + u.role + '">' + (u.role === 'admin' ? '<i class="fas fa-shield-alt" style="font-size:10px"></i> ' : '') + u.role + '</span></td>' +
|
||||
'<td><span class="badge badge-' + (u.active ? 'active' : 'inactive') + '">' + (u.active ? 'Active' : 'Inactive') + '</span></td>' +
|
||||
'<td><div class="quota-bar"><div class="progress-bar" style="width:80px"><div class="progress-fill ' + quotaColor + '" style="width:' + Math.min(quotaPct, 100) + '%"></div></div><span class="quota-text">' + quotaText + '</span></div></td>' +
|
||||
'<td style="font-size:.8rem;color:#6b7280">' + timeAgo(u.last_login_at) + '</td>' +
|
||||
'<td style="font-size:12px;color:#94a3b8">' + timeAgo(u.last_login_at) + '</td>' +
|
||||
'<td><div class="actions-row">' +
|
||||
'<button class="btn btn-sm btn-secondary" onclick="openQuotaModal(\'' + u.id + '\',\'' + u.username + '\',' + u.storage_quota_bytes + ')" title="Edit quota">📦</button>' +
|
||||
'<button class="btn btn-sm btn-secondary" onclick="toggleRole(\'' + u.id + '\',\'' + u.role + '\')" title="Toggle role"' + (isSelf ? ' disabled' : '') + '>' + (u.role === 'admin' ? '👤' : '👑') + '</button>' +
|
||||
'<button class="btn btn-sm ' + (u.active ? 'btn-danger' : 'btn-success') + '" onclick="toggleActive(\'' + u.id + '\',' + u.active + ')" title="' + (u.active ? 'Deactivate' : 'Activate') + '"' + (isSelf && u.active ? ' disabled' : '') + '>' + (u.active ? '🚫' : '✅') + '</button>' +
|
||||
'<button class="btn btn-sm btn-danger" onclick="deleteUser(\'' + u.id + '\',\'' + u.username + '\')" title="Delete"' + (isSelf ? ' disabled' : '') + '>🗑</button>' +
|
||||
'<button class="btn btn-sm btn-secondary" onclick="openQuotaModal(\'' + u.id + '\',\'' + u.username + '\',' + u.storage_quota_bytes + ')" title="Edit quota"><i class="fas fa-box"></i></button>' +
|
||||
'<button class="btn btn-sm btn-secondary" onclick="toggleRole(\'' + u.id + '\',\'' + u.role + '\')" title="Toggle role"' + (isSelf ? ' disabled' : '') + '><i class="fas fa-' + (u.role === 'admin' ? 'user' : 'crown') + '"></i></button>' +
|
||||
'<button class="btn btn-sm ' + (u.active ? 'btn-danger' : 'btn-success') + '" onclick="toggleActive(\'' + u.id + '\',' + u.active + ')" title="' + (u.active ? 'Deactivate' : 'Activate') + '"' + (isSelf && u.active ? ' disabled' : '') + '><i class="fas fa-' + (u.active ? 'ban' : 'check') + '"></i></button>' +
|
||||
'<button class="btn btn-sm btn-danger" onclick="deleteUser(\'' + u.id + '\',\'' + u.username + '\')" title="Delete"' + (isSelf ? ' disabled' : '') + '><i class="fas fa-trash-alt"></i></button>' +
|
||||
'</div></td></tr>';
|
||||
}).join('');
|
||||
|
||||
@@ -416,7 +490,7 @@ async function loadUsers() {
|
||||
document.getElementById('prev-btn').disabled = usersPage === 0;
|
||||
document.getElementById('next-btn').disabled = (usersPage + 1) * PAGE_SIZE >= totalUsers;
|
||||
} catch (e) {
|
||||
tbody.innerHTML = '<tr><td colspan="6" style="color:#991b1b">Error: ' + e.message + '</td></tr>';
|
||||
tbody.innerHTML = '<tr><td colspan="6" style="color:#991b1b;padding:20px"><i class="fas fa-exclamation-circle"></i> Error: ' + e.message + '</td></tr>';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -501,24 +575,24 @@ async function testConnection() {
|
||||
const url = document.getElementById('issuer-url').value.trim();
|
||||
if (!url) { showOidcStatus('Enter an Issuer URL first', 'error'); return; }
|
||||
const btn = document.getElementById('discover-btn');
|
||||
btn.disabled = true; btn.textContent = '⏳ …';
|
||||
btn.disabled = true; btn.innerHTML = '<i class="fas fa-spinner fa-spin"></i> Discovering…';
|
||||
const resultDiv = document.getElementById('discovery-result');
|
||||
try {
|
||||
const resp = await fetch(API + '/admin/settings/oidc/test', { method: 'POST', headers: headers(), body: JSON.stringify({ issuer_url: url }) });
|
||||
const r = await resp.json();
|
||||
if (r.success) {
|
||||
resultDiv.innerHTML = '<div class="discovery-result ok"><strong>✓ ' + r.message + '</strong><dl><dt>Issuer</dt><dd>' + (r.issuer||'—') + '</dd><dt>Auth Endpoint</dt><dd>' + (r.authorization_endpoint||'—') + '</dd></dl></div>';
|
||||
resultDiv.innerHTML = '<div class="discovery-result ok"><strong><i class="fas fa-check-circle"></i> ' + r.message + '</strong><dl><dt>Issuer</dt><dd>' + (r.issuer||'—') + '</dd><dt>Auth Endpoint</dt><dd>' + (r.authorization_endpoint||'—') + '</dd></dl></div>';
|
||||
if (!document.getElementById('provider-name').value && r.provider_name_suggestion) document.getElementById('provider-name').value = r.provider_name_suggestion;
|
||||
} else {
|
||||
resultDiv.innerHTML = '<div class="discovery-result fail"><strong>✗ ' + r.message + '</strong></div>';
|
||||
resultDiv.innerHTML = '<div class="discovery-result fail"><strong><i class="fas fa-times-circle"></i> ' + r.message + '</strong></div>';
|
||||
}
|
||||
} catch (e) { resultDiv.innerHTML = '<div class="discovery-result fail">Error: ' + e.message + '</div>'; }
|
||||
btn.disabled = false; btn.textContent = '🔍 Auto-discover';
|
||||
} catch (e) { resultDiv.innerHTML = '<div class="discovery-result fail"><i class="fas fa-times-circle"></i> Error: ' + e.message + '</div>'; }
|
||||
btn.disabled = false; btn.innerHTML = '<i class="fas fa-search"></i> Auto-discover';
|
||||
}
|
||||
|
||||
async function saveOidcSettings() {
|
||||
const btn = document.getElementById('save-btn');
|
||||
btn.disabled = true; btn.textContent = '⏳ …';
|
||||
btn.disabled = true; btn.innerHTML = '<i class="fas fa-spinner fa-spin"></i> Saving…';
|
||||
const body = {
|
||||
enabled: document.getElementById('oidc-enabled').checked,
|
||||
issuer_url: document.getElementById('issuer-url').value.trim(),
|
||||
@@ -535,7 +609,7 @@ async function saveOidcSettings() {
|
||||
if (resp.ok) { showOidcStatus('Settings saved — OIDC is now ' + (body.enabled ? 'active' : 'disabled'), 'success'); loadDashboard(); }
|
||||
else { const e = await resp.json().catch(()=>({})); showOidcStatus('Error: ' + (e.message || resp.statusText), 'error'); }
|
||||
} catch (e) { showOidcStatus('Network error: ' + e.message, 'error'); }
|
||||
btn.disabled = false; btn.textContent = '💾 Save';
|
||||
btn.disabled = false; btn.innerHTML = '<i class="fas fa-save"></i> Save';
|
||||
}
|
||||
|
||||
// ── Init ──
|
||||
@@ -584,4 +658,4 @@ function showAccessDenied() {
|
||||
init();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
+155
-253
@@ -214,285 +214,196 @@
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* Auto-detected language banner */
|
||||
.lang-autodetected {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
background: linear-gradient(135deg, #f0fdf4, #ecfdf5);
|
||||
border: 1px solid #bbf7d0;
|
||||
border-radius: 8px;
|
||||
padding: 10px 16px;
|
||||
margin-bottom: 16px;
|
||||
color: #16a34a;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.lang-autodetected i {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.language-subtitle {
|
||||
color: #64748b;
|
||||
font-size: 16px;
|
||||
margin-bottom: 30px;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.language-options {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
margin-bottom: 25px;
|
||||
/* ====== Compact Language Picker ====== */
|
||||
.lang-picker {
|
||||
position: relative;
|
||||
margin-bottom: 24px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.language-option {
|
||||
.lang-picker-selected {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 15px 20px;
|
||||
padding: 14px 18px;
|
||||
border: 2px solid #e2e8f0;
|
||||
border-radius: 10px;
|
||||
border-radius: 12px;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
background-color: #f9fafb;
|
||||
transition: all 0.2s ease;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.language-option:hover {
|
||||
.lang-picker-selected:hover {
|
||||
border-color: #ff5e3a;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.language-option.selected {
|
||||
.lang-picker.open .lang-picker-selected {
|
||||
border-color: #ff5e3a;
|
||||
background-color: #fff5f3;
|
||||
background-color: #fff;
|
||||
border-bottom-left-radius: 0;
|
||||
border-bottom-right-radius: 0;
|
||||
box-shadow: 0 0 0 3px rgba(255, 94, 58, 0.1);
|
||||
}
|
||||
|
||||
.language-option input[type="radio"] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.language-radio {
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
border: 2px solid #cbd5e1;
|
||||
border-radius: 50%;
|
||||
margin-right: 15px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.language-option.selected .language-radio {
|
||||
border-color: #ff5e3a;
|
||||
}
|
||||
|
||||
.language-radio::after {
|
||||
content: '';
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
background-color: #ff5e3a;
|
||||
border-radius: 50%;
|
||||
opacity: 0;
|
||||
transition: opacity 0.2s ease;
|
||||
}
|
||||
|
||||
.language-option.selected .language-radio::after {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.language-flag {
|
||||
font-size: 28px;
|
||||
margin-right: 15px;
|
||||
}
|
||||
|
||||
.language-name {
|
||||
font-size: 16px;
|
||||
font-weight: 500;
|
||||
color: #1e293b;
|
||||
}
|
||||
|
||||
.language-native {
|
||||
font-size: 14px;
|
||||
color: #64748b;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
/* "More languages" button */
|
||||
.lang-more-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
width: 100%;
|
||||
padding: 12px;
|
||||
margin-bottom: 20px;
|
||||
border: 1px dashed #cbd5e1;
|
||||
border-radius: 10px;
|
||||
background: transparent;
|
||||
color: #64748b;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.lang-more-btn:hover {
|
||||
border-color: #ff5e3a;
|
||||
color: #ff5e3a;
|
||||
background: #fff5f3;
|
||||
}
|
||||
|
||||
.lang-more-btn i {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
/* ====== Language Modal ====== */
|
||||
.lang-modal-overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 9999;
|
||||
padding: 20px;
|
||||
animation: fadeIn 0.2s ease;
|
||||
}
|
||||
|
||||
@keyframes fadeIn {
|
||||
from { opacity: 0; }
|
||||
to { opacity: 1; }
|
||||
}
|
||||
|
||||
.lang-modal {
|
||||
background: #fff;
|
||||
border-radius: 16px;
|
||||
width: 100%;
|
||||
max-width: 480px;
|
||||
max-height: 70vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
|
||||
animation: slideUp 0.25s ease;
|
||||
}
|
||||
|
||||
@keyframes slideUp {
|
||||
from { transform: translateY(20px); opacity: 0; }
|
||||
to { transform: translateY(0); opacity: 1; }
|
||||
}
|
||||
|
||||
.lang-modal-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 20px 24px 12px;
|
||||
}
|
||||
|
||||
.lang-modal-header h3 {
|
||||
margin: 0;
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
color: #1e293b;
|
||||
}
|
||||
|
||||
.lang-modal-close {
|
||||
background: none;
|
||||
border: none;
|
||||
font-size: 24px;
|
||||
color: #94a3b8;
|
||||
cursor: pointer;
|
||||
padding: 4px 8px;
|
||||
border-radius: 6px;
|
||||
line-height: 1;
|
||||
transition: all 0.15s;
|
||||
}
|
||||
|
||||
.lang-modal-close:hover {
|
||||
background: #f1f5f9;
|
||||
color: #475569;
|
||||
}
|
||||
|
||||
.lang-modal-search {
|
||||
position: relative;
|
||||
padding: 0 24px 12px;
|
||||
}
|
||||
|
||||
.lang-modal-search i {
|
||||
position: absolute;
|
||||
left: 38px;
|
||||
top: 12px;
|
||||
color: #94a3b8;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.lang-modal-search input {
|
||||
width: 100%;
|
||||
padding: 10px 14px 10px 36px;
|
||||
border: 2px solid #e2e8f0;
|
||||
border-radius: 10px;
|
||||
font-size: 14px;
|
||||
outline: none;
|
||||
transition: border-color 0.2s;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.lang-modal-search input:focus {
|
||||
border-color: #ff5e3a;
|
||||
}
|
||||
|
||||
.lang-modal-list {
|
||||
overflow-y: auto;
|
||||
padding: 0 12px 16px;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.lang-modal-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 12px 14px;
|
||||
border-radius: 10px;
|
||||
cursor: pointer;
|
||||
transition: all 0.15s;
|
||||
}
|
||||
|
||||
.lang-modal-item:hover {
|
||||
background: #f8fafc;
|
||||
}
|
||||
|
||||
.lang-modal-item.selected {
|
||||
background: #fff5f3;
|
||||
}
|
||||
|
||||
.lang-modal-flag {
|
||||
font-size: 24px;
|
||||
.lang-picker-flag {
|
||||
font-size: 26px;
|
||||
margin-right: 14px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.lang-modal-native {
|
||||
.lang-picker-name {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: #1e293b;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.lang-picker-arrow {
|
||||
color: #94a3b8;
|
||||
font-size: 13px;
|
||||
transition: transform 0.2s ease;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.lang-picker.open .lang-picker-arrow {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
|
||||
/* Dropdown */
|
||||
.lang-picker-dropdown {
|
||||
display: none;
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
left: 0;
|
||||
right: 0;
|
||||
background: #fff;
|
||||
border: 2px solid #ff5e3a;
|
||||
border-top: 1px solid #f1f5f9;
|
||||
border-bottom-left-radius: 12px;
|
||||
border-bottom-right-radius: 12px;
|
||||
box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
|
||||
z-index: 100;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.lang-picker.open .lang-picker-dropdown {
|
||||
display: block;
|
||||
animation: langPickerSlideDown 0.2s ease;
|
||||
}
|
||||
|
||||
@keyframes langPickerSlideDown {
|
||||
from { opacity: 0; transform: translateY(-4px); }
|
||||
to { opacity: 1; transform: translateY(0); }
|
||||
}
|
||||
|
||||
/* Search inside dropdown */
|
||||
.lang-picker-search {
|
||||
position: relative;
|
||||
padding: 10px 14px;
|
||||
border-bottom: 1px solid #f1f5f9;
|
||||
}
|
||||
|
||||
.lang-picker-search i {
|
||||
position: absolute;
|
||||
left: 26px;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
color: #94a3b8;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.lang-picker-search input {
|
||||
width: 100%;
|
||||
padding: 8px 12px 8px 32px;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 8px;
|
||||
font-size: 14px;
|
||||
outline: none;
|
||||
box-sizing: border-box;
|
||||
transition: border-color 0.2s;
|
||||
}
|
||||
|
||||
.lang-picker-search input:focus {
|
||||
border-color: #ff5e3a;
|
||||
}
|
||||
|
||||
/* Scrollable list */
|
||||
.lang-picker-list {
|
||||
max-height: 240px;
|
||||
overflow-y: auto;
|
||||
padding: 6px;
|
||||
}
|
||||
|
||||
.lang-picker-list::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
|
||||
.lang-picker-list::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.lang-picker-list::-webkit-scrollbar-thumb {
|
||||
background: #cbd5e1;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.lang-picker-list::-webkit-scrollbar-thumb:hover {
|
||||
background: #94a3b8;
|
||||
}
|
||||
|
||||
/* Language item in dropdown */
|
||||
.lang-picker-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 10px 12px;
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
transition: all 0.12s ease;
|
||||
}
|
||||
|
||||
.lang-picker-item:hover {
|
||||
background: #f8fafc;
|
||||
}
|
||||
|
||||
.lang-picker-item.selected {
|
||||
background: #fff5f3;
|
||||
}
|
||||
|
||||
.lang-picker-item-flag {
|
||||
font-size: 22px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.lang-picker-item-name {
|
||||
font-size: 15px;
|
||||
font-weight: 500;
|
||||
color: #1e293b;
|
||||
}
|
||||
|
||||
.lang-modal-english {
|
||||
.lang-picker-item-english {
|
||||
font-size: 13px;
|
||||
color: #94a3b8;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.lang-modal-check {
|
||||
.lang-picker-item-check {
|
||||
color: #ff5e3a;
|
||||
font-size: 14px;
|
||||
font-size: 13px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.lang-modal-empty {
|
||||
.lang-picker-empty {
|
||||
text-align: center;
|
||||
color: #94a3b8;
|
||||
padding: 30px;
|
||||
padding: 20px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
@@ -501,21 +412,12 @@
|
||||
width: 90%;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.language-option {
|
||||
padding: 12px 15px;
|
||||
}
|
||||
|
||||
.language-flag {
|
||||
font-size: 24px;
|
||||
|
||||
.lang-picker-selected {
|
||||
padding: 12px 14px;
|
||||
}
|
||||
|
||||
.lang-modal {
|
||||
max-height: 80vh;
|
||||
}
|
||||
|
||||
.lang-autodetected {
|
||||
font-size: 13px;
|
||||
padding: 8px 12px;
|
||||
.lang-picker-list {
|
||||
max-height: 200px;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -211,11 +211,11 @@ function setupUserMenu() {
|
||||
});
|
||||
}
|
||||
|
||||
// Profile button — shows user info modal
|
||||
// Profile button — navigates to profile page
|
||||
if (profileBtn) {
|
||||
profileBtn.addEventListener('click', () => {
|
||||
wrapper.classList.remove('open');
|
||||
showUserProfileModal();
|
||||
window.location.href = '/profile.html';
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+106
-173
@@ -56,15 +56,6 @@ const LANGUAGE_TEXTS = {
|
||||
modalTitle: 'انتخاب زبان',
|
||||
searchPlaceholder: 'جستجوی زبان...'
|
||||
}
|
||||
de: {
|
||||
title: 'Willkommen bei OxiCloud',
|
||||
subtitle: 'Bitte wählen Sie Ihre Sprache',
|
||||
continue: 'Fortfahren',
|
||||
autodetected: 'Wir haben Ihre Sprache automatisch erkannt',
|
||||
moreLanguages: 'Weitere Sprachen...',
|
||||
modalTitle: 'Sprache auswählen',
|
||||
searchPlaceholder: 'Sprache suchen...'
|
||||
}
|
||||
};
|
||||
|
||||
// Complete language registry — add new languages here, they'll appear automatically
|
||||
@@ -138,103 +129,127 @@ function detectBrowserLanguage() {
|
||||
|
||||
// Build a language option element (card style)
|
||||
function buildLanguageCard(lang, isSelected) {
|
||||
const label = document.createElement('label');
|
||||
label.className = 'language-option' + (isSelected ? ' selected' : '');
|
||||
label.setAttribute('data-lang', lang.code);
|
||||
label.innerHTML = `
|
||||
<input type="radio" name="language" value="${lang.code}" ${isSelected ? 'checked' : ''}>
|
||||
<span class="language-radio"></span>
|
||||
<span class="language-flag">${lang.flag}</span>
|
||||
<span class="language-name">${lang.nativeName}</span>
|
||||
const item = document.createElement('div');
|
||||
item.className = 'lang-picker-item' + (isSelected ? ' selected' : '');
|
||||
item.setAttribute('data-lang', lang.code);
|
||||
item.setAttribute('role', 'option');
|
||||
item.setAttribute('aria-selected', isSelected);
|
||||
item.innerHTML = `
|
||||
<span class="lang-picker-item-flag">${lang.flag}</span>
|
||||
<span class="lang-picker-item-name">${lang.nativeName}</span>
|
||||
<span class="lang-picker-item-english">${lang.name}</span>
|
||||
${isSelected ? '<i class="fas fa-check lang-picker-item-check"></i>' : ''}
|
||||
`;
|
||||
return label;
|
||||
return item;
|
||||
}
|
||||
|
||||
// Initialize language selector panel with hybrid approach
|
||||
// Initialize language selector panel with compact dropdown approach
|
||||
function initLanguageSelector() {
|
||||
const languagePanel = document.getElementById('language-panel');
|
||||
const continueBtn = document.getElementById('language-continue');
|
||||
const optionsContainer = document.getElementById('language-options');
|
||||
const moreLangBtn = document.getElementById('lang-more-btn');
|
||||
const picker = document.getElementById('lang-picker');
|
||||
const pickerSelected = document.getElementById('lang-picker-selected');
|
||||
const pickerDropdown = document.getElementById('lang-picker-dropdown');
|
||||
const pickerList = document.getElementById('lang-picker-list');
|
||||
const pickerFlag = document.getElementById('lang-picker-flag');
|
||||
const pickerName = document.getElementById('lang-picker-name');
|
||||
const searchInput = document.getElementById('lang-picker-search-input');
|
||||
|
||||
if (!languagePanel || !optionsContainer) return;
|
||||
|
||||
let selectedLanguage = null;
|
||||
if (!languagePanel || !picker) return;
|
||||
|
||||
// --- Auto-detect browser language ---
|
||||
const detected = detectBrowserLanguage();
|
||||
let selectedLanguage = detected.code;
|
||||
|
||||
// Build the list of popular languages to show as cards
|
||||
// If the detected language isn't already popular, promote it to the top
|
||||
let popularLangs = ALL_LANGUAGES.filter(l => l.popular);
|
||||
const detectedInPopular = popularLangs.find(l => l.code === detected.code);
|
||||
if (!detectedInPopular) {
|
||||
// Insert detected language at the top of popular cards
|
||||
popularLangs = [detected, ...popularLangs];
|
||||
}
|
||||
// Update the selected box with detected language
|
||||
pickerFlag.textContent = detected.flag;
|
||||
pickerName.textContent = detected.nativeName;
|
||||
updateLanguagePanelTexts(selectedLanguage);
|
||||
|
||||
// Auto-select the detected language
|
||||
selectedLanguage = detected.code;
|
||||
continueBtn.disabled = false;
|
||||
|
||||
// Show autodetection banner
|
||||
const autodetectedBanner = document.getElementById('lang-autodetected');
|
||||
if (autodetectedBanner) {
|
||||
autodetectedBanner.style.display = 'flex';
|
||||
}
|
||||
updateLanguagePanelTexts(detected.code);
|
||||
|
||||
// --- Render popular language cards ---
|
||||
optionsContainer.innerHTML = '';
|
||||
popularLangs.forEach(lang => {
|
||||
const card = buildLanguageCard(lang, lang.code === selectedLanguage);
|
||||
card.addEventListener('click', () => {
|
||||
// Deselect all
|
||||
optionsContainer.querySelectorAll('.language-option').forEach(o => o.classList.remove('selected'));
|
||||
card.classList.add('selected');
|
||||
card.querySelector('input[type="radio"]').checked = true;
|
||||
selectedLanguage = lang.code;
|
||||
continueBtn.disabled = false;
|
||||
updateLanguagePanelTexts(lang.code);
|
||||
// Render dropdown list
|
||||
function renderDropdownList(filter = '') {
|
||||
pickerList.innerHTML = '';
|
||||
const filterLower = filter.toLowerCase();
|
||||
|
||||
const filtered = ALL_LANGUAGES.filter(lang => {
|
||||
if (!filter) return true;
|
||||
return lang.name.toLowerCase().includes(filterLower) ||
|
||||
lang.nativeName.toLowerCase().includes(filterLower) ||
|
||||
lang.code.toLowerCase().includes(filterLower);
|
||||
});
|
||||
optionsContainer.appendChild(card);
|
||||
|
||||
if (filtered.length === 0) {
|
||||
pickerList.innerHTML = '<div class="lang-picker-empty">—</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
filtered.forEach(lang => {
|
||||
const item = buildLanguageCard(lang, lang.code === selectedLanguage);
|
||||
item.addEventListener('click', (e) => {
|
||||
e.stopPropagation();
|
||||
selectedLanguage = lang.code;
|
||||
pickerFlag.textContent = lang.flag;
|
||||
pickerName.textContent = lang.nativeName;
|
||||
updateLanguagePanelTexts(lang.code);
|
||||
closePicker();
|
||||
renderDropdownList('');
|
||||
});
|
||||
pickerList.appendChild(item);
|
||||
});
|
||||
}
|
||||
|
||||
function openPicker() {
|
||||
picker.classList.add('open');
|
||||
pickerSelected.setAttribute('aria-expanded', 'true');
|
||||
renderDropdownList('');
|
||||
if (searchInput) {
|
||||
searchInput.value = '';
|
||||
setTimeout(() => searchInput.focus(), 50);
|
||||
}
|
||||
// Scroll active item into view
|
||||
setTimeout(() => {
|
||||
const active = pickerList.querySelector('.lang-picker-item.selected');
|
||||
if (active) active.scrollIntoView({ block: 'nearest' });
|
||||
}, 60);
|
||||
}
|
||||
|
||||
function closePicker() {
|
||||
picker.classList.remove('open');
|
||||
pickerSelected.setAttribute('aria-expanded', 'false');
|
||||
if (searchInput) searchInput.value = '';
|
||||
}
|
||||
|
||||
// Toggle dropdown
|
||||
pickerSelected.addEventListener('click', (e) => {
|
||||
e.stopPropagation();
|
||||
if (picker.classList.contains('open')) {
|
||||
closePicker();
|
||||
} else {
|
||||
openPicker();
|
||||
}
|
||||
});
|
||||
|
||||
// --- "More languages" button opens the modal ---
|
||||
if (moreLangBtn) {
|
||||
moreLangBtn.addEventListener('click', () => openLanguageModal(selectedLanguage, (langCode) => {
|
||||
selectedLanguage = langCode;
|
||||
continueBtn.disabled = false;
|
||||
updateLanguagePanelTexts(langCode);
|
||||
|
||||
// Update cards to reflect new selection
|
||||
optionsContainer.querySelectorAll('.language-option').forEach(o => {
|
||||
const isThis = o.getAttribute('data-lang') === langCode;
|
||||
o.classList.toggle('selected', isThis);
|
||||
o.querySelector('input[type="radio"]').checked = isThis;
|
||||
});
|
||||
|
||||
// If selected lang is not in the popular cards, add it temporarily
|
||||
if (!optionsContainer.querySelector(`[data-lang="${langCode}"]`)) {
|
||||
const lang = ALL_LANGUAGES.find(l => l.code === langCode);
|
||||
if (lang) {
|
||||
// Deselect all existing
|
||||
optionsContainer.querySelectorAll('.language-option').forEach(o => o.classList.remove('selected'));
|
||||
const card = buildLanguageCard(lang, true);
|
||||
card.addEventListener('click', () => {
|
||||
optionsContainer.querySelectorAll('.language-option').forEach(o => o.classList.remove('selected'));
|
||||
card.classList.add('selected');
|
||||
card.querySelector('input[type="radio"]').checked = true;
|
||||
selectedLanguage = lang.code;
|
||||
updateLanguagePanelTexts(lang.code);
|
||||
});
|
||||
// Insert at the top
|
||||
optionsContainer.insertBefore(card, optionsContainer.firstChild);
|
||||
}
|
||||
}
|
||||
}));
|
||||
// Keyboard support
|
||||
pickerSelected.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Enter' || e.key === ' ') {
|
||||
e.preventDefault();
|
||||
if (picker.classList.contains('open')) closePicker(); else openPicker();
|
||||
} else if (e.key === 'Escape') {
|
||||
closePicker();
|
||||
}
|
||||
});
|
||||
|
||||
// Search input
|
||||
if (searchInput) {
|
||||
searchInput.addEventListener('input', () => renderDropdownList(searchInput.value));
|
||||
searchInput.addEventListener('click', (e) => e.stopPropagation());
|
||||
}
|
||||
|
||||
// Close when clicking outside
|
||||
document.addEventListener('click', (e) => {
|
||||
if (!picker.contains(e.target)) closePicker();
|
||||
});
|
||||
|
||||
// --- Continue button ---
|
||||
continueBtn.addEventListener('click', async () => {
|
||||
if (!selectedLanguage) return;
|
||||
@@ -276,99 +291,17 @@ function initLanguageSelector() {
|
||||
});
|
||||
}
|
||||
|
||||
// Open the full language modal with search
|
||||
function openLanguageModal(currentSelection, onSelect) {
|
||||
const overlay = document.getElementById('lang-modal-overlay');
|
||||
const list = document.getElementById('lang-modal-list');
|
||||
const searchInput = document.getElementById('lang-search-input');
|
||||
const closeBtn = document.getElementById('lang-modal-close');
|
||||
|
||||
if (!overlay || !list) return;
|
||||
|
||||
// Render all languages
|
||||
function renderList(filter = '') {
|
||||
list.innerHTML = '';
|
||||
const filterLower = filter.toLowerCase();
|
||||
|
||||
const filtered = ALL_LANGUAGES.filter(lang => {
|
||||
if (!filter) return true;
|
||||
return lang.name.toLowerCase().includes(filterLower) ||
|
||||
lang.nativeName.toLowerCase().includes(filterLower) ||
|
||||
lang.code.toLowerCase().includes(filterLower);
|
||||
});
|
||||
|
||||
if (filtered.length === 0) {
|
||||
list.innerHTML = '<div class="lang-modal-empty">No languages found</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
filtered.forEach(lang => {
|
||||
const item = document.createElement('div');
|
||||
item.className = 'lang-modal-item' + (lang.code === currentSelection ? ' selected' : '');
|
||||
item.setAttribute('data-lang', lang.code);
|
||||
item.innerHTML = `
|
||||
<span class="lang-modal-flag">${lang.flag}</span>
|
||||
<span class="lang-modal-native">${lang.nativeName}</span>
|
||||
<span class="lang-modal-english">${lang.name}</span>
|
||||
${lang.code === currentSelection ? '<i class="fas fa-check lang-modal-check"></i>' : ''}
|
||||
`;
|
||||
item.addEventListener('click', () => {
|
||||
currentSelection = lang.code;
|
||||
onSelect(lang.code);
|
||||
closeModal();
|
||||
});
|
||||
list.appendChild(item);
|
||||
});
|
||||
}
|
||||
|
||||
function closeModal() {
|
||||
overlay.style.display = 'none';
|
||||
if (searchInput) searchInput.value = '';
|
||||
}
|
||||
|
||||
// Show modal
|
||||
overlay.style.display = 'flex';
|
||||
renderList();
|
||||
|
||||
// Focus search
|
||||
if (searchInput) {
|
||||
setTimeout(() => searchInput.focus(), 100);
|
||||
searchInput.value = '';
|
||||
searchInput.oninput = () => renderList(searchInput.value);
|
||||
}
|
||||
|
||||
// Close handlers
|
||||
if (closeBtn) {
|
||||
closeBtn.onclick = closeModal;
|
||||
}
|
||||
overlay.onclick = (e) => {
|
||||
if (e.target === overlay) closeModal();
|
||||
};
|
||||
document.addEventListener('keydown', function escHandler(e) {
|
||||
if (e.key === 'Escape') {
|
||||
closeModal();
|
||||
document.removeEventListener('keydown', escHandler);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Update language panel texts based on selected language
|
||||
function updateLanguagePanelTexts(lang) {
|
||||
const texts = LANGUAGE_TEXTS[lang] || LANGUAGE_TEXTS.en;
|
||||
const titleEl = document.getElementById('language-title');
|
||||
const subtitleEl = document.getElementById('language-subtitle');
|
||||
const continueBtn = document.getElementById('language-continue');
|
||||
const autodetectedText = document.getElementById('lang-autodetected-text');
|
||||
const moreText = document.getElementById('lang-more-text');
|
||||
const modalTitle = document.getElementById('lang-modal-title');
|
||||
const searchInput = document.getElementById('lang-search-input');
|
||||
const searchInput = document.getElementById('lang-picker-search-input');
|
||||
|
||||
if (titleEl) titleEl.textContent = texts.title;
|
||||
if (subtitleEl) subtitleEl.textContent = texts.subtitle;
|
||||
if (continueBtn) continueBtn.textContent = texts.continue;
|
||||
if (autodetectedText) autodetectedText.textContent = texts.autodetected;
|
||||
if (moreText) moreText.textContent = texts.moreLanguages;
|
||||
if (modalTitle) modalTitle.textContent = texts.modalTitle;
|
||||
if (searchInput) searchInput.placeholder = texts.searchPlaceholder;
|
||||
}
|
||||
|
||||
@@ -1176,4 +1109,4 @@ function logout() {
|
||||
localStorage.removeItem(TOKEN_EXPIRY_KEY);
|
||||
localStorage.removeItem(USER_DATA_KEY);
|
||||
window.location.href = '/login.html';
|
||||
}
|
||||
}
|
||||
+17
-33
@@ -28,44 +28,28 @@
|
||||
<div class="auth-logo-text">OxiCloud</div>
|
||||
</div>
|
||||
|
||||
<!-- Auto-detected language banner -->
|
||||
<div class="lang-autodetected" id="lang-autodetected" style="display: none;">
|
||||
<i class="fas fa-magic"></i>
|
||||
<span id="lang-autodetected-text">We detected your language</span>
|
||||
</div>
|
||||
|
||||
<h2 class="auth-title" id="language-title">Welcome to OxiCloud</h2>
|
||||
<p class="language-subtitle" id="language-subtitle">Please select your language</p>
|
||||
|
||||
<!-- Popular languages shown as cards -->
|
||||
<div class="language-options" id="language-options">
|
||||
<!-- Populated dynamically by auth.js -->
|
||||
<!-- Single selected language box with inline dropdown -->
|
||||
<div class="lang-picker" id="lang-picker">
|
||||
<div class="lang-picker-selected" id="lang-picker-selected" role="button" tabindex="0" aria-haspopup="listbox" aria-expanded="false">
|
||||
<span class="lang-picker-flag" id="lang-picker-flag">🇬🇧</span>
|
||||
<span class="lang-picker-name" id="lang-picker-name">English</span>
|
||||
<i class="fas fa-chevron-down lang-picker-arrow"></i>
|
||||
</div>
|
||||
<div class="lang-picker-dropdown" id="lang-picker-dropdown" role="listbox">
|
||||
<div class="lang-picker-search">
|
||||
<i class="fas fa-search"></i>
|
||||
<input type="text" id="lang-picker-search-input" placeholder="Search language..." autocomplete="off">
|
||||
</div>
|
||||
<div class="lang-picker-list" id="lang-picker-list">
|
||||
<!-- Populated dynamically by auth.js -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- "More languages" link -->
|
||||
<button type="button" class="lang-more-btn" id="lang-more-btn">
|
||||
<i class="fas fa-globe"></i>
|
||||
<span id="lang-more-text">More languages...</span>
|
||||
</button>
|
||||
|
||||
<button type="button" class="auth-button" id="language-continue" disabled>Continue</button>
|
||||
</div>
|
||||
|
||||
<!-- Modal: All languages with search -->
|
||||
<div class="lang-modal-overlay" id="lang-modal-overlay" style="display: none;">
|
||||
<div class="lang-modal">
|
||||
<div class="lang-modal-header">
|
||||
<h3 id="lang-modal-title">Select language</h3>
|
||||
<button type="button" class="lang-modal-close" id="lang-modal-close">×</button>
|
||||
</div>
|
||||
<div class="lang-modal-search">
|
||||
<i class="fas fa-search"></i>
|
||||
<input type="text" id="lang-search-input" placeholder="Search language..." autocomplete="off">
|
||||
</div>
|
||||
<div class="lang-modal-list" id="lang-modal-list">
|
||||
<!-- Populated dynamically -->
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="auth-button" id="language-continue">Continue</button>
|
||||
</div>
|
||||
|
||||
<div class="auth-panel" id="login-panel" style="display: none;">
|
||||
|
||||
@@ -0,0 +1,367 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>OxiCloud — My Profile</title>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
|
||||
<style>
|
||||
*{box-sizing:border-box;margin:0;padding:0;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Oxygen,Ubuntu,Cantarell,'Open Sans','Helvetica Neue',sans-serif}
|
||||
body{background:#f5f7fa;color:#1e293b;min-height:100vh;display:flex;flex-direction:column}
|
||||
|
||||
/* ── Scrollbar ── */
|
||||
::-webkit-scrollbar{width:8px}
|
||||
::-webkit-scrollbar-track{background:transparent}
|
||||
::-webkit-scrollbar-thumb{background:rgba(0,0,0,.15);border-radius:4px}
|
||||
*{scrollbar-width:thin;scrollbar-color:rgba(0,0,0,.15) transparent}
|
||||
|
||||
/* ── Header ── */
|
||||
.profile-header{
|
||||
background:linear-gradient(135deg,#2a3042 0%,#232838 100%);
|
||||
padding:0 32px;height:64px;display:flex;align-items:center;justify-content:space-between;
|
||||
box-shadow:0 2px 12px rgba(0,0,0,.15);position:sticky;top:0;z-index:100;
|
||||
}
|
||||
.profile-header-left{display:flex;align-items:center;gap:14px}
|
||||
.profile-logo{
|
||||
width:38px;height:38px;background:linear-gradient(135deg,#ff5e3a,#ff2d55);border-radius:11px;
|
||||
display:flex;align-items:center;justify-content:center;
|
||||
box-shadow:0 3px 10px rgba(255,94,58,.35);
|
||||
}
|
||||
.profile-logo svg{width:20px;height:20px;fill:#fff}
|
||||
.profile-title{font-size:17px;font-weight:700;color:#fff;letter-spacing:.3px}
|
||||
.profile-title span{color:rgba(255,255,255,.5);font-weight:400;margin-left:6px}
|
||||
.profile-header-right a{
|
||||
color:rgba(255,255,255,.65);text-decoration:none;font-size:13px;font-weight:500;
|
||||
display:flex;align-items:center;gap:6px;transition:color .2s;
|
||||
}
|
||||
.profile-header-right a:hover{color:#fff}
|
||||
|
||||
/* ── Container ── */
|
||||
.profile-container{max-width:720px;margin:0 auto;padding:32px 24px 60px;width:100%}
|
||||
|
||||
/* ── Card ── */
|
||||
.profile-card{background:#fff;border-radius:16px;box-shadow:0 1px 4px rgba(0,0,0,.06),0 0 0 1px rgba(0,0,0,.03);padding:32px;margin-bottom:22px}
|
||||
.profile-card h2{font-size:16px;font-weight:700;margin-bottom:20px;color:#1e293b;display:flex;align-items:center;gap:10px}
|
||||
.profile-card h2 i{color:#ff5e3a;font-size:17px}
|
||||
|
||||
/* ── Avatar Section ── */
|
||||
.avatar-section{display:flex;align-items:center;gap:24px;margin-bottom:8px}
|
||||
.avatar-large{
|
||||
width:88px;height:88px;border-radius:50%;
|
||||
background:linear-gradient(135deg,#ff5e3a,#ff2d55);
|
||||
display:flex;align-items:center;justify-content:center;
|
||||
color:#fff;font-size:32px;font-weight:700;letter-spacing:1px;
|
||||
box-shadow:0 6px 20px rgba(255,94,58,.3);flex-shrink:0;
|
||||
}
|
||||
.avatar-info h1{font-size:22px;font-weight:700;color:#1e293b;margin-bottom:4px}
|
||||
.avatar-info .email{font-size:14px;color:#64748b;margin-bottom:8px}
|
||||
.avatar-info .role-badge{
|
||||
display:inline-flex;align-items:center;gap:5px;font-size:12px;font-weight:600;
|
||||
padding:4px 12px;border-radius:20px;
|
||||
}
|
||||
.role-badge-admin{background:#dbeafe;color:#1d4ed8}
|
||||
.role-badge-user{background:#f1f5f9;color:#64748b}
|
||||
|
||||
/* ── Info Grid ── */
|
||||
.info-grid{display:grid;grid-template-columns:1fr 1fr;gap:16px}
|
||||
@media(max-width:560px){.info-grid{grid-template-columns:1fr}}
|
||||
.info-item{padding:16px;background:#f8fafc;border-radius:12px;border:1px solid #e2e8f0}
|
||||
.info-item .info-label{font-size:11.5px;color:#94a3b8;text-transform:uppercase;letter-spacing:.06em;font-weight:700;margin-bottom:4px;display:flex;align-items:center;gap:6px}
|
||||
.info-item .info-label i{font-size:12px;color:#cbd5e1}
|
||||
.info-item .info-value{font-size:15px;font-weight:600;color:#1e293b}
|
||||
|
||||
/* ── Storage ── */
|
||||
.storage-section{margin-top:4px}
|
||||
.storage-stats{display:grid;grid-template-columns:1fr 1fr 1fr;gap:14px;margin-bottom:16px}
|
||||
@media(max-width:560px){.storage-stats{grid-template-columns:1fr}}
|
||||
.storage-stat{text-align:center;padding:16px;background:#f8fafc;border-radius:12px;border:1px solid #e2e8f0}
|
||||
.storage-stat .stat-value{font-size:1.5rem;font-weight:800;color:#1e293b}
|
||||
.storage-stat .stat-label{font-size:11px;color:#94a3b8;text-transform:uppercase;letter-spacing:.06em;font-weight:600;margin-top:2px}
|
||||
.storage-bar-wrap{margin-top:4px}
|
||||
.storage-bar{height:10px;background:#e2e8f0;border-radius:5px;overflow:hidden}
|
||||
.storage-fill{height:100%;border-radius:5px;transition:width .6s ease}
|
||||
.storage-fill.green{background:linear-gradient(90deg,#059669,#10b981)}
|
||||
.storage-fill.orange{background:linear-gradient(90deg,#d97706,#f59e0b)}
|
||||
.storage-fill.red{background:linear-gradient(90deg,#dc2626,#ef4444)}
|
||||
.storage-text{font-size:12px;color:#94a3b8;text-align:right;margin-top:6px}
|
||||
|
||||
/* ── Change Password ── */
|
||||
.form-group{margin-bottom:16px}
|
||||
.form-group label{display:block;font-size:13px;font-weight:600;margin-bottom:4px;color:#334155}
|
||||
.form-group input{
|
||||
width:100%;padding:10px 14px;border:2px solid #e2e8f0;border-radius:10px;font-size:14px;
|
||||
background:#f8fafc;transition:all .2s;font-family:inherit;color:#1e293b;
|
||||
}
|
||||
.form-group input:focus{outline:none;border-color:#ff5e3a;background:#fff;box-shadow:0 0 0 3px rgba(255,94,58,.1)}
|
||||
.form-group small{color:#94a3b8;font-size:12px;display:block;margin-top:3px}
|
||||
|
||||
.btn{
|
||||
padding:10px 22px;border:none;border-radius:10px;font-size:14px;font-weight:600;
|
||||
cursor:pointer;transition:all .15s;white-space:nowrap;display:inline-flex;align-items:center;gap:6px;
|
||||
}
|
||||
.btn-primary{background:linear-gradient(135deg,#ff5e3a,#ff2d55);color:#fff;box-shadow:0 2px 8px rgba(255,94,58,.25)}
|
||||
.btn-primary:hover{box-shadow:0 4px 14px rgba(255,94,58,.35);transform:translateY(-1px)}
|
||||
.btn-primary:disabled{opacity:.4;cursor:not-allowed;transform:none!important}
|
||||
|
||||
.alert{padding:12px 16px;border-radius:10px;font-size:13px;margin-top:14px;font-weight:500}
|
||||
.alert-success{background:#ecfdf5;color:#065f46;border:1px solid #a7f3d0}
|
||||
.alert-error{background:#fef2f2;color:#991b1b;border:1px solid #fecaca}
|
||||
|
||||
/* ── Loading / Error ── */
|
||||
#loading{text-align:center;padding:80px;color:#94a3b8;font-size:15px}
|
||||
#loading i{font-size:32px;color:#ff5e3a;display:block;margin-bottom:12px;animation:spin 1s linear infinite}
|
||||
@keyframes spin{to{transform:rotate(360deg)}}
|
||||
#auth-error{display:none;text-align:center;padding:80px 20px}
|
||||
#auth-error .err-icon{width:80px;height:80px;background:#fef2f2;border-radius:50%;display:flex;align-items:center;justify-content:center;margin:0 auto 20px}
|
||||
#auth-error .err-icon i{font-size:32px;color:#ef4444}
|
||||
#auth-error h2{color:#991b1b;margin-bottom:8px;font-size:20px}
|
||||
#auth-error p{color:#64748b;margin-bottom:20px;font-size:14px}
|
||||
#auth-error a{display:inline-flex;align-items:center;gap:6px;padding:10px 24px;background:linear-gradient(135deg,#ff5e3a,#ff2d55);color:#fff;text-decoration:none;border-radius:10px;font-weight:600;font-size:14px;box-shadow:0 3px 12px rgba(255,94,58,.3);transition:all .2s}
|
||||
#auth-error a:hover{transform:translateY(-1px);box-shadow:0 5px 18px rgba(255,94,58,.4)}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- Header -->
|
||||
<div class="profile-header">
|
||||
<div class="profile-header-left">
|
||||
<div class="profile-logo">
|
||||
<svg viewBox="0 0 500 500">
|
||||
<path d="M345 310c32 0 58-26 58-58s-26-58-58-58c-6.2 0-12 0.9-17.5 2.7C318 166 289 143 255 143c-34.3 0-63.1 22.6-73 53.7C176.9 195.7 171 195 165 195c-32 0-58 26-58 58s26 58 58 58h180z"/>
|
||||
</svg>
|
||||
</div>
|
||||
<div class="profile-title">OxiCloud <span>· Profile</span></div>
|
||||
</div>
|
||||
<div class="profile-header-right">
|
||||
<a href="/"><i class="fas fa-arrow-left"></i> Back to OxiCloud</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="profile-container">
|
||||
<div id="loading"><i class="fas fa-circle-notch"></i> Loading…</div>
|
||||
<div id="auth-error">
|
||||
<div class="err-icon"><i class="fas fa-lock"></i></div>
|
||||
<h2>Not Authenticated</h2>
|
||||
<p>Please sign in to view your profile.</p>
|
||||
<a href="/login.html"><i class="fas fa-sign-in-alt"></i> Sign in</a>
|
||||
</div>
|
||||
|
||||
<div id="main-content" style="display:none">
|
||||
<!-- Profile Header Card -->
|
||||
<div class="profile-card">
|
||||
<div class="avatar-section">
|
||||
<div class="avatar-large" id="p-avatar">—</div>
|
||||
<div class="avatar-info">
|
||||
<h1 id="p-username">—</h1>
|
||||
<div class="email" id="p-email">—</div>
|
||||
<span class="role-badge" id="p-role-badge">—</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Account Details -->
|
||||
<div class="profile-card">
|
||||
<h2><i class="fas fa-id-card"></i> Account Details</h2>
|
||||
<div class="info-grid">
|
||||
<div class="info-item">
|
||||
<div class="info-label"><i class="fas fa-user"></i> Username</div>
|
||||
<div class="info-value" id="p-detail-username">—</div>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<div class="info-label"><i class="fas fa-envelope"></i> Email</div>
|
||||
<div class="info-value" id="p-detail-email">—</div>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<div class="info-label"><i class="fas fa-shield-alt"></i> Role</div>
|
||||
<div class="info-value" id="p-detail-role">—</div>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<div class="info-label"><i class="fas fa-clock"></i> Last Login</div>
|
||||
<div class="info-value" id="p-detail-login">—</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Storage -->
|
||||
<div class="profile-card">
|
||||
<h2><i class="fas fa-hdd"></i> Storage</h2>
|
||||
<div class="storage-stats">
|
||||
<div class="storage-stat">
|
||||
<div class="stat-value" id="p-storage-used">—</div>
|
||||
<div class="stat-label">Used</div>
|
||||
</div>
|
||||
<div class="storage-stat">
|
||||
<div class="stat-value" id="p-storage-quota">—</div>
|
||||
<div class="stat-label">Quota</div>
|
||||
</div>
|
||||
<div class="storage-stat">
|
||||
<div class="stat-value" id="p-storage-pct">—</div>
|
||||
<div class="stat-label">Usage</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="storage-bar-wrap">
|
||||
<div class="storage-bar"><div class="storage-fill green" id="p-storage-bar" style="width:0%"></div></div>
|
||||
<div class="storage-text" id="p-storage-text">—</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Change Password -->
|
||||
<div class="profile-card" id="password-section">
|
||||
<h2><i class="fas fa-key"></i> Change Password</h2>
|
||||
<form id="password-form" onsubmit="return changePassword(event)">
|
||||
<div class="form-group">
|
||||
<label for="current-password">Current Password</label>
|
||||
<input type="password" id="current-password" required autocomplete="current-password">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="new-password">New Password</label>
|
||||
<input type="password" id="new-password" required minlength="8" autocomplete="new-password">
|
||||
<small>At least 8 characters</small>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="confirm-password">Confirm New Password</label>
|
||||
<input type="password" id="confirm-password" required minlength="8" autocomplete="new-password">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary" id="pw-submit"><i class="fas fa-save"></i> Update Password</button>
|
||||
<div id="pw-status"></div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const API = '/api';
|
||||
const token = localStorage.getItem('oxicloud_token') || localStorage.getItem('token') || localStorage.getItem('access_token');
|
||||
|
||||
function headers() {
|
||||
return { 'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json' };
|
||||
}
|
||||
|
||||
function formatBytes(bytes) {
|
||||
if (bytes === 0) return '0 B';
|
||||
const k = 1024, sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
||||
return parseFloat((bytes / Math.pow(k, i)).toFixed(1)) + ' ' + sizes[i];
|
||||
}
|
||||
|
||||
function timeAgo(dateStr) {
|
||||
if (!dateStr) return 'Never';
|
||||
const d = new Date(dateStr);
|
||||
const now = new Date();
|
||||
const secs = Math.floor((now - d) / 1000);
|
||||
if (secs < 60) return 'Just now';
|
||||
if (secs < 3600) return Math.floor(secs/60) + ' min ago';
|
||||
if (secs < 86400) return Math.floor(secs/3600) + 'h ago';
|
||||
if (secs < 2592000) return Math.floor(secs/86400) + ' days ago';
|
||||
return d.toLocaleDateString();
|
||||
}
|
||||
|
||||
async function init() {
|
||||
if (!token) { showError(); return; }
|
||||
try {
|
||||
const resp = await fetch(API + '/auth/me', { headers: headers() });
|
||||
if (!resp.ok) { showError(); return; }
|
||||
const user = await resp.json();
|
||||
|
||||
// Avatar
|
||||
const initials = (user.username || '?').substring(0, 2).toUpperCase();
|
||||
document.getElementById('p-avatar').textContent = initials;
|
||||
document.getElementById('p-username').textContent = user.username;
|
||||
document.getElementById('p-email').textContent = user.email || '';
|
||||
|
||||
// Role badge
|
||||
const badge = document.getElementById('p-role-badge');
|
||||
if (user.role === 'admin') {
|
||||
badge.className = 'role-badge role-badge-admin';
|
||||
badge.innerHTML = '<i class="fas fa-shield-alt"></i> Administrator';
|
||||
} else {
|
||||
badge.className = 'role-badge role-badge-user';
|
||||
badge.innerHTML = '<i class="fas fa-user"></i> User';
|
||||
}
|
||||
|
||||
// Details
|
||||
document.getElementById('p-detail-username').textContent = user.username;
|
||||
document.getElementById('p-detail-email').textContent = user.email || '—';
|
||||
document.getElementById('p-detail-role').textContent = user.role === 'admin' ? 'Administrator' : 'User';
|
||||
document.getElementById('p-detail-login').textContent = timeAgo(user.last_login_at);
|
||||
|
||||
// Storage
|
||||
const used = user.storage_used_bytes || 0;
|
||||
const quota = user.storage_quota_bytes || 0;
|
||||
const pct = quota > 0 ? Math.min(Math.round((used / quota) * 100), 100) : 0;
|
||||
|
||||
document.getElementById('p-storage-used').textContent = formatBytes(used);
|
||||
document.getElementById('p-storage-quota').textContent = quota > 0 ? formatBytes(quota) : '∞';
|
||||
document.getElementById('p-storage-pct').textContent = quota > 0 ? pct + '%' : '—';
|
||||
|
||||
const bar = document.getElementById('p-storage-bar');
|
||||
bar.style.width = pct + '%';
|
||||
bar.className = 'storage-fill ' + (pct > 90 ? 'red' : pct > 70 ? 'orange' : 'green');
|
||||
document.getElementById('p-storage-text').textContent = formatBytes(used) + ' / ' + (quota > 0 ? formatBytes(quota) : 'Unlimited');
|
||||
|
||||
// Hide change password for OIDC-only users
|
||||
if (user.auth_provider && user.auth_provider !== 'local') {
|
||||
document.getElementById('password-section').style.display = 'none';
|
||||
}
|
||||
|
||||
document.getElementById('loading').style.display = 'none';
|
||||
document.getElementById('main-content').style.display = 'block';
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
showError();
|
||||
}
|
||||
}
|
||||
|
||||
function showError() {
|
||||
document.getElementById('loading').style.display = 'none';
|
||||
document.getElementById('auth-error').style.display = 'block';
|
||||
}
|
||||
|
||||
async function changePassword(e) {
|
||||
e.preventDefault();
|
||||
const currentPw = document.getElementById('current-password').value;
|
||||
const newPw = document.getElementById('new-password').value;
|
||||
const confirmPw = document.getElementById('confirm-password').value;
|
||||
const statusEl = document.getElementById('pw-status');
|
||||
|
||||
if (newPw !== confirmPw) {
|
||||
statusEl.innerHTML = '<div class="alert alert-error"><i class="fas fa-exclamation-circle"></i> Passwords do not match</div>';
|
||||
return false;
|
||||
}
|
||||
|
||||
if (newPw.length < 8) {
|
||||
statusEl.innerHTML = '<div class="alert alert-error"><i class="fas fa-exclamation-circle"></i> Password must be at least 8 characters</div>';
|
||||
return false;
|
||||
}
|
||||
|
||||
const btn = document.getElementById('pw-submit');
|
||||
btn.disabled = true;
|
||||
btn.innerHTML = '<i class="fas fa-spinner fa-spin"></i> Updating…';
|
||||
|
||||
try {
|
||||
const resp = await fetch(API + '/auth/change-password', {
|
||||
method: 'PUT',
|
||||
headers: headers(),
|
||||
body: JSON.stringify({ current_password: currentPw, new_password: newPw })
|
||||
});
|
||||
|
||||
if (resp.ok) {
|
||||
statusEl.innerHTML = '<div class="alert alert-success"><i class="fas fa-check-circle"></i> Password updated successfully</div>';
|
||||
document.getElementById('password-form').reset();
|
||||
} else {
|
||||
const err = await resp.json().catch(() => ({}));
|
||||
statusEl.innerHTML = '<div class="alert alert-error"><i class="fas fa-exclamation-circle"></i> ' + (err.message || 'Failed to change password') + '</div>';
|
||||
}
|
||||
} catch (err) {
|
||||
statusEl.innerHTML = '<div class="alert alert-error"><i class="fas fa-exclamation-circle"></i> Network error: ' + err.message + '</div>';
|
||||
}
|
||||
|
||||
btn.disabled = false;
|
||||
btn.innerHTML = '<i class="fas fa-save"></i> Update Password';
|
||||
return false;
|
||||
}
|
||||
|
||||
init();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user