Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | <script lang="ts" setup>
import { CircleArrowLeft, Loader2, Users, Settings, Terminal, ChevronDown, Trash2, GitBranch, User, Calendar, Clock, Package, AlertCircle, CheckCircle, XCircle, StopCircle, Flame, Copy, Check, Send, PauseCircle, PlayCircle, RefreshCw, Server, Network, Shield } from 'lucide-vue-next'
import BaseButton from '@/components/ui/BaseButton.vue'
import Modal from '@/components/ui/Modal.vue'
import { useRoute, useRouter } from 'vue-router'
import { useDeploymentStore } from '@/stores/deployment.store'
import { useAuthStore } from '@/stores/auth.store'
import { useRole } from '@/composables/useRole'
import { useToastStore } from '@/stores/toast.store'
import { ref, computed, onMounted, onBeforeUnmount, watch } from 'vue'
import { useI18n } from 'vue-i18n'
import { taskApi } from '@/api/task.api'
import { deploymentApi } from '@/api/deployment.api'
import type { Task, DeploymentResource } from '@/types'
import { useDeploymentStream } from '@/composables/useDeploymentStream'
import InfrastructureVmCard from '@/components/InfrastructureVmCard.vue'
import InfrastructureVmDrawer from '@/components/InfrastructureVmDrawer.vue'
import MarkdownRenderer from '@/components/MarkdownRenderer.vue'
import { Eye, EyeOff } from 'lucide-vue-next' // Stelle sicher, dass die Icons importiert sind
// Zustand für die Passwort-Sichtbarkeit (Key ist der Index/Key des Accounts)
const visiblePasswords = ref<Record<string | number, boolean>>({})
const togglePasswordVisibility = (key: string | number) => {
visiblePasswords.value[key] = !visiblePasswords.value[key]
}
// Build a copy-paste SSH command from an account. Skips ``-p`` for the
// default port 22 so the line stays short for the common case.
const sshCommandFor = (data: { username?: string; ip?: string; port?: number }): string => {
if (!data.username || !data.ip) return ''
const portFlag = data.port && data.port !== 22 ? `-p ${data.port} ` : ''
return `ssh ${portFlag}${data.username}@${data.ip}`
}
const route = useRoute()
const router = useRouter()
const deploymentStore = useDeploymentStore()
const authStore = useAuthStore()
const { isStaff } = useRole()
const toastStore = useToastStore()
const { t } = useI18n()
const tasks = ref<Task[]>([])
const loadingTasks = ref(false)
const selectedTask = ref<Task | null>(null)
//NEU
const latestTaskOutputs = ref<Task | null>(null)
// Liefert immer den aktuell aktiven Daten-Task für die UI-Blöcke
const activeDataTask = computed(() => selectedTask.value || latestTaskOutputs.value)
const loadingTaskDetail = ref(false)
const deploymentId = route.params.id as string
const deployment = computed(() => deploymentStore.currentDeployment)
// Interface für die Struktur eines einzelnen Accounts
interface UserAccount {
username: string
team: string
ip: string
port: number
auth: string
authtype?: 'ssh' | 'url' | string
url?: string
}
const typedUserAccounts = computed<Record<string, UserAccount> | null>(() => {
const currentTarget = selectedTask.value || latestTaskOutputs.value
const rawOutputs = currentTarget?.outputs
if (!rawOutputs) return null
let outputsObj: any = rawOutputs
// Fall 1: Outputs kommen als JSON-String aus der Text-Spalte der DB
if (typeof rawOutputs === 'string') {
try {
const trimmed = rawOutputs.trim()
if (trimmed.startsWith('{')) {
outputsObj = JSON.parse(trimmed)
}
} catch (e) {
console.error('Fehler beim Parsen der Outputs-Rohdaten:', e)
return null
}
}
// Fall 2: Es ist bereits ein Objekt (oder wurde oben erfolgreich geparst)
if (outputsObj && typeof outputsObj === 'object' && 'user_accounts' in outputsObj) {
const userAccountsContainer = outputsObj.user_accounts
// Sicherstellen, dass wir an das .value-Objekt von Terraform herankommen
if (userAccountsContainer && userAccountsContainer.value) {
console.log("=== TERRAFORM USER ACCOUNTS OUTPUT ===", userAccountsContainer.value)
return userAccountsContainer.value as Record<string, UserAccount>
}
}
return null
})
const enrichedTeams = computed(() => {
const currentDeployment = deployment && 'value' in deployment
? deployment.value
: deployment;
if (!currentDeployment?.teams) return [];
const accounts = typedUserAccounts && 'value' in typedUserAccounts
? typedUserAccounts.value
: typedUserAccounts;
// Team-level VM metadata from terraform's ``team_vms`` output. Apps
// that serve a Web-UI publish ``url`` here; SSH-only apps don't.
// We surface that as ``team.vm`` so the template can decide between
// a URL pill and an SSH-command pill per team.
const teamVms = extractTeamVms()
// Resolve member ↔ account.
//
// The canonical contract is the ``user_accounts`` MAP KEY. Every
// app template we ship (Online-IDE, pgAdmin, etc.) constructs the
// key the same way:
//
// key = "<team>-" + email.split("@")[0].replace(".", "-")
//
// i.e. ``team-name + "-" + sanitised-email-local-part``. Because
// we have the member's email and team on the backend side, we can
// reproduce that key deterministically and skip all heuristics.
//
// The value's ``username`` field is NOT a reliable identifier:
// Online-IDE writes the email's local-part there (per-member
// credential), pgAdmin writes a synthetic team-wide pseudo-email
// (``team-1@example.com``, shared by every member of the team).
// Older heuristics that compared keycloak ``member.username`` to
// either field broke whenever those diverged (e.g. keycloak user
// ``okann`` with email ``okso2004@gmail.com``).
//
// We index by key once and look up the derived key per member.
// Three legacy fallbacks survive for templates we haven't seen
// yet, but on every current template the derived-key strategy
// resolves on the first try.
const accountByEmail = new Map<string, { key: string; data: UserAccount }>()
const accountByUsername = new Map<string, { key: string; data: UserAccount }>()
const accountByKey = new Map<string, { key: string; data: UserAccount }>()
if (accounts) {
for (const [key, acc] of Object.entries(accounts)) {
const candidate = acc?.username?.trim().toLowerCase()
if (candidate && candidate.includes('@')) {
accountByEmail.set(candidate, { key, data: acc })
} else if (candidate) {
accountByUsername.set(candidate, { key, data: acc })
}
accountByKey.set(key.trim().toLowerCase(), { key, data: acc })
}
}
// Mirror the terraform key sanitisation: lowercase the local-part
// and replace dots with dashes. Only dots — terraform's
// ``replace(local_part, ".", "-")`` does not touch other characters.
const deriveExpectedKey = (teamName: string, email: string | undefined): string | null => {
if (!email) return null
const localPart = email.split('@')[0]
if (!localPart) return null
const sanitised = localPart.replace(/\./g, '-').toLowerCase()
return `${teamName.trim().toLowerCase()}-${sanitised}`
}
return currentDeployment.teams.map(team => {
const vm = teamVms?.[team.name] ?? null
const teamNameLower = team.name.trim().toLowerCase()
return {
...team,
vm,
members: team.members.map(member => {
const memberEmail = member?.email?.trim().toLowerCase()
const memberName = member?.username?.trim().toLowerCase()
// Strategy 0 (canonical): derive the terraform key from
// member.email + team.name and look it up directly.
let hit: { key: string; data: UserAccount } | undefined
const expectedKey = deriveExpectedKey(team.name, memberEmail)
if (expectedKey) hit = accountByKey.get(expectedKey)
// Strategy 1: email-based (templates that write the
// member's full email into ``account.username``).
if (!hit && memberEmail) hit = accountByEmail.get(memberEmail)
// Strategy 2: username substring against account.username
if (!hit && memberName) {
for (const [accUser, entry] of accountByUsername) {
if (accUser.includes(memberName) || memberName.includes(accUser)) {
hit = entry
break
}
}
}
// Strategy 3: username substring against the account key
// (``Team #1-leon-priemer`` etc.). Last-resort fallback
// for templates where ``account.username`` is missing
// and the keycloak username happens to match the slug.
if (!hit && memberName) {
for (const [accKey, entry] of accountByKey) {
if (accKey.includes(memberName)) {
hit = entry
break
}
}
}
// Team scope guard so an account from team A can't be
// attached to a member of team B.
const accountTeam = hit?.data.team?.trim().toLowerCase()
const keyLower = hit?.key.trim().toLowerCase()
const teamMatches = hit && (
accountTeam === teamNameLower ||
(keyLower?.startsWith(`${teamNameLower}-`) ?? false) ||
(keyLower?.includes(teamNameLower) ?? false)
)
return {
...member,
account: teamMatches ? hit : null
};
})
};
});
});
/**
* Pull the ``team_vms`` object out of the active task's outputs. Same
* unwrap chain as ``typedUserAccounts`` — the outputs may arrive as a
* raw JSON string from the DB or as an already-parsed object, and the
* actual map sits under ``.value`` because Terraform stamps the output
* shape on the wrapper. Returns ``null`` if anything along the way
* isn't there.
*/
function extractTeamVms(): Record<string, { url?: string; floating_ip?: string; fixed_ip?: string }> | null {
const currentTarget = selectedTask.value || latestTaskOutputs.value
const rawOutputs = currentTarget?.outputs
if (!rawOutputs) return null
let outputsObj: any = rawOutputs
if (typeof rawOutputs === 'string') {
try {
const trimmed = rawOutputs.trim()
if (trimmed.startsWith('{')) outputsObj = JSON.parse(trimmed)
} catch {
return null
}
}
const vms = outputsObj?.team_vms?.value
return vms && typeof vms === 'object' ? vms : null
}
// Zählt die Ressourcen im State für die kleine Sub-Headline im Header
const tfResourcesCount = computed(() => {
const state = selectedTask.value?.tf_state
if (!state) return 0
try {
const parsed = typeof state === 'string' ? JSON.parse(state) : state
return parsed?.resources?.length || 0
} catch {
return 0
}
})
// Leichtgewichtiges und sicheres Syntax Highlighting für JSON
const highlightJson = (jsonString: string): string => {
if (!jsonString) return ''
let safeStr = jsonString
.replace(/&/g, '&')
.replace(/</g, '<')
.replace(/>/g, '>')
return safeStr.replace(
/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?)/g,
(match) => {
let cls = 'text-amber-400'
if (/^"/.test(match)) {
if (/:$/.test(match)) {
cls = 'text-blue-500 font-medium' // Keys (Blau)
} else {
cls = 'text-emerald-500' // String-Werte (Grün)
}
} else if (/true|false/.test(match)) {
cls = 'text-purple-500 font-bold' // Booleans (Lila)
} else if (/null/.test(match)) {
cls = 'text-gray-500 italic' // Null (Grau)
} else {
cls = 'text-cyan-500' // Zahlen (Cyan)
}
return `<span class="${cls}">${match}</span>`
}
)
}
// Owner-view vs member-view — mirrors backend/app/utils/permissions.py
// ``is_deployment_owner_view``. Drives every gated UI element on
// this page: tasks/logs sections, terraform-state/outputs blocks,
// the Delete button, the SSE live-stream connection, and the
// resend-credentials buttons of *other* members in the same team.
//
// We trust the backend on the source-of-truth side (it returns 403
// or filters data when the caller isn't owner-view); this computed
// just hides the affordances so the user doesn't see buttons that
// would 403 on click.
const isOwnerView = computed(() => {
if (isStaff.value) return true
const ownerId = deployment.value?.userId
return !!ownerId && String(ownerId) === String(authStore.userId)
})
// ----------------------------------------------------------------
// INFRASTRUCTURE TAB — Stage-1 list + Stage-2 drawer + redeploy
// ----------------------------------------------------------------
//
// State for the resource panel sits on the page (not in a Pinia
// store) because it's strictly per-deployment and we want it to
// reset on navigation. The list view polls gently when the latest
// task is idle and refreshes once when a task transitions to
// success/failed; the drawer fetches lazy.
const resources = ref<DeploymentResource[]>([])
const resourcesLoading = ref(false)
const resourcesError = ref<string | null>(null)
// Addresses currently waiting on a redeploy task. Used both to
// disable the button on the card and to know we should refetch the
// list as soon as the task finishes.
const redeployInFlight = ref<Set<string>>(new Set())
// Address of the VM whose detail drawer is currently open. ``null``
// means the drawer is closed; the drawer component lazy-loads on
// mount, so toggling this prop is enough.
const openDrawerAddress = ref<string | null>(null)
const loadResources = async (refresh = true) => {
if (!isOwnerView.value) return
resourcesLoading.value = true
resourcesError.value = null
try {
const response = await deploymentApi.listResources(deploymentId, { refresh })
resources.value = response.data.resources
} catch (err: any) {
const status = err?.response?.status
if (status === 412) {
resourcesError.value = t('vm.resourcesErrors.missingCredentials')
} else if (status === 502) {
resourcesError.value = t('vm.resourcesErrors.unreachable')
} else if (status === 404) {
// Deployment wurde upstream soft-deleted (z.B. unmittelbar
// nach einem erfolgreichen Destroy, während die Detail-
// Seite noch offen ist). Resources sind dann definitiv
// weg; ein roter Error-Banner ist Symptom-statt-Ursache.
// Den ``gone``-Pfad übernimmt der Stream-Watcher; hier
// einfach silent leeren.
resources.value = []
} else {
resourcesError.value = err?.message || t('vm.resourcesErrors.generic')
}
} finally {
resourcesLoading.value = false
}
}
// Separate compute groups for the three sub-sections.
const vmResources = computed(() => resources.value.filter(r => r.category === 'instance'))
const networkResources = computed(() => resources.value.filter(
r => r.category === 'network' || r.category === 'subnet' || r.category === 'floating_ip'
))
const securityResources = computed(() => resources.value.filter(r => r.category === 'security_group'))
// Click on the card's "Details" button toggles the inline panel:
// open if a different card is currently shown (or none), close if the
// same card is already expanded. Matches accordion semantics — only
// one VM detail is visible at a time.
const openVmDrawer = (address: string) => {
if (openDrawerAddress.value === address) {
openDrawerAddress.value = null
} else {
openDrawerAddress.value = address
}
}
const closeVmDrawer = () => {
openDrawerAddress.value = null
}
// Redeploy is a two-step UX: the VmCard's "Redeploy" button emits
// ``@redeploy`` with an address, which opens a confirmation Modal
// (same pattern as Delete). The actual API call lives in
// ``executeRedeploy`` so the Modal's confirm button can call it
// without re-doing the address-extraction.
const redeployVm = (address: string) => {
if (redeployInFlight.value.has(address)) return
redeployTargetAddress.value = address
showRedeployModal.value = true
}
const executeRedeploy = async (address: string) => {
redeployInFlight.value.add(address)
try {
await deploymentApi.redeployResource(deploymentId, address)
toastStore.success(`Redeploy gestartet für ${address}`)
// Refresh the task list right away so the freshly-dispatched
// REDEPLOY row shows up as the new ``activeTask``. That in
// turn flips ``isStreamRelevant`` to true → the SSE stream
// attaches → live progress + logs render under the page's
// existing active-task card, identical to deploy/destroy.
// Without this poll, the new task only becomes visible on
// the next manual page reload.
await loadTasks()
} catch (err: any) {
redeployInFlight.value.delete(address)
const detail = err?.response?.data?.detail
const reason = detail?.reason
if (reason === 'non_redeployable_resource_type') {
toastStore.error('Nur Compute-Instanzen können einzeln redeployed werden.')
} else if (reason === 'resource_not_in_state') {
toastStore.error('Diese Resource ist nicht mehr im aktuellen State.')
} else if (err?.response?.status === 409) {
toastStore.error('Es läuft bereits eine Lifecycle-Aktion für dieses Deployment.')
} else {
toastStore.error(err?.message || 'Redeploy fehlgeschlagen.')
}
}
}
// Lifecycle action gating — the action bar exposes Delete plus a
// dynamic Pause/Resume button. The backend picks the right Delete
// behaviour (terraform destroy + soft-delete vs. straight soft-delete)
// based on status, so the frontend just surfaces availability.
// Mirrors backend/app/services/lifecycle.py:
// * success → Delete (dispatches Destroy), Pause
// * paused → Delete (dispatches Destroy), Resume
// * pause_failed → Delete, Pause-Retry, Resume
// * resume_failed → Delete, Resume-Retry, Pause
// * failed → Delete (Destroy or soft-delete)
// * cancelled → Delete (soft-delete)
// * pending / running / destroying / pausing / resuming → 409, all disabled
//
// Members can never act on lifecycle; the action-bar hides the
// buttons entirely for them rather than rendering permanently-disabled
// controls.
const DELETE_STATUSES = [
'success', 'failed', 'cancelled', 'paused', 'pause_failed', 'resume_failed',
]
const canDelete = computed(() => {
if (!isOwnerView.value) return false
return DELETE_STATUSES.includes(deployment.value?.status ?? '')
})
const deleteDisabledReason = computed(() => {
if (canDelete.value) return ''
return `Delete available when status is ${DELETE_STATUSES.join(', ')}`
})
// One Pause/Resume button — what it does depends on status. Most
// common case: ``success`` → Pause; ``paused`` → Resume. Failure
// states (pause_failed / resume_failed) also expose a retry that
// matches what just broke. Anything else hides it entirely.
const canPause = computed(() => {
if (!isOwnerView.value) return false
const s = deployment.value?.status
return s === 'success' || s === 'pause_failed' || s === 'resume_failed'
})
const canResume = computed(() => {
if (!isOwnerView.value) return false
const s = deployment.value?.status
return s === 'paused' || s === 'pause_failed' || s === 'resume_failed'
})
const canPauseOrResume = computed(() => canPause.value || canResume.value)
const pauseResumeAction = computed<'pause' | 'resume' | null>(() => {
// Prefer the action that matches the steady-state semantic of
// the current status: from ``success`` we pause, from ``paused``
// we resume. From the failure states we pick the retry that
// matches what just broke.
const s = deployment.value?.status
if (s === 'success' || s === 'pause_failed') return 'pause'
if (s === 'paused' || s === 'resume_failed') return 'resume'
return null
})
const showDeleteModal = ref(false)
// Per-VM redeploy confirmation. Mirrors the Delete-modal pattern, but
// the action targets a single resource (identified by its TF state
// address), so we also remember which VM the user clicked while the
// modal is open.
const showRedeployModal = ref(false)
const redeployTargetAddress = ref<string | null>(null)
const showPauseResumeModal = ref(false)
const pauseResumeBusy = ref(false)
onMounted(async () => {
await deploymentStore.fetchDeploymentById(deploymentId)
await loadTasks() // Lädt die Historie in tasks.value
// Wenn Tasks vorhanden sind, holen wir uns die Outputs des neuesten Tasks für oben
if (tasks.value && tasks.value.length > 0) {
const sortedTasks = [...tasks.value].sort((a, b) =>
b.created_at.localeCompare(a.created_at)
)
const latestTask = sortedTasks[0]
if (latestTask) {
// Wir holen die Details direkt von der API und packen sie in die neue Variable
try {
const { data } = await taskApi.getById(latestTask.taskId)
latestTaskOutputs.value = data
} catch (err) {
console.error('Error seeding top outputs:', err)
}
}
}
// Fire the resource load in parallel — it's a separate roundtrip
// (OpenStack live-fetch can take ~1s) and the page should render
// its other panels while it's in flight.
loadResources()
// Wenn Tasks vorhanden sind, holen wir uns die Outputs des neuesten Tasks für oben
if (tasks.value && tasks.value.length > 0) {
const sortedTasks = [...tasks.value].sort((a, b) =>
b.created_at.localeCompare(a.created_at)
)
const latestTask = sortedTasks[0]
if (latestTask) {
// Wir holen die Details direkt von der API und packen sie in die neue Variable
try {
const { data } = await taskApi.getById(latestTask.taskId)
latestTaskOutputs.value = data
} catch (err) {
console.error('Error seeding top outputs:', err)
}
}
}
})
const loadTasks = async () => {
// Members can't read tasks (backend returns 403 for the
// owner-only endpoint). Skip the call entirely so the network
// tab stays clean and the UI doesn't briefly flicker a loader
// for data we'll never receive.
if (!isOwnerView.value) {
tasks.value = []
return
}
loadingTasks.value = true
try {
const { data } = await taskApi.listByDeployment(deploymentId)
tasks.value = data
} catch (err) {
console.error('Error loading tasks:', err)
} finally {
loadingTasks.value = false
}
}
// ----------------------------------------------------------------
// LIVE STREAM (progress bar + log tail)
// ----------------------------------------------------------------
//
// We attach the SSE stream once we know the deployment ID and keep it
// open until the task reaches a terminal state. The composable
// auto-reconnects on transient errors and exposes ``connectionState``
// for a small status badge.
//
// Refs are destructured out of the composable so Vue's template
// auto-unwrap recognises them as top-level setup bindings — without
// destructuring, ``stream.currentPhase`` in the template would be the
// ref *object*, not the string, and downstream calls like
// ``phase.split(...)`` would crash.
const deploymentIdRef = computed(() => deploymentId)
const {
progress: streamProgress,
currentPhase: streamCurrentPhase,
currentPhaseIndex: streamCurrentPhaseIndex,
totalPhases: streamTotalPhases,
phaseNames: streamPhaseNames,
liveLogs: streamLiveLogs,
totalLogCount: streamTotalLogCount,
connectionState: streamConnectionState,
start: startStream,
stop: stopStream,
} = useDeploymentStream(deploymentIdRef)
const activeTask = computed<Task | null>(() => {
if (!tasks.value.length) return null
// The "active" task is the one we still expect events from.
// Fall back to the latest task by created_at if all are terminal —
// its progress columns may still be useful for context.
const sorted = [...tasks.value].sort((a, b) => b.created_at.localeCompare(a.created_at))
return sorted.find((t) => t.status === 'pending' || t.status === 'running') ?? sorted[0] ?? null
})
const isStreamRelevant = computed(() => {
// Members never get the live stream — backend would 403 the SSE
// endpoint anyway, the gate here just keeps the UI from poking
// at it. Owners see the stream while there's an active task.
if (!isOwnerView.value) return false
return activeTask.value?.status === 'pending' || activeTask.value?.status === 'running'
})
// True while the deployment (or its active task) is still moving. The
// resend-access button reads this to stay disabled until the run is
// terminal — otherwise an operator could mail credentials before the
// VMs/services they point at are reachable.
const isDeploymentBusy = computed(() => {
const dStatus = deployment.value?.status
if (dStatus === 'pending' || dStatus === 'running') return true
const tStatus = activeTask.value?.status
return tStatus === 'pending' || tStatus === 'running'
})
// Tasks that aren't the currently running one. Shown as the history
// list below the active-task card so the running task isn't rendered
// twice (once in the live block, once in the static list).
const historyTasks = computed<Task[]>(() => {
const active = activeTask.value
const list = [...tasks.value].sort((a, b) => b.created_at.localeCompare(a.created_at))
if (!active || !isStreamRelevant.value) return list
return list.filter((t) => t.taskId !== active.taskId)
})
// Phase stepper — N dots based on the live ``totalPhases`` reported by
// the worker. Phase names live in the worker (different sets for
// deploy/destroy), so the frontend stays task-type-agnostic for the
// dot count. We do keep label tables for the deploy/destroy presets
// here so the stepper renders meaningful labels under each dot when
// the worker's totals match a known shape; an unknown count falls
// back to numbered labels (``1``..``N``) instead of empty space.
//
// Default to a conservative 11-dot view before the first event arrives
// so the layout doesn't jump when the worker first reports its real
// phase count (which could be 8 for deploy-without-packer or 7 for
// destroy).
const DEFAULT_PHASE_COUNT = 11
const PHASE_LABELS_DEPLOY_FULL = [
'STARTING',
'OPENSTACK_SETUP',
'GIT_CLONE',
'CREDS_MATERIALISE',
'PACKER_INIT',
'PACKER_VALIDATE',
'PACKER_BUILD',
'TERRAFORM_INIT',
'TERRAFORM_PLAN',
'TERRAFORM_APPLY',
'OUTPUTS_AND_CLEANUP',
] as const
const PHASE_LABELS_DEPLOY_NO_PACKER = [
'STARTING',
'OPENSTACK_SETUP',
'GIT_CLONE',
'CREDS_MATERIALISE',
'TERRAFORM_INIT',
'TERRAFORM_PLAN',
'TERRAFORM_APPLY',
'OUTPUTS_AND_CLEANUP',
] as const
const PHASE_LABELS_DESTROY = [
'STARTING',
'OPENSTACK_SETUP',
'GIT_CLONE',
'CREDS_MATERIALISE',
'TERRAFORM_INIT',
'TERRAFORM_DESTROY',
'CLEANUP',
] as const
// Pause/Resume share the destroy preamble (clone + clouds + tf init
// to be able to state-pull) but their hot phase is a CLI-driven
// server stop/start, NOT a terraform destroy. Same length as
// ``PHASE_LABELS_DESTROY`` (7) — that's the bug a previous version
// of ``phaseStepLabel`` ran into when it picked the table by length
// alone and silently rendered "TERRAFORM DESTROY" while the worker
// emitted a "Server Stop" header. The fix below picks tables by
// task type first and only falls back to length-matching if the
// type is unknown (e.g. live-stream attached before tasks were
// loaded).
const PHASE_LABELS_PAUSE = [
'STARTING',
'OPENSTACK_SETUP',
'GIT_CLONE',
'CREDS_MATERIALISE',
'TERRAFORM_INIT',
'SERVER_STOP',
'CLEANUP',
] as const
const PHASE_LABELS_RESUME = [
'STARTING',
'OPENSTACK_SETUP',
'GIT_CLONE',
'CREDS_MATERIALISE',
'TERRAFORM_INIT',
'SERVER_START',
'CLEANUP',
] as const
// Per-VM redeploy reuses the destroy preamble (clone, clouds.yaml,
// init) and then runs ``terraform apply -replace=… -target=…`` for
// the single targeted resource. Phase shape mirrors
// ``worker/app/tasks.py:_PHASES_REDEPLOY``.
const PHASE_LABELS_REDEPLOY = [
'STARTING',
'OPENSTACK_SETUP',
'GIT_CLONE',
'CREDS_MATERIALISE',
'TERRAFORM_INIT',
'TERRAFORM_APPLY',
'CLEANUP',
] as const
// Stepper-Labels: der Worker schickt mit jedem Progress-Event die
// volle Phase-Sequenz als ``phase_names`` mit (siehe ``StructuredLogger
// .progress()``). Das ist die einzige authoritative Quelle, weil
// Multi-Image-Deploys eine dynamische Sequenz haben, deren Template-
// Keys das Frontend nicht raten kann.
//
// Vor dem ersten Progress-Event (Page-Load mitten in einer langen
// Phase, oder bevor der Worker das erste Mal "STARTING" emittiert
// hat) fallen wir auf die statischen Tabellen unten zurück — sie
// decken die fixen Legacy-Shapes (Single-Image-Deploy / Destroy /
// Pause / Resume / Redeploy) korrekt ab. Wir RATEN nichts mehr für
// Multi-Image: solange ``phase_names`` leer ist, zeigt der Stepper
// dort nur die fixen Vorphasen plus generische Slot-Nummern für
// die noch nicht offenbarten Packer-Trios.
const phaseStepCount = computed<number>(() => {
return streamTotalPhases.value > 0 ? streamTotalPhases.value : DEFAULT_PHASE_COUNT
})
// Return the label for a given 0-based index. Order of precedence:
// 1. ``streamPhaseNames`` — authoritative, ships from the worker on
// every progress event for every real task (deploy / destroy /
// pause / resume / redeploy). Contains the exact phase names
// including ``:<template_key>`` suffixes for multi-image builds.
// 2. Static table picked by ``activeTask.type`` — used in the brief
// window between page-load and the first progress event, and
// always for legacy Single-Image-Deploy where the worker's
// sequence is byte-identical to ``PHASE_LABELS_DEPLOY_FULL``.
// 3. Numeric slot index — empty-slot guard so the stepper height
// doesn't collapse during the loading flicker.
const phaseStepLabel = (idx: number): string => {
// 1. Worker-authoritative list.
const fromStream = streamPhaseNames.value
if (Array.isArray(fromStream) && idx >= 0 && idx < fromStream.length) {
return phaseLabel(fromStream[idx])
}
// 2. Static fallback by active task type. Used until the first
// progress event lands.
let table: readonly string[] | null = null
const activeType = activeTask.value?.type
if (activeType === 'pause') {
table = PHASE_LABELS_PAUSE
} else if (activeType === 'resume') {
table = PHASE_LABELS_RESUME
} else if (activeType === 'destroy') {
table = PHASE_LABELS_DESTROY
} else if (activeType === 'redeploy') {
table = PHASE_LABELS_REDEPLOY
} else if (activeType === 'deploy') {
// Without the worker's ``phase_names`` we can't tell legacy
// (11) apart from multi-image (14, 17, ...). The total is
// already known from the stream though, so pick the matching
// table when it fits exactly — otherwise leave ``table = null``
// and let the loop fall through to numeric slot indices.
// Once the first progress event arrives, ``phase_names`` takes
// over and the predicted slots are replaced with real labels.
if (streamTotalPhases.value === PHASE_LABELS_DEPLOY_NO_PACKER.length) {
table = PHASE_LABELS_DEPLOY_NO_PACKER
} else if (streamTotalPhases.value === PHASE_LABELS_DEPLOY_FULL.length) {
table = PHASE_LABELS_DEPLOY_FULL
}
}
// Length-based last resort (no active task type known yet).
if (!table) {
const total = streamTotalPhases.value
if (total === PHASE_LABELS_DEPLOY_FULL.length) table = PHASE_LABELS_DEPLOY_FULL
else if (total === PHASE_LABELS_DEPLOY_NO_PACKER.length) table = PHASE_LABELS_DEPLOY_NO_PACKER
else if (total === PHASE_LABELS_DESTROY.length) table = PHASE_LABELS_DESTROY
}
if (table && idx >= 0 && idx < table.length) {
return phaseLabel(table[idx])
}
// 3. Numeric placeholder so the slot has a non-empty label.
return String(idx + 1)
}
// 0-based index of the active dot. Prefer the worker's authoritative
// ``phase_index`` (1-based) from the SSE payload — only fall back to
// rounding ``progress_pct`` if no progress event has arrived yet.
const currentPhaseIndex = computed<number>(() => {
if (streamCurrentPhaseIndex.value !== null && streamCurrentPhaseIndex.value > 0) {
return streamCurrentPhaseIndex.value - 1
}
if (streamProgress.value === null) return -1
const total = phaseStepCount.value
const pct = Math.max(0, Math.min(100, streamProgress.value))
return Math.max(0, Math.min(total - 1, Math.round((pct / 100) * total) - 1))
})
// Initialise progress bar + stepper from whatever the DB has on the
// latest task — covers the gap between page load and the first SSE
// event. Important when the user opens the detail view *mid-deploy*:
// without a seed they'd see the loader card until the next worker
// progress event, which can be 30s+ during long phases like
// ``terraform apply``.
//
// Only seed from a *live* task. The persisted progress columns of a
// finished deploy would otherwise paint the stepper at 100% / phase
// "OUTPUTS_AND_CLEANUP" right after the user clicks delete, before
// the new destroy task's first progress event arrives.
watch(
activeTask,
(task) => {
if (!task) return
const live = task.status === 'pending' || task.status === 'running'
if (!live) return
if (task.progress_pct != null && streamProgress.value === null) {
streamProgress.value = task.progress_pct
}
if (task.current_phase && streamCurrentPhase.value === null) {
streamCurrentPhase.value = task.current_phase
// Approximate the phase index from the persisted percent so
// the stepper renders meaningfully *before* the first SSE
// progress event lands. The worker emits the authoritative
// 1-based ``phase_index`` shortly after; until then this is
// the same math the worker used to derive the percent in
// the first place (round(idx/total*100)). Default total is
// 11 (``streamTotalPhases`` ref); good enough for visual.
if (task.progress_pct != null && streamCurrentPhaseIndex.value === null) {
const total = streamTotalPhases.value || DEFAULT_PHASE_COUNT
streamCurrentPhaseIndex.value = Math.max(
1,
Math.min(total, Math.round((task.progress_pct / 100) * total)),
)
}
}
},
{ immediate: true },
)
watch(
isStreamRelevant,
(relevant, wasRelevant) => {
if (relevant && !wasRelevant) {
startStream()
} else if (!relevant && wasRelevant) {
stopStream()
// Refresh the task list once on completion so the final
// logs/outputs land in the static rendering below.
loadTasks()
// A redeploy task that just finished produces a new TF
// state — reload the resource list so the redrawn card
// reflects post-apply lifecycle. We also clear the
// in-flight set; whichever address was waiting on this
// task is now in the freshly-fetched list.
redeployInFlight.value.clear()
loadResources()
}
},
{ immediate: true },
)
// When the SSE stream signals it has ended (terminal lifecycle event
// from the backend), reload the deployment + tasks so the detail view
// switches from the live progress bar to the static log/output render.
//
// Special case: a successful destroy auto-soft-deletes the deployment
// on the backend, so the detail row disappears. Two ways we detect
// it: (1) the active task we last saw was a DESTROY that just hit a
// terminal status, or (2) the refetch comes back without a current
// deployment (the store's fetchDeploymentById swallows the 404 into
// ``state.error`` instead of throwing, so we can't try/catch — we
// check ``deploymentStore.currentDeployment`` directly after).
watch(streamConnectionState, async (state) => {
if (state !== 'ended') return
const wasDestroy = activeTask.value?.type === 'destroy'
// Snapshot the active task BEFORE the refetch so we can decide
// whether to fire a pause/resume failure toast even when the
// refresh races and clears the live state.
const lastActiveType = activeTask.value?.type
const lastActiveStatus = activeTask.value?.status
await deploymentStore.fetchDeploymentById(deploymentId)
await loadTasks()
// The deployment row only disappears when destroy *actually*
// succeeded — the celery event listener auto-soft-deletes on
// ``task-succeeded`` of a DESTROY task. A failed destroy leaves
// the row in place; the user should stay on the detail page so
// they can read the logs and decide what to do (retry destroy
// / dig into terraform state / etc.).
const gone = !deploymentStore.currentDeployment
|| deploymentStore.currentDeployment.deploymentId !== deploymentId
if (gone) {
// Soft-deleted upstream — the destroy ran clean.
toastStore.addToast({
type: 'success',
message: t('DeploymentDetailView.deleteSuccessToast'),
})
router.push({ name: 'deployments.list' })
return
}
// Destroy *attempted* but the row still exists → it failed
// (auto-soft-delete only fires on success). Fire a clear error
// toast and leave the user on the detail page so they can
// inspect the logs and retry.
if (wasDestroy) {
toastStore.addToast({
type: 'error',
message: t('DeploymentDetailView.deleteFailedAsyncToast'),
})
return
}
// Pause/Resume failed asynchronously. The store has the latest
// task list now; ``activeTask`` won't be set anymore (no
// PENDING/RUNNING), so we look at ``tasks.value[0]`` (sorted
// newest-first by created_at via ``activeTask``'s computed
// implementation pattern). The toast is intentionally separate
// from the logs panel — the user gets a clear "the lifecycle
// pass failed but the deployment is still up" hint without us
// pulling raw exception text into the toast itself.
const sortedTasks = [...(tasks.value || [])]
.sort((a, b) => b.created_at.localeCompare(a.created_at))
const newestTask = sortedTasks[0]
const failedKind = (newestTask?.type === 'pause' || newestTask?.type === 'resume')
&& newestTask.status === 'failed'
? newestTask.type
: null
// Belt-and-braces: even if loadTasks() raced, the snapshot from
// before the await should still tell us what was active.
const fallbackKind = (lastActiveType === 'pause' || lastActiveType === 'resume')
&& lastActiveStatus === 'failed'
? lastActiveType
: null
const kind = failedKind || fallbackKind
if (kind === 'pause') {
toastStore.addToast({
type: 'error',
message: t('DeploymentDetailView.pauseFailedAsyncToast'),
})
} else if (kind === 'resume') {
toastStore.addToast({
type: 'error',
message: t('DeploymentDetailView.resumeFailedAsyncToast'),
})
}
})
onBeforeUnmount(() => {
stopStream()
})
// Pretty phase label for the progress bar header. Keeps the enum
// naming convention from the worker (UPPER_SNAKE_CASE) but renders
// it human-friendly. Defensive: anything that isn't a non-empty
// string falls back to an empty label so the template never sees a
// non-string slip through (e.g. the brief moment an unwrapped ref
// produced the original ``phase.split is not a function`` crash).
// Pretty-print arbitrary JSON-ish values for the terraform state /
// outputs / raw-logs blocks. The backend persists these as TEXT
// columns, so they arrive as either:
//
// * a JSON string (terraform state pulled from the pg backend, or the
// JSON-stringified outputs map),
// * a real object/array (when the API layer has already parsed it),
// * a plain non-JSON string (a stack trace, a single error line),
// * null / undefined when the worker had nothing to record.
//
// The helper unifies those into a 2-space-indented JSON dump when the
// payload parses, and falls back to the raw text otherwise so we never
// clobber a non-JSON string by trying to parse it.
const prettyJson = (value: unknown): string => {
if (value === null || value === undefined) return ''
if (typeof value === 'object') {
try {
return JSON.stringify(value, null, 2)
} catch {
return String(value)
}
}
if (typeof value === 'string') {
const trimmed = value.trim()
// Cheap pre-check: only attempt JSON.parse on strings that look
// like JSON. Saves a try/catch round-trip for ordinary log
// text and avoids accidentally parsing a bare number or "null"
// string into something the consumer didn't expect.
if (
(trimmed.startsWith('{') && trimmed.endsWith('}')) ||
(trimmed.startsWith('[') && trimmed.endsWith(']'))
) {
try {
return JSON.stringify(JSON.parse(trimmed), null, 2)
} catch {
return value
}
}
return value
}
return String(value)
}
// Copy-to-clipboard state. Each "card" (logs/state/outputs) tags its
// copy button with a unique key; the key of whichever was last
// successfully copied is stored here for ~1.5s so we can flip its
// icon to a check as feedback. Multiple cards can share the same state
// because only one can be the "just copied" target at a time.
const copiedKey = ref<string | null>(null)
let copyResetTimer: number | null = null
const copyToClipboard = async (text: string, key: string) => {
if (!text) return
try {
// Modern ``navigator.clipboard`` requires a secure context
// (https or localhost). Falls back to the legacy
// ``execCommand('copy')`` so the button still works behind
// plain http on the dev box.
if (navigator.clipboard && window.isSecureContext) {
await navigator.clipboard.writeText(text)
} else {
const ta = document.createElement('textarea')
ta.value = text
ta.style.position = 'fixed'
ta.style.opacity = '0'
document.body.appendChild(ta)
ta.select()
document.execCommand('copy')
document.body.removeChild(ta)
}
copiedKey.value = key
if (copyResetTimer !== null) window.clearTimeout(copyResetTimer)
copyResetTimer = window.setTimeout(() => {
copiedKey.value = null
copyResetTimer = null
}, 1500)
} catch (err) {
console.error('Copy failed:', err)
}
}
const phaseLabel = (phase: unknown): string => {
if (typeof phase !== 'string' || !phase) return ''
// Worker-emittierte Multi-Image-Phasen tragen den Template-Key als
// ``:<key>``-Suffix (z.B. ``PACKER_BUILD:database``). Wir trennen
// den Suffix ab, formatieren den Basis-Phase-Namen wie gewohnt
// (Title-Case mit Leerzeichen statt Underscores) und hängen den
// Sub-Key als ``[<key>]`` in einer Read-Friendly-Form an. So liest
// sich der Stepper-Header als ``Packer Build [database]`` statt
// ``Packer Build:database``.
const colonIdx = phase.indexOf(':')
const base = colonIdx === -1 ? phase : phase.slice(0, colonIdx)
const subKey = colonIdx === -1 ? '' : phase.slice(colonIdx + 1).trim()
const formattedBase = base
.split('_')
.map((w) => w.charAt(0) + w.slice(1).toLowerCase())
.join(' ')
return subKey ? `${formattedBase} [${subKey}]` : formattedBase
}
// Count of log entries inside ``selectedTask.logs`` for the badge in
// the Logs card header. Logs arrive in three flavours:
//
// * an object ``{logs: [...], error?: ...}`` — the Failure payload
// serialised by the worker on a failed deploy
// * a plain array on the success path (the success result is just
// ``logs: list[dict]``)
// * a JSON string when the API serialises one of the above as text
//
// The computed handles all three so the "N entries" pill stays
// accurate regardless of the wire shape; returns null when the count
// can't be determined (e.g. logs is a non-JSON string), in which case
// the badge is hidden.
const logEntryCount = computed<number | null>(() => {
const raw = selectedTask.value?.logs
if (raw == null) return null
let value: unknown = raw
if (typeof value === 'string') {
const trimmed = value.trim()
if (
(trimmed.startsWith('{') && trimmed.endsWith('}')) ||
(trimmed.startsWith('[') && trimmed.endsWith(']'))
) {
try {
value = JSON.parse(trimmed)
} catch {
return null
}
} else {
return null
}
}
if (Array.isArray(value)) return value.length
if (value && typeof value === 'object') {
const inner = (value as Record<string, unknown>).logs
if (Array.isArray(inner)) return inner.length
}
return null
})
const deploymentTimestamp = computed(() => {
return deployment.value?.created_at ? formatDate(deployment.value.created_at) : '-'
})
const getStatusStyles = (status?: string) => {
switch (status) {
case 'success':
return {
label: 'DeploymentsView.deploymentSuccessful',
dotClass: 'bg-green-500 shadow-[0_0_10px_rgba(34,197,94,0.4)]',
textClass: 'text-gray-900',
badgeClass: 'bg-green-100 text-green-800 border-green-300',
icon: CheckCircle
}
case 'running':
return {
label: 'DeploymentsView.deploymentRunning',
dotClass: 'bg-blue-500 animate-pulse shadow-[0_0_12px_rgba(59,130,246,0.6)]',
textClass: 'text-gray-900',
badgeClass: 'bg-blue-100 text-blue-800 border-blue-300',
icon: Loader2
}
case 'pending':
return {
label: 'DeploymentsView.deploymentPending',
dotClass: 'bg-yellow-500 shadow-[0_0_10px_rgba(234,179,8,0.4)]',
textClass: 'text-gray-900',
badgeClass: 'bg-yellow-100 text-yellow-800 border-yellow-300',
icon: Clock
}
case 'failed':
return {
label: 'DeploymentsView.deploymentFailed',
dotClass: 'bg-red-500 shadow-[0_0_10px_rgba(239,68,68,0.4)]',
textClass: 'text-gray-900',
badgeClass: 'bg-red-100 text-red-800 border-red-300',
icon: XCircle
}
case 'destroying':
return {
label: 'DeploymentsView.deploymentDestroying',
dotClass: 'bg-orange-500 animate-pulse shadow-[0_0_12px_rgba(249,115,22,0.6)]',
textClass: 'text-gray-900',
badgeClass: 'bg-orange-100 text-orange-700 border-orange-300',
icon: Loader2
}
case 'cancelled':
return {
label: 'DeploymentsView.deploymentCancelled',
dotClass: 'bg-gray-400',
textClass: 'text-gray-900',
badgeClass: 'bg-gray-100 text-gray-700 border-gray-300',
icon: StopCircle
}
case 'destroyed':
return {
label: 'DeploymentsView.deploymentDestroyed',
dotClass: 'bg-orange-500 shadow-[0_0_10px_rgba(249,115,22,0.4)]',
textClass: 'text-gray-900',
badgeClass: 'bg-orange-100 text-orange-800 border-orange-300',
icon: Flame
}
case 'pausing':
return {
// ``pausing``/``resuming`` borrow the orange "in flight"
// palette from destroying — the user reads "something
// active is happening" at a glance, distinct from the
// calm green of success.
label: 'DeploymentsView.deploymentPausing',
dotClass: 'bg-amber-500 animate-pulse shadow-[0_0_12px_rgba(245,158,11,0.6)]',
textClass: 'text-gray-900',
badgeClass: 'bg-amber-100 text-amber-800 border-amber-300',
icon: Loader2
}
case 'paused':
return {
label: 'DeploymentsView.deploymentPaused',
dotClass: 'bg-slate-400 shadow-[0_0_10px_rgba(148,163,184,0.4)]',
textClass: 'text-gray-900',
badgeClass: 'bg-slate-100 text-slate-700 border-slate-300',
icon: PauseCircle
}
case 'resuming':
return {
label: 'DeploymentsView.deploymentResuming',
dotClass: 'bg-emerald-500 animate-pulse shadow-[0_0_12px_rgba(16,185,129,0.6)]',
textClass: 'text-gray-900',
badgeClass: 'bg-emerald-100 text-emerald-800 border-emerald-300',
icon: Loader2
}
case 'pause_failed':
// The deployment itself is unaffected — only the
// pause-pass tripped. Use the warning palette so the
// user reads "needs attention" rather than the harsher
// red of a deploy-failed.
return {
label: 'DeploymentsView.deploymentPauseFailed',
dotClass: 'bg-amber-500 shadow-[0_0_10px_rgba(245,158,11,0.4)]',
textClass: 'text-gray-900',
badgeClass: 'bg-amber-100 text-amber-900 border-amber-300',
icon: AlertCircle
}
case 'resume_failed':
return {
label: 'DeploymentsView.deploymentResumeFailed',
dotClass: 'bg-amber-500 shadow-[0_0_10px_rgba(245,158,11,0.4)]',
textClass: 'text-gray-900',
badgeClass: 'bg-amber-100 text-amber-900 border-amber-300',
icon: AlertCircle
}
default:
return {
label: 'DeploymentsView.noStatus',
dotClass: 'bg-gray-300',
textClass: 'text-gray-400',
badgeClass: 'bg-gray-100 text-gray-800 border-gray-300',
icon: AlertCircle
}
}
}
const selectedGroup = ref<number | null>(null)
const selectGroup = (groupIndex: number) => {
selectedGroup.value = groupIndex
}
const deselectGroup = () => {
selectedGroup.value = null
}
const groups = computed(() => {
if (!deployment.value?.userInputVar) return []
try {
const data = typeof deployment.value.userInputVar === 'string'
? JSON.parse(deployment.value.userInputVar)
: deployment.value.userInputVar
const groupNames = data.groupNames || []
const assignments = data.assignments || {}
return Object.keys(assignments).map((groupIndex, idx) => ({
index: parseInt(groupIndex),
name: groupNames[idx] || `Gruppe ${parseInt(groupIndex) + 1}`,
students: assignments[groupIndex] || []
}))
} catch (e) {
console.error('Error parsing userInputVar:', e)
return []
}
})
const currentGroup = computed(() => {
if (selectedGroup.value === null) return null
return groups.value[selectedGroup.value] ?? null
})
const deploymentVariables = computed(() => {
if (!deployment.value?.userInputVar) return {}
try {
const data = typeof deployment.value.userInputVar === 'string'
? JSON.parse(deployment.value.userInputVar)
: deployment.value.userInputVar
return data.variables || {}
} catch (e) {
console.error('Error parsing userInputVar:', e)
return {}
}
})
const cleanVariableValue = (value?: string) => {
const str = String(value ?? '')
let cleaned = str.split('#')[0]?.trim() ?? ''
cleaned = cleaned.replace(/["']/g, '')
return cleaned.trim() || '-'
}
/**
* Defensive ``axios``-error → human string. ``err.response?.data?.detail``
* is the FastAPI convention but the backend can ship it as either
* a string or a dict (see e.g. ``{ reason: "openstack_credentials_missing" }``
* for PRECONDITION_FAILED). Plain interpolation would print
* ``[object Object]`` for the dict case; we drill into ``.reason``
* when present and fall back to ``err.message`` so the toast is
* always readable.
*/
const extractErrorMessage = (err: any): string => {
const detail = err?.response?.data?.detail
if (typeof detail === 'string') return detail
if (detail && typeof detail === 'object') {
if (typeof detail.reason === 'string') return detail.reason
if (typeof detail.message === 'string') return detail.message
}
return err?.message || 'Unknown error'
}
/**
* Split a task-logs string into a friendly headline + a collapsible
* technical-details body. The backend's ``celery_event_listener.py``
* emits Celery-infrastructure failures (``NotRegistered``,
* ``WorkerLostError``, …) in a stable two-section format separated
* by ``--- Technische Details ---``; we honour that boundary so the
* raw stack trace stays available but isn't shoved into the user's
* face by default.
*
* Returns ``{headline, details, isFailure}`` — ``isFailure`` lets
* the template pick the destructive palette without re-doing the
* regex on render.
*/
const FAILURE_DETAIL_DIVIDER = '--- Technische Details ---'
const splitTaskLogs = (raw: string | Record<string, unknown> | null | undefined) => {
if (!raw) return { headline: '', details: '', isFailure: false }
const text = String(raw)
// Backend "infra" failure with the explicit divider — we get a
// one-line headline and a raw block underneath.
const dividerIdx = text.indexOf(FAILURE_DETAIL_DIVIDER)
if (dividerIdx >= 0) {
return {
headline: text.slice(0, dividerIdx).trim(),
details: text.slice(dividerIdx + FAILURE_DETAIL_DIVIDER.length).trim(),
isFailure: true,
}
}
// Fallback: the legacy ``Task failed: ...\n<traceback>`` shape.
// Take the first line as headline if the body is multi-line.
if (text.startsWith('Task failed:')) {
const newlineIdx = text.indexOf('\n')
if (newlineIdx > 0) {
return {
headline: text.slice(0, newlineIdx).trim(),
details: text.slice(newlineIdx + 1).trim(),
isFailure: true,
}
}
return { headline: text.trim(), details: '', isFailure: true }
}
return { headline: '', details: '', isFailure: false }
}
// ``logs`` can be either a backend-formatted ``Task failed: ...`` string
// (the failure shape this splitter cares about) or a structured
// ``TaskLogsObject`` for normal runs. Only the string form triggers the
// headline/details split — anything else falls through to the generic
// pretty-print path below.
const taskLogsSplit = computed(() => {
const raw = selectedTask.value?.logs
return splitTaskLogs(typeof raw === 'string' ? raw : null)
})
const showTaskLogsTrace = ref(false)
// Unified delete handler. The backend's DELETE endpoint returns 202
// when it dispatched a destroy task (live progress to follow) or 204
// when it soft-deleted directly (no resources to clean up). Branch
// on response.status so the UX matches what's actually happening:
// * 202 → stay on the page, refresh tasks so the live stream
// attaches to the new DESTROY task; the streamConnectionState
// watcher routes back to the list when the task completes.
// * 204 → leave immediately with a success toast.
const confirmDelete = async () => {
if (!deploymentId) return
try {
const response = await deploymentStore.deleteDeployment(deploymentId)
if (response?.status === 202) {
// Destroy task dispatched. Reload deployment + tasks so
// ``activeTask`` flips to the new DESTROY row and the
// live-progress card swaps in.
toastStore.addToast({
type: 'info',
message: t('DeploymentDetailView.deleteStartedToast'),
})
await deploymentStore.fetchDeploymentById(deploymentId)
await loadTasks()
} else {
// 204: nothing to destroy, soft-delete completed
// synchronously. Row is gone — back to the list.
toastStore.addToast({
type: 'success',
message: t('DeploymentDetailView.deleteSuccessToast'),
})
router.push({ name: 'deployments.list' })
}
} catch (err: any) {
toastStore.addToast({
type: 'error',
message: `${t('DeploymentDetailView.deleteErrorToast')}: ` + extractErrorMessage(err),
})
} finally {
showDeleteModal.value = false
}
}
// Redeploy confirmation handler — close the modal first (so the user
// gets immediate visual feedback that their click registered) and
// then dispatch the actual API call. ``executeRedeploy`` owns its
// own toast handling and adds/removes the in-flight marker.
const confirmRedeploy = async () => {
const address = redeployTargetAddress.value
showRedeployModal.value = false
if (!address) return
try {
await executeRedeploy(address)
} finally {
redeployTargetAddress.value = null
}
}
// Pause / resume handler — same wiring as ``confirmDelete``: the
// backend returns 202 with a ``task_id`` when it dispatched the
// worker, so we just reload the deployment + tasks and the existing
// SSE stream / activeTask plumbing takes over from there. The button
// itself is hidden while ``pausing``/``resuming`` so the user can't
// double-click; ``pauseResumeBusy`` debounces the in-flight HTTP call
// in case the click lands faster than the deployment status refresh.
const confirmPauseResume = async () => {
if (!deploymentId || pauseResumeBusy.value) return
const action = pauseResumeAction.value
if (!action) return
pauseResumeBusy.value = true
try {
const call = action === 'pause'
? deploymentStore.pauseDeployment(deploymentId)
: deploymentStore.resumeDeployment(deploymentId)
await call
toastStore.addToast({
type: 'info',
message: action === 'pause'
? t('DeploymentDetailView.pauseStartedToast')
: t('DeploymentDetailView.resumeStartedToast'),
})
await deploymentStore.fetchDeploymentById(deploymentId)
await loadTasks()
} catch (err: any) {
toastStore.addToast({
type: 'error',
message: (action === 'pause'
? t('DeploymentDetailView.pauseErrorToast')
: t('DeploymentDetailView.resumeErrorToast'))
+ ': '
+ extractErrorMessage(err),
})
} finally {
pauseResumeBusy.value = false
showPauseResumeModal.value = false
}
}
// Per-user resend-access state. Map ``userId → 'sending' | 'sent' | 'error'``
// so the button can show inline feedback on the row that was clicked
// without forcing a re-render of the whole list. The 'sent' state
// auto-clears after 2s so the user can resend again.
const resendState = ref<Record<string, 'sending' | 'sent' | 'error'>>({})
const resendAccess = async (teamId: string, userId: string) => {
resendState.value = { ...resendState.value, [userId]: 'sending' }
try {
await deploymentApi.resendAccess(deploymentId, teamId, userId)
resendState.value = { ...resendState.value, [userId]: 'sent' }
toastStore.addToast({
type: 'success',
message: t('DeploymentDetailView.resendAccessSuccess'),
})
window.setTimeout(() => {
const next = { ...resendState.value }
delete next[userId]
resendState.value = next
}, 2000)
} catch (err: any) {
resendState.value = { ...resendState.value, [userId]: 'error' }
// Backend returns ``{detail: {reason: '...'}}``; surface the
// reason verbatim — the UI doesn't need to localise every
// possible code, the toast is for the operator.
//
// Two reasons get a dedicated toast string so the user
// understands WHY mail didn't go out:
// * smtp_disabled (503): platform-wide kill-switch; needs
// an admin to flip ``SMTP_ENABLED`` in the backend env.
// A generic "Failed to send" toast would mislead them
// into thinking the SMTP server is down.
// * everything else: stays in the existing failure path
// so SMTP-rejected-the-recipient, transient errors, and
// unknown reasons all get the verbose toast.
const reason = err?.response?.data?.detail?.reason || err?.message || 'unknown'
const isSmtpDisabled = err?.response?.status === 503 && reason === 'smtp_disabled'
const isDeploymentBusyErr = err?.response?.status === 409 && reason === 'deployment_busy'
toastStore.addToast({
type: (isSmtpDisabled || isDeploymentBusyErr) ? 'warning' : 'error',
message: isSmtpDisabled
? t('DeploymentDetailView.resendAccessSmtpDisabled')
: isDeploymentBusyErr
? t('DeploymentDetailView.resendAccessDeploymentBusy')
: `${t('DeploymentDetailView.resendAccessError')}: ${reason}`,
})
window.setTimeout(() => {
const next = { ...resendState.value }
delete next[userId]
resendState.value = next
}, 3000)
}
}
const formatDate = (dateString?: string | null) => {
if (!dateString) return '-'
return new Date(dateString).toLocaleString('de-DE', {
day: '2-digit', month: '2-digit', year: 'numeric',
hour: '2-digit', minute: '2-digit', second: '2-digit'
})
}
const selectTask = async (task: Task) => {
loadingTaskDetail.value = true
try {
const { data } = await taskApi.getById(task.taskId)
selectedTask.value = data
} catch (err) {
console.error('Error loading task details:', err)
toastStore.addToast({
type: 'error',
message: 'Failed to load task details'
})
} finally {
loadingTaskDetail.value = false
}
}
const deselectTask = () => {
selectedTask.value = null
}
</script>
<template>
<div v-if="deployment" class="space-y-6">
<!--
Two-column layout: the deployment detail content stays on
the left, and the VM-detail sidebar — when an inline VM is
selected — anchors as a sticky right column. The sidebar
sits under the App-Header (the parent layout's main
wrapper) and to the right of the App-Sidebar; it is part
of the page's normal flow, never an overlay. When no VM
is selected the left column expands to full width.
-->
<div class="flex gap-6 items-start">
<div class="flex-1 min-w-0 space-y-6">
<!-- Header mit Back Button und Status Badge -->
<div class="flex items-center justify-between">
<div class="flex items-center gap-4">
<RouterLink :to="{ name: 'deployments.list' }">
<button
class="w-10 h-10 rounded-full flex items-center justify-center hover:bg-gray-100 transition">
<CircleArrowLeft :size="24" class="text-gray-700" />
</button>
</RouterLink>
<div>
<h1 class="text-3xl font-bold text-gray-900">{{ deployment.name }}</h1>
<p class="text-sm text-gray-500 mt-1">Deployment Details</p>
</div>
</div>
<div class="flex items-center gap-4">
<div class="flex items-center gap-3">
<component :is="getStatusStyles(deployment.status).icon" :size="20" :class="deployment.status === 'success' ? 'text-green-600' :
deployment.status === 'failed' ? 'text-red-600' :
deployment.status === 'running' ? 'text-blue-600' : 'text-yellow-600'" />
<span
class="inline-flex items-center px-3 py-1.5 rounded-lg text-sm font-semibold border capitalize"
:class="getStatusStyles(deployment.status).badgeClass">
{{ $t(getStatusStyles(deployment.status).label) }}
</span>
</div>
<!-- Pause / Resume button. One slot, two states —
visible only when the lifecycle matrix permits
the action right now. While ``pausing``/``resuming``
it stays hidden (no point clicking; the live
stream shows progress). The Trash button below
handles destroy/delete and stays available even
for ``paused`` deployments. -->
<BaseButton
v-if="canPauseOrResume"
@click="!pauseResumeBusy && (showPauseResumeModal = true)"
:disabled="pauseResumeBusy"
:title="pauseResumeAction === 'pause'
? $t('DeploymentDetailView.pauseTooltip')
: $t('DeploymentDetailView.resumeTooltip')"
class="flex items-center gap-2 px-4 py-2"
:variant="pauseResumeAction === 'pause' ? 'yellow' : 'green'">
<PauseCircle v-if="pauseResumeAction === 'pause'" :size="18" />
<PlayCircle v-else :size="18" />
<span class="font-medium">
{{ pauseResumeAction === 'pause'
? $t('DeploymentDetailView.deploymentPause')
: $t('DeploymentDetailView.deploymentResume') }}
</span>
</BaseButton>
<!-- Single Delete button. The backend decides whether
this triggers a destroy task (live progress to
follow) or a straight soft-delete based on status.
Hidden entirely for members — they can read the
deployment but never tear it down. -->
<BaseButton v-if="isOwnerView" @click="canDelete && (showDeleteModal = true)" :disabled="!canDelete"
:title="deleteDisabledReason" class="flex items-center gap-2 px-4 py-2" variant="red">
<Trash2 :size="18" />
<span class="font-medium">{{ $t('DeploymentDetailView.deploymentDelete') }}</span>
</BaseButton>
</div>
</div>
<!-- Main Info Grid mit 3 Cards -->
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
<!-- Deployment Info Card -->
<div class="bg-white rounded-xl border border-gray-200 p-6 shadow-sm">
<h2 class="text-lg font-semibold text-gray-900 mb-4 flex items-center gap-2">
<Package :size="20" class="text-primary" />
Deployment Info
</h2>
<div class="space-y-4">
<div>
<div class="text-xs text-gray-500 uppercase tracking-wide mb-1">
{{ $t('DeploymentsView.deploymentName') }}
</div>
<div class="text-sm font-medium text-gray-900">{{ deployment.name }}</div>
</div>
<div>
<div class="text-xs text-gray-500 uppercase tracking-wide mb-1">Release Tag</div>
<div class="text-sm">
<span
class="inline-flex items-center px-2.5 py-1 rounded-md text-xs font-semibold bg-indigo-100 text-indigo-800 border border-indigo-300">
<GitBranch :size="12" class="mr-1" />
{{ deployment.releaseTag }}
</span>
</div>
</div>
<div>
<div class="text-xs text-gray-500 uppercase tracking-wide mb-1">
{{ $t('DeploymentDetailView.deploymentCreated') }}
</div>
<div class="text-sm font-medium text-gray-700 flex items-center gap-1">
<Calendar :size="14" />
{{ deploymentTimestamp }}
</div>
</div>
</div>
</div>
<!-- App Info Card -->
<div class="bg-white rounded-xl border border-gray-200 p-6 shadow-sm">
<h2 class="text-lg font-semibold text-gray-900 mb-4 flex items-center gap-2">
<Package :size="20" class="text-emerald-600" />
{{ $t('DeploymentsView.deploymentApp') }}
</h2>
<div class="space-y-4" v-if="deployment.app">
<div>
<div class="text-xs text-gray-500 uppercase tracking-wide mb-1">App Name</div>
<div class="text-sm font-medium text-gray-900">{{ deployment.app.name }}</div>
</div>
<div>
<div class="text-xs text-gray-500 uppercase tracking-wide mb-1">{{
$t('DeploymentDetailView.deploymentDescription') }}</div>
<MarkdownRenderer
v-if="deployment.app.description && deployment.app.description.trim()"
:source="deployment.app.description"
variant="compact"
:clamp="3"
:expandable="true"
class="text-sm"
/>
<div v-else class="text-sm text-gray-500 italic">No description</div>
</div>
<div>
<div class="text-xs text-gray-500 uppercase tracking-wide mb-1">Git Repository</div>
<a :href="deployment.app.git_link ?? undefined" target="_blank"
class="text-sm text-blue-600 hover:text-blue-800 underline break-all">
{{ deployment.app.git_link }}
</a>
</div>
</div>
<div v-else class="text-sm text-gray-500">No app information available</div>
</div>
<!-- User Info Card -->
<div class="bg-white rounded-xl border border-gray-200 p-6 shadow-sm">
<h2 class="text-lg font-semibold text-gray-900 mb-4 flex items-center gap-2">
<User :size="20" class="text-blue-600" />
{{ $t('DeploymentDetailView.deploymentOwner') }}
</h2>
<div class="space-y-4" v-if="deployment.user">
<div>
<div class="text-xs text-gray-500 uppercase tracking-wide mb-1">{{
$t('DeploymentDetailView.deploymentUserName') }}</div>
<div class="text-sm font-medium text-gray-900 flex items-center gap-2">
<div
class="w-6 h-6 rounded-full bg-primary/10 flex items-center justify-center text-[10px] text-primary font-bold">
{{ deployment.user.username.substring(0, 2).toUpperCase() }}
</div>
{{ deployment.user.username }}
</div>
</div>
<div>
<div class="text-xs text-gray-500 uppercase tracking-wide mb-1">Email</div>
<div class="text-sm text-gray-700">{{ deployment.user.email }}</div>
</div>
<div>
<div class="text-xs text-gray-500 uppercase tracking-wide mb-1">{{
$t('DeploymentDetailView.deploymentUserRole') }}</div>
<div class="text-sm">
<span
class="inline-flex items-center px-2.5 py-1 rounded-md text-xs font-semibold bg-purple-100 text-purple-800 border border-purple-300 capitalize">
{{ deployment.user.role }}
</span>
</div>
</div>
</div>
<div v-else class="text-sm text-gray-500">No user information available</div>
</div>
</div>
<!-- Gruppen Section -->
<div class="bg-white rounded-xl border border-gray-200 p-6 shadow-sm" v-if="groups.length > 0">
<h2 class="text-lg font-semibold text-gray-900 mb-4 flex items-center gap-2">
<Users :size="20" class="text-primary" />
{{ $t('DeploymentDetailView.deploymentGroups') }}
</h2>
<Transition mode="out-in" enter-active-class="transition-all duration-200 ease-out"
enter-from-class="opacity-0 translate-x-2" enter-to-class="opacity-100 translate-x-0"
leave-active-class="transition-all duration-200 ease-out absolute top-0 left-0 right-0"
leave-from-class="opacity-100 translate-x-0" leave-to-class="opacity-0 -translate-x-2">
<div v-if="currentGroup" key="detail" class="bg-gray-50 rounded-lg p-4">
<button @click="deselectGroup"
class="flex items-center gap-2 text-primary hover:text-primary/80 transition-colors mb-3 group">
<CircleArrowLeft :size="20" class="group-hover:-translate-x-1 transition-transform" />
<span class="text-sm font-medium">{{ $t('DeploymentDetailView.deploymentGroupsBack') }}</span>
</button>
<div class="flex items-center gap-3 mb-4 pb-3 border-b border-gray-200">
<div class="w-8 h-8 rounded-full bg-primary/20 flex items-center justify-center">
<span class="text-primary font-bold text-sm">{{ currentGroup.index + 1 }}</span>
</div>
<div class="font-semibold text-lg">{{ currentGroup.name }}</div>
</div>
<div class="space-y-2">
<div class="text-xs text-gray-500 uppercase tracking-wide mb-2">
{{ $t('DeploymentDetailView.deploymentStudentCount', {
n: currentGroup?.students?.length ||
0
}, currentGroup?.students?.length || 0) }}
</div>
<div v-for="(student, idx) in currentGroup.students" :key="student"
class="flex items-center gap-3 bg-white rounded-lg px-3 py-2 border border-gray-200">
<div
class="w-6 h-6 rounded-full bg-primary/10 flex items-center justify-center text-xs text-primary font-bold">
{{ Number(idx) + 1 }}
</div>
<span class="font-mono text-sm text-gray-700">{{ student }}</span>
</div>
</div>
</div>
<div v-else key="overview" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
<div v-for="group in groups" :key="group.index" @click="selectGroup(group.index)"
class="bg-gray-50 rounded-lg p-4 cursor-pointer hover:bg-gray-100 transition-colors border border-gray-200 hover:border-primary/30">
<div class="flex items-center gap-3 mb-2">
<div class="w-8 h-8 rounded-full bg-primary/20 flex items-center justify-center">
<span class="text-primary font-bold text-sm">{{ group.index + 1 }}</span>
</div>
<div class="font-semibold">{{ group.name }}</div>
</div>
<div class="text-sm text-gray-600 ml-11">
{{ $t('DeploymentDetailView.deploymentStudentCount', { n: group.students.length },
group.students.length) }}
</div>
</div>
</div>
</Transition>
</div>
<!-- Deployment Variables -->
<div class="bg-white rounded-xl border border-gray-200 p-6 shadow-sm"
v-if="Object.keys(deploymentVariables).length > 0">
<h2 class="text-lg font-semibold text-gray-900 mb-4 flex items-center gap-2">
<Settings :size="20" class="text-orange-600" />
{{ $t('DeploymentDetailView.deploymentConfig') }}
</h2>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div v-for="(value, key) in deploymentVariables" :key="key"
class="bg-gray-50 rounded-lg p-4 border border-gray-200">
<div class="text-xs text-gray-500 uppercase tracking-wide mb-1 font-mono">{{ key }}</div>
<div class="font-medium text-gray-800 break-all text-sm">
{{ cleanVariableValue(value) }}
</div>
</div>
</div>
</div>
<!-- Latest task info is shown inline in the Active Task card
below while the deployment is running, and inline in the
Tasks & Logs history once it has finished. The previous
standalone "Latest Task" row was redundant with both. -->
<!-- Active Task — live progress + log tail for the currently
running task. Replaces the previous mix of "Latest Task"
info card + duplicate entry in the Tasks & Logs list. -->
<div v-if="isStreamRelevant && activeTask"
class="bg-white rounded-xl border border-blue-300 shadow-sm overflow-hidden">
<!-- Header strip: gradient + live indicator + task type/status -->
<div class="bg-gradient-to-r from-blue-50 to-indigo-50 px-6 py-4 border-b border-blue-200">
<div class="flex items-center justify-between">
<div class="flex items-center gap-3">
<div class="relative">
<div class="w-2.5 h-2.5 bg-green-500 rounded-full"></div>
<div class="absolute inset-0 w-2.5 h-2.5 bg-green-500 rounded-full animate-ping"></div>
</div>
<div>
<div class="flex items-center gap-2">
<span class="text-sm font-semibold text-gray-900 capitalize">{{ activeTask.type
}}</span>
<span class="text-xs font-medium text-gray-500">·</span>
<span class="text-xs text-gray-600">running since {{ formatDate(activeTask.started_at ||
activeTask.created_at) }}</span>
</div>
<div class="text-xs text-gray-500 font-mono mt-0.5">{{ activeTask.taskId }}</div>
</div>
</div>
<span class="text-xs px-2 py-1 rounded-md font-medium" :class="streamConnectionState === 'live'
? 'bg-green-100 text-green-700 border border-green-200'
: streamConnectionState === 'reconnecting'
? 'bg-yellow-100 text-yellow-700 border border-yellow-200'
: 'bg-gray-100 text-gray-600 border border-gray-200'">
{{ streamConnectionState === 'live' ? 'Stream live' : streamConnectionState }}
</span>
</div>
</div>
<!-- Body: progress bar + phase stepper + live tail -->
<div class="p-6 space-y-5">
<!-- The "Worker is starting up" loader covers the very
first seconds of a fresh task, before any phase
info is available — neither the SSE stream nor
the DB-seeded ``current_phase`` is set yet.
``streamCurrentPhaseIndex`` carries either the
authoritative live value or the percent-derived
guess from the DB seed, so checking it alone is
enough to decide whether to render the stepper. -->
<template v-if="streamCurrentPhaseIndex === null && !streamCurrentPhase">
<div class="flex items-center gap-3 py-6 justify-center text-gray-500">
<Loader2 class="animate-spin" :size="20" />
<span class="text-sm">Worker is starting up…</span>
</div>
</template>
<template v-else>
<!-- Progress headline -->
<div>
<div class="flex items-baseline justify-between mb-2">
<span class="text-base font-semibold text-gray-900">
{{ phaseLabel(streamCurrentPhase) || 'Starting…' }}
</span>
<span class="text-2xl font-bold text-gray-900 tabular-nums">
{{ streamProgress ?? 0 }}<span class="text-sm text-gray-500 font-medium">%</span>
</span>
</div>
<div class="w-full bg-gray-100 rounded-full h-2 overflow-hidden">
<div class="bg-gradient-to-r from-blue-500 to-indigo-500 h-2 rounded-full transition-all duration-500 ease-out"
:style="{ width: (streamProgress ?? 0) + '%' }"></div>
</div>
</div>
<!-- Phase stepper. Renders ``phaseStepCount`` dots based
on the live ``totalPhases``, with labels picked by
the live total (matches deploy/destroy presets).
Generous ``py-3`` padding prevents the active
dot's ``ring-4`` + ``scale-125`` halo from clipping
against the parent's bottom edge. -->
<div class="flex items-start gap-1.5 overflow-x-auto py-3">
<template v-for="idx in phaseStepCount" :key="idx - 1">
<div class="flex-shrink-0 flex flex-col items-center gap-2 min-w-[60px]">
<div class="w-2.5 h-2.5 rounded-full transition-all" :class="(idx - 1) < currentPhaseIndex
? 'bg-blue-500'
: (idx - 1) === currentPhaseIndex
? 'bg-blue-500 ring-4 ring-blue-200 scale-125'
: 'bg-gray-200'"></div>
<span
class="text-[10px] uppercase tracking-wide font-medium whitespace-nowrap text-center"
:class="(idx - 1) <= currentPhaseIndex ? 'text-blue-700' : 'text-gray-400'">
{{ phaseStepLabel(idx - 1) }}
</span>
</div>
<div v-if="(idx - 1) < phaseStepCount - 1" class="flex-1 h-px min-w-[8px] mt-[5px]"
:class="(idx - 1) < currentPhaseIndex ? 'bg-blue-300' : 'bg-gray-200'"></div>
</template>
</div>
</template>
<!-- Live log tail. ``streamTotalLogCount`` keeps
growing past the visible buffer (capped at 100
lines via the ring buffer in the composable),
so the user sees that the worker is still
producing output even after the box is full. -->
<div v-if="streamLiveLogs.length > 0" class="space-y-2">
<div class="flex items-center justify-between">
<span class="text-xs uppercase tracking-wide font-semibold text-gray-600">Live output</span>
<span class="text-xs text-gray-500">
{{ streamTotalLogCount.toLocaleString() }} {{ streamTotalLogCount === 1 ? 'line' : 'lines'
}}
<span v-if="streamLiveLogs.length < streamTotalLogCount" class="text-gray-400">
· last {{ streamLiveLogs.length }} shown
</span>
</span>
</div>
<div class="bg-gray-900 rounded-md p-3 max-h-72 overflow-y-auto font-mono text-xs">
<div v-for="(log, idx) in streamLiveLogs" :key="`${log.timestamp}-${idx}`"
class="text-gray-200 whitespace-pre-wrap break-words" :class="{
'text-red-400': log.level === 'ERROR',
'text-yellow-300': log.level === 'WARNING',
'text-green-400': log.level === 'SUCCESS',
'text-gray-400': log.streaming,
}">
<span class="text-gray-500 mr-2">{{ log.timestamp.split('T')[1]?.slice(0, 8) || '' }}</span>
<span v-if="log.tool" class="text-blue-400 mr-1">[{{ log.tool }}]</span>{{ log.message }}
</div>
</div>
</div>
<div v-else class="bg-gray-50 border border-gray-200 rounded-md p-4 text-center text-xs text-gray-500">
Waiting for first log line…
</div>
</div>
</div>
<!-- Teams & Members section — appears above Infrastructure so
the human-readable view (who has access to what) precedes
the technical resource listing. -->
<div v-if="deployment.teams && deployment.teams.length > 0"
class="bg-white rounded-xl border border-gray-200 p-6 shadow-sm mb-8">
<div class="flex items-center gap-3 mb-5">
<div class="p-2 bg-gray-100 rounded-lg">
<Users :size="20" class="text-gray-600" />
</div>
<span class="text-lg font-semibold text-gray-900">
{{ $t('DeploymentDetailView.teamsAndMembers') }}
</span>
<span class="px-2 py-0.5 bg-gray-100 text-gray-600 text-xs font-bold rounded">
{{ deployment.teams.length }}
</span>
</div>
<div class="space-y-4">
<div v-for="team in enrichedTeams" :key="team.teamId"
class="border border-gray-200 rounded-lg overflow-hidden">
<div class="bg-gray-50 px-4 py-3 flex items-center justify-between border-b border-gray-200">
<div class="flex items-center gap-2">
<span class="font-semibold text-gray-900">{{ team.name }}</span>
<span class="text-xs text-gray-500">·</span>
<span class="text-xs text-gray-600">
{{ team.members.length }}
{{ team.members.length === 1 ? 'member' : 'members' }}
</span>
</div>
</div>
<div v-if="team.members.length === 0" class="px-4 py-6 text-center text-sm text-gray-500">
No members assigned to this team.
</div>
<div v-else>
<div v-for="member in team.members" :key="member.userId"
class="flex flex-col lg:flex-row lg:items-center justify-between gap-4 px-4 py-4 border-b border-gray-100 last:border-b-0 hover:bg-gray-50/50 transition-colors">
<div class="flex items-center gap-3 min-w-0 flex-1">
<div
class="w-9 h-9 rounded-full bg-primary/10 text-primary flex items-center justify-center flex-shrink-0">
<User :size="16" />
</div>
<div class="min-w-0 pr-2">
<div class="font-medium text-gray-900 truncate">{{ member.username }}</div>
<div class="text-xs text-gray-500 truncate">{{ member.email }}</div>
</div>
</div>
<div v-if="member.account"
class="flex flex-wrap items-center gap-4 text-xs font-mono text-gray-600 lg:justify-end">
<!-- Web-App-URL aus ``team_vms.<team>.url`` —
für jedes Mitglied des Teams gleich. Wenn
gesetzt, fällt die SSH-Pille weg und der
Username steht daneben. -->
<div v-if="team.vm?.url"
class="flex items-center gap-1.5 bg-gray-50 px-2 py-1 rounded border border-gray-100">
<span class="text-gray-400 font-sans text-[10px] uppercase tracking-wider flex-shrink-0">User:</span>
<span>{{ member.account.data.username }}</span>
<button
@click="copyToClipboard(member.account.data.username, 'user-' + member.account.key)"
class="text-gray-400 hover:text-amber-600 p-0.5 rounded hover:bg-gray-200 transition-colors flex-shrink-0"
:title="copiedKey === 'user-' + member.account.key ? 'Kopiert!' : 'Username kopieren'">
<component :is="copiedKey === 'user-' + member.account.key ? Check : Copy" :size="12" />
</button>
</div>
<div v-if="team.vm?.url"
class="flex items-center gap-1.5 bg-gray-50 px-2 py-1 rounded border border-gray-100 max-w-[280px]">
<span class="text-gray-400 font-sans text-[10px] uppercase tracking-wider flex-shrink-0">URL:</span>
<a :href="team.vm.url" target="_blank" rel="noopener noreferrer"
class="text-blue-600 hover:underline truncate">{{ team.vm.url.replace(/^https?:\/\//, '') }}</a>
<button
@click="copyToClipboard(team.vm.url, 'vmurl-' + member.account.key)"
class="text-gray-400 hover:text-amber-600 p-0.5 rounded hover:bg-gray-200 transition-colors flex-shrink-0"
:title="copiedKey === 'vmurl-' + member.account.key ? 'Kopiert!' : 'URL kopieren'">
<component :is="copiedKey === 'vmurl-' + member.account.key ? Check : Copy" :size="12" />
</button>
</div>
<!-- Fertige SSH-Befehlszeile — enthält bereits
username, IP und (bei nicht-22) den Port,
darum reichen IP/Port-Chips daneben nicht
mehr; eine reicht. -->
<div v-if="!team.vm?.url && member.account.data.ip && member.account.data.username && (!member.account.data.authtype || member.account.data.authtype === 'ssh')"
class="flex items-center gap-1.5 bg-gray-50 px-2 py-1 rounded border border-gray-100 max-w-full">
<span class="text-gray-400 font-sans text-[10px] uppercase tracking-wider flex-shrink-0">SSH:</span>
<span class="truncate">{{ sshCommandFor(member.account.data) }}</span>
<button
@click="copyToClipboard(sshCommandFor(member.account.data), 'ssh-' + member.account.key)"
class="text-gray-400 hover:text-amber-600 p-0.5 rounded hover:bg-gray-200 transition-colors flex-shrink-0"
:title="copiedKey === 'ssh-' + member.account.key ? 'Kopiert!' : 'SSH-Befehl kopieren'">
<component :is="copiedKey === 'ssh-' + member.account.key ? Check : Copy" :size="12" />
</button>
</div>
<div v-if="member.account.data.auth"
class="flex items-center gap-1.5 bg-gray-50 px-2 py-1 rounded border border-gray-100 min-w-[150px] justify-between">
<div class="truncate mr-1">
<span
class="text-gray-400 font-sans text-[10px] uppercase tracking-wider mr-1">PW:</span>
<template v-if="visiblePasswords[member.account.key]">{{
member.account.data.auth }}</template>
<span v-else class="tracking-widest text-gray-400 select-none">••••••••</span>
</div>
<div class="flex items-center gap-0.5 flex-shrink-0">
<button @click="togglePasswordVisibility(member.account.key)"
class="text-gray-400 hover:text-gray-600 p-0.5 rounded hover:bg-gray-200 transition-colors">
<component :is="visiblePasswords[member.account.key] ? EyeOff : Eye"
:size="12" />
</button>
<button
@click="copyToClipboard(member.account.data.auth, 'auth-' + member.account.key)"
class="text-gray-400 hover:text-amber-600 p-0.5 rounded hover:bg-gray-200 transition-colors"
:title="copiedKey === 'auth-' + member.account.key ? 'Kopiert!' : 'Passwort kopieren'">
<component :is="copiedKey === 'auth-' + member.account.key ? Check : Copy"
:size="12" />
</button>
</div>
</div>
</div>
<div class="flex-shrink-0 flex lg:justify-end">
<button v-if="isOwnerView || String(member.userId) === String(authStore.userId)"
@click="resendAccess(team.teamId, member.userId)"
:disabled="resendState[member.userId] === 'sending' || isDeploymentBusy"
:title="isDeploymentBusy
? $t('DeploymentDetailView.resendAccessBusyTooltip')
: $t('DeploymentDetailView.resendAccessTooltip')"
class="w-full lg:w-auto flex items-center justify-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-md border transition-colors"
:class="resendState[member.userId] === 'sent'
? 'bg-green-600 text-white border-green-600'
: resendState[member.userId] === 'error'
? 'bg-red-50 text-red-700 border-red-300'
: 'bg-white text-gray-700 border-gray-300 hover:bg-gray-50 disabled:opacity-50'">
<Loader2 v-if="resendState[member.userId] === 'sending'" :size="14"
class="animate-spin" />
<Check v-else-if="resendState[member.userId] === 'sent'" :size="14" />
<AlertCircle v-else-if="resendState[member.userId] === 'error'" :size="14" />
<Send v-else :size="14" />
<span>
{{ resendState[member.userId] === 'sending'
? $t('DeploymentDetailView.resendAccessSending')
: resendState[member.userId] === 'sent'
? $t('DeploymentDetailView.resendAccessSent')
: resendState[member.userId] === 'error'
? $t('DeploymentDetailView.resendAccessRetry')
: $t('DeploymentDetailView.resendAccessButton') }}
</span>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Infrastructure section — per-VM cards + read-only listings.
Owner-only (the backend gates it the same way); members
skip the section entirely so they don't see an empty/
permission-error panel. Visually mirrors the other
page sections (Teams, Tasks, Outputs): same
``bg-white rounded-xl border ... p-6 shadow-sm`` shell,
same icon-tile header, same sub-section spacing. -->
<div v-if="isOwnerView"
class="bg-white rounded-xl border border-gray-200 p-6 shadow-sm mb-8">
<div class="flex items-center justify-between mb-5 gap-3 flex-wrap">
<div class="flex items-center gap-3">
<div class="p-2 bg-gray-100 rounded-lg">
<Server :size="20" class="text-gray-600" />
</div>
<span class="text-lg font-semibold text-gray-900">Infrastruktur</span>
</div>
<button
@click="loadResources()"
:disabled="resourcesLoading"
class="text-xs font-semibold px-3 py-1.5 rounded-lg border border-gray-300 hover:bg-gray-50 disabled:opacity-60 disabled:cursor-not-allowed inline-flex items-center gap-1.5 transition-colors"
title="Live-Status neu abfragen"
>
<RefreshCw :size="13" :class="resourcesLoading ? 'animate-spin' : ''" />
Aktualisieren
</button>
</div>
<div
v-if="resourcesError"
class="text-sm p-3 rounded-lg border bg-red-50 text-red-800 border-red-200 mb-4 flex items-start gap-2"
>
<AlertCircle :size="16" class="mt-0.5 shrink-0" />
<p>{{ resourcesError }}</p>
</div>
<!-- VMs — primary section, cards inherit their own visual
styling from ``InfrastructureVmCard``. -->
<section class="mb-6">
<div class="flex items-center gap-2 mb-3">
<Server :size="14" class="text-gray-400" />
<h3 class="text-sm font-bold uppercase tracking-wider text-gray-600">
Virtuelle Maschinen
</h3>
<span
v-if="vmResources.length > 0"
class="px-2 py-0.5 bg-gray-100 text-gray-600 text-xs font-bold rounded"
>
{{ vmResources.length }}
</span>
</div>
<div
v-if="resourcesLoading && vmResources.length === 0"
class="text-sm text-gray-500 italic px-4 py-6 bg-gray-50 rounded-lg border border-gray-100 text-center"
>
Lade VMs…
</div>
<div
v-else-if="vmResources.length === 0"
class="text-sm text-gray-500 italic px-4 py-6 bg-gray-50 rounded-lg border border-gray-100 text-center"
>
Keine VMs im aktuellen Terraform-State.
</div>
<div v-else class="grid grid-cols-1 md:grid-cols-2 gap-3">
<InfrastructureVmCard
v-for="vm in vmResources"
:key="vm.address"
:resource="vm"
:redeploying="redeployInFlight.has(vm.address)"
:is-expanded="openDrawerAddress === vm.address"
@open-details="openVmDrawer"
@redeploy="redeployVm"
/>
</div>
</section>
<!-- Networks / Subnets / Floating IPs (read-only) -->
<section v-if="networkResources.length > 0" class="mb-6">
<div class="flex items-center gap-2 mb-3">
<Network :size="14" class="text-gray-400" />
<h3 class="text-sm font-bold uppercase tracking-wider text-gray-600">
Netzwerk
</h3>
<span class="px-2 py-0.5 bg-gray-100 text-gray-600 text-xs font-bold rounded">
{{ networkResources.length }}
</span>
</div>
<ul class="space-y-1.5 text-xs">
<li
v-for="res in networkResources"
:key="res.address"
class="px-3 py-2 bg-gray-50 rounded-lg border border-gray-100 flex items-center justify-between"
>
<div class="min-w-0">
<p class="font-semibold text-gray-900 truncate">
{{ res.display_name }}
</p>
<p class="text-gray-500 font-mono truncate" :title="res.address">
{{ res.address }}
</p>
</div>
<span class="text-[10px] uppercase tracking-wider bg-white px-2 py-0.5 rounded border border-gray-300 text-gray-600 ml-2 shrink-0">
{{ res.category }}
</span>
</li>
</ul>
</section>
<!-- Security Groups (read-only) -->
<section v-if="securityResources.length > 0">
<div class="flex items-center gap-2 mb-3">
<Shield :size="14" class="text-gray-400" />
<h3 class="text-sm font-bold uppercase tracking-wider text-gray-600">
Sicherheit
</h3>
<span class="px-2 py-0.5 bg-gray-100 text-gray-600 text-xs font-bold rounded">
{{ securityResources.length }}
</span>
</div>
<ul class="space-y-1.5 text-xs">
<li
v-for="res in securityResources"
:key="res.address"
class="px-3 py-2 bg-gray-50 rounded-lg border border-gray-100"
>
<p class="font-semibold text-gray-900">{{ res.display_name }}</p>
<p class="text-gray-500 font-mono">{{ res.address }}</p>
</li>
</ul>
</section>
</div>
<!-- Tasks / Logs Section — history of finished tasks. The active
task (if any) is rendered above in its own card, so the
list filters it out to avoid double-rendering.
Only the deployment owner / staff sees the actual task
contents — members get a placeholder card instead so the
page layout stays consistent across roles. -->
<div v-if="!isOwnerView" class="bg-white rounded-xl border border-gray-200 p-6 shadow-sm">
<div class="flex items-center gap-3 mb-3">
<div class="p-2 bg-gray-100 rounded-lg">
<Terminal :size="20" class="text-gray-400" />
</div>
<span class="text-lg font-semibold text-gray-700">{{ $t('DeploymentDetailView.tasksAndLogs') }}</span>
</div>
<div class="text-sm text-gray-500 flex items-start gap-2 px-2">
<AlertCircle :size="16" class="text-gray-400 mt-0.5 flex-shrink-0" />
<span>{{ $t('DeploymentDetailView.tasksOwnerOnly') }}</span>
</div>
</div>
<div v-else class="bg-white rounded-xl border border-gray-200 p-6 shadow-sm">
<div class="flex items-center justify-between mb-4">
<div class="flex items-center gap-3">
<div class="p-2 bg-gray-100 rounded-lg">
<Terminal :size="20" class="text-gray-600" />
</div>
<span class="text-lg font-semibold text-gray-900">
{{ isStreamRelevant ? 'Task History' : 'Tasks & Logs' }}
</span>
<span v-if="historyTasks.length > 0"
class="px-2 py-0.5 bg-gray-100 text-gray-600 text-xs font-bold rounded">
{{ historyTasks.length }}
</span>
</div>
<button v-if="selectedTask" @click="deselectTask"
class="flex items-center gap-2 text-primary hover:text-primary/80 transition-colors text-sm">
<CircleArrowLeft :size="16" />
<span>Back to list</span>
</button>
</div>
<!-- Task List View -->
<div v-if="!selectedTask">
<div v-if="loadingTasks" class="flex justify-center py-10">
<Loader2 class="animate-spin text-primary" :size="32" />
</div>
<div v-else-if="historyTasks.length === 0" class="text-center py-10 text-gray-500">
{{ isStreamRelevant ? 'No previous tasks for this deployment.' : 'No tasks found' }}
</div>
<div v-else class="space-y-2">
<div v-for="task in historyTasks" :key="task.taskId" @click="selectTask(task)"
class="flex items-center justify-between p-4 bg-gray-50 rounded-lg hover:bg-gray-100 transition-colors cursor-pointer border border-gray-200 hover:border-primary/30">
<div class="flex items-center gap-4 flex-1">
<component :is="getStatusStyles(task.status).icon" :size="18" :class="task.status === 'success' ? 'text-green-600' :
task.status === 'failed' ? 'text-red-600' :
task.status === 'running' ? 'text-blue-600' : 'text-yellow-600'" />
<div class="flex-1">
<div class="flex items-center gap-3 mb-1">
<span class="font-medium text-gray-900 capitalize">{{ task.type }}</span>
<span
class="inline-flex items-center px-2 py-0.5 rounded text-xs font-semibold border capitalize"
:class="getStatusStyles(task.status).badgeClass">
{{ task.status }}
</span>
</div>
<div class="text-xs text-gray-500">
Created: {{ formatDate(task.created_at) }}
</div>
</div>
</div>
<ChevronDown :size="20" class="text-gray-400 transform -rotate-90" />
</div>
</div>
</div>
<!-- Task Detail View -->
<div v-else class="space-y-4">
<div v-if="loadingTaskDetail" class="flex justify-center py-10">
<Loader2 class="animate-spin text-primary" :size="32" />
</div>
<div v-else>
<div class="bg-gray-50 rounded-lg p-4 border border-gray-200 mb-4">
<div class="grid grid-cols-2 md:grid-cols-4 gap-4 mb-4">
<div>
<div class="text-xs text-gray-500 uppercase tracking-wide mb-1">Type</div>
<div class="text-sm font-medium text-gray-900 capitalize">{{ selectedTask.type }}</div>
</div>
<div>
<div class="text-xs text-gray-500 uppercase tracking-wide mb-1">Status</div>
<span
class="inline-flex items-center px-2 py-0.5 rounded text-xs font-semibold border capitalize"
:class="getStatusStyles(selectedTask.status).badgeClass">
{{ selectedTask.status }}
</span>
</div>
<div>
<div class="text-xs text-gray-500 uppercase tracking-wide mb-1">Started</div>
<div class="text-sm text-gray-700">{{ formatDate(selectedTask.started_at) }}</div>
</div>
<div>
<div class="text-xs text-gray-500 uppercase tracking-wide mb-1">Finished</div>
<div class="text-sm text-gray-700">{{ formatDate(selectedTask.finished_at) }}</div>
</div>
</div>
<div class="grid grid-cols-1 gap-3">
<div>
<div class="text-xs text-gray-500 uppercase tracking-wide mb-1">Task ID</div>
<div class="text-xs font-mono text-gray-700 bg-white px-2 py-1 rounded">{{
selectedTask.taskId
}}</div>
</div>
<div>
<div class="text-xs text-gray-500 uppercase tracking-wide mb-1">Celery Task ID</div>
<div class="text-xs font-mono text-gray-700 bg-white px-2 py-1 rounded">{{
selectedTask.celeryTaskId }}</div>
</div>
<div>
<div class="text-xs text-gray-500 uppercase tracking-wide mb-1">Created At</div>
<div class="text-sm text-gray-700">{{ formatDate(selectedTask.created_at) }}</div>
</div>
</div>
</div>
<!-- Logs — same simple ``<pre>`` rendering as the
Terraform State and Outputs blocks below. The
previous formatted/raw toggle plus numbered
entry cards added a lot of UI surface for
little extra information; pretty-printed JSON
is uniform and lets the browser handle search
(Cmd+F) consistently across all three blocks. -->
<div v-if="selectedTask.logs" class="mb-4">
<div class="bg-white rounded-lg border border-gray-200 overflow-hidden">
<div
class="bg-gradient-to-r from-emerald-50 to-green-50 px-4 py-3 border-b border-gray-200 flex items-center justify-between">
<div class="flex items-center gap-2">
<div class="p-1.5 bg-white rounded-md border border-emerald-200">
<Terminal :size="16" class="text-emerald-600" />
</div>
<span class="font-semibold text-gray-900">Logs</span>
<span v-if="logEntryCount !== null"
class="px-2 py-0.5 bg-emerald-100 text-emerald-700 text-xs font-bold rounded border border-emerald-200">
{{ logEntryCount }} entries
</span>
</div>
<button @click="copyToClipboard(prettyJson(selectedTask.logs), 'logs')"
:title="copiedKey === 'logs' ? 'Copied!' : 'Copy to clipboard'"
class="flex items-center gap-1.5 px-2.5 py-1 text-xs font-medium rounded-md border transition-colors"
:class="copiedKey === 'logs'
? 'bg-emerald-600 text-white border-emerald-600'
: 'bg-white text-gray-700 border-gray-300 hover:bg-gray-50'">
<component :is="copiedKey === 'logs' ? Check : Copy" :size="13" />
{{ copiedKey === 'logs' ? 'Copied' : 'Copy' }}
</button>
</div>
<div class="bg-gray-50 p-4 overflow-y-auto max-h-[500px]">
<div class="bg-white rounded-lg border border-gray-200 p-4">
<!-- Failure-Sonderfall: bei einem
backend-formatierten
``Task failed: ...``-String
splitten wir die freundliche
Headline von der technischen
Trace-Section. Die Headline
steht direkt sichtbar in rot;
die Details liegen hinter
einem Toggle, damit der
Endnutzer nicht sofort einen
30-zeiligen Python-Stack-Trace
vor sich hat. -->
<template v-if="taskLogsSplit.isFailure">
<div class="flex items-start gap-2 text-sm text-red-700 mb-3">
<AlertCircle :size="18" class="mt-0.5 flex-shrink-0" />
<div class="font-medium leading-relaxed whitespace-pre-wrap">{{ taskLogsSplit.headline }}</div>
</div>
<button
v-if="taskLogsSplit.details"
type="button"
class="text-xs text-gray-600 hover:text-gray-900 underline mb-2"
@click="showTaskLogsTrace = !showTaskLogsTrace"
>
{{ showTaskLogsTrace ? 'Technische Details ausblenden' : 'Technische Details anzeigen' }}
</button>
<pre
v-if="showTaskLogsTrace && taskLogsSplit.details"
class="text-gray-700 font-mono text-xs leading-relaxed whitespace-pre-wrap"
>{{ taskLogsSplit.details }}</pre>
</template>
<pre v-else class="text-gray-700 font-mono text-xs leading-relaxed whitespace-pre-wrap" v-html="highlightJson(prettyJson(selectedTask.logs))"></pre>
</div>
</div>
</div>
</div>
<div v-else class="mb-4">
<div class="bg-white rounded-lg border border-gray-200 overflow-hidden">
<div class="bg-gray-50 px-4 py-3 border-b border-gray-200">
<div class="flex items-center gap-2">
<Terminal :size="16" class="text-gray-400" />
<span class="font-semibold text-gray-700">Logs</span>
</div>
</div>
<div class="text-center py-8 text-gray-500">
<Terminal :size="32" class="mx-auto mb-2 text-gray-300" />
<p class="text-sm">No logs available for this task</p>
</div>
</div>
</div>
<div v-if="activeDataTask?.tf_state" class="mb-4">
<div class="bg-white rounded-lg border border-gray-200 overflow-hidden shadow-sm">
<div
class="bg-gradient-to-r from-blue-50 to-indigo-50 px-4 py-3 border-b border-gray-200 flex items-center justify-between select-none">
<div class="flex items-center gap-2">
<div class="p-1.5 bg-white rounded-md border border-blue-200">
<Settings :size="16" class="text-blue-600" />
</div>
<div class="flex flex-col text-left">
<span class="font-semibold text-gray-900">{{
$t('DeploymentDetailView.terraformState')
}}</span>
<span class="text-xs text-gray-500">
{{ tfResourcesCount > 0 ? `${tfResourcesCount} verwaltete Ressourcen` :
'Erweiterte Details' }}
</span>
</div>
</div>
<button @click="copyToClipboard(prettyJson(activeDataTask?.tf_state), 'tf_state')"
:title="copiedKey === 'tf_state' ? 'Kopiert!' : 'In die Zwischenablage kopieren'"
class="flex items-center gap-1.5 px-2.5 py-1 text-xs font-medium rounded-md border transition-colors flex-shrink-0"
:class="copiedKey === 'tf_state'
? 'bg-blue-600 text-white border-blue-600'
: 'bg-white text-gray-700 border-gray-300 hover:bg-gray-50'">
<component :is="copiedKey === 'tf_state' ? Check : Copy" :size="13" />
{{ copiedKey === 'tf_state' ? 'Copied' : 'Copy' }}
</button>
</div>
<div class="bg-white p-4 overflow-y-auto max-h-[500px]">
<div
class="font-mono text-xs leading-relaxed text-left whitespace-pre-wrap select-text">
<pre v-html="highlightJson(prettyJson(activeDataTask.tf_state))"></pre>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!--
VM detail sidebar — sticky right column. Conditionally
rendered: only takes space when the user opened a VM.
``sticky top-6`` keeps the panel in view as the user
scrolls the main content; ``max-h-[calc(100vh-6rem)]``
clamps the panel to the viewport (minus the App-Header
+ a comfortable gap at top/bottom). The inner
``InfrastructureVmDrawer`` keeps its own
``overflow-y-auto`` body, so the panel scrolls
independently of the left column without breaking
its rounded corners.
On smaller screens (below ``xl``) the sidebar falls
into the page flow as a normal-width card under the
main content — no sticky there, the column-layout
doesn't survive narrow viewports anyway.
-->
<aside
v-if="openDrawerAddress"
class="w-full xl:w-[420px] xl:shrink-0 xl:sticky xl:top-0 xl:self-start xl:max-h-[calc(100vh-3.5rem)] xl:flex xl:flex-col"
>
<InfrastructureVmDrawer
:deployment-id="deploymentId"
:address="openDrawerAddress"
class="xl:flex-1 xl:min-h-0"
@close="closeVmDrawer"
/>
</aside>
</div>
<!-- Delete Confirmation Modal -->
<Modal :show="showDeleteModal" @close="showDeleteModal = false">
<template #title>
{{ $t('DeploymentDetailView.confirmDeleteTitle') }}
</template>
<template #body>
<p class="text-gray-700" v-html="$t('DeploymentDetailView.confirmDeleteMessage', { name: deployment.name })"></p>
</template>
<template #footer>
<div class="flex justify-end gap-3">
<BaseButton variant="ghost" @click="showDeleteModal = false">
{{ $t('DeploymentDetailView.cancelButton') }}
</BaseButton>
<BaseButton variant="red" @click="confirmDelete">
{{ $t('DeploymentDetailView.confirmButton') }}
</BaseButton>
</div>
</template>
</Modal>
<!-- Redeploy Confirmation Modal — same shape as Delete: a
yellow Cancel and a red Confirm. We surface the VM
address in the body so the user can sanity-check which
instance they're about to recreate. The Modal is the
single source of truth; we never fall back to
``window.confirm``. -->
<Modal :show="showRedeployModal" @close="showRedeployModal = false">
<template #title>
VM neu erstellen?
</template>
<template #body>
<div class="space-y-3">
<p class="text-gray-700">
Diese VM wird zerstört und identisch neu erstellt.
Andere VMs in diesem Deployment bleiben unangetastet.
</p>
<p v-if="redeployTargetAddress" class="text-xs font-mono text-gray-600 bg-gray-50 border border-gray-200 rounded-lg px-3 py-2 break-all">
{{ redeployTargetAddress }}
</p>
</div>
</template>
<template #footer>
<div class="flex justify-end gap-3">
<BaseButton variant="ghost" @click="showRedeployModal = false">
{{ $t('DeploymentDetailView.cancelButton') }}
</BaseButton>
<BaseButton variant="red" @click="confirmRedeploy">
Redeploy
</BaseButton>
</div>
</template>
</Modal>
<!-- Pause / Resume confirm. Same pattern as Delete: a tiny
modal that asks the user to confirm before we POST. The
title/body switch on ``pauseResumeAction`` so we don't
render two near-identical modals. -->
<Modal :show="showPauseResumeModal" @close="showPauseResumeModal = false">
<template #title>
{{ pauseResumeAction === 'pause'
? $t('DeploymentDetailView.confirmPauseTitle')
: $t('DeploymentDetailView.confirmResumeTitle') }}
</template>
<template #body>
<p class="text-gray-700" v-html="pauseResumeAction === 'pause'
? $t('DeploymentDetailView.confirmPauseMessage', { name: deployment.name })
: $t('DeploymentDetailView.confirmResumeMessage', { name: deployment.name })"></p>
</template>
<template #footer>
<div class="flex justify-end gap-3">
<BaseButton variant="ghost" @click="showPauseResumeModal = false">
{{ $t('DeploymentDetailView.cancelButton') }}
</BaseButton>
<BaseButton
:variant="pauseResumeAction === 'pause' ? 'yellow' : 'green'"
@click="confirmPauseResume"
:disabled="pauseResumeBusy">
{{ pauseResumeAction === 'pause'
? $t('DeploymentDetailView.deploymentPause')
: $t('DeploymentDetailView.deploymentResume') }}
</BaseButton>
</div>
</template>
</Modal>
</div>
<!-- Loading State -->
<div v-else class="flex items-center justify-center py-20">
<Loader2 class="animate-spin text-primary" :size="40" />
</div>
</template> |