File size: 5,622 Bytes
5a81b95
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29da98c
 
 
 
 
 
 
5a81b95
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
import { ExternalLink, Info } from 'lucide-react';
import {
  Tooltip,
  TooltipContent,
  TooltipTrigger,
} from '@/components/ui/tooltip';
import { cn } from '@/lib/utils';

export interface DataSource {
  id: string;
  name: string;
  url?: string;
  lastUpdated?: string;
  description?: string;
}

interface SourceLinkProps {
  source: DataSource;
  variant?: 'icon' | 'text' | 'badge';
  className?: string;
}

const SourceLink = ({ source, variant = 'icon', className }: SourceLinkProps) => {
  const handleClick = (e: React.MouseEvent) => {
    e.stopPropagation();
    if (source.url) {
      window.open(source.url, '_blank', 'noopener,noreferrer');
    }
  };

  const content = (
    <div className="space-y-2 max-w-xs">
      <div className="flex items-center gap-2">
        <span className="font-mono text-xs text-primary font-semibold">{source.name}</span>
        {source.url && <ExternalLink className="w-3 h-3 text-primary" />}
      </div>
      {source.description && (
        <p className="text-xs text-muted-foreground">{source.description}</p>
      )}
      {source.lastUpdated && (
        <p className="text-[10px] text-muted-foreground/70">
          Sidst opdateret: {source.lastUpdated}
        </p>
      )}
      {source.url && (
        <p className="text-[10px] text-primary/70">Klik for at åbne kilde</p>
      )}
    </div>
  );

  if (variant === 'badge') {
    return (
      <Tooltip>
        <TooltipTrigger asChild>
          <button
            onClick={handleClick}
            className={cn(
              "inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[8px] font-mono",
              "bg-primary/10 text-primary/70 hover:bg-primary/20 hover:text-primary",
              "transition-colors cursor-pointer border border-primary/20",
              className
            )}
          >
            <Info className="w-2.5 h-2.5" />
            KILDE
          </button>
        </TooltipTrigger>
        <TooltipContent side="top" className="bg-card border-primary/30">
          {content}
        </TooltipContent>
      </Tooltip>
    );
  }

  if (variant === 'text') {
    return (
      <Tooltip>
        <TooltipTrigger asChild>
          <button
            onClick={handleClick}
            className={cn(
              "inline-flex items-center gap-1 text-[9px] font-mono",
              "text-muted-foreground/50 hover:text-primary",
              "transition-colors cursor-pointer underline-offset-2 hover:underline",
              className
            )}
          >
            <span>{source.name}</span>
            <ExternalLink className="w-2.5 h-2.5" />
          </button>
        </TooltipTrigger>
        <TooltipContent side="top" className="bg-card border-primary/30">
          {content}
        </TooltipContent>
      </Tooltip>
    );
  }

  // Default: icon variant
  return (
    <Tooltip>
      <TooltipTrigger asChild>
        <button
          onClick={handleClick}
          className={cn(
            "inline-flex items-center justify-center w-4 h-4 rounded-full",
            "bg-primary/10 text-primary/50 hover:bg-primary/20 hover:text-primary",
            "transition-colors cursor-pointer",
            className
          )}
        >
          <Info className="w-2.5 h-2.5" />
        </button>
      </TooltipTrigger>
      <TooltipContent side="top" className="bg-card border-primary/30">
        {content}
      </TooltipContent>
    </Tooltip>
  );
};

export default SourceLink;

// Common data sources for the platform
export const dataSources: Record<string, DataSource> = {
  systemMetrics: {
    id: 'system-metrics',
    name: 'System Metrics API',
    url: 'https://api.cyberterm.io/metrics',
    lastUpdated: new Date().toLocaleString('da-DK'),
    description: 'Real-time system performance data fra intern overvågning'
  },
  userAnalytics: {
    id: 'user-analytics',
    name: 'User Analytics',
    url: 'https://analytics.cyberterm.io',
    lastUpdated: new Date().toLocaleString('da-DK'),
    description: 'Brugerstatistik og engagement metrics'
  },
  securityLog: {
    id: 'security-log',
    name: 'Security Log',
    url: 'https://security.cyberterm.io/logs',
    lastUpdated: new Date().toLocaleString('da-DK'),
    description: 'Sikkerhedslogfiler og trusselsvurderinger'
  },
  networkStatus: {
    id: 'network-status',
    name: 'Network Monitor',
    url: 'https://network.cyberterm.io/status',
    lastUpdated: new Date().toLocaleString('da-DK'),
    description: 'Netværksstatus og forbindelsesdata'
  },
  cryptoMarket: {
    id: 'crypto-market',
    name: 'CoinGecko API',
    url: 'https://www.coingecko.com',
    lastUpdated: new Date().toLocaleString('da-DK'),
    description: 'Cryptocurrency markedsdata'
  },
  weatherApi: {
    id: 'weather-api',
    name: 'OpenWeather',
    url: 'https://openweathermap.org',
    lastUpdated: new Date().toLocaleString('da-DK'),
    description: 'Vejrdata og prognoser'
  },
  internalDb: {
    id: 'internal-db',
    name: 'Intern Database',
    url: 'https://db.cyberterm.io',
    lastUpdated: new Date().toLocaleString('da-DK'),
    description: 'Intern datalagring og registre'
  },
  aiEngine: {
    id: 'ai-engine',
    name: 'AI Analysis Engine',
    url: 'https://ai.cyberterm.io',
    lastUpdated: new Date().toLocaleString('da-DK'),
    description: 'Machine learning baserede analyser'
  },
  threatIntel: {
    id: 'threat-intel',
    name: 'Threat Intelligence Feed',
    url: 'https://threatintel.cyberterm.io',
    lastUpdated: new Date().toLocaleString('da-DK'),
    description: 'Real-time trussel information og IOC feeds'
  },
};