feat(khira): enterprise suite overhaul with analytics dashboard, bulk actions, command palette, SLA monitoring, and zero-FOUT vector icons
This commit is contained in:
@@ -132,10 +132,60 @@ CREATE TABLE IF NOT EXISTS khira_sequences (
|
||||
val INT NOT NULL DEFAULT 100
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS ticket_tags (
|
||||
ticket_id VARCHAR(32) NOT NULL REFERENCES tickets(id) ON DELETE CASCADE,
|
||||
tag VARCHAR(64) NOT NULL,
|
||||
PRIMARY KEY (ticket_id, tag)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS error_tags (
|
||||
error_id VARCHAR(32) NOT NULL REFERENCES errors(id) ON DELETE CASCADE,
|
||||
tag VARCHAR(64) NOT NULL,
|
||||
PRIMARY KEY (error_id, tag)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS ticket_relations (
|
||||
id SERIAL PRIMARY KEY,
|
||||
ticket_a VARCHAR(32) NOT NULL REFERENCES tickets(id) ON DELETE CASCADE,
|
||||
ticket_b VARCHAR(32) NOT NULL REFERENCES tickets(id) ON DELETE CASCADE,
|
||||
relation_type VARCHAR(32) NOT NULL DEFAULT 'related',
|
||||
created_by VARCHAR(64) NOT NULL DEFAULT '',
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
UNIQUE(ticket_a, ticket_b)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS saved_filters (
|
||||
id VARCHAR(64) PRIMARY KEY,
|
||||
user_id VARCHAR(64) NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||
name VARCHAR(128) NOT NULL,
|
||||
filter_json TEXT NOT NULL,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS api_tokens (
|
||||
id VARCHAR(64) PRIMARY KEY,
|
||||
user_id VARCHAR(64) NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||
name VARCHAR(128) NOT NULL,
|
||||
token_hash VARCHAR(128) NOT NULL UNIQUE,
|
||||
scopes TEXT NOT NULL DEFAULT 'errors:write',
|
||||
last_used_at TIMESTAMPTZ,
|
||||
revoked BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
||||
ALTER TABLE tickets ADD COLUMN IF NOT EXISTS due_date TIMESTAMPTZ;
|
||||
ALTER TABLE tickets ADD COLUMN IF NOT EXISTS sla_hours INT NOT NULL DEFAULT 0;
|
||||
ALTER TABLE tickets ADD COLUMN IF NOT EXISTS sla_breached BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
|
||||
ALTER TABLE users ADD COLUMN IF NOT EXISTS active BOOLEAN NOT NULL DEFAULT TRUE;
|
||||
ALTER TABLE users ADD COLUMN IF NOT EXISTS last_active_at TIMESTAMPTZ;
|
||||
ALTER TABLE users ADD COLUMN IF NOT EXISTS deactivated_at TIMESTAMPTZ;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_tickets_assigned_to ON tickets(assigned_to);
|
||||
CREATE INDEX IF NOT EXISTS idx_tickets_status ON tickets(status);
|
||||
CREATE INDEX IF NOT EXISTS idx_tickets_created_at ON tickets(created_at DESC);
|
||||
CREATE INDEX IF NOT EXISTS idx_ticket_remarks_ticket_id ON ticket_remarks(ticket_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_ticket_tags_tag ON ticket_tags(tag);
|
||||
CREATE INDEX IF NOT EXISTS idx_errors_status ON errors(status);
|
||||
CREATE INDEX IF NOT EXISTS idx_errors_last_seen ON errors(last_seen DESC);
|
||||
CREATE INDEX IF NOT EXISTS idx_notifications_user_read ON notifications(user_id, read);
|
||||
|
||||
@@ -0,0 +1,685 @@
|
||||
package khira
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"crypto/sha256"
|
||||
"database/sql"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// Default SLA hours per priority
|
||||
var DefaultSLAHours = map[string]int{
|
||||
"critical": 4,
|
||||
"high": 24,
|
||||
"medium": 72,
|
||||
"low": 168,
|
||||
"p0": 4,
|
||||
"p1": 24,
|
||||
"p2": 72,
|
||||
"p3": 168,
|
||||
}
|
||||
|
||||
func calculateDefaultSLA(priority string) int {
|
||||
p := strings.ToLower(strings.TrimSpace(priority))
|
||||
if h, ok := DefaultSLAHours[p]; ok {
|
||||
return h
|
||||
}
|
||||
return 72
|
||||
}
|
||||
|
||||
// CheckSLABreaches inspects active tickets and flags overdue ones
|
||||
func (s *Store) CheckSLABreaches() (int, error) {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
rows, err := s.primaryDB.Query(`
|
||||
SELECT id, priority, assigned_to, created_by, due_date
|
||||
FROM tickets
|
||||
WHERE status IN ('open', 'in_progress', 'on_hold')
|
||||
AND due_date IS NOT NULL
|
||||
AND due_date < NOW()
|
||||
AND sla_breached = FALSE
|
||||
AND archived = FALSE
|
||||
`)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
type breachItem struct {
|
||||
id string
|
||||
priority string
|
||||
assignedTo string
|
||||
createdBy string
|
||||
dueDate time.Time
|
||||
}
|
||||
|
||||
var breaches []breachItem
|
||||
for rows.Next() {
|
||||
var b breachItem
|
||||
if err := rows.Scan(&b.id, &b.priority, &b.assignedTo, &b.createdBy, &b.dueDate); err == nil {
|
||||
breaches = append(breaches, b)
|
||||
}
|
||||
}
|
||||
|
||||
now := time.Now()
|
||||
for _, b := range breaches {
|
||||
_, _ = s.primaryDB.Exec(`UPDATE tickets SET sla_breached = TRUE, updated_at = $1 WHERE id = $2`, now, b.id)
|
||||
|
||||
// Record remark
|
||||
remID := uuid.New().String()
|
||||
_, _ = s.primaryDB.Exec(`
|
||||
INSERT INTO ticket_remarks (id, ticket_id, author_username, author_name, author_role, type, text, created_at)
|
||||
VALUES ($1, $2, 'system', 'SLA Monitor', 'System', 'sla_breach', $3, $4)
|
||||
`, remID, b.id, fmt.Sprintf("SLA breached! Due date (%s) has passed.", b.dueDate.Format("2006-01-02 15:04")), now)
|
||||
|
||||
// Notify assignee & creator
|
||||
if b.assignedTo != "" {
|
||||
s.addNotification(b.assignedTo, b.id, "SLA Breached", fmt.Sprintf("Ticket %s is overdue!", b.id), "sla_breach")
|
||||
}
|
||||
if b.createdBy != "" && !strings.EqualFold(b.createdBy, b.assignedTo) {
|
||||
s.addNotification(b.createdBy, b.id, "SLA Breached", fmt.Sprintf("Ticket %s is overdue!", b.id), "sla_breach")
|
||||
}
|
||||
}
|
||||
|
||||
return len(breaches), nil
|
||||
}
|
||||
|
||||
// StartSLAMonitor periodically evaluates SLA breaches in the background
|
||||
func (s *Store) StartSLAMonitor() {
|
||||
go func() {
|
||||
ticker := time.NewTicker(3 * time.Minute)
|
||||
defer ticker.Stop()
|
||||
for range ticker.C {
|
||||
_, _ = s.CheckSLABreaches()
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
// GetAnalyticsData calculates comprehensive productivity, SLA, and error metrics
|
||||
func (s *Store) GetAnalyticsData() (*AnalyticsData, error) {
|
||||
data := &AnalyticsData{
|
||||
ByPriority: make(map[string]int),
|
||||
}
|
||||
|
||||
// 1. Summary Counts
|
||||
_ = s.primaryDB.QueryRow(`SELECT count(*) FROM tickets WHERE archived = FALSE`).Scan(&data.Summary.TotalTickets)
|
||||
_ = s.primaryDB.QueryRow(`SELECT count(*) FROM tickets WHERE status = 'open' AND archived = FALSE`).Scan(&data.Summary.OpenTickets)
|
||||
_ = s.primaryDB.QueryRow(`SELECT count(*) FROM tickets WHERE status = 'in_progress' AND archived = FALSE`).Scan(&data.Summary.InProgressTickets)
|
||||
_ = s.primaryDB.QueryRow(`SELECT count(*) FROM tickets WHERE status = 'on_hold' AND archived = FALSE`).Scan(&data.Summary.OnHoldTickets)
|
||||
_ = s.primaryDB.QueryRow(`SELECT count(*) FROM tickets WHERE status = 'completed' AND archived = FALSE`).Scan(&data.Summary.CompletedTickets)
|
||||
_ = s.primaryDB.QueryRow(`SELECT count(*) FROM tickets WHERE archived = TRUE`).Scan(&data.Summary.ArchivedTickets)
|
||||
_ = s.primaryDB.QueryRow(`SELECT count(*) FROM tickets WHERE sla_breached = TRUE AND archived = FALSE`).Scan(&data.Summary.SLABreachedTickets)
|
||||
|
||||
// Avg resolution time in hours
|
||||
var avgSeconds sql.NullFloat64
|
||||
_ = s.primaryDB.QueryRow(`
|
||||
SELECT AVG(EXTRACT(EPOCH FROM (completed_at - created_at)))
|
||||
FROM tickets
|
||||
WHERE status = 'completed' AND completed_at IS NOT NULL
|
||||
`).Scan(&avgSeconds)
|
||||
if avgSeconds.Valid && avgSeconds.Float64 > 0 {
|
||||
data.Summary.AvgResolutionHours = float64(int(avgSeconds.Float64/360.0)) / 10.0 // 1 decimal place
|
||||
}
|
||||
|
||||
// 2. Priority Breakdown
|
||||
pRows, err := s.primaryDB.Query(`
|
||||
SELECT LOWER(priority), count(*)
|
||||
FROM tickets
|
||||
WHERE archived = FALSE
|
||||
GROUP BY LOWER(priority)
|
||||
`)
|
||||
if err == nil {
|
||||
defer pRows.Close()
|
||||
for pRows.Next() {
|
||||
var p string
|
||||
var c int
|
||||
if err := pRows.Scan(&p, &c); err == nil {
|
||||
data.ByPriority[p] = c
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Weekly Velocity (past 8 weeks)
|
||||
for i := 7; i >= 0; i-- {
|
||||
start := time.Now().AddDate(0, 0, -7*(i+1))
|
||||
end := time.Now().AddDate(0, 0, -7*i)
|
||||
weekLabel := end.Format("01/02")
|
||||
|
||||
var createdCount, resolvedCount int
|
||||
_ = s.primaryDB.QueryRow(`
|
||||
SELECT count(*) FROM tickets WHERE created_at >= $1 AND created_at < $2
|
||||
`, start, end).Scan(&createdCount)
|
||||
|
||||
_ = s.primaryDB.QueryRow(`
|
||||
SELECT count(*) FROM tickets WHERE completed_at >= $1 AND completed_at < $2
|
||||
`, start, end).Scan(&resolvedCount)
|
||||
|
||||
data.Velocity = append(data.Velocity, VelocityPoint{
|
||||
Week: weekLabel,
|
||||
Created: createdCount,
|
||||
Resolved: resolvedCount,
|
||||
})
|
||||
}
|
||||
|
||||
// 4. Assignee Workload
|
||||
uRows, err := s.primaryDB.Query(`
|
||||
SELECT u.username, u.name, u.role, u.role_display, u.avatar,
|
||||
COUNT(CASE WHEN t.status = 'open' AND t.archived = FALSE THEN 1 END) AS open_cnt,
|
||||
COUNT(CASE WHEN t.status = 'in_progress' AND t.archived = FALSE THEN 1 END) AS in_prog_cnt,
|
||||
COUNT(CASE WHEN t.status = 'completed' AND t.archived = FALSE THEN 1 END) AS comp_cnt,
|
||||
COALESCE(AVG(CASE WHEN t.status = 'completed' AND t.completed_at IS NOT NULL THEN EXTRACT(EPOCH FROM (t.completed_at - t.created_at)) / 3600 END), 0) AS avg_h
|
||||
FROM users u
|
||||
LEFT JOIN tickets t ON LOWER(t.assigned_to) = LOWER(u.username)
|
||||
WHERE u.active = TRUE
|
||||
GROUP BY u.username, u.name, u.role, u.role_display, u.avatar
|
||||
ORDER BY COUNT(CASE WHEN t.status IN ('open', 'in_progress') AND t.archived = FALSE THEN 1 END) DESC, u.name ASC
|
||||
`)
|
||||
if err == nil {
|
||||
defer uRows.Close()
|
||||
for uRows.Next() {
|
||||
var w AssigneeWorkload
|
||||
if err := uRows.Scan(&w.Username, &w.Name, &w.Role, &w.RoleDisplay, &w.Avatar, &w.Open, &w.InProgress, &w.Completed, &w.AvgHours); err == nil {
|
||||
w.AvgHours = float64(int(w.AvgHours*10)) / 10.0
|
||||
data.ByAssignee = append(data.ByAssignee, w)
|
||||
}
|
||||
}
|
||||
}
|
||||
if data.ByAssignee == nil {
|
||||
data.ByAssignee = []AssigneeWorkload{}
|
||||
}
|
||||
|
||||
// 5. Error Summary
|
||||
_ = s.primaryDB.QueryRow(`SELECT count(*) FROM errors WHERE archived = FALSE`).Scan(&data.ErrorSummary.TotalErrors)
|
||||
_ = s.primaryDB.QueryRow(`SELECT count(*) FROM errors WHERE status = 'unresolved' AND archived = FALSE`).Scan(&data.ErrorSummary.UnresolvedErrors)
|
||||
_ = s.primaryDB.QueryRow(`SELECT count(*) FROM errors WHERE status = 'resolved' AND archived = FALSE`).Scan(&data.ErrorSummary.ResolvedErrors)
|
||||
_ = s.primaryDB.QueryRow(`SELECT count(*) FROM errors WHERE LOWER(severity) = 'critical' AND archived = FALSE`).Scan(&data.ErrorSummary.CriticalErrors)
|
||||
|
||||
// Top Apps by Errors
|
||||
appRows, err := s.primaryDB.Query(`
|
||||
SELECT app_name, count(*) as c
|
||||
FROM errors
|
||||
WHERE archived = FALSE AND app_name != ''
|
||||
GROUP BY app_name
|
||||
ORDER BY c DESC
|
||||
LIMIT 5
|
||||
`)
|
||||
if err == nil {
|
||||
defer appRows.Close()
|
||||
for appRows.Next() {
|
||||
var st AppErrorStat
|
||||
if err := appRows.Scan(&st.App, &st.Count); err == nil {
|
||||
data.TopAppsByErrors = append(data.TopAppsByErrors, st)
|
||||
}
|
||||
}
|
||||
}
|
||||
if data.TopAppsByErrors == nil {
|
||||
data.TopAppsByErrors = []AppErrorStat{}
|
||||
}
|
||||
|
||||
// 6. Recent Activity
|
||||
actRows, err := s.primaryDB.Query(`
|
||||
SELECT r.id, r.ticket_id, COALESCE(t.title, ''), r.type, r.author_username, r.author_name, r.author_role, r.text, r.created_at
|
||||
FROM ticket_remarks r
|
||||
LEFT JOIN tickets t ON r.ticket_id = t.id
|
||||
ORDER BY r.created_at DESC
|
||||
LIMIT 15
|
||||
`)
|
||||
if err == nil {
|
||||
defer actRows.Close()
|
||||
for actRows.Next() {
|
||||
var act ActivityItem
|
||||
if err := actRows.Scan(&act.ID, &act.TicketID, &act.Title, &act.Type, &act.Author, &act.Name, &act.Role, &act.Text, &act.CreatedAt); err == nil {
|
||||
data.RecentActivity = append(data.RecentActivity, act)
|
||||
}
|
||||
}
|
||||
}
|
||||
if data.RecentActivity == nil {
|
||||
data.RecentActivity = []ActivityItem{}
|
||||
}
|
||||
|
||||
return data, nil
|
||||
}
|
||||
|
||||
// BulkAction applies updates to a slice of ticket IDs
|
||||
func (s *Store) BulkAction(ids []string, action, value string, actor *User) (map[string]any, error) {
|
||||
if len(ids) == 0 {
|
||||
return map[string]any{"updated": 0, "skipped": 0}, nil
|
||||
}
|
||||
|
||||
updated := 0
|
||||
skipped := 0
|
||||
now := time.Now()
|
||||
|
||||
for _, id := range ids {
|
||||
id = strings.TrimSpace(id)
|
||||
if id == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
switch strings.ToLower(action) {
|
||||
case "archive":
|
||||
_, err := s.ArchiveTicket(id, actor)
|
||||
if err == nil {
|
||||
updated++
|
||||
} else {
|
||||
skipped++
|
||||
}
|
||||
case "unarchive":
|
||||
_, err := s.UnarchiveTicket(id, actor)
|
||||
if err == nil {
|
||||
updated++
|
||||
} else {
|
||||
skipped++
|
||||
}
|
||||
case "delete":
|
||||
err := s.DeleteTicket(id, actor)
|
||||
if err == nil {
|
||||
updated++
|
||||
} else {
|
||||
skipped++
|
||||
}
|
||||
case "assign":
|
||||
if strings.TrimSpace(value) == "" {
|
||||
skipped++
|
||||
continue
|
||||
}
|
||||
targetUser, _ := s.GetUser(value)
|
||||
targetName := value
|
||||
targetRole := ""
|
||||
if targetUser != nil {
|
||||
targetName = targetUser.Name
|
||||
targetRole = targetUser.RoleDisplay
|
||||
}
|
||||
res, err := s.primaryDB.Exec(`
|
||||
UPDATE tickets SET assigned_to = $1, assigned_to_name = $2, assigned_to_role = $3, updated_at = $4
|
||||
WHERE id = $5
|
||||
`, value, targetName, targetRole, now, id)
|
||||
if err == nil {
|
||||
if n, _ := res.RowsAffected(); n > 0 {
|
||||
remID := uuid.New().String()
|
||||
_, _ = s.primaryDB.Exec(`
|
||||
INSERT INTO ticket_remarks (id, ticket_id, author_username, author_name, author_role, type, text, created_at)
|
||||
VALUES ($1, $2, $3, $4, $5, 'reassign', $6, $7)
|
||||
`, remID, id, actor.Username, actor.Name, actor.RoleDisplay, fmt.Sprintf("Bulk reassigned ticket to %s.", targetName), now)
|
||||
s.addNotification(value, id, "Ticket Reassigned", fmt.Sprintf("Ticket %s assigned to you", id), "assignment")
|
||||
updated++
|
||||
} else {
|
||||
skipped++
|
||||
}
|
||||
} else {
|
||||
skipped++
|
||||
}
|
||||
case "priority":
|
||||
p := strings.ToLower(strings.TrimSpace(value))
|
||||
if p != "critical" && p != "high" && p != "medium" && p != "low" {
|
||||
skipped++
|
||||
continue
|
||||
}
|
||||
res, err := s.primaryDB.Exec(`UPDATE tickets SET priority = $1, updated_at = $2 WHERE id = $3`, p, now, id)
|
||||
if err == nil {
|
||||
if n, _ := res.RowsAffected(); n > 0 {
|
||||
remID := uuid.New().String()
|
||||
_, _ = s.primaryDB.Exec(`
|
||||
INSERT INTO ticket_remarks (id, ticket_id, author_username, author_name, author_role, type, text, created_at)
|
||||
VALUES ($1, $2, $3, $4, $5, 'priority_change', $6, $7)
|
||||
`, remID, id, actor.Username, actor.Name, actor.RoleDisplay, fmt.Sprintf("Priority changed to %s.", strings.ToUpper(p)), now)
|
||||
updated++
|
||||
} else {
|
||||
skipped++
|
||||
}
|
||||
} else {
|
||||
skipped++
|
||||
}
|
||||
case "status":
|
||||
st := strings.ToLower(strings.TrimSpace(value))
|
||||
if st == "completed" {
|
||||
_, err := s.CompleteTicket(id, actor, "Marked as completed via bulk action")
|
||||
if err == nil {
|
||||
updated++
|
||||
} else {
|
||||
skipped++
|
||||
}
|
||||
} else if st == "open" || st == "in_progress" {
|
||||
res, err := s.primaryDB.Exec(`UPDATE tickets SET status = $1, updated_at = $2 WHERE id = $3`, st, now, id)
|
||||
if err == nil {
|
||||
if n, _ := res.RowsAffected(); n > 0 {
|
||||
updated++
|
||||
} else {
|
||||
skipped++
|
||||
}
|
||||
} else {
|
||||
skipped++
|
||||
}
|
||||
} else {
|
||||
skipped++
|
||||
}
|
||||
default:
|
||||
skipped++
|
||||
}
|
||||
}
|
||||
|
||||
return map[string]any{
|
||||
"updated": updated,
|
||||
"skipped": skipped,
|
||||
"action": action,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Tag Management
|
||||
func (s *Store) AddTicketTag(ticketID, tag string) error {
|
||||
tag = strings.ToLower(strings.TrimSpace(tag))
|
||||
if tag == "" {
|
||||
return errors.New("tag cannot be empty")
|
||||
}
|
||||
_, err := s.primaryDB.Exec(`
|
||||
INSERT INTO ticket_tags (ticket_id, tag) VALUES ($1, $2)
|
||||
ON CONFLICT (ticket_id, tag) DO NOTHING
|
||||
`, ticketID, tag)
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *Store) RemoveTicketTag(ticketID, tag string) error {
|
||||
tag = strings.ToLower(strings.TrimSpace(tag))
|
||||
_, err := s.primaryDB.Exec(`DELETE FROM ticket_tags WHERE ticket_id = $1 AND tag = $2`, ticketID, tag)
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *Store) ListAllTags() ([]map[string]any, error) {
|
||||
rows, err := s.primaryDB.Query(`
|
||||
SELECT tag, count(*) as count
|
||||
FROM ticket_tags
|
||||
GROUP BY tag
|
||||
ORDER BY count DESC, tag ASC
|
||||
`)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
var tags []map[string]any
|
||||
for rows.Next() {
|
||||
var tag string
|
||||
var count int
|
||||
if err := rows.Scan(&tag, &count); err == nil {
|
||||
tags = append(tags, map[string]any{"tag": tag, "count": count})
|
||||
}
|
||||
}
|
||||
if tags == nil {
|
||||
tags = []map[string]any{}
|
||||
}
|
||||
return tags, nil
|
||||
}
|
||||
|
||||
// Ticket Relations
|
||||
func (s *Store) LinkTickets(ticketA, ticketB, relType string, actor *User) error {
|
||||
if ticketA == ticketB {
|
||||
return errors.New("cannot link a ticket to itself")
|
||||
}
|
||||
if relType == "" {
|
||||
relType = "related"
|
||||
}
|
||||
|
||||
actorUser := ""
|
||||
if actor != nil {
|
||||
actorUser = actor.Username
|
||||
}
|
||||
|
||||
_, err := s.primaryDB.Exec(`
|
||||
INSERT INTO ticket_relations (ticket_a, ticket_b, relation_type, created_by, created_at)
|
||||
VALUES ($1, $2, $3, $4, NOW())
|
||||
ON CONFLICT (ticket_a, ticket_b) DO UPDATE SET relation_type = $3
|
||||
`, ticketA, ticketB, relType, actorUser)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Add remark to ticket A
|
||||
remID := uuid.New().String()
|
||||
_, _ = s.primaryDB.Exec(`
|
||||
INSERT INTO ticket_remarks (id, ticket_id, author_username, author_name, author_role, type, text, created_at)
|
||||
VALUES ($1, $2, $3, $4, $5, 'link', $6, NOW())
|
||||
`, remID, ticketA, actor.Username, actor.Name, actor.RoleDisplay, fmt.Sprintf("Linked related ticket %s.", ticketB))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Store) UnlinkTickets(ticketA, ticketB string) error {
|
||||
_, err := s.primaryDB.Exec(`
|
||||
DELETE FROM ticket_relations
|
||||
WHERE (ticket_a = $1 AND ticket_b = $2) OR (ticket_a = $2 AND ticket_b = $1)
|
||||
`, ticketA, ticketB)
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *Store) GetRelatedTickets(ticketID string) ([]string, error) {
|
||||
rows, err := s.primaryDB.Query(`
|
||||
SELECT ticket_b FROM ticket_relations WHERE ticket_a = $1
|
||||
UNION
|
||||
SELECT ticket_a FROM ticket_relations WHERE ticket_b = $1
|
||||
`, ticketID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
var related []string
|
||||
for rows.Next() {
|
||||
var id string
|
||||
if err := rows.Scan(&id); err == nil {
|
||||
related = append(related, id)
|
||||
}
|
||||
}
|
||||
if related == nil {
|
||||
related = []string{}
|
||||
}
|
||||
return related, nil
|
||||
}
|
||||
|
||||
// Saved Filters
|
||||
func (s *Store) GetSavedFilters(userID string) ([]SavedFilter, error) {
|
||||
rows, err := s.primaryDB.Query(`
|
||||
SELECT id, user_id, name, filter_json, created_at
|
||||
FROM saved_filters
|
||||
WHERE user_id = $1
|
||||
ORDER BY created_at DESC
|
||||
`, userID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
var filters []SavedFilter
|
||||
for rows.Next() {
|
||||
var f SavedFilter
|
||||
if err := rows.Scan(&f.ID, &f.UserID, &f.Name, &f.FilterJSON, &f.CreatedAt); err == nil {
|
||||
filters = append(filters, f)
|
||||
}
|
||||
}
|
||||
if filters == nil {
|
||||
filters = []SavedFilter{}
|
||||
}
|
||||
return filters, nil
|
||||
}
|
||||
|
||||
func (s *Store) SaveFilter(userID, name, filterJSON string) (*SavedFilter, error) {
|
||||
id := uuid.New().String()
|
||||
now := time.Now()
|
||||
_, err := s.primaryDB.Exec(`
|
||||
INSERT INTO saved_filters (id, user_id, name, filter_json, created_at)
|
||||
VALUES ($1, $2, $3, $4, $5)
|
||||
`, id, userID, name, filterJSON, now)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &SavedFilter{
|
||||
ID: id,
|
||||
UserID: userID,
|
||||
Name: name,
|
||||
FilterJSON: filterJSON,
|
||||
CreatedAt: now,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *Store) DeleteSavedFilter(filterID, userID string) error {
|
||||
_, err := s.primaryDB.Exec(`DELETE FROM saved_filters WHERE id = $1 AND user_id = $2`, filterID, userID)
|
||||
return err
|
||||
}
|
||||
|
||||
// API Tokens
|
||||
func generateSecureToken() (string, string, error) {
|
||||
bytes := make([]byte, 24)
|
||||
if _, err := rand.Read(bytes); err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
raw := "khr_" + hex.EncodeToString(bytes)
|
||||
sum := sha256.Sum256([]byte(raw))
|
||||
hash := hex.EncodeToString(sum[:])
|
||||
return raw, hash, nil
|
||||
}
|
||||
|
||||
func (s *Store) CreateAPIToken(userID, name, scopes string) (string, *APIToken, error) {
|
||||
raw, hash, err := generateSecureToken()
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
|
||||
id := uuid.New().String()
|
||||
now := time.Now()
|
||||
if scopes == "" {
|
||||
scopes = "errors:write"
|
||||
}
|
||||
|
||||
_, err = s.primaryDB.Exec(`
|
||||
INSERT INTO api_tokens (id, user_id, name, token_hash, scopes, created_at)
|
||||
VALUES ($1, $2, $3, $4, $5, $6)
|
||||
`, id, userID, name, hash, scopes, now)
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
|
||||
tok := &APIToken{
|
||||
ID: id,
|
||||
UserID: userID,
|
||||
Name: name,
|
||||
Scopes: scopes,
|
||||
CreatedAt: now,
|
||||
}
|
||||
return raw, tok, nil
|
||||
}
|
||||
|
||||
func (s *Store) ListAPITokens(userID string) ([]APIToken, error) {
|
||||
rows, err := s.primaryDB.Query(`
|
||||
SELECT id, user_id, name, scopes, last_used_at, revoked, created_at
|
||||
FROM api_tokens
|
||||
WHERE user_id = $1 AND revoked = FALSE
|
||||
ORDER BY created_at DESC
|
||||
`, userID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
var tokens []APIToken
|
||||
for rows.Next() {
|
||||
var tok APIToken
|
||||
if err := rows.Scan(&tok.ID, &tok.UserID, &tok.Name, &tok.Scopes, &tok.LastUsedAt, &tok.Revoked, &tok.CreatedAt); err == nil {
|
||||
tokens = append(tokens, tok)
|
||||
}
|
||||
}
|
||||
if tokens == nil {
|
||||
tokens = []APIToken{}
|
||||
}
|
||||
return tokens, nil
|
||||
}
|
||||
|
||||
func (s *Store) RevokeAPIToken(tokenID, userID string) error {
|
||||
_, err := s.primaryDB.Exec(`UPDATE api_tokens SET revoked = TRUE WHERE id = $1 AND user_id = $2`, tokenID, userID)
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *Store) ValidateAPIToken(rawToken string) (*User, error) {
|
||||
sum := sha256.Sum256([]byte(strings.TrimSpace(rawToken)))
|
||||
hash := hex.EncodeToString(sum[:])
|
||||
|
||||
var userID string
|
||||
err := s.primaryDB.QueryRow(`
|
||||
SELECT user_id FROM api_tokens
|
||||
WHERE token_hash = $1 AND revoked = FALSE
|
||||
`, hash).Scan(&userID)
|
||||
if err != nil {
|
||||
return nil, errors.New("invalid or revoked token")
|
||||
}
|
||||
|
||||
// Update last used timestamp
|
||||
_, _ = s.primaryDB.Exec(`UPDATE api_tokens SET last_used_at = NOW() WHERE token_hash = $1`, hash)
|
||||
|
||||
u, _ := s.GetUser(userID)
|
||||
return u, nil
|
||||
}
|
||||
|
||||
// Admin User Management
|
||||
func (s *Store) ListAllUsersAdmin() ([]*User, error) {
|
||||
rows, err := s.primaryDB.Query(`
|
||||
SELECT id, username, name, role, role_display, avatar, avatar_type, profile_image, active, last_active_at, created_at, updated_at
|
||||
FROM users
|
||||
ORDER BY role = 'team_lead' DESC, name ASC
|
||||
`)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
var users []*User
|
||||
for rows.Next() {
|
||||
var u User
|
||||
if err := rows.Scan(&u.ID, &u.Username, &u.Name, &u.Role, &u.RoleDisplay, &u.Avatar, &u.AvatarType, &u.ProfileImage, &u.Active, &u.LastActiveAt, &u.CreatedAt, &u.UpdatedAt); err == nil {
|
||||
users = append(users, &u)
|
||||
}
|
||||
}
|
||||
return users, nil
|
||||
}
|
||||
|
||||
func (s *Store) UpdateUserRoleAdmin(targetUsername, newRole string) error {
|
||||
r := Role(newRole)
|
||||
if !r.IsValid() {
|
||||
return errors.New("invalid role")
|
||||
}
|
||||
|
||||
_, err := s.primaryDB.Exec(`
|
||||
UPDATE users SET role = $1, role_display = $2, updated_at = NOW()
|
||||
WHERE LOWER(username) = LOWER($3)
|
||||
`, string(r), r.DisplayName(), targetUsername)
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *Store) SetUserActiveStatus(targetUsername string, active bool) error {
|
||||
now := time.Now()
|
||||
var deactAt *time.Time
|
||||
if !active {
|
||||
deactAt = &now
|
||||
}
|
||||
_, err := s.primaryDB.Exec(`
|
||||
UPDATE users SET active = $1, deactivated_at = $2, updated_at = $3
|
||||
WHERE LOWER(username) = LOWER($4)
|
||||
`, active, deactAt, now, targetUsername)
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *Store) ResetUserPasswordAdmin(targetUsername, newPassword string) error {
|
||||
if len(newPassword) < 4 {
|
||||
return errors.New("password must be at least 4 characters")
|
||||
}
|
||||
hash := hashPassword(newPassword)
|
||||
_, err := s.primaryDB.Exec(`
|
||||
UPDATE users SET password_hash = $1, updated_at = NOW()
|
||||
WHERE LOWER(username) = LOWER($2)
|
||||
`, hash, targetUsername)
|
||||
return err
|
||||
}
|
||||
@@ -29,10 +29,19 @@ func (s *Server) writeJSON(w http.ResponseWriter, status int, data any) {
|
||||
}
|
||||
|
||||
func (s *Server) getActor(r *http.Request) *User {
|
||||
// 1. Check custom header (useful for client SPA / API calls)
|
||||
// 1. Check Bearer API Token
|
||||
authHdr := r.Header.Get("Authorization")
|
||||
if strings.HasPrefix(strings.ToLower(authHdr), "bearer ") {
|
||||
tok := strings.TrimSpace(authHdr[7:])
|
||||
if u, err := s.Store.ValidateAPIToken(tok); err == nil && u != nil {
|
||||
return u
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Check custom header (useful for client SPA / API calls)
|
||||
username := r.Header.Get("X-Khira-User")
|
||||
if username == "" {
|
||||
// 2. Check cookie
|
||||
// 3. Check cookie
|
||||
if cookie, err := r.Cookie("khira_session_user"); err == nil && cookie.Value != "" {
|
||||
username = cookie.Value
|
||||
}
|
||||
@@ -145,6 +154,47 @@ func (s *Server) RegisterRoutes(r chi.Router) {
|
||||
api.Post("/admin/db/sync", s.handleDBSync)
|
||||
api.Post("/admin/db/rollback", s.handleDBRollback)
|
||||
api.Get("/admin/db/status", s.handleDBStatus)
|
||||
|
||||
// Enterprise Features
|
||||
// Analytics
|
||||
api.Get("/analytics", s.handleAnalytics)
|
||||
|
||||
// Bulk Actions
|
||||
api.Post("/tickets/bulk", s.handleBulkActions)
|
||||
|
||||
// Tags
|
||||
api.Get("/tags", s.handleListTags)
|
||||
api.Post("/tickets/{id}/tags", s.handleAddTag)
|
||||
api.Delete("/tickets/{id}/tags/{tag}", s.handleRemoveTag)
|
||||
|
||||
// Relations / Ticket Linking
|
||||
api.Post("/tickets/{id}/relations", s.handleLinkTickets)
|
||||
api.Delete("/tickets/{id}/relations/{target}", s.handleUnlinkTickets)
|
||||
|
||||
// Saved Filters
|
||||
api.Get("/filters", s.handleListSavedFilters)
|
||||
api.Post("/filters", s.handleCreateSavedFilter)
|
||||
api.Delete("/filters/{id}", s.handleDeleteSavedFilter)
|
||||
|
||||
// API Tokens
|
||||
api.Get("/tokens", s.handleListAPITokens)
|
||||
api.Post("/tokens", s.handleCreateAPIToken)
|
||||
api.Delete("/tokens/{id}", s.handleRevokeAPIToken)
|
||||
|
||||
// Admin User Management
|
||||
api.Get("/admin/users", s.handleAdminListUsers)
|
||||
api.Patch("/admin/users/{username}/role", s.handleAdminUpdateRole)
|
||||
api.Patch("/admin/users/{username}/status", s.handleAdminUpdateStatus)
|
||||
api.Post("/admin/users/{username}/reset-password", s.handleAdminResetPassword)
|
||||
|
||||
// Export CSV
|
||||
api.Get("/tickets/export", s.handleExportTickets)
|
||||
api.Get("/errors/export", s.handleExportErrors)
|
||||
|
||||
// Notifications Single Item Ops
|
||||
api.Delete("/notifications/{id}", s.handleDeleteNotification)
|
||||
api.Delete("/notifications", s.handleClearNotifications)
|
||||
api.Post("/notifications/{id}/read", s.handleMarkNotificationReadSingle)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -387,6 +437,9 @@ func (s *Server) handleCreateTicket(w http.ResponseWriter, r *http.Request) {
|
||||
AssigneeUsername string `json:"assignee_username"`
|
||||
DeveloperAccount string `json:"developer_account"`
|
||||
ImageURL string `json:"image_url"`
|
||||
DueDate string `json:"due_date"`
|
||||
SLAHours int `json:"sla_hours"`
|
||||
Tags []string `json:"tags"`
|
||||
Attachments []Attachment `json:"attachments"`
|
||||
Links []string `json:"links"`
|
||||
}
|
||||
@@ -502,10 +555,20 @@ func (s *Server) handleCreateTicket(w http.ResponseWriter, r *http.Request) {
|
||||
AssistanceRequired: assistance,
|
||||
AdditionalInfo: additionalInfo,
|
||||
AssignedTo: assignedTo,
|
||||
SLAHours: req.SLAHours,
|
||||
Tags: req.Tags,
|
||||
Links: req.Links,
|
||||
Attachments: atts,
|
||||
}
|
||||
|
||||
if req.DueDate != "" {
|
||||
if parsed, err := time.Parse(time.RFC3339, req.DueDate); err == nil {
|
||||
ticket.DueDate = &parsed
|
||||
} else if parsed, err := time.Parse("2006-01-02", req.DueDate); err == nil {
|
||||
ticket.DueDate = &parsed
|
||||
}
|
||||
}
|
||||
|
||||
created, err := s.Store.CreateTicket(ticket, actor)
|
||||
if err != nil {
|
||||
s.writeJSON(w, http.StatusInternalServerError, map[string]string{"error": err.Error()})
|
||||
|
||||
@@ -0,0 +1,475 @@
|
||||
package khira
|
||||
|
||||
import (
|
||||
"encoding/csv"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/go-chi/chi/v5"
|
||||
)
|
||||
|
||||
// Analytics
|
||||
func (s *Server) handleAnalytics(w http.ResponseWriter, r *http.Request) {
|
||||
data, err := s.Store.GetAnalyticsData()
|
||||
if err != nil {
|
||||
s.writeJSON(w, http.StatusInternalServerError, map[string]string{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
s.writeJSON(w, http.StatusOK, data)
|
||||
}
|
||||
|
||||
// Bulk Actions
|
||||
func (s *Server) handleBulkActions(w http.ResponseWriter, r *http.Request) {
|
||||
actor := s.getActor(r)
|
||||
if actor == nil {
|
||||
s.writeJSON(w, http.StatusUnauthorized, map[string]string{"error": "Authentication required"})
|
||||
return
|
||||
}
|
||||
|
||||
var req struct {
|
||||
IDs []string `json:"ids"`
|
||||
Action string `json:"action"`
|
||||
Value string `json:"value"`
|
||||
}
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||
s.writeJSON(w, http.StatusBadRequest, map[string]string{"error": "Invalid request body"})
|
||||
return
|
||||
}
|
||||
|
||||
res, err := s.Store.BulkAction(req.IDs, req.Action, req.Value, actor)
|
||||
if err != nil {
|
||||
s.writeJSON(w, http.StatusInternalServerError, map[string]string{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
s.writeJSON(w, http.StatusOK, res)
|
||||
}
|
||||
|
||||
// Tags
|
||||
func (s *Server) handleListTags(w http.ResponseWriter, r *http.Request) {
|
||||
tags, err := s.Store.ListAllTags()
|
||||
if err != nil {
|
||||
s.writeJSON(w, http.StatusInternalServerError, map[string]string{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
s.writeJSON(w, http.StatusOK, map[string]any{"tags": tags})
|
||||
}
|
||||
|
||||
func (s *Server) handleAddTag(w http.ResponseWriter, r *http.Request) {
|
||||
actor := s.getActor(r)
|
||||
if actor == nil {
|
||||
s.writeJSON(w, http.StatusUnauthorized, map[string]string{"error": "Authentication required"})
|
||||
return
|
||||
}
|
||||
ticketID := chi.URLParam(r, "id")
|
||||
var req struct {
|
||||
Tag string `json:"tag"`
|
||||
}
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil || req.Tag == "" {
|
||||
s.writeJSON(w, http.StatusBadRequest, map[string]string{"error": "Tag is required"})
|
||||
return
|
||||
}
|
||||
|
||||
if err := s.Store.AddTicketTag(ticketID, req.Tag); err != nil {
|
||||
s.writeJSON(w, http.StatusInternalServerError, map[string]string{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
s.writeJSON(w, http.StatusOK, map[string]string{"status": "ok", "tag": req.Tag})
|
||||
}
|
||||
|
||||
func (s *Server) handleRemoveTag(w http.ResponseWriter, r *http.Request) {
|
||||
actor := s.getActor(r)
|
||||
if actor == nil {
|
||||
s.writeJSON(w, http.StatusUnauthorized, map[string]string{"error": "Authentication required"})
|
||||
return
|
||||
}
|
||||
ticketID := chi.URLParam(r, "id")
|
||||
tag := chi.URLParam(r, "tag")
|
||||
|
||||
if err := s.Store.RemoveTicketTag(ticketID, tag); err != nil {
|
||||
s.writeJSON(w, http.StatusInternalServerError, map[string]string{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
s.writeJSON(w, http.StatusOK, map[string]string{"status": "ok", "removed": tag})
|
||||
}
|
||||
|
||||
// Ticket Relations
|
||||
func (s *Server) handleLinkTickets(w http.ResponseWriter, r *http.Request) {
|
||||
actor := s.getActor(r)
|
||||
if actor == nil {
|
||||
s.writeJSON(w, http.StatusUnauthorized, map[string]string{"error": "Authentication required"})
|
||||
return
|
||||
}
|
||||
ticketID := chi.URLParam(r, "id")
|
||||
|
||||
var req struct {
|
||||
TargetID string `json:"target_id"`
|
||||
Type string `json:"type"`
|
||||
}
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil || req.TargetID == "" {
|
||||
s.writeJSON(w, http.StatusBadRequest, map[string]string{"error": "Target ticket ID is required"})
|
||||
return
|
||||
}
|
||||
|
||||
if err := s.Store.LinkTickets(ticketID, req.TargetID, req.Type, actor); err != nil {
|
||||
s.writeJSON(w, http.StatusInternalServerError, map[string]string{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
s.writeJSON(w, http.StatusOK, map[string]string{"status": "ok", "linked": req.TargetID})
|
||||
}
|
||||
|
||||
func (s *Server) handleUnlinkTickets(w http.ResponseWriter, r *http.Request) {
|
||||
actor := s.getActor(r)
|
||||
if actor == nil {
|
||||
s.writeJSON(w, http.StatusUnauthorized, map[string]string{"error": "Authentication required"})
|
||||
return
|
||||
}
|
||||
ticketID := chi.URLParam(r, "id")
|
||||
targetID := chi.URLParam(r, "target")
|
||||
|
||||
if err := s.Store.UnlinkTickets(ticketID, targetID); err != nil {
|
||||
s.writeJSON(w, http.StatusInternalServerError, map[string]string{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
s.writeJSON(w, http.StatusOK, map[string]string{"status": "ok", "unlinked": targetID})
|
||||
}
|
||||
|
||||
// Saved Filters
|
||||
func (s *Server) handleListSavedFilters(w http.ResponseWriter, r *http.Request) {
|
||||
actor := s.getActor(r)
|
||||
if actor == nil {
|
||||
s.writeJSON(w, http.StatusUnauthorized, map[string]string{"error": "Authentication required"})
|
||||
return
|
||||
}
|
||||
filters, err := s.Store.GetSavedFilters(actor.Username)
|
||||
if err != nil {
|
||||
s.writeJSON(w, http.StatusInternalServerError, map[string]string{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
s.writeJSON(w, http.StatusOK, map[string]any{"filters": filters})
|
||||
}
|
||||
|
||||
func (s *Server) handleCreateSavedFilter(w http.ResponseWriter, r *http.Request) {
|
||||
actor := s.getActor(r)
|
||||
if actor == nil {
|
||||
s.writeJSON(w, http.StatusUnauthorized, map[string]string{"error": "Authentication required"})
|
||||
return
|
||||
}
|
||||
|
||||
var req struct {
|
||||
Name string `json:"name"`
|
||||
FilterJSON string `json:"filter_json"`
|
||||
}
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil || req.Name == "" {
|
||||
s.writeJSON(w, http.StatusBadRequest, map[string]string{"error": "Filter name is required"})
|
||||
return
|
||||
}
|
||||
|
||||
sf, err := s.Store.SaveFilter(actor.Username, req.Name, req.FilterJSON)
|
||||
if err != nil {
|
||||
s.writeJSON(w, http.StatusInternalServerError, map[string]string{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
s.writeJSON(w, http.StatusCreated, sf)
|
||||
}
|
||||
|
||||
func (s *Server) handleDeleteSavedFilter(w http.ResponseWriter, r *http.Request) {
|
||||
actor := s.getActor(r)
|
||||
if actor == nil {
|
||||
s.writeJSON(w, http.StatusUnauthorized, map[string]string{"error": "Authentication required"})
|
||||
return
|
||||
}
|
||||
filterID := chi.URLParam(r, "id")
|
||||
if err := s.Store.DeleteSavedFilter(filterID, actor.Username); err != nil {
|
||||
s.writeJSON(w, http.StatusInternalServerError, map[string]string{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
s.writeJSON(w, http.StatusOK, map[string]string{"status": "ok"})
|
||||
}
|
||||
|
||||
// API Tokens
|
||||
func (s *Server) handleListAPITokens(w http.ResponseWriter, r *http.Request) {
|
||||
actor := s.getActor(r)
|
||||
if actor == nil {
|
||||
s.writeJSON(w, http.StatusUnauthorized, map[string]string{"error": "Authentication required"})
|
||||
return
|
||||
}
|
||||
tokens, err := s.Store.ListAPITokens(actor.Username)
|
||||
if err != nil {
|
||||
s.writeJSON(w, http.StatusInternalServerError, map[string]string{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
s.writeJSON(w, http.StatusOK, map[string]any{"tokens": tokens})
|
||||
}
|
||||
|
||||
func (s *Server) handleCreateAPIToken(w http.ResponseWriter, r *http.Request) {
|
||||
actor := s.getActor(r)
|
||||
if actor == nil {
|
||||
s.writeJSON(w, http.StatusUnauthorized, map[string]string{"error": "Authentication required"})
|
||||
return
|
||||
}
|
||||
|
||||
var req struct {
|
||||
Name string `json:"name"`
|
||||
Scopes string `json:"scopes"`
|
||||
}
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil || req.Name == "" {
|
||||
s.writeJSON(w, http.StatusBadRequest, map[string]string{"error": "Token name is required"})
|
||||
return
|
||||
}
|
||||
|
||||
raw, tok, err := s.Store.CreateAPIToken(actor.Username, req.Name, req.Scopes)
|
||||
if err != nil {
|
||||
s.writeJSON(w, http.StatusInternalServerError, map[string]string{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
s.writeJSON(w, http.StatusCreated, map[string]any{
|
||||
"token": raw,
|
||||
"meta": tok,
|
||||
})
|
||||
}
|
||||
|
||||
func (s *Server) handleRevokeAPIToken(w http.ResponseWriter, r *http.Request) {
|
||||
actor := s.getActor(r)
|
||||
if actor == nil {
|
||||
s.writeJSON(w, http.StatusUnauthorized, map[string]string{"error": "Authentication required"})
|
||||
return
|
||||
}
|
||||
tokenID := chi.URLParam(r, "id")
|
||||
if err := s.Store.RevokeAPIToken(tokenID, actor.Username); err != nil {
|
||||
s.writeJSON(w, http.StatusInternalServerError, map[string]string{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
s.writeJSON(w, http.StatusOK, map[string]string{"status": "ok"})
|
||||
}
|
||||
|
||||
// Admin Management
|
||||
func (s *Server) handleAdminListUsers(w http.ResponseWriter, r *http.Request) {
|
||||
actor := s.getActor(r)
|
||||
if !s.isAdmin(actor) {
|
||||
s.writeJSON(w, http.StatusForbidden, map[string]string{"error": "Admin access required"})
|
||||
return
|
||||
}
|
||||
|
||||
users, err := s.Store.ListAllUsersAdmin()
|
||||
if err != nil {
|
||||
s.writeJSON(w, http.StatusInternalServerError, map[string]string{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
s.writeJSON(w, http.StatusOK, map[string]any{"users": users})
|
||||
}
|
||||
|
||||
func (s *Server) handleAdminUpdateRole(w http.ResponseWriter, r *http.Request) {
|
||||
actor := s.getActor(r)
|
||||
if !s.isAdmin(actor) {
|
||||
s.writeJSON(w, http.StatusForbidden, map[string]string{"error": "Admin access required"})
|
||||
return
|
||||
}
|
||||
|
||||
target := chi.URLParam(r, "username")
|
||||
var req struct {
|
||||
Role string `json:"role"`
|
||||
}
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil || req.Role == "" {
|
||||
s.writeJSON(w, http.StatusBadRequest, map[string]string{"error": "Role is required"})
|
||||
return
|
||||
}
|
||||
|
||||
if err := s.Store.UpdateUserRoleAdmin(target, req.Role); err != nil {
|
||||
s.writeJSON(w, http.StatusBadRequest, map[string]string{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
s.writeJSON(w, http.StatusOK, map[string]string{"status": "ok", "message": "User role updated"})
|
||||
}
|
||||
|
||||
func (s *Server) handleAdminUpdateStatus(w http.ResponseWriter, r *http.Request) {
|
||||
actor := s.getActor(r)
|
||||
if !s.isAdmin(actor) {
|
||||
s.writeJSON(w, http.StatusForbidden, map[string]string{"error": "Admin access required"})
|
||||
return
|
||||
}
|
||||
|
||||
target := chi.URLParam(r, "username")
|
||||
if strings.EqualFold(target, actor.Username) {
|
||||
s.writeJSON(w, http.StatusBadRequest, map[string]string{"error": "Cannot deactivate your own account"})
|
||||
return
|
||||
}
|
||||
|
||||
var req struct {
|
||||
Active bool `json:"active"`
|
||||
}
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||
s.writeJSON(w, http.StatusBadRequest, map[string]string{"error": "Active flag is required"})
|
||||
return
|
||||
}
|
||||
|
||||
if err := s.Store.SetUserActiveStatus(target, req.Active); err != nil {
|
||||
s.writeJSON(w, http.StatusInternalServerError, map[string]string{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
s.writeJSON(w, http.StatusOK, map[string]string{"status": "ok", "message": "User active status updated"})
|
||||
}
|
||||
|
||||
func (s *Server) handleAdminResetPassword(w http.ResponseWriter, r *http.Request) {
|
||||
actor := s.getActor(r)
|
||||
if !s.isAdmin(actor) {
|
||||
s.writeJSON(w, http.StatusForbidden, map[string]string{"error": "Admin access required"})
|
||||
return
|
||||
}
|
||||
|
||||
target := chi.URLParam(r, "username")
|
||||
var req struct {
|
||||
NewPassword string `json:"new_password"`
|
||||
}
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil || len(req.NewPassword) < 4 {
|
||||
s.writeJSON(w, http.StatusBadRequest, map[string]string{"error": "Password must be at least 4 characters"})
|
||||
return
|
||||
}
|
||||
|
||||
if err := s.Store.ResetUserPasswordAdmin(target, req.NewPassword); err != nil {
|
||||
s.writeJSON(w, http.StatusInternalServerError, map[string]string{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
s.writeJSON(w, http.StatusOK, map[string]string{"status": "ok", "message": "Password reset successfully"})
|
||||
}
|
||||
|
||||
// Export (CSV)
|
||||
func (s *Server) handleExportTickets(w http.ResponseWriter, r *http.Request) {
|
||||
status := r.URL.Query().Get("status")
|
||||
priority := r.URL.Query().Get("priority")
|
||||
assignee := r.URL.Query().Get("assignee")
|
||||
reporter := r.URL.Query().Get("reporter")
|
||||
q := r.URL.Query().Get("q")
|
||||
|
||||
tickets := s.Store.ListTickets(status, priority, "", assignee, reporter, q, "")
|
||||
|
||||
w.Header().Set("Content-Type", "text/csv; charset=utf-8")
|
||||
w.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=khira_tickets_%s.csv", time.Now().Format("2006-01-02_1504")))
|
||||
|
||||
writer := csv.NewWriter(w)
|
||||
defer writer.Flush()
|
||||
|
||||
// Header row
|
||||
_ = writer.Write([]string{
|
||||
"Ticket ID", "Type", "Title", "App Name", "Version", "Feature",
|
||||
"Priority", "Status", "Created By", "Assigned To", "Created At",
|
||||
"Due Date", "SLA Breached", "Tags", "Archived",
|
||||
})
|
||||
|
||||
for _, t := range tickets {
|
||||
dueDateStr := ""
|
||||
if t.DueDate != nil {
|
||||
dueDateStr = t.DueDate.Format("2006-01-02 15:04")
|
||||
}
|
||||
tagsStr := strings.Join(t.Tags, ", ")
|
||||
_ = writer.Write([]string{
|
||||
t.ID,
|
||||
t.TicketType,
|
||||
t.Title,
|
||||
t.AppName,
|
||||
t.Version,
|
||||
t.FeatureName,
|
||||
t.Priority,
|
||||
t.Status,
|
||||
t.CreatedByName,
|
||||
t.AssignedToName,
|
||||
t.CreatedAt.Format("2006-01-02 15:04"),
|
||||
dueDateStr,
|
||||
strconv.FormatBool(t.SLABreached),
|
||||
tagsStr,
|
||||
strconv.FormatBool(t.Archived),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) handleExportErrors(w http.ResponseWriter, r *http.Request) {
|
||||
status := r.URL.Query().Get("status")
|
||||
severity := r.URL.Query().Get("severity")
|
||||
app := r.URL.Query().Get("app")
|
||||
q := r.URL.Query().Get("q")
|
||||
|
||||
errorsList := s.Store.ListErrors(status, severity, app, q)
|
||||
|
||||
w.Header().Set("Content-Type", "text/csv; charset=utf-8")
|
||||
w.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=khira_errors_%s.csv", time.Now().Format("2006-01-02_1504")))
|
||||
|
||||
writer := csv.NewWriter(w)
|
||||
defer writer.Flush()
|
||||
|
||||
// Header row
|
||||
_ = writer.Write([]string{
|
||||
"Error ID", "App Name", "Version", "Environment", "Service", "Endpoint",
|
||||
"Exception Type", "Message", "Severity", "Status", "Occurrences",
|
||||
"First Seen", "Last Seen", "Escalated Ticket", "Archived",
|
||||
})
|
||||
|
||||
for _, e := range errorsList {
|
||||
_ = writer.Write([]string{
|
||||
e.ID,
|
||||
e.AppName,
|
||||
e.Version,
|
||||
e.Environment,
|
||||
e.Service,
|
||||
e.Endpoint,
|
||||
e.ExceptionType,
|
||||
e.Message,
|
||||
e.Severity,
|
||||
e.Status,
|
||||
strconv.Itoa(e.Occurrences),
|
||||
e.FirstSeen.Format("2006-01-02 15:04"),
|
||||
e.LastSeen.Format("2006-01-02 15:04"),
|
||||
e.LinkedTicketID,
|
||||
strconv.FormatBool(e.Archived),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Notifications single item operations
|
||||
func (s *Server) handleDeleteNotification(w http.ResponseWriter, r *http.Request) {
|
||||
actor := s.getActor(r)
|
||||
if actor == nil {
|
||||
s.writeJSON(w, http.StatusUnauthorized, map[string]string{"error": "Authentication required"})
|
||||
return
|
||||
}
|
||||
id := chi.URLParam(r, "id")
|
||||
_, err := s.Store.primaryDB.Exec(`DELETE FROM notifications WHERE id = $1 AND user_id = $2`, id, actor.Username)
|
||||
if err != nil {
|
||||
s.writeJSON(w, http.StatusInternalServerError, map[string]string{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
s.writeJSON(w, http.StatusOK, map[string]string{"status": "ok"})
|
||||
}
|
||||
|
||||
func (s *Server) handleClearNotifications(w http.ResponseWriter, r *http.Request) {
|
||||
actor := s.getActor(r)
|
||||
if actor == nil {
|
||||
s.writeJSON(w, http.StatusUnauthorized, map[string]string{"error": "Authentication required"})
|
||||
return
|
||||
}
|
||||
_, err := s.Store.primaryDB.Exec(`DELETE FROM notifications WHERE user_id = $1`, actor.Username)
|
||||
if err != nil {
|
||||
s.writeJSON(w, http.StatusInternalServerError, map[string]string{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
s.writeJSON(w, http.StatusOK, map[string]string{"status": "ok"})
|
||||
}
|
||||
|
||||
func (s *Server) handleMarkNotificationReadSingle(w http.ResponseWriter, r *http.Request) {
|
||||
actor := s.getActor(r)
|
||||
if actor == nil {
|
||||
s.writeJSON(w, http.StatusUnauthorized, map[string]string{"error": "Authentication required"})
|
||||
return
|
||||
}
|
||||
id := chi.URLParam(r, "id")
|
||||
_, err := s.Store.primaryDB.Exec(`UPDATE notifications SET read = TRUE WHERE id = $1 AND user_id = $2`, id, actor.Username)
|
||||
if err != nil {
|
||||
s.writeJSON(w, http.StatusInternalServerError, map[string]string{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
s.writeJSON(w, http.StatusOK, map[string]string{"status": "ok"})
|
||||
}
|
||||
+108
-12
@@ -44,17 +44,20 @@ func (r Role) IsValid() bool {
|
||||
}
|
||||
|
||||
type User struct {
|
||||
ID string `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Name string `json:"name"`
|
||||
PasswordHash string `json:"password_hash,omitempty"`
|
||||
Role string `json:"role"`
|
||||
RoleDisplay string `json:"role_display"`
|
||||
Avatar string `json:"avatar"`
|
||||
AvatarType string `json:"avatar_type"`
|
||||
ProfileImage string `json:"profile_image"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
ID string `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Name string `json:"name"`
|
||||
PasswordHash string `json:"password_hash,omitempty"`
|
||||
Role string `json:"role"`
|
||||
RoleDisplay string `json:"role_display"`
|
||||
Avatar string `json:"avatar"`
|
||||
AvatarType string `json:"avatar_type"`
|
||||
ProfileImage string `json:"profile_image"`
|
||||
Active bool `json:"active"`
|
||||
LastActiveAt *time.Time `json:"last_active_at,omitempty"`
|
||||
DeactivatedAt *time.Time `json:"deactivated_at,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
func (u *User) Public() *User {
|
||||
@@ -138,6 +141,11 @@ type Ticket struct {
|
||||
Links []string `json:"links,omitempty"`
|
||||
LinkedErrorID string `json:"linked_error_id,omitempty"`
|
||||
Archived bool `json:"archived"`
|
||||
DueDate *time.Time `json:"due_date,omitempty"`
|
||||
SLAHours int `json:"sla_hours"`
|
||||
SLABreached bool `json:"sla_breached"`
|
||||
Tags []string `json:"tags,omitempty"`
|
||||
RelatedTicketIDs []string `json:"related_ticket_ids,omitempty"`
|
||||
Remarks []Remark `json:"remarks"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
@@ -194,7 +202,95 @@ type Notification struct {
|
||||
TicketID string `json:"ticket_id"`
|
||||
Title string `json:"title"`
|
||||
Message string `json:"message"`
|
||||
Type string `json:"type"` // assignment, status_change, hold, complete, remark
|
||||
Type string `json:"type"` // assignment, status_change, hold, complete, remark, mention, sla_breach
|
||||
Read bool `json:"read"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
type SavedFilter struct {
|
||||
ID string `json:"id"`
|
||||
UserID string `json:"user_id"`
|
||||
Name string `json:"name"`
|
||||
FilterJSON string `json:"filter_json"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
type APIToken struct {
|
||||
ID string `json:"id"`
|
||||
UserID string `json:"user_id"`
|
||||
Name string `json:"name"`
|
||||
TokenHash string `json:"-"`
|
||||
Scopes string `json:"scopes"`
|
||||
LastUsedAt *time.Time `json:"last_used_at,omitempty"`
|
||||
Revoked bool `json:"revoked"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
type TicketRelation struct {
|
||||
ID int `json:"id"`
|
||||
TicketA string `json:"ticket_a"`
|
||||
TicketB string `json:"ticket_b"`
|
||||
RelationType string `json:"relation_type"`
|
||||
CreatedBy string `json:"created_by"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
type AnalyticsData struct {
|
||||
Summary struct {
|
||||
TotalTickets int `json:"total_tickets"`
|
||||
OpenTickets int `json:"open_tickets"`
|
||||
InProgressTickets int `json:"in_progress_tickets"`
|
||||
OnHoldTickets int `json:"on_hold_tickets"`
|
||||
CompletedTickets int `json:"completed_tickets"`
|
||||
ArchivedTickets int `json:"archived_tickets"`
|
||||
SLABreachedTickets int `json:"sla_breached_tickets"`
|
||||
AvgResolutionHours float64 `json:"avg_resolution_hours"`
|
||||
} `json:"summary"`
|
||||
Velocity []VelocityPoint `json:"velocity"`
|
||||
ByPriority map[string]int `json:"by_priority"`
|
||||
ByAssignee []AssigneeWorkload `json:"by_assignee"`
|
||||
ErrorSummary struct {
|
||||
TotalErrors int `json:"total_errors"`
|
||||
UnresolvedErrors int `json:"unresolved_errors"`
|
||||
ResolvedErrors int `json:"resolved_errors"`
|
||||
CriticalErrors int `json:"critical_errors"`
|
||||
} `json:"error_summary"`
|
||||
TopAppsByErrors []AppErrorStat `json:"top_apps_by_errors"`
|
||||
RecentActivity []ActivityItem `json:"recent_activity"`
|
||||
}
|
||||
|
||||
type VelocityPoint struct {
|
||||
Week string `json:"week"`
|
||||
Created int `json:"created"`
|
||||
Resolved int `json:"resolved"`
|
||||
}
|
||||
|
||||
type AssigneeWorkload struct {
|
||||
Username string `json:"username"`
|
||||
Name string `json:"name"`
|
||||
Role string `json:"role"`
|
||||
RoleDisplay string `json:"role_display"`
|
||||
Avatar string `json:"avatar"`
|
||||
Open int `json:"open"`
|
||||
InProgress int `json:"in_progress"`
|
||||
Completed int `json:"completed"`
|
||||
AvgHours float64 `json:"avg_hours"`
|
||||
}
|
||||
|
||||
type AppErrorStat struct {
|
||||
App string `json:"app"`
|
||||
Count int `json:"count"`
|
||||
}
|
||||
|
||||
type ActivityItem struct {
|
||||
ID string `json:"id"`
|
||||
TicketID string `json:"ticket_id"`
|
||||
Title string `json:"title"`
|
||||
Type string `json:"type"`
|
||||
Author string `json:"author"`
|
||||
Name string `json:"name"`
|
||||
Role string `json:"role"`
|
||||
Text string `json:"text"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
|
||||
+64
-7
@@ -78,6 +78,9 @@ func NewStore(dataDir string) (*Store, error) {
|
||||
}
|
||||
}
|
||||
|
||||
// Start background SLA monitor
|
||||
s.StartSLAMonitor()
|
||||
|
||||
return s, nil
|
||||
}
|
||||
|
||||
@@ -317,6 +320,14 @@ func (s *Store) CreateTicket(t *Ticket, actor *User) (*Ticket, error) {
|
||||
t.AssignedToRole = role
|
||||
}
|
||||
|
||||
if t.SLAHours <= 0 {
|
||||
t.SLAHours = calculateDefaultSLA(t.Priority)
|
||||
}
|
||||
if t.DueDate == nil {
|
||||
d := t.CreatedAt.Add(time.Duration(t.SLAHours) * time.Hour)
|
||||
t.DueDate = &d
|
||||
}
|
||||
|
||||
tx, err := s.primaryDB.Begin()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -327,15 +338,23 @@ func (s *Store) CreateTicket(t *Ticket, actor *User) (*Ticket, error) {
|
||||
INSERT INTO tickets (
|
||||
id, ticket_type, title, general_category, department, app_name, version, feature_name, api_key, issue_type,
|
||||
priority, status, description, assistance_required, additional_info, created_by, created_by_name, created_by_role,
|
||||
assigned_to, assigned_to_name, assigned_to_role, linked_error_id, created_at, updated_at
|
||||
) VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23,$24)
|
||||
assigned_to, assigned_to_name, assigned_to_role, linked_error_id, created_at, updated_at, due_date, sla_hours, sla_breached
|
||||
) VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23,$24,$25,$26,$27)
|
||||
`, t.ID, t.TicketType, t.Title, t.GeneralCategory, t.Department, t.AppName, t.Version, t.FeatureName, t.APIKey, t.IssueType,
|
||||
t.Priority, t.Status, t.Description, t.AssistanceRequired, t.AdditionalInfo, t.CreatedBy, t.CreatedByName, t.CreatedByRole,
|
||||
t.AssignedTo, t.AssignedToName, t.AssignedToRole, t.LinkedErrorID, t.CreatedAt, t.UpdatedAt)
|
||||
t.AssignedTo, t.AssignedToName, t.AssignedToRole, t.LinkedErrorID, t.CreatedAt, t.UpdatedAt, t.DueDate, t.SLAHours, t.SLABreached)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to insert ticket: %w", err)
|
||||
}
|
||||
|
||||
// Insert tags if present
|
||||
for _, tg := range t.Tags {
|
||||
tg = strings.ToLower(strings.TrimSpace(tg))
|
||||
if tg != "" {
|
||||
_, _ = tx.Exec(`INSERT INTO ticket_tags (ticket_id, tag) VALUES ($1, $2) ON CONFLICT DO NOTHING`, t.ID, tg)
|
||||
}
|
||||
}
|
||||
|
||||
// Add creation remark
|
||||
createRemarkText := fmt.Sprintf("Created ticket with priority %s.", strings.ToUpper(t.Priority))
|
||||
if t.AssignedToName != "" {
|
||||
@@ -398,13 +417,13 @@ func (s *Store) GetTicket(id string) (*Ticket, error) {
|
||||
SELECT id, ticket_type, title, general_category, department, app_name, version, feature_name, api_key, issue_type,
|
||||
priority, status, description, assistance_required, additional_info, created_by, created_by_name, created_by_role,
|
||||
assigned_to, assigned_to_name, assigned_to_role, hold_reason, held_by, held_at, completion_remarks, completed_by,
|
||||
completed_at, linked_error_id, archived, created_at, updated_at
|
||||
completed_at, linked_error_id, archived, created_at, updated_at, due_date, sla_hours, sla_breached
|
||||
FROM tickets WHERE id = $1
|
||||
`, id).Scan(
|
||||
&t.ID, &t.TicketType, &t.Title, &t.GeneralCategory, &t.Department, &t.AppName, &t.Version, &t.FeatureName, &t.APIKey, &t.IssueType,
|
||||
&t.Priority, &t.Status, &t.Description, &t.AssistanceRequired, &t.AdditionalInfo, &t.CreatedBy, &t.CreatedByName, &t.CreatedByRole,
|
||||
&t.AssignedTo, &t.AssignedToName, &t.AssignedToRole, &t.HoldReason, &t.HeldBy, &t.HeldAt, &t.CompletionRemarks, &t.CompletedBy,
|
||||
&t.CompletedAt, &t.LinkedErrorID, &t.Archived, &t.CreatedAt, &t.UpdatedAt,
|
||||
&t.CompletedAt, &t.LinkedErrorID, &t.Archived, &t.CreatedAt, &t.UpdatedAt, &t.DueDate, &t.SLAHours, &t.SLABreached,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, errors.New("ticket not found")
|
||||
@@ -461,6 +480,27 @@ func (s *Store) GetTicket(id string) (*Ticket, error) {
|
||||
t.Links = []string{}
|
||||
}
|
||||
|
||||
// Tags
|
||||
tagRows, err := s.primaryDB.Query(`SELECT tag FROM ticket_tags WHERE ticket_id = $1 ORDER BY tag ASC`, id)
|
||||
if err == nil {
|
||||
defer tagRows.Close()
|
||||
for tagRows.Next() {
|
||||
var tg string
|
||||
if err := tagRows.Scan(&tg); err == nil {
|
||||
t.Tags = append(t.Tags, tg)
|
||||
}
|
||||
}
|
||||
}
|
||||
if t.Tags == nil {
|
||||
t.Tags = []string{}
|
||||
}
|
||||
|
||||
// Relations
|
||||
t.RelatedTicketIDs, _ = s.GetRelatedTickets(id)
|
||||
if t.RelatedTicketIDs == nil {
|
||||
t.RelatedTicketIDs = []string{}
|
||||
}
|
||||
|
||||
return &t, nil
|
||||
}
|
||||
|
||||
@@ -703,7 +743,7 @@ func (s *Store) ListTickets(status, priority, app, assignee, reporter, query, ti
|
||||
SELECT id, ticket_type, title, general_category, department, app_name, version, feature_name, api_key, issue_type,
|
||||
priority, status, description, assistance_required, additional_info, created_by, created_by_name, created_by_role,
|
||||
assigned_to, assigned_to_name, assigned_to_role, hold_reason, held_by, held_at, completion_remarks, completed_by,
|
||||
completed_at, linked_error_id, archived, created_at, updated_at
|
||||
completed_at, linked_error_id, archived, created_at, updated_at, due_date, sla_hours, sla_breached
|
||||
FROM tickets
|
||||
%s
|
||||
ORDER BY created_at DESC
|
||||
@@ -722,11 +762,12 @@ func (s *Store) ListTickets(status, priority, app, assignee, reporter, query, ti
|
||||
&t.ID, &t.TicketType, &t.Title, &t.GeneralCategory, &t.Department, &t.AppName, &t.Version, &t.FeatureName, &t.APIKey, &t.IssueType,
|
||||
&t.Priority, &t.Status, &t.Description, &t.AssistanceRequired, &t.AdditionalInfo, &t.CreatedBy, &t.CreatedByName, &t.CreatedByRole,
|
||||
&t.AssignedTo, &t.AssignedToName, &t.AssignedToRole, &t.HoldReason, &t.HeldBy, &t.HeldAt, &t.CompletionRemarks, &t.CompletedBy,
|
||||
&t.CompletedAt, &t.LinkedErrorID, &t.Archived, &t.CreatedAt, &t.UpdatedAt,
|
||||
&t.CompletedAt, &t.LinkedErrorID, &t.Archived, &t.CreatedAt, &t.UpdatedAt, &t.DueDate, &t.SLAHours, &t.SLABreached,
|
||||
); err == nil {
|
||||
t.Remarks = []Remark{}
|
||||
t.Attachments = []Attachment{}
|
||||
t.Links = []string{}
|
||||
t.Tags = []string{}
|
||||
list = append(list, &t)
|
||||
}
|
||||
}
|
||||
@@ -756,6 +797,22 @@ func (s *Store) ListTickets(status, priority, app, assignee, reporter, query, ti
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fetch tags for listed tickets
|
||||
tagRows, err := s.primaryDB.Query(fmt.Sprintf(`
|
||||
SELECT ticket_id, tag FROM ticket_tags WHERE ticket_id IN (%s)
|
||||
`, inClause))
|
||||
if err == nil {
|
||||
defer tagRows.Close()
|
||||
for tagRows.Next() {
|
||||
var tid, tg string
|
||||
if err := tagRows.Scan(&tid, &tg); err == nil {
|
||||
if t, exists := tIdxMap[tid]; exists {
|
||||
t.Tags = append(t.Tags, tg)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return list
|
||||
|
||||
+1148
-589
File diff suppressed because it is too large
Load Diff
+124
-21
@@ -4,13 +4,12 @@
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
|
||||
<meta name="theme-color" content="#06080c" id="tc">
|
||||
<title>Khira</title>
|
||||
<title>Khira Enterprise Issue Tracker</title>
|
||||
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Crect width='64' height='64' rx='18' fill='%2306080c'/%3E%3Cpath d='M22 16h8v12l10-12h10L38 31l13 17H41L30 34v14h-8z' fill='%2310b981'/%3E%3C/svg%3E">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Roboto+Flex:wght@400;500;600&family=Roboto+Mono:wght@400;500&display=swap" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@24,400,0,0&display=block" rel="stylesheet">
|
||||
<link rel="stylesheet" href="/khira/styles.css">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Roboto+Flex:wght@400;500;600;700&family=Roboto+Mono:wght@400;500&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="/khira/styles.css?v=2">
|
||||
<script>try{document.documentElement.dataset.theme=localStorage.khira_theme||'dark'}catch(e){}</script>
|
||||
</head>
|
||||
<body>
|
||||
@@ -39,9 +38,11 @@
|
||||
|
||||
<main id="auth" class="auth" hidden>
|
||||
<div class="ac">
|
||||
<div class="logo"><span class="ms">confirmation_number</span></div>
|
||||
<div class="logo">
|
||||
<svg class="brand-ic" width="34" height="34" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z"/><path d="M13 5v2"/><path d="M13 11v2"/><path d="M13 17v2"/></svg>
|
||||
</div>
|
||||
<h1>Khira</h1>
|
||||
<p class="sub">Tickets and error tracking for your engineering team.</p>
|
||||
<p class="sub">Enterprise issue tracking and telemetry for engineering teams.</p>
|
||||
<div class="seg" id="atabs"><button class="on" data-a="in">Sign in</button><button data-a="up">Create account</button></div>
|
||||
<form id="fIn" novalidate>
|
||||
<label class="fld"><input id="lu" placeholder=" " autocomplete="username" required><span>Username</span></label>
|
||||
@@ -62,8 +63,10 @@
|
||||
|
||||
<div id="app" class="app" hidden>
|
||||
<nav class="nav">
|
||||
<button data-s="tickets" class="on"><span class="pill"><span class="ms">confirmation_number</span></span>Tickets</button>
|
||||
<button data-s="errors"><span class="pill"><span class="ms">bug_report</span></span>Errors</button>
|
||||
<button data-s="tickets" class="on" title="Tickets (T)"><span class="pill"><svg class="nav-ic" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z"/><path d="M13 5v2"/><path d="M13 11v2"/><path d="M13 17v2"/></svg></span>Tickets</button>
|
||||
<button data-s="errors" title="Errors (E)"><span class="pill"><svg class="nav-ic" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m8 2 1.88 1.88"/><path d="M14.12 3.88 16 2"/><path d="M9 7.13v-1a3.003 3.003 0 1 1 6 0v1"/><path d="M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6"/><path d="M12 20v-9"/><path d="M6.53 9C4.6 8.8 3 7.1 3 5"/><path d="M6 13H2"/><path d="M3 21c0-2.1 1.7-3.9 3.8-4"/><path d="M20.97 5c0 2.1-1.6 3.8-3.5 4"/><path d="M22 13h-4"/><path d="M17.2 17c2.1.1 3.8 1.9 3.8 4"/></svg></span>Errors</button>
|
||||
<button data-s="analytics" title="Analytics (A)"><span class="pill"><svg class="nav-ic" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="20" x2="18" y2="10"/><line x1="12" y1="20" x2="12" y2="4"/><line x1="6" y1="20" x2="6" y2="14"/></svg></span>Analytics</button>
|
||||
<button data-s="admin" id="navAdmin" hidden title="Admin Panel"><span class="pill"><svg class="nav-ic" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/></svg></span>Admin</button>
|
||||
</nav>
|
||||
|
||||
<div class="main">
|
||||
@@ -71,18 +74,21 @@
|
||||
<h1 id="title">Tickets</h1>
|
||||
<span class="sp"></span>
|
||||
<div id="adminDbTools" class="tr" hidden>
|
||||
<button class="chip db-btn sync" id="btnSyncBackup" title="Sync Primary DB to Backup DB"><span class="ms">cloud_sync</span><span class="btn-txt">Backup DB</span></button>
|
||||
<button class="chip db-btn rollback" id="btnRollbackBackup" title="Rollback Primary DB from Backup DB"><span class="ms">history</span><span class="btn-txt">Rollback DB</span></button>
|
||||
<button class="chip db-btn sync" id="btnSyncBackup" title="Sync Primary DB to Backup DB"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="margin-right:5px;vertical-align:middle"><polyline points="23 4 23 10 17 10"/><polyline points="1 20 1 14 7 14"/><path d="M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"/></svg><span class="btn-txt">Backup DB</span></button>
|
||||
<button class="chip db-btn rollback" id="btnRollbackBackup" title="Rollback Primary DB from Backup DB"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="margin-right:5px;vertical-align:middle"><circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/></svg><span class="btn-txt">Rollback DB</span></button>
|
||||
</div>
|
||||
<button class="chip lens-toggle-btn" id="btnToggleLens" title="Toggle Liquid Glass Precision Lens (kube.io)"><span class="ms">search</span><span class="btn-txt">Lens</span></button>
|
||||
<button class="ib" id="theme" aria-label="Toggle theme"><span class="ms">dark_mode</span></button>
|
||||
<button class="ib" id="bell" aria-label="Notifications"><span class="ms">notifications</span><i id="dot" hidden></i></button>
|
||||
<button class="chip cmd-k-btn" id="btnCmdK" title="Command Palette (Cmd+K / Ctrl+K)"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="margin-right:5px;vertical-align:middle"><path d="M18 3a3 3 0 0 0-3 3v12a3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0-3-3H6a3 3 0 0 0-3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3V6a3 3 0 0 0-3-3 3 3 0 0 0-3 3 3 3 0 0 0 3 3h12a3 3 0 0 0 3-3 3 3 0 0 0-3-3z"/></svg><span class="btn-txt">⌘K</span></button>
|
||||
<button class="chip lens-toggle-btn" id="btnToggleLens" title="Toggle Liquid Glass Precision Lens (kube.io)"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="margin-right:5px;vertical-align:middle"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg><span class="btn-txt">Lens</span></button>
|
||||
<button class="ib" id="btnShortcutsHelp" title="Keyboard Shortcuts (?)" aria-label="Shortcuts"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg></button>
|
||||
<button class="ib" id="theme" aria-label="Toggle theme"><svg id="themeIcon" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"/></svg></button>
|
||||
<button class="ib" id="bell" aria-label="Notifications"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"/><path d="M13.73 21a2 2 0 0 1-3.46 0"/></svg><i id="dot" hidden></i></button>
|
||||
<button class="me-btn" id="me" aria-label="Profile"></button>
|
||||
</header>
|
||||
|
||||
<div class="pg">
|
||||
<label class="search"><span class="ms">search</span><input id="q" placeholder="Search tickets" aria-label="Search"></label>
|
||||
<label class="search"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg><input id="q" placeholder="Search tickets, errors, apps... (press / to focus)" aria-label="Search"></label>
|
||||
|
||||
<!-- TICKETS VIEW -->
|
||||
<section id="vT">
|
||||
<div class="hero"><h2 id="hi">Welcome</h2><p id="sum"></p></div>
|
||||
<div class="stats" id="stats"></div>
|
||||
@@ -90,45 +96,142 @@
|
||||
<div class="tools">
|
||||
<div class="chips" id="stChips"></div>
|
||||
<div class="tr">
|
||||
<label class="fsel"><select id="fp"><option value="">Any priority</option><option>P0</option><option>P1</option><option>P2</option><option>P3</option></select></label>
|
||||
<button class="chip" id="btnToggleBulk" title="Toggle bulk selection mode"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="margin-right:4px;vertical-align:middle"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><polyline points="9 11 12 14 22 4"/></svg><span>Select</span></button>
|
||||
<button class="chip" id="btnExportTickets" title="Export tickets as CSV"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="margin-right:4px;vertical-align:middle"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg><span>Export</span></button>
|
||||
<label class="fsel"><select id="fp"><option value="">Any priority</option><option>Critical</option><option>High</option><option>Medium</option><option>Low</option></select></label>
|
||||
<label class="fsel"><select id="ft"><option value="">Any type</option><option value="application">Application</option><option value="general">General</option></select></label>
|
||||
<label class="fsel"><select id="fa"><option value="">Any assignee</option></select></label>
|
||||
<div class="seg ic" id="vsw"><button class="on" data-v="board" aria-label="Board"><span class="ms">view_kanban</span></button><button data-v="list" aria-label="List"><span class="ms">view_list</span></button></div>
|
||||
<div class="seg ic" id="vsw"><button class="on" data-v="board" aria-label="Board"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="5" height="18" rx="1"/><rect x="11" y="3" width="5" height="12" rx="1"/><rect x="19" y="3" width="5" height="15" rx="1"/></svg></button><button data-v="list" aria-label="List"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="8" y1="6" x2="21" y2="6"/><line x1="8" y1="12" x2="21" y2="12"/><line x1="8" y1="18" x2="21" y2="18"/><line x1="3" y1="6" x2="3.01" y2="6"/><line x1="3" y1="12" x2="3.01" y2="12"/><line x1="3" y1="18" x2="3.01" y2="18"/></svg></button></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="savedFilterChips" class="saved-filter-bar" style="display:none"></div>
|
||||
<div id="board" class="board"></div>
|
||||
<div id="list" class="list" hidden></div>
|
||||
</section>
|
||||
|
||||
<!-- ERRORS VIEW -->
|
||||
<section id="vE" hidden>
|
||||
<div class="hero"><h2>Error tracking</h2><p>Runtime errors reported by your services.</p></div>
|
||||
<div class="hero"><h2>Error telemetry & tracking</h2><p>Real-time runtime exceptions logged across all enterprise services.</p></div>
|
||||
<div class="stats" id="estats"></div>
|
||||
<div class="tools">
|
||||
<div class="chips" id="eChips"></div>
|
||||
<div class="tr">
|
||||
<button class="chip" id="btnExportErrors" title="Export errors as CSV"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="margin-right:4px;vertical-align:middle"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg><span>Export CSV</span></button>
|
||||
<button class="chip" id="btnLogAppErr" title="Log and continue assigning errors for an application"><svg class="btn-ic" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:middle;margin-right:6px"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="16"/><line x1="8" y1="12" x2="16" y2="12"/></svg><span>Testing Phase: Log Errors</span></button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="elist" class="list"></div>
|
||||
</section>
|
||||
|
||||
<!-- ANALYTICS DASHBOARD VIEW -->
|
||||
<section id="vA" hidden>
|
||||
<div class="hero"><h2>Productivity & SLA Analytics</h2><p>Real-time engineering velocity, resolution benchmarks, and team workload.</p></div>
|
||||
<div class="stats" id="astats"></div>
|
||||
<div class="analytics-grid">
|
||||
<div class="chart-card velocity-card">
|
||||
<div class="chart-header">
|
||||
<h3>8-Week Velocity (Created vs Resolved)</h3>
|
||||
<span class="chart-legend"><i class="leg-created"></i> Created <i class="leg-resolved"></i> Resolved</span>
|
||||
</div>
|
||||
<div class="canvas-wrap"><canvas id="velocityCanvas" width="600" height="240"></canvas></div>
|
||||
</div>
|
||||
<div class="chart-card priority-card">
|
||||
<div class="chart-header"><h3>Priority Distribution</h3></div>
|
||||
<div class="canvas-wrap"><canvas id="priorityCanvas" width="300" height="240"></canvas></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="analytics-subgrid">
|
||||
<div class="workload-card">
|
||||
<h3>Team Workload Heatmap</h3>
|
||||
<div id="workloadTable" class="workload-table-wrap"></div>
|
||||
</div>
|
||||
<div class="activity-card">
|
||||
<h3>Live Activity Stream</h3>
|
||||
<div id="activityStream" class="activity-stream-wrap"></div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- ADMIN PANEL VIEW -->
|
||||
<section id="vAdmin" hidden>
|
||||
<div class="hero"><h2>System Administration</h2><p>Team governance, database disaster recovery, and API credentials.</p></div>
|
||||
<div class="admin-tabs-bar">
|
||||
<div class="seg" id="adminTabs"><button class="on" data-at="users">Team Members</button><button data-at="tokens">API Tokens</button><button data-at="database">Database Recovery</button></div>
|
||||
</div>
|
||||
<div id="adminTabUsers" class="admin-tab-pane"></div>
|
||||
<div id="adminTabTokens" class="admin-tab-pane" hidden></div>
|
||||
<div id="adminTabDatabase" class="admin-tab-pane" hidden></div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button class="fab" id="fab"><span class="ms">add</span><span class="fl" id="fabl">New ticket</span></button>
|
||||
<button class="fab" id="fab" title="New Ticket (N)"><svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg><span class="fl" id="fabl">New ticket</span></button>
|
||||
<div class="pop" id="pop" hidden></div>
|
||||
|
||||
<!-- Bulk Action Bottom Floating Bar -->
|
||||
<div id="bulkBar" class="bulk-bar" hidden>
|
||||
<div class="bulk-info"><span id="bulkCount">0</span> tickets selected</div>
|
||||
<div class="bulk-actions">
|
||||
<button class="chip" id="btnBulkStatus">Status ▾</button>
|
||||
<button class="chip" id="btnBulkPriority">Priority ▾</button>
|
||||
<button class="chip" id="btnBulkAssign">Assign ▾</button>
|
||||
<button class="chip" id="btnBulkArchive">Archive</button>
|
||||
<button class="chip del" id="btnBulkDelete">Delete</button>
|
||||
<button class="ib" id="btnBulkCancel" title="Clear selection">×</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Kube.io Liquid Glass Precision Lens Capsule -->
|
||||
<div id="kubePrecisionLens" class="kube-lens-capsule" draggable="false" hidden>
|
||||
<div class="kube-lens-drag-handle">
|
||||
<div class="kube-lens-badge"><span class="ms" style="font-size:13px;vertical-align:middle;margin-right:4px">biotech</span>Liquid Glass · 1.5x</div>
|
||||
<div class="kube-lens-badge"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:middle;margin-right:4px"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg>Liquid Glass · 1.5x</div>
|
||||
<button type="button" class="kube-lens-close" id="btnCloseLens" title="Close Lens">×</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Command Palette Modal -->
|
||||
<div id="cmdPalette" class="cmd-palette-overlay" hidden>
|
||||
<div class="cmd-palette-box">
|
||||
<div class="cmd-palette-search">
|
||||
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg>
|
||||
<input id="cmdInput" placeholder="Type a command or search tickets, errors, team members..." autocomplete="off">
|
||||
<kbd>Esc</kbd>
|
||||
</div>
|
||||
<div id="cmdResults" class="cmd-results-list"></div>
|
||||
<div class="cmd-footer">
|
||||
<span><kbd>↑</kbd><kbd>↓</kbd> Navigate</span>
|
||||
<span><kbd>↵</kbd> Select</span>
|
||||
<span><kbd>Esc</kbd> Close</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Keyboard Shortcuts Modal -->
|
||||
<div id="shortcutsModal" class="cmd-palette-overlay" hidden>
|
||||
<div class="cmd-palette-box shortcuts-box">
|
||||
<div class="shortcuts-header">
|
||||
<h3>Keyboard Shortcuts</h3>
|
||||
<button class="ib" id="btnCloseShortcuts">×</button>
|
||||
</div>
|
||||
<div class="shortcuts-content">
|
||||
<div class="sc-row"><span><kbd>⌘</kbd> + <kbd>K</kbd> / <kbd>Ctrl</kbd> + <kbd>K</kbd></span><span>Open Command Palette</span></div>
|
||||
<div class="sc-row"><span><kbd>N</kbd></span><span>Create New Ticket</span></div>
|
||||
<div class="sc-row"><span><kbd>T</kbd></span><span>Switch to Tickets view</span></div>
|
||||
<div class="sc-row"><span><kbd>E</kbd></span><span>Switch to Errors view</span></div>
|
||||
<div class="sc-row"><span><kbd>A</kbd></span><span>Switch to Analytics view</span></div>
|
||||
<div class="sc-row"><span><kbd>B</kbd></span><span>Switch to Kanban Board</span></div>
|
||||
<div class="sc-row"><span><kbd>L</kbd></span><span>Switch to List view</span></div>
|
||||
<div class="sc-row"><span><kbd>/</kbd></span><span>Focus global search</span></div>
|
||||
<div class="sc-row"><span><kbd>?</kbd></span><span>Open this shortcuts help</span></div>
|
||||
<div class="sc-row"><span><kbd>Esc</kbd></span><span>Close modal or sheet</span></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<dialog id="sheet"></dialog>
|
||||
<dialog id="dlg"></dialog>
|
||||
<div class="snack" id="snack" role="status"></div>
|
||||
<script src="/khira/app.js" defer></script>
|
||||
<script src="/khira/app.js?v=2" defer></script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
+508
-10
@@ -237,14 +237,14 @@ button {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border-radius: 50%;
|
||||
background: var(--sc-hi);
|
||||
background: transparent;
|
||||
font-size: 18px;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
margin-left: 4px;
|
||||
overflow: hidden;
|
||||
flex-shrink: 0;
|
||||
border: 1px solid rgba(255, 255, 255, 0.14);
|
||||
border: none !important;
|
||||
}
|
||||
.av img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
|
||||
|
||||
@@ -1333,28 +1333,33 @@ dd { word-break: break-word; }
|
||||
inset: 0;
|
||||
border-radius: 50%;
|
||||
pointer-events: none;
|
||||
-webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3.8px), #fff calc(100% - 3.2px));
|
||||
mask: radial-gradient(farthest-side, transparent calc(100% - 3.8px), #fff calc(100% - 3.2px));
|
||||
-webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2.5px), #fff calc(100% - 2px));
|
||||
mask: radial-gradient(farthest-side, transparent calc(100% - 2.5px), #fff calc(100% - 2px));
|
||||
}
|
||||
|
||||
.av-core {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
width: calc(100% - 8px);
|
||||
height: calc(100% - 8px);
|
||||
border-radius: 50%;
|
||||
background: transparent;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
overflow: hidden;
|
||||
font-size: calc(var(--sz) * 0.58);
|
||||
box-shadow: none;
|
||||
font-size: calc(var(--sz) * 0.52);
|
||||
border: none !important;
|
||||
outline: none !important;
|
||||
box-shadow: none !important;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.av-wrap.av-admin .av-core {
|
||||
font-size: calc(var(--sz-admin) * 0.58);
|
||||
width: calc(100% - 8px);
|
||||
height: calc(100% - 8px);
|
||||
font-size: calc(var(--sz-admin) * 0.52);
|
||||
background: none;
|
||||
box-shadow: none;
|
||||
box-shadow: none !important;
|
||||
border: none !important;
|
||||
}
|
||||
|
||||
.av-img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
|
||||
@@ -1700,3 +1705,496 @@ dd { word-break: break-word; }
|
||||
box-shadow: 0 0 16px rgba(16, 185, 129, 0.3);
|
||||
}
|
||||
|
||||
|
||||
/* ══════════════════════════════════════════════════════════════════════════════
|
||||
ENTERPRISE SUITE STYLES (Analytics, SLA, Bulk Actions, Admin, Cmd+K, Tags)
|
||||
══════════════════════════════════════════════════════════════════════════════ */
|
||||
|
||||
/* ── Card Priority Accents & Checkboxes ── */
|
||||
.card {
|
||||
position: relative;
|
||||
transition: transform 0.2s var(--e), border-color 0.2s, box-shadow 0.2s;
|
||||
}
|
||||
.card.p-critical { border-left: 3px solid #ef4444 !important; }
|
||||
.card.p-high { border-left: 3px solid #f97316 !important; }
|
||||
.card.p-medium { border-left: 3px solid #eab308 !important; }
|
||||
.card.p-low { border-left: 3px solid #10b981 !important; }
|
||||
|
||||
.card-check {
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
right: 10px;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
accent-color: #10b981;
|
||||
cursor: pointer;
|
||||
z-index: 2;
|
||||
opacity: 0.85;
|
||||
}
|
||||
.card.selected {
|
||||
border-color: rgba(16, 185, 129, 0.6) !important;
|
||||
background: rgba(16, 185, 129, 0.08) !important;
|
||||
box-shadow: 0 0 16px rgba(16, 185, 129, 0.15) !important;
|
||||
}
|
||||
|
||||
/* ── SLA Progress Bar & Overdue Chip ── */
|
||||
.sla-wrap {
|
||||
margin-top: 10px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
.sla-meta {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
font-size: 11px;
|
||||
color: var(--sub);
|
||||
}
|
||||
.sla-bar {
|
||||
width: 100%;
|
||||
height: 4px;
|
||||
background: rgba(255, 255, 255, 0.08);
|
||||
border-radius: 2px;
|
||||
overflow: hidden;
|
||||
}
|
||||
.sla-fill {
|
||||
height: 100%;
|
||||
border-radius: 2px;
|
||||
transition: width 0.3s ease;
|
||||
}
|
||||
.sla-fill.good { background: #10b981; }
|
||||
.sla-fill.warning { background: #f59e0b; }
|
||||
.sla-fill.danger { background: #f97316; }
|
||||
.sla-fill.breached { background: #ef4444; }
|
||||
|
||||
.badge-overdue {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
background: rgba(239, 68, 68, 0.2);
|
||||
color: #f87171;
|
||||
border: 1px solid rgba(239, 68, 68, 0.4);
|
||||
font-size: 10px;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
padding: 2px 6px;
|
||||
border-radius: 6px;
|
||||
animation: pulseOverdue 2s infinite ease-in-out;
|
||||
}
|
||||
@keyframes pulseOverdue {
|
||||
0%, 100% { opacity: 1; }
|
||||
50% { opacity: 0.6; }
|
||||
}
|
||||
|
||||
/* ── Tags / Labels ── */
|
||||
.tag-pill {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
font-size: 11px;
|
||||
font-weight: 500;
|
||||
padding: 2px 8px;
|
||||
border-radius: 12px;
|
||||
background: rgba(255, 255, 255, 0.06);
|
||||
border: 1px solid rgba(255, 255, 255, 0.12);
|
||||
color: var(--txt);
|
||||
white-space: nowrap;
|
||||
}
|
||||
.tag-list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
margin-top: 8px;
|
||||
}
|
||||
.tag-remove-btn {
|
||||
background: none;
|
||||
border: none;
|
||||
color: var(--sub);
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
font-size: 13px;
|
||||
line-height: 1;
|
||||
}
|
||||
.tag-remove-btn:hover { color: #f87171; }
|
||||
|
||||
/* ── Bulk Actions Floating Toolbar ── */
|
||||
.bulk-bar {
|
||||
position: fixed;
|
||||
bottom: 24px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%) translate3d(0, 0, 0);
|
||||
z-index: 900;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
padding: 10px 20px;
|
||||
background: rgba(10, 14, 22, 0.85);
|
||||
backdrop-filter: blur(20px) saturate(180%);
|
||||
border: 1px solid rgba(255, 255, 255, 0.18);
|
||||
border-radius: 36px;
|
||||
box-shadow: 0 16px 48px rgba(0, 0, 0, 0.8), 0 0 24px rgba(16, 185, 129, 0.2);
|
||||
transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s;
|
||||
}
|
||||
.bulk-bar[hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
.bulk-info {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: var(--txt);
|
||||
white-space: nowrap;
|
||||
}
|
||||
.bulk-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
.bulk-actions .chip.del {
|
||||
color: #f87171;
|
||||
border-color: rgba(239, 68, 68, 0.3);
|
||||
}
|
||||
.bulk-actions .chip.del:hover {
|
||||
background: rgba(239, 68, 68, 0.2);
|
||||
border-color: #ef4444;
|
||||
}
|
||||
|
||||
/* ── Analytics Dashboard ── */
|
||||
.analytics-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1.8fr 1fr;
|
||||
gap: 16px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
@media (max-width: 900px) {
|
||||
.analytics-grid { grid-template-columns: 1fr; }
|
||||
}
|
||||
.chart-card {
|
||||
background: rgba(12, 16, 26, 0.65);
|
||||
border: 1px solid rgba(255, 255, 255, 0.08);
|
||||
border-radius: 20px;
|
||||
padding: 20px;
|
||||
backdrop-filter: blur(14px);
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
|
||||
}
|
||||
.chart-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.chart-header h3 {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: var(--txt);
|
||||
}
|
||||
.chart-legend {
|
||||
font-size: 12px;
|
||||
color: var(--sub);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
.chart-legend i {
|
||||
display: inline-block;
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
border-radius: 2px;
|
||||
vertical-align: middle;
|
||||
margin-right: 4px;
|
||||
}
|
||||
.leg-created { background: #38bdf8; }
|
||||
.leg-resolved { background: #10b981; }
|
||||
|
||||
.canvas-wrap {
|
||||
width: 100%;
|
||||
position: relative;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
}
|
||||
.canvas-wrap canvas {
|
||||
width: 100% !important;
|
||||
max-height: 240px;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.analytics-subgrid {
|
||||
display: grid;
|
||||
grid-template-columns: 1.4fr 1fr;
|
||||
gap: 16px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
@media (max-width: 900px) {
|
||||
.analytics-subgrid { grid-template-columns: 1fr; }
|
||||
}
|
||||
.workload-card, .activity-card {
|
||||
background: rgba(12, 16, 26, 0.65);
|
||||
border: 1px solid rgba(255, 255, 255, 0.08);
|
||||
border-radius: 20px;
|
||||
padding: 20px;
|
||||
backdrop-filter: blur(14px);
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
|
||||
}
|
||||
.workload-card h3, .activity-card h3 {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
margin-bottom: 14px;
|
||||
color: var(--txt);
|
||||
}
|
||||
|
||||
.workload-table-wrap {
|
||||
overflow-x: auto;
|
||||
}
|
||||
.workload-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
font-size: 13px;
|
||||
}
|
||||
.workload-table th {
|
||||
text-align: left;
|
||||
padding: 8px 12px;
|
||||
color: var(--sub);
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.08);
|
||||
}
|
||||
.workload-table td {
|
||||
padding: 10px 12px;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.04);
|
||||
color: var(--txt);
|
||||
}
|
||||
.workload-user {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
.stat-pill {
|
||||
display: inline-block;
|
||||
padding: 2px 8px;
|
||||
border-radius: 10px;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.stat-pill.open { background: rgba(56, 189, 248, 0.15); color: #38bdf8; }
|
||||
.stat-pill.prog { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
|
||||
.stat-pill.done { background: rgba(16, 185, 129, 0.15); color: #34d399; }
|
||||
|
||||
.activity-stream-wrap {
|
||||
max-height: 380px;
|
||||
overflow-y: auto;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
padding-right: 6px;
|
||||
}
|
||||
.act-item {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
padding: 8px 0;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.04);
|
||||
font-size: 12px;
|
||||
}
|
||||
.act-body {
|
||||
flex: 1;
|
||||
}
|
||||
.act-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 3px;
|
||||
}
|
||||
.act-head strong { color: var(--txt); }
|
||||
.act-head span { color: var(--sub); font-size: 11px; }
|
||||
.act-text { color: var(--sub); line-height: 1.4; }
|
||||
|
||||
/* ── Admin Management ── */
|
||||
.admin-tabs-bar {
|
||||
margin: 16px 0;
|
||||
}
|
||||
.admin-users-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
background: rgba(12, 16, 26, 0.65);
|
||||
border: 1px solid rgba(255, 255, 255, 0.08);
|
||||
border-radius: 18px;
|
||||
overflow: hidden;
|
||||
font-size: 13px;
|
||||
}
|
||||
.admin-users-table th {
|
||||
text-align: left;
|
||||
padding: 12px 16px;
|
||||
color: var(--sub);
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
background: rgba(255, 255, 255, 0.02);
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.08);
|
||||
}
|
||||
.admin-users-table td {
|
||||
padding: 12px 16px;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.04);
|
||||
color: var(--txt);
|
||||
}
|
||||
.admin-role-select {
|
||||
background: rgba(255, 255, 255, 0.06);
|
||||
border: 1px solid rgba(255, 255, 255, 0.14);
|
||||
border-radius: 8px;
|
||||
color: var(--txt);
|
||||
padding: 4px 8px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
/* ── Command Palette (Cmd+K) ── */
|
||||
.cmd-palette-overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: rgba(0, 0, 0, 0.65);
|
||||
backdrop-filter: blur(16px);
|
||||
z-index: 1000;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
padding: 20px;
|
||||
}
|
||||
.cmd-palette-box {
|
||||
width: 100%;
|
||||
max-width: 580px;
|
||||
background: rgba(14, 18, 28, 0.95);
|
||||
border: 1px solid rgba(255, 255, 255, 0.16);
|
||||
border-radius: 20px;
|
||||
box-shadow: 0 24px 64px rgba(0, 0, 0, 0.9), 0 0 32px rgba(16, 185, 129, 0.15);
|
||||
overflow: hidden;
|
||||
}
|
||||
.cmd-palette-search {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 14px 18px;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.08);
|
||||
color: var(--sub);
|
||||
}
|
||||
.cmd-palette-search input {
|
||||
flex: 1;
|
||||
background: none;
|
||||
border: none;
|
||||
outline: none;
|
||||
color: var(--txt);
|
||||
font-size: 15px;
|
||||
}
|
||||
.cmd-palette-search kbd, .cmd-footer kbd, .shortcuts-content kbd {
|
||||
background: rgba(255, 255, 255, 0.08);
|
||||
border: 1px solid rgba(255, 255, 255, 0.15);
|
||||
border-radius: 4px;
|
||||
padding: 2px 6px;
|
||||
font-size: 11px;
|
||||
font-family: inherit;
|
||||
color: var(--sub);
|
||||
}
|
||||
.cmd-results-list {
|
||||
max-height: 340px;
|
||||
overflow-y: auto;
|
||||
padding: 8px;
|
||||
}
|
||||
.cmd-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 10px 14px;
|
||||
border-radius: 12px;
|
||||
cursor: pointer;
|
||||
transition: all 0.15s;
|
||||
font-size: 13px;
|
||||
color: var(--txt);
|
||||
}
|
||||
.cmd-item:hover, .cmd-item.active {
|
||||
background: rgba(16, 185, 129, 0.15);
|
||||
color: #34d399;
|
||||
}
|
||||
.cmd-item-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
.cmd-item-type {
|
||||
font-size: 11px;
|
||||
color: var(--sub);
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
padding: 2px 6px;
|
||||
border-radius: 6px;
|
||||
}
|
||||
.cmd-footer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: 16px;
|
||||
padding: 10px 18px;
|
||||
border-top: 1px solid rgba(255, 255, 255, 0.06);
|
||||
font-size: 11px;
|
||||
color: var(--sub);
|
||||
}
|
||||
|
||||
/* ── Keyboard Shortcuts Modal ── */
|
||||
.shortcuts-box {
|
||||
max-width: 480px;
|
||||
padding: 20px;
|
||||
}
|
||||
.shortcuts-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.shortcuts-header h3 { font-size: 16px; color: var(--txt); }
|
||||
.shortcuts-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
.sc-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 6px 0;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.04);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
/* ── Loading Skeletons & Empty States ── */
|
||||
@keyframes shimmer {
|
||||
0% { background-position: -400px 0; }
|
||||
100% { background-position: 400px 0; }
|
||||
}
|
||||
.skeleton-card {
|
||||
height: 120px;
|
||||
border-radius: 16px;
|
||||
background: linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.03) 75%);
|
||||
background-size: 800px 100%;
|
||||
animation: shimmer 1.5s infinite linear;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.empty-state {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 60px 20px;
|
||||
text-align: center;
|
||||
color: var(--sub);
|
||||
}
|
||||
.empty-state svg {
|
||||
margin-bottom: 14px;
|
||||
color: rgba(255, 255, 255, 0.2);
|
||||
}
|
||||
.empty-state h4 {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: var(--txt);
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
.empty-state p {
|
||||
font-size: 13px;
|
||||
max-width: 320px;
|
||||
line-height: 1.4;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user