UI Updates, and fix UTF8 issues
This commit is contained in:
+30
-20
@@ -918,10 +918,7 @@
|
||||
"permission denied",
|
||||
"no supported methods",
|
||||
];
|
||||
const hostKeyPatterns = [
|
||||
"host key",
|
||||
"fingerprint",
|
||||
];
|
||||
const hostKeyPatterns = ["host key", "fingerprint"];
|
||||
|
||||
if (authPatterns.some((p) => msg.includes(p))) {
|
||||
return {
|
||||
@@ -959,17 +956,23 @@
|
||||
const session = this.state.getSession(sessionId);
|
||||
const label = session?.tabName || session?.host || "Session";
|
||||
const body = `${info.message}\n\n${message}`;
|
||||
this._showGuidedErrorModal(info.title, label, body, (action) => {
|
||||
if (action === "edit" && session?.profileId) {
|
||||
this.profileEditor.openEdit(session.profileId);
|
||||
}
|
||||
if (action === "retry") {
|
||||
this.tabs._reconnect(sessionId);
|
||||
}
|
||||
if (action === "knownhosts") {
|
||||
this.settings.openTab("knownhosts");
|
||||
}
|
||||
}, info.actions);
|
||||
this._showGuidedErrorModal(
|
||||
info.title,
|
||||
label,
|
||||
body,
|
||||
(action) => {
|
||||
if (action === "edit" && session?.profileId) {
|
||||
this.profileEditor.openEdit(session.profileId);
|
||||
}
|
||||
if (action === "retry") {
|
||||
this.tabs._reconnect(sessionId);
|
||||
}
|
||||
if (action === "knownhosts") {
|
||||
this.settings.openTab("knownhosts");
|
||||
}
|
||||
},
|
||||
info.actions,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1005,15 +1008,20 @@
|
||||
|
||||
const footer = modal.querySelector(".modal-footer");
|
||||
const addActionBtn = (label, action, primary) => {
|
||||
const btn = createElement("button", `btn btn-sm${primary ? " btn-primary" : ""}`, {
|
||||
textContent: label,
|
||||
});
|
||||
const btn = createElement(
|
||||
"button",
|
||||
`btn btn-sm${primary ? " btn-primary" : ""}`,
|
||||
{
|
||||
textContent: label,
|
||||
},
|
||||
);
|
||||
btn.addEventListener("click", () => close(action));
|
||||
footer.appendChild(btn);
|
||||
};
|
||||
|
||||
addActionBtn("Close", null, false);
|
||||
if (actions.includes("knownhosts")) addActionBtn("Known Hosts", "knownhosts", false);
|
||||
if (actions.includes("knownhosts"))
|
||||
addActionBtn("Known Hosts", "knownhosts", false);
|
||||
if (actions.includes("edit")) addActionBtn("Edit Profile", "edit", false);
|
||||
if (actions.includes("retry")) addActionBtn("Retry", "retry", true);
|
||||
|
||||
@@ -1024,7 +1032,9 @@
|
||||
if (action) onAction(action);
|
||||
};
|
||||
|
||||
modal.querySelector(".modal-close").addEventListener("click", () => close(null));
|
||||
modal
|
||||
.querySelector(".modal-close")
|
||||
.addEventListener("click", () => close(null));
|
||||
backdrop.addEventListener("click", (e) => {
|
||||
if (e.target === backdrop) close(null);
|
||||
});
|
||||
|
||||
+331
-299
@@ -1,17 +1,17 @@
|
||||
(function() {
|
||||
/**
|
||||
* Nexus Terminal — GitHub repository viewer.
|
||||
* Renders a scrollable list of repositories grouped by owner/organisation,
|
||||
* sorted by last commit date (newest first). Automatically refreshes via
|
||||
* Wails events emitted by the Go backend.
|
||||
*/
|
||||
(function () {
|
||||
/**
|
||||
* Nexus Terminal — GitHub repository viewer.
|
||||
* Renders a scrollable list of repositories grouped by owner/organisation,
|
||||
* sorted by last commit date (newest first). Automatically refreshes via
|
||||
* Wails events emitted by the Go backend.
|
||||
*/
|
||||
|
||||
const { createElement, escapeHtml, relativeTime, $ } = window.NexusTerminal;
|
||||
const { createElement, escapeHtml, relativeTime, $ } = window.NexusTerminal;
|
||||
|
||||
class GitHubViewer {
|
||||
class GitHubViewer {
|
||||
constructor() {
|
||||
/** @type {Map<string, GitHubViewerInstance>} sessionID → viewer */
|
||||
this._viewers = new Map();
|
||||
/** @type {Map<string, GitHubViewerInstance>} sessionID → viewer */
|
||||
this._viewers = new Map();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -21,11 +21,15 @@ class GitHubViewer {
|
||||
* @param {string} profileName
|
||||
*/
|
||||
createViewer(sessionID, container, profileName) {
|
||||
if (this._viewers.has(sessionID)) return;
|
||||
if (this._viewers.has(sessionID)) return;
|
||||
|
||||
const viewer = new GitHubViewerInstance(sessionID, container, profileName);
|
||||
this._viewers.set(sessionID, viewer);
|
||||
viewer.render();
|
||||
const viewer = new GitHubViewerInstance(
|
||||
sessionID,
|
||||
container,
|
||||
profileName,
|
||||
);
|
||||
this._viewers.set(sessionID, viewer);
|
||||
viewer.render();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -33,11 +37,11 @@ class GitHubViewer {
|
||||
* @param {string} sessionID
|
||||
*/
|
||||
destroyViewer(sessionID) {
|
||||
const viewer = this._viewers.get(sessionID);
|
||||
if (viewer) {
|
||||
viewer.destroy();
|
||||
this._viewers.delete(sessionID);
|
||||
}
|
||||
const viewer = this._viewers.get(sessionID);
|
||||
if (viewer) {
|
||||
viewer.destroy();
|
||||
this._viewers.delete(sessionID);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -47,10 +51,10 @@ class GitHubViewer {
|
||||
* @param {Array} repos
|
||||
*/
|
||||
updateRepos(sessionID, login, repos) {
|
||||
const viewer = this._viewers.get(sessionID);
|
||||
if (viewer) {
|
||||
viewer.setData(login, repos);
|
||||
}
|
||||
const viewer = this._viewers.get(sessionID);
|
||||
if (viewer) {
|
||||
viewer.setData(login, repos);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,10 +63,10 @@ class GitHubViewer {
|
||||
* @param {string} message
|
||||
*/
|
||||
setStatus(sessionID, message) {
|
||||
const viewer = this._viewers.get(sessionID);
|
||||
if (viewer) {
|
||||
viewer.setStatus(message);
|
||||
}
|
||||
const viewer = this._viewers.get(sessionID);
|
||||
if (viewer) {
|
||||
viewer.setStatus(message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,98 +75,98 @@ class GitHubViewer {
|
||||
* @param {string} message
|
||||
*/
|
||||
showError(sessionID, message) {
|
||||
const viewer = this._viewers.get(sessionID);
|
||||
if (viewer) {
|
||||
viewer.showError(message);
|
||||
}
|
||||
const viewer = this._viewers.get(sessionID);
|
||||
if (viewer) {
|
||||
viewer.showError(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class GitHubViewerInstance {
|
||||
class GitHubViewerInstance {
|
||||
/**
|
||||
* @param {string} sessionID
|
||||
* @param {HTMLElement} container
|
||||
* @param {string} profileName
|
||||
*/
|
||||
constructor(sessionID, container, profileName) {
|
||||
this.sessionID = sessionID;
|
||||
this.container = container;
|
||||
this.profileName = profileName;
|
||||
this.sessionID = sessionID;
|
||||
this.container = container;
|
||||
this.profileName = profileName;
|
||||
|
||||
/** @type {string} */
|
||||
this._login = '';
|
||||
/** @type {string} */
|
||||
this._login = "";
|
||||
|
||||
/** @type {Array} */
|
||||
this._repos = [];
|
||||
/** @type {Array} */
|
||||
this._repos = [];
|
||||
|
||||
/** @type {string} */
|
||||
this._filter = '';
|
||||
/** @type {string} */
|
||||
this._filter = "";
|
||||
|
||||
/** @type {HTMLElement|null} */
|
||||
this._el = null;
|
||||
/** @type {HTMLElement|null} */
|
||||
this._el = null;
|
||||
|
||||
/** @type {HTMLElement|null} */
|
||||
this._listEl = null;
|
||||
/** @type {HTMLElement|null} */
|
||||
this._listEl = null;
|
||||
|
||||
/** @type {HTMLElement|null} */
|
||||
this._statusEl = null;
|
||||
/** @type {HTMLElement|null} */
|
||||
this._statusEl = null;
|
||||
|
||||
/** @type {number|null} */
|
||||
this._refreshTimer = null;
|
||||
/** @type {number|null} */
|
||||
this._refreshTimer = null;
|
||||
}
|
||||
|
||||
render() {
|
||||
this.container.innerHTML = '';
|
||||
this.container.innerHTML = "";
|
||||
|
||||
const wrapper = createElement('div', 'github-viewer');
|
||||
const wrapper = createElement("div", "github-viewer");
|
||||
|
||||
// ── Header bar ──────────────────────────────────────────
|
||||
const header = createElement('div', 'github-viewer-header');
|
||||
// ── Header bar ──────────────────────────────────────────
|
||||
const header = createElement("div", "github-viewer-header");
|
||||
|
||||
const titleArea = createElement('div', 'github-viewer-title-area');
|
||||
const icon = createElement('span', 'github-viewer-icon');
|
||||
icon.innerHTML = this._githubSVG();
|
||||
titleArea.appendChild(icon);
|
||||
const titleArea = createElement("div", "github-viewer-title-area");
|
||||
const icon = createElement("span", "github-viewer-icon");
|
||||
icon.innerHTML = this._githubSVG();
|
||||
titleArea.appendChild(icon);
|
||||
|
||||
const titleText = createElement('span', 'github-viewer-title');
|
||||
titleText.textContent = this.profileName || 'GitHub';
|
||||
titleArea.appendChild(titleText);
|
||||
header.appendChild(titleArea);
|
||||
const titleText = createElement("span", "github-viewer-title");
|
||||
titleText.textContent = this.profileName || "GitHub";
|
||||
titleArea.appendChild(titleText);
|
||||
header.appendChild(titleArea);
|
||||
|
||||
// Search / filter
|
||||
const searchWrap = createElement('div', 'github-viewer-search');
|
||||
const searchInput = createElement('input', 'github-viewer-search-input', {
|
||||
type: 'text',
|
||||
placeholder: 'Filter repositories…',
|
||||
});
|
||||
searchInput.addEventListener('input', (e) => {
|
||||
this._filter = e.target.value.toLowerCase();
|
||||
this._renderList();
|
||||
});
|
||||
searchWrap.appendChild(searchInput);
|
||||
header.appendChild(searchWrap);
|
||||
// Search / filter
|
||||
const searchWrap = createElement("div", "github-viewer-search");
|
||||
const searchInput = createElement("input", "github-viewer-search-input", {
|
||||
type: "text",
|
||||
placeholder: "Filter repositories…",
|
||||
});
|
||||
searchInput.addEventListener("input", (e) => {
|
||||
this._filter = e.target.value.toLowerCase();
|
||||
this._renderList();
|
||||
});
|
||||
searchWrap.appendChild(searchInput);
|
||||
header.appendChild(searchWrap);
|
||||
|
||||
// Refresh button
|
||||
const refreshBtn = createElement('button', 'github-viewer-refresh', {
|
||||
title: 'Refresh now',
|
||||
});
|
||||
refreshBtn.innerHTML = '↻';
|
||||
refreshBtn.addEventListener('click', () => this._manualRefresh());
|
||||
header.appendChild(refreshBtn);
|
||||
// Refresh button
|
||||
const refreshBtn = createElement("button", "github-viewer-refresh", {
|
||||
title: "Refresh now",
|
||||
});
|
||||
refreshBtn.innerHTML = "↻";
|
||||
refreshBtn.addEventListener("click", () => this._manualRefresh());
|
||||
header.appendChild(refreshBtn);
|
||||
|
||||
wrapper.appendChild(header);
|
||||
wrapper.appendChild(header);
|
||||
|
||||
// ── Status bar ──────────────────────────────────────────
|
||||
this._statusEl = createElement('div', 'github-viewer-status');
|
||||
this._statusEl.textContent = 'Connecting…';
|
||||
wrapper.appendChild(this._statusEl);
|
||||
// ── Status bar ──────────────────────────────────────────
|
||||
this._statusEl = createElement("div", "github-viewer-status");
|
||||
this._statusEl.textContent = "Connecting…";
|
||||
wrapper.appendChild(this._statusEl);
|
||||
|
||||
// ── Repo list ───────────────────────────────────────────
|
||||
this._listEl = createElement('div', 'github-viewer-list');
|
||||
wrapper.appendChild(this._listEl);
|
||||
// ── Repo list ───────────────────────────────────────────
|
||||
this._listEl = createElement("div", "github-viewer-list");
|
||||
wrapper.appendChild(this._listEl);
|
||||
|
||||
this.container.appendChild(wrapper);
|
||||
this._el = wrapper;
|
||||
this.container.appendChild(wrapper);
|
||||
this._el = wrapper;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -171,10 +175,10 @@ class GitHubViewerInstance {
|
||||
* @param {Array} repos
|
||||
*/
|
||||
setData(login, repos) {
|
||||
this._login = login;
|
||||
this._repos = repos || [];
|
||||
this._updateStatus();
|
||||
this._renderList();
|
||||
this._login = login;
|
||||
this._repos = repos || [];
|
||||
this._updateStatus();
|
||||
this._renderList();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -182,9 +186,9 @@ class GitHubViewerInstance {
|
||||
* @param {string} message
|
||||
*/
|
||||
setStatus(message) {
|
||||
if (!this._statusEl) return;
|
||||
this._statusEl.classList.remove('github-viewer-status-error');
|
||||
this._statusEl.textContent = message || '';
|
||||
if (!this._statusEl) return;
|
||||
this._statusEl.classList.remove("github-viewer-status-error");
|
||||
this._statusEl.textContent = message || "";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -192,89 +196,108 @@ class GitHubViewerInstance {
|
||||
* @param {string} message
|
||||
*/
|
||||
showError(message) {
|
||||
if (this._statusEl) {
|
||||
this._statusEl.textContent = `⚠ ${message}`;
|
||||
this._statusEl.classList.add('github-viewer-status-error');
|
||||
}
|
||||
if (this._statusEl) {
|
||||
this._statusEl.textContent = `⚠ ${message}`;
|
||||
this._statusEl.classList.add("github-viewer-status-error");
|
||||
}
|
||||
}
|
||||
|
||||
destroy() {
|
||||
if (this._refreshTimer) {
|
||||
clearInterval(this._refreshTimer);
|
||||
this._refreshTimer = null;
|
||||
}
|
||||
if (this._el) {
|
||||
this._el.remove();
|
||||
this._el = null;
|
||||
}
|
||||
if (this._refreshTimer) {
|
||||
clearInterval(this._refreshTimer);
|
||||
this._refreshTimer = null;
|
||||
}
|
||||
if (this._el) {
|
||||
this._el.remove();
|
||||
this._el = null;
|
||||
}
|
||||
}
|
||||
|
||||
// ── Private ──────────────────────────────────────────────────
|
||||
|
||||
_updateStatus() {
|
||||
if (!this._statusEl) return;
|
||||
this._statusEl.classList.remove('github-viewer-status-error');
|
||||
if (!this._statusEl) return;
|
||||
this._statusEl.classList.remove("github-viewer-status-error");
|
||||
|
||||
const count = this._repos.length;
|
||||
const now = new Date().toLocaleTimeString();
|
||||
this._statusEl.textContent = `${this._login} · ${count} repositor${count === 1 ? 'y' : 'ies'} · updated ${now}`;
|
||||
const count = this._repos.length;
|
||||
const now = new Date().toLocaleTimeString();
|
||||
this._statusEl.textContent = `${this._login} · ${count} repositor${count === 1 ? "y" : "ies"} · updated ${now}`;
|
||||
}
|
||||
|
||||
_renderList() {
|
||||
if (!this._listEl) return;
|
||||
this._listEl.innerHTML = '';
|
||||
if (!this._listEl) return;
|
||||
this._listEl.innerHTML = "";
|
||||
|
||||
// Filter
|
||||
let filtered = this._repos;
|
||||
if (this._filter) {
|
||||
filtered = this._repos.filter((r) =>
|
||||
r.fullName.toLowerCase().includes(this._filter) ||
|
||||
(r.description || '').toLowerCase().includes(this._filter) ||
|
||||
(r.language || '').toLowerCase().includes(this._filter)
|
||||
);
|
||||
}
|
||||
// Filter
|
||||
let filtered = this._repos;
|
||||
if (this._filter) {
|
||||
filtered = this._repos.filter(
|
||||
(r) =>
|
||||
r.fullName.toLowerCase().includes(this._filter) ||
|
||||
(r.description || "").toLowerCase().includes(this._filter) ||
|
||||
(r.language || "").toLowerCase().includes(this._filter),
|
||||
);
|
||||
}
|
||||
|
||||
if (filtered.length === 0) {
|
||||
const empty = createElement('div', 'github-viewer-empty');
|
||||
empty.textContent = this._filter ? 'No matching repositories.' : 'No repositories found.';
|
||||
this._listEl.appendChild(empty);
|
||||
return;
|
||||
}
|
||||
if (filtered.length === 0) {
|
||||
const empty = createElement("div", "github-viewer-empty");
|
||||
empty.textContent = this._filter
|
||||
? "No matching repositories."
|
||||
: "No repositories found.";
|
||||
this._listEl.appendChild(empty);
|
||||
return;
|
||||
}
|
||||
|
||||
// Group by owner
|
||||
const groups = new Map();
|
||||
for (const repo of filtered) {
|
||||
const owner = repo.owner || 'unknown';
|
||||
if (!groups.has(owner)) groups.set(owner, []);
|
||||
groups.get(owner).push(repo);
|
||||
}
|
||||
const commitTimestamp = (repo) => {
|
||||
const raw = repo.latestCommitAt || repo.pushedAt || repo.updatedAt || "";
|
||||
const ts = new Date(raw).getTime();
|
||||
return Number.isNaN(ts) ? 0 : ts;
|
||||
};
|
||||
|
||||
// Sort groups alphabetically (user's own repos first)
|
||||
const sortedKeys = [...groups.keys()].sort((a, b) => {
|
||||
if (a === this._login) return -1;
|
||||
if (b === this._login) return 1;
|
||||
return a.localeCompare(b);
|
||||
});
|
||||
// Group by owner
|
||||
const groups = new Map();
|
||||
for (const repo of filtered) {
|
||||
const owner = repo.owner || "unknown";
|
||||
if (!groups.has(owner)) groups.set(owner, []);
|
||||
groups.get(owner).push(repo);
|
||||
}
|
||||
|
||||
for (const owner of sortedKeys) {
|
||||
const repos = groups.get(owner);
|
||||
// Sort repos within each group by latest commit (newest first)
|
||||
for (const repos of groups.values()) {
|
||||
repos.sort((a, b) => commitTimestamp(b) - commitTimestamp(a));
|
||||
}
|
||||
|
||||
// Group header
|
||||
const groupEl = createElement('div', 'github-group');
|
||||
const groupHeader = createElement('div', 'github-group-header');
|
||||
groupHeader.innerHTML = `
|
||||
// Sort groups by most recent commit in each group (login first on ties)
|
||||
const sortedKeys = [...groups.keys()].sort((a, b) => {
|
||||
const aRepos = groups.get(a) || [];
|
||||
const bRepos = groups.get(b) || [];
|
||||
const aMax = aRepos.length > 0 ? commitTimestamp(aRepos[0]) : 0;
|
||||
const bMax = bRepos.length > 0 ? commitTimestamp(bRepos[0]) : 0;
|
||||
if (aMax !== bMax) return bMax - aMax;
|
||||
if (a === this._login) return -1;
|
||||
if (b === this._login) return 1;
|
||||
return a.localeCompare(b);
|
||||
});
|
||||
|
||||
for (const owner of sortedKeys) {
|
||||
const repos = groups.get(owner);
|
||||
|
||||
// Group header
|
||||
const groupEl = createElement("div", "github-group");
|
||||
const groupHeader = createElement("div", "github-group-header");
|
||||
groupHeader.innerHTML = `
|
||||
<span class="github-group-name">${escapeHtml(owner)}</span>
|
||||
<span class="github-group-count">${repos.length}</span>
|
||||
`;
|
||||
groupEl.appendChild(groupHeader);
|
||||
groupEl.appendChild(groupHeader);
|
||||
|
||||
// Repo cards
|
||||
for (const repo of repos) {
|
||||
groupEl.appendChild(this._renderRepoCard(repo));
|
||||
}
|
||||
|
||||
this._listEl.appendChild(groupEl);
|
||||
// Repo cards
|
||||
for (const repo of repos) {
|
||||
groupEl.appendChild(this._renderRepoCard(repo));
|
||||
}
|
||||
|
||||
this._listEl.appendChild(groupEl);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -283,135 +306,145 @@ class GitHubViewerInstance {
|
||||
* @returns {HTMLElement}
|
||||
*/
|
||||
_renderRepoCard(repo) {
|
||||
const card = createElement('div', 'github-repo-card');
|
||||
card.addEventListener('click', () => {
|
||||
if (repo.htmlURL) window.open(repo.htmlURL, '_blank');
|
||||
});
|
||||
const card = createElement("div", "github-repo-card");
|
||||
card.addEventListener("click", () => {
|
||||
if (repo.htmlURL) window.open(repo.htmlURL, "_blank");
|
||||
});
|
||||
|
||||
// Top row: name + badges
|
||||
const topRow = createElement('div', 'github-repo-top');
|
||||
const nameEl = createElement('span', 'github-repo-name');
|
||||
nameEl.textContent = repo.name;
|
||||
topRow.appendChild(nameEl);
|
||||
// Top row: name + badges
|
||||
const topRow = createElement("div", "github-repo-top");
|
||||
const nameEl = createElement("span", "github-repo-name");
|
||||
nameEl.textContent = repo.name;
|
||||
topRow.appendChild(nameEl);
|
||||
|
||||
if (repo.private) {
|
||||
const badge = createElement(
|
||||
"span",
|
||||
"github-repo-badge github-repo-private",
|
||||
);
|
||||
badge.textContent = "Private";
|
||||
topRow.appendChild(badge);
|
||||
}
|
||||
if (repo.fork) {
|
||||
const badge = createElement(
|
||||
"span",
|
||||
"github-repo-badge github-repo-fork",
|
||||
);
|
||||
badge.textContent = "Fork";
|
||||
topRow.appendChild(badge);
|
||||
}
|
||||
if (repo.archived) {
|
||||
const badge = createElement(
|
||||
"span",
|
||||
"github-repo-badge github-repo-archived",
|
||||
);
|
||||
badge.textContent = "Archived";
|
||||
topRow.appendChild(badge);
|
||||
}
|
||||
|
||||
if (repo.private) {
|
||||
const badge = createElement('span', 'github-repo-badge github-repo-private');
|
||||
badge.textContent = 'Private';
|
||||
topRow.appendChild(badge);
|
||||
}
|
||||
if (repo.fork) {
|
||||
const badge = createElement('span', 'github-repo-badge github-repo-fork');
|
||||
badge.textContent = 'Fork';
|
||||
topRow.appendChild(badge);
|
||||
}
|
||||
if (repo.archived) {
|
||||
const badge = createElement('span', 'github-repo-badge github-repo-archived');
|
||||
badge.textContent = 'Archived';
|
||||
topRow.appendChild(badge);
|
||||
const actions = createElement("div", "github-repo-actions");
|
||||
|
||||
const downloadBtn = createElement("button", "github-repo-download", {
|
||||
textContent: "ZIP",
|
||||
title: "Download repository as zip",
|
||||
});
|
||||
downloadBtn.addEventListener("click", (e) => {
|
||||
e.stopPropagation();
|
||||
this._downloadRepo(repo);
|
||||
});
|
||||
actions.appendChild(downloadBtn);
|
||||
|
||||
const visitLink = createElement("button", "github-repo-visit", {
|
||||
textContent: "Visit",
|
||||
title: "Open repository in browser",
|
||||
});
|
||||
visitLink.addEventListener("click", (e) => {
|
||||
e.stopPropagation();
|
||||
if (repo.htmlURL) {
|
||||
if (window.runtime && window.runtime.BrowserOpenURL) {
|
||||
window.runtime.BrowserOpenURL(repo.htmlURL);
|
||||
} else {
|
||||
window.open(repo.htmlURL, "_blank");
|
||||
}
|
||||
}
|
||||
});
|
||||
actions.appendChild(visitLink);
|
||||
|
||||
const actions = createElement('div', 'github-repo-actions');
|
||||
topRow.appendChild(actions);
|
||||
|
||||
const downloadBtn = createElement('button', 'github-repo-download', {
|
||||
textContent: 'ZIP',
|
||||
title: 'Download repository as zip',
|
||||
});
|
||||
downloadBtn.addEventListener('click', (e) => {
|
||||
e.stopPropagation();
|
||||
this._downloadRepo(repo);
|
||||
});
|
||||
actions.appendChild(downloadBtn);
|
||||
card.appendChild(topRow);
|
||||
|
||||
const visitLink = createElement('button', 'github-repo-visit', {
|
||||
textContent: 'Visit',
|
||||
title: 'Open repository in browser',
|
||||
});
|
||||
visitLink.addEventListener('click', (e) => {
|
||||
e.stopPropagation();
|
||||
if (repo.htmlURL) {
|
||||
if (window.runtime && window.runtime.BrowserOpenURL) {
|
||||
window.runtime.BrowserOpenURL(repo.htmlURL);
|
||||
} else {
|
||||
window.open(repo.htmlURL, '_blank');
|
||||
}
|
||||
}
|
||||
});
|
||||
actions.appendChild(visitLink);
|
||||
if (repo.latestCommitter && repo.latestCommitAt) {
|
||||
const commitLine = createElement("div", "github-repo-commit");
|
||||
const when = new Date(repo.latestCommitAt);
|
||||
const whenText = isNaN(when.getTime())
|
||||
? repo.latestCommitAt
|
||||
: when.toLocaleString();
|
||||
commitLine.textContent = `Last commit: ${whenText} by ${repo.latestCommitter}`;
|
||||
card.appendChild(commitLine);
|
||||
}
|
||||
|
||||
topRow.appendChild(actions);
|
||||
// Description
|
||||
if (repo.description) {
|
||||
const desc = createElement("div", "github-repo-desc");
|
||||
desc.textContent = repo.description;
|
||||
card.appendChild(desc);
|
||||
}
|
||||
|
||||
card.appendChild(topRow);
|
||||
// Meta row: language, stars, pushed
|
||||
const meta = createElement("div", "github-repo-meta");
|
||||
|
||||
if (repo.latestCommitter && repo.latestCommitAt) {
|
||||
const commitLine = createElement('div', 'github-repo-commit');
|
||||
const when = new Date(repo.latestCommitAt);
|
||||
const whenText = isNaN(when.getTime()) ? repo.latestCommitAt : when.toLocaleString();
|
||||
commitLine.textContent = `Last commit: ${whenText} by ${repo.latestCommitter}`;
|
||||
card.appendChild(commitLine);
|
||||
}
|
||||
if (repo.language) {
|
||||
const lang = createElement("span", "github-repo-lang");
|
||||
lang.innerHTML = `<span class="github-lang-dot" style="background:${this._langColour(repo.language)}"></span> ${escapeHtml(repo.language)}`;
|
||||
meta.appendChild(lang);
|
||||
}
|
||||
|
||||
// Description
|
||||
if (repo.description) {
|
||||
const desc = createElement('div', 'github-repo-desc');
|
||||
desc.textContent = repo.description;
|
||||
card.appendChild(desc);
|
||||
}
|
||||
if (repo.stars > 0) {
|
||||
const stars = createElement("span", "github-repo-stars");
|
||||
stars.textContent = `★ ${repo.stars.toLocaleString()}`;
|
||||
meta.appendChild(stars);
|
||||
}
|
||||
|
||||
// Meta row: language, stars, pushed
|
||||
const meta = createElement('div', 'github-repo-meta');
|
||||
if (repo.pushedAt) {
|
||||
const pushed = createElement("span", "github-repo-pushed");
|
||||
pushed.textContent = relativeTime(repo.pushedAt);
|
||||
pushed.title = new Date(repo.pushedAt).toLocaleString();
|
||||
meta.appendChild(pushed);
|
||||
}
|
||||
|
||||
if (repo.language) {
|
||||
const lang = createElement('span', 'github-repo-lang');
|
||||
lang.innerHTML = `<span class="github-lang-dot" style="background:${this._langColour(repo.language)}"></span> ${escapeHtml(repo.language)}`;
|
||||
meta.appendChild(lang);
|
||||
}
|
||||
card.appendChild(meta);
|
||||
|
||||
if (repo.stars > 0) {
|
||||
const stars = createElement('span', 'github-repo-stars');
|
||||
stars.textContent = `★ ${repo.stars.toLocaleString()}`;
|
||||
meta.appendChild(stars);
|
||||
}
|
||||
|
||||
if (repo.pushedAt) {
|
||||
const pushed = createElement('span', 'github-repo-pushed');
|
||||
pushed.textContent = relativeTime(repo.pushedAt);
|
||||
pushed.title = new Date(repo.pushedAt).toLocaleString();
|
||||
meta.appendChild(pushed);
|
||||
}
|
||||
|
||||
card.appendChild(meta);
|
||||
|
||||
return card;
|
||||
return card;
|
||||
}
|
||||
|
||||
async _downloadRepo(repo) {
|
||||
if (!this._statusEl) return;
|
||||
const ref = repo.defaultBranch || '';
|
||||
this._statusEl.classList.remove('github-viewer-status-error');
|
||||
this._statusEl.textContent = `Downloading ${repo.fullName}...`;
|
||||
if (!this._statusEl) return;
|
||||
const ref = repo.defaultBranch || "";
|
||||
this._statusEl.classList.remove("github-viewer-status-error");
|
||||
this._statusEl.textContent = `Downloading ${repo.fullName}...`;
|
||||
|
||||
try {
|
||||
await window.go.api.Service.DownloadGitHubRepoArchive(
|
||||
this.sessionID,
|
||||
repo.fullName,
|
||||
ref,
|
||||
);
|
||||
this._updateStatus();
|
||||
} catch (err) {
|
||||
this._statusEl.textContent = `⚠ Download failed: ${err}`;
|
||||
this._statusEl.classList.add('github-viewer-status-error');
|
||||
}
|
||||
try {
|
||||
await window.go.api.Service.DownloadGitHubRepoArchive(
|
||||
this.sessionID,
|
||||
repo.fullName,
|
||||
ref,
|
||||
);
|
||||
this._updateStatus();
|
||||
} catch (err) {
|
||||
this._statusEl.textContent = `⚠ Download failed: ${err}`;
|
||||
this._statusEl.classList.add("github-viewer-status-error");
|
||||
}
|
||||
}
|
||||
|
||||
async _manualRefresh() {
|
||||
if (!this._statusEl) return;
|
||||
this._statusEl.textContent = 'Refreshing…';
|
||||
try {
|
||||
await window.go.api.Service.RefreshGitHubRepos(this.sessionID);
|
||||
} catch (err) {
|
||||
this.showError(err.message || 'Refresh failed');
|
||||
}
|
||||
if (!this._statusEl) return;
|
||||
this._statusEl.textContent = "Refreshing…";
|
||||
try {
|
||||
await window.go.api.Service.RefreshGitHubRepos(this.sessionID);
|
||||
} catch (err) {
|
||||
this.showError(err.message || "Refresh failed");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -421,33 +454,33 @@ class GitHubViewerInstance {
|
||||
* @returns {string} CSS colour value.
|
||||
*/
|
||||
_langColour(lang) {
|
||||
const colours = {
|
||||
'JavaScript': '#f1e05a',
|
||||
'TypeScript': '#3178c6',
|
||||
'Python': '#3572A5',
|
||||
'Go': '#00ADD8',
|
||||
'Rust': '#dea584',
|
||||
'Java': '#b07219',
|
||||
'C': '#555555',
|
||||
'C++': '#f34b7d',
|
||||
'C#': '#178600',
|
||||
'Ruby': '#701516',
|
||||
'PHP': '#4F5D95',
|
||||
'Swift': '#F05138',
|
||||
'Kotlin': '#A97BFF',
|
||||
'Shell': '#89e051',
|
||||
'HTML': '#e34c26',
|
||||
'CSS': '#563d7c',
|
||||
'Dart': '#00B4AB',
|
||||
'Lua': '#000080',
|
||||
'Scala': '#c22d40',
|
||||
'Elixir': '#6e4a7e',
|
||||
'Haskell': '#5e5086',
|
||||
'Zig': '#ec915c',
|
||||
'Vue': '#41b883',
|
||||
'SCSS': '#c6538c',
|
||||
};
|
||||
return colours[lang] || '#8b949e';
|
||||
const colours = {
|
||||
JavaScript: "#f1e05a",
|
||||
TypeScript: "#3178c6",
|
||||
Python: "#3572A5",
|
||||
Go: "#00ADD8",
|
||||
Rust: "#dea584",
|
||||
Java: "#b07219",
|
||||
C: "#555555",
|
||||
"C++": "#f34b7d",
|
||||
"C#": "#178600",
|
||||
Ruby: "#701516",
|
||||
PHP: "#4F5D95",
|
||||
Swift: "#F05138",
|
||||
Kotlin: "#A97BFF",
|
||||
Shell: "#89e051",
|
||||
HTML: "#e34c26",
|
||||
CSS: "#563d7c",
|
||||
Dart: "#00B4AB",
|
||||
Lua: "#000080",
|
||||
Scala: "#c22d40",
|
||||
Elixir: "#6e4a7e",
|
||||
Haskell: "#5e5086",
|
||||
Zig: "#ec915c",
|
||||
Vue: "#41b883",
|
||||
SCSS: "#c6538c",
|
||||
};
|
||||
return colours[lang] || "#8b949e";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -455,11 +488,10 @@ class GitHubViewerInstance {
|
||||
* @returns {string}
|
||||
*/
|
||||
_githubSVG() {
|
||||
return '<svg viewBox="0 0 16 16" width="20" height="20" fill="currentColor"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"/></svg>';
|
||||
return '<svg viewBox="0 0 16 16" width="20" height="20" fill="currentColor"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"/></svg>';
|
||||
}
|
||||
}
|
||||
|
||||
window.NexusTerminal = window.NexusTerminal || {};
|
||||
window.NexusTerminal.GitHubViewer = new GitHubViewer();
|
||||
}
|
||||
|
||||
window.NexusTerminal = window.NexusTerminal || {};
|
||||
window.NexusTerminal.GitHubViewer = new GitHubViewer();
|
||||
})();
|
||||
|
||||
+1697
-1214
File diff suppressed because it is too large
Load Diff
+605
-404
File diff suppressed because it is too large
Load Diff
+553
-483
File diff suppressed because it is too large
Load Diff
@@ -214,6 +214,10 @@
|
||||
searchAddon,
|
||||
webLinksAddon,
|
||||
observer,
|
||||
decoder:
|
||||
typeof TextDecoder !== "undefined"
|
||||
? new TextDecoder("utf-8")
|
||||
: null,
|
||||
});
|
||||
|
||||
return term;
|
||||
@@ -230,7 +234,16 @@
|
||||
|
||||
try {
|
||||
const raw = atob(base64Data);
|
||||
entry.term.write(raw);
|
||||
if (entry.decoder) {
|
||||
const bytes = new Uint8Array(raw.length);
|
||||
for (let i = 0; i < raw.length; i++) {
|
||||
bytes[i] = raw.charCodeAt(i);
|
||||
}
|
||||
const text = entry.decoder.decode(bytes, { stream: true });
|
||||
entry.term.write(text);
|
||||
} else {
|
||||
entry.term.write(raw);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("Failed to decode session data:", err);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user