Source: Ora 0.6.1
Browse files- app/package.json +1 -1
- app/renderer/automate.js +48 -13
- app/renderer/styles.css +5 -0
app/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
{
|
| 2 |
"name": "devseis-ora",
|
| 3 |
"productName": "Ora",
|
| 4 |
-
"version": "0.6.
|
| 5 |
"description": "Ora: a step-by-step marketing plan with AI drafts, captions and pictures, on your own free Cloudflare account.",
|
| 6 |
"author": {
|
| 7 |
"name": "Devseis",
|
|
|
|
| 1 |
{
|
| 2 |
"name": "devseis-ora",
|
| 3 |
"productName": "Ora",
|
| 4 |
+
"version": "0.6.1",
|
| 5 |
"description": "Ora: a step-by-step marketing plan with AI drafts, captions and pictures, on your own free Cloudflare account.",
|
| 6 |
"author": {
|
| 7 |
"name": "Devseis",
|
app/renderer/automate.js
CHANGED
|
@@ -18,6 +18,7 @@ const AUTO_LATER = [
|
|
| 18 |
function autoState(id) {
|
| 19 |
const n = online.n8n || {};
|
| 20 |
if (!n.connected) return { key: 'no-n8n', label: 'Needs n8n' };
|
|
|
|
| 21 |
if ((n.off || {})[id]) return { key: 'off', label: 'Disconnected' };
|
| 22 |
if (autoOld(id)) return { key: 'old', label: 'Needs the new file' };
|
| 23 |
const st = (n.accounts || {})[id] || {};
|
|
@@ -86,15 +87,35 @@ function switchBox(a, info) {
|
|
| 86 |
box.appendChild(switchGuide(a.id, online.n8n || {}, {}));
|
| 87 |
return box;
|
| 88 |
}
|
| 89 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
function resetBox(a, info, n) {
|
| 91 |
const box = document.createElement('div'); box.className = 'auto-switch';
|
| 92 |
-
box.innerHTML = '<
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
box.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
return box;
|
| 97 |
}
|
|
|
|
| 98 |
let autoFocus = null, autoScrolled = false; // the card to highlight and bring into view (from Send to n8n)
|
| 99 |
function renderAutomations() {
|
| 100 |
const n = online.n8n || {};
|
|
@@ -118,7 +139,7 @@ function renderAutomations() {
|
|
| 118 |
for (const a of N8N_ACCOUNTS) {
|
| 119 |
const info = AUTO_INFO[a.id], st = autoState(a.id), raw = (n.accounts || {})[a.id] || {};
|
| 120 |
const c = document.createElement('section'); c.className = `panel plan-card auto-card st-${st.key}`; c.dataset.id = a.id;
|
| 121 |
-
c.innerHTML = '<div class="auto-head"><span class="auto-icon"></span><div class="auto-title"><h3></h3><p class="muted small"></p></div><span class="spacer"></span><span class="auto-state"></span></div><div class="auto-when small"><b>Runs:</b> <span></span></div><div class="auto-body"></div>';
|
| 122 |
c.querySelector('.auto-icon').textContent = info.icon; c.querySelector('h3').textContent = info.name;
|
| 123 |
c.querySelector('.auto-title p').textContent = a.does.charAt(0).toUpperCase() + a.does.slice(1) + '.';
|
| 124 |
c.querySelector('.auto-state').textContent = st.label; c.querySelector('.auto-when span').textContent = info.when();
|
|
@@ -131,13 +152,17 @@ function renderAutomations() {
|
|
| 131 |
for (const [label, cls, reset] of [['Reconnect', 'primary', false], ['Reset', 'ghost', true]]) {
|
| 132 |
const b = document.createElement('button'); b.type = 'button'; b.className = cls; b.textContent = label;
|
| 133 |
b.addEventListener('click', async () => {
|
| 134 |
-
|
| 135 |
-
|
|
|
|
|
|
|
| 136 |
autoChecked = 0; renderConnDots(); renderAutomations();
|
| 137 |
});
|
| 138 |
row.appendChild(b);
|
| 139 |
}
|
| 140 |
body.appendChild(row);
|
|
|
|
|
|
|
| 141 |
} else if (st.key === 'old') {
|
| 142 |
// the swap steps once, in the first card that needs them; any other such card points there
|
| 143 |
const first = Object.keys(AUTO_INFO).find(autoOld);
|
|
@@ -147,17 +172,16 @@ function renderAutomations() {
|
|
| 147 |
// Disconnect only once it was ever in use (n8n answered for it, or Ora has its link or address)
|
| 148 |
if (st.key === 'ok' || (raw.why && raw.why !== 'off') || (a.id === 'sheets' ? n.sheetLink : a.id === 'gmail' ? n.email : false)) {
|
| 149 |
const off = document.createElement('button'); off.type = 'button'; off.className = 'mini-link'; off.textContent = 'Disconnect';
|
| 150 |
-
off.addEventListener('click', () => { delete switching[a.id];
|
| 151 |
-
if (st.key === 'ok' && !switching[a.id]
|
| 152 |
const ch = document.createElement('button'); ch.type = 'button'; ch.className = 'link small sw-link'; ch.textContent = 'Change account';
|
| 153 |
-
ch.addEventListener('click', () => { startSwitch(a.id); renderAutomations(); });
|
| 154 |
top.appendChild(ch);
|
| 155 |
}
|
| 156 |
top.appendChild(off);
|
| 157 |
}
|
| 158 |
if (switching[a.id]) { body.appendChild(switchBox(a, info)); list.appendChild(c); continue; }
|
| 159 |
// after Reset: the original setup steps from step 1 (even if the old sign-in still answers), until Done
|
| 160 |
-
if (resetting[a.id]) { body.appendChild(resetBox(a, info, n)); list.appendChild(c); continue; }
|
| 161 |
if (st.key === 'ok') {
|
| 162 |
// set up: the useful bits only
|
| 163 |
const row = document.createElement('div'); row.className = 'ad-row';
|
|
@@ -186,7 +210,7 @@ function renderAutomations() {
|
|
| 186 |
const later = document.createElement('h4'); later.className = 'auto-group'; later.textContent = 'Coming later'; list.appendChild(later);
|
| 187 |
for (const a of AUTO_LATER) {
|
| 188 |
const c = document.createElement('section'); c.className = 'panel plan-card auto-card st-later'; c.dataset.id = a.id;
|
| 189 |
-
c.innerHTML = '<div class="auto-head"><span class="auto-icon"></span><div class="auto-title"><h3></h3><p class="muted small"></p></div><span class="spacer"></span><span class="auto-state">Coming later</span></div><div class="auto-when small"><b>Why not yet:</b> <span></span></div>';
|
| 190 |
c.querySelector('.auto-icon').textContent = a.icon; c.querySelector('h3').textContent = a.name;
|
| 191 |
c.querySelector('.auto-title p').textContent = a.does; c.querySelector('.auto-when span').textContent = a.why;
|
| 192 |
list.appendChild(c);
|
|
@@ -206,6 +230,17 @@ function renderAutomations() {
|
|
| 206 |
$('autoLast').textContent = sent ? `Last sent ${new Date(sent).toLocaleString(undefined, { day: 'numeric', month: 'short', hour: '2-digit', minute: '2-digit' })}: ${plan.automate.posts} posts. Sending again only adds what is new or changed.` : 'Every planned day goes to n8n: a row in your sheet now, a reminder on each post\'s morning, and the LinkedIn posts at their time.';
|
| 207 |
// bring the card that needs attention into view
|
| 208 |
// (the highlight stays until the page is opened again; the scroll happens once)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 209 |
if (autoFocus) {
|
| 210 |
const el = list.querySelector(`[data-id="${autoFocus}"]`) || list.firstElementChild;
|
| 211 |
if (el) { el.classList.add('focus'); if (!autoScrolled) { autoScrolled = true; setTimeout(() => el.scrollIntoView({ behavior: 'smooth', block: 'start' }), 80); } }
|
|
|
|
| 18 |
function autoState(id) {
|
| 19 |
const n = online.n8n || {};
|
| 20 |
if (!n.connected) return { key: 'no-n8n', label: 'Needs n8n' };
|
| 21 |
+
if (resetting()[id]) return { key: 'reset', label: 'Setting up again' };
|
| 22 |
if ((n.off || {})[id]) return { key: 'off', label: 'Disconnected' };
|
| 23 |
if (autoOld(id)) return { key: 'old', label: 'Needs the new file' };
|
| 24 |
const st = (n.accounts || {})[id] || {};
|
|
|
|
| 87 |
box.appendChild(switchGuide(a.id, online.n8n || {}, {}));
|
| 88 |
return box;
|
| 89 |
}
|
| 90 |
+
// After Reset an automation stays off in Ora (n8n may still have the old sign-in, which would answer "on") while its
|
| 91 |
+
// steps show from step 1; Turn it on and test ends the reset when n8n answers that it works. Kept across restarts.
|
| 92 |
+
const RESET_KEY = 'ora.autoReset';
|
| 93 |
+
const resetting = () => store(RESET_KEY) || {};
|
| 94 |
+
const setResetting = (id, on) => { const r = resetting(); if (on) r[id] = true; else delete r[id]; store(RESET_KEY, r); };
|
| 95 |
function resetBox(a, info, n) {
|
| 96 |
const box = document.createElement('div'); box.className = 'auto-switch';
|
| 97 |
+
box.innerHTML = '<p class="muted small">Ora does not use it while you set it up. Use your old account or a new one: when n8n asks you to sign in (<i>Credential</i>), choose <b>Create new</b> to use another account.</p><div class="g-end"></div>';
|
| 98 |
+
const g = a.guide(n, {}), parts = g.querySelectorAll('.g-part');
|
| 99 |
+
if (parts.length > 1) parts[parts.length - 1].remove(); // its own "Check it" part: Turn it on and test below does that
|
| 100 |
+
box.insertBefore(g, box.querySelector('.g-end'));
|
| 101 |
+
const end = el('<button class="primary" type="button">Turn it on and test</button><button class="link" type="button">Cancel</button><span class="small"></span>');
|
| 102 |
+
const [go, cancel] = end.querySelectorAll('button'), note = end.querySelector('span');
|
| 103 |
+
go.addEventListener('click', async () => {
|
| 104 |
+
go.disabled = true; note.className = 'small'; note.textContent = 'Asking n8n…';
|
| 105 |
+
try {
|
| 106 |
+
online = { ...online, ...(await window.ora.n8nAccount(a.id, true)) };
|
| 107 |
+
online = { ...online, ...(await window.ora.n8nTest()) };
|
| 108 |
+
if (((online.n8n.accounts || {})[a.id] || {}).ok) { setResetting(a.id, false); autoChecked = Date.now(); renderConnDots(); renderAutomations(); return; }
|
| 109 |
+
online = { ...online, ...(await window.ora.n8nAccount(a.id, false)) };
|
| 110 |
+
note.className = 'small err'; note.textContent = `Not working yet: finish the steps above (sign-in, switch the boxes on, Save and Publish), then try again.`;
|
| 111 |
+
} catch (e) { note.className = 'small err'; note.textContent = cleanErr(e); }
|
| 112 |
+
go.disabled = false;
|
| 113 |
+
});
|
| 114 |
+
cancel.addEventListener('click', () => { setResetting(a.id, false); renderConnDots(); renderAutomations(); }); // back to Disconnected
|
| 115 |
+
box.querySelector('.g-end').appendChild(end);
|
| 116 |
return box;
|
| 117 |
}
|
| 118 |
+
const openCards = new Set(); // automation cards the learner opened (all start closed)
|
| 119 |
let autoFocus = null, autoScrolled = false; // the card to highlight and bring into view (from Send to n8n)
|
| 120 |
function renderAutomations() {
|
| 121 |
const n = online.n8n || {};
|
|
|
|
| 139 |
for (const a of N8N_ACCOUNTS) {
|
| 140 |
const info = AUTO_INFO[a.id], st = autoState(a.id), raw = (n.accounts || {})[a.id] || {};
|
| 141 |
const c = document.createElement('section'); c.className = `panel plan-card auto-card st-${st.key}`; c.dataset.id = a.id;
|
| 142 |
+
c.innerHTML = '<div class="auto-head"><span class="auto-icon"></span><div class="auto-title"><h3></h3><p class="muted small"></p></div><span class="spacer"></span><span class="auto-state"></span></div><div class="auto-more"><div class="auto-when small"><b>Runs:</b> <span></span></div><div class="auto-body"></div></div>';
|
| 143 |
c.querySelector('.auto-icon').textContent = info.icon; c.querySelector('h3').textContent = info.name;
|
| 144 |
c.querySelector('.auto-title p').textContent = a.does.charAt(0).toUpperCase() + a.does.slice(1) + '.';
|
| 145 |
c.querySelector('.auto-state').textContent = st.label; c.querySelector('.auto-when span').textContent = info.when();
|
|
|
|
| 152 |
for (const [label, cls, reset] of [['Reconnect', 'primary', false], ['Reset', 'ghost', true]]) {
|
| 153 |
const b = document.createElement('button'); b.type = 'button'; b.className = cls; b.textContent = label;
|
| 154 |
b.addEventListener('click', async () => {
|
| 155 |
+
openCards.add(a.id);
|
| 156 |
+
// Reconnect turns it on; Reset keeps it off until its steps are done and tested
|
| 157 |
+
if (reset) { setResetting(a.id, true); const t = ticks(); for (const k of Object.keys(t)) if (k.startsWith(`${a.id}.`)) delete t[k]; store(GUIDE_KEY, t); }
|
| 158 |
+
else online = { ...online, ...(await window.ora.n8nAccount(a.id, true)) };
|
| 159 |
autoChecked = 0; renderConnDots(); renderAutomations();
|
| 160 |
});
|
| 161 |
row.appendChild(b);
|
| 162 |
}
|
| 163 |
body.appendChild(row);
|
| 164 |
+
} else if (st.key === 'reset') {
|
| 165 |
+
body.appendChild(resetBox(a, info, n));
|
| 166 |
} else if (st.key === 'old') {
|
| 167 |
// the swap steps once, in the first card that needs them; any other such card points there
|
| 168 |
const first = Object.keys(AUTO_INFO).find(autoOld);
|
|
|
|
| 172 |
// Disconnect only once it was ever in use (n8n answered for it, or Ora has its link or address)
|
| 173 |
if (st.key === 'ok' || (raw.why && raw.why !== 'off') || (a.id === 'sheets' ? n.sheetLink : a.id === 'gmail' ? n.email : false)) {
|
| 174 |
const off = document.createElement('button'); off.type = 'button'; off.className = 'mini-link'; off.textContent = 'Disconnect';
|
| 175 |
+
off.addEventListener('click', () => { delete switching[a.id]; disconnectAccount(a); });
|
| 176 |
+
if (st.key === 'ok' && !switching[a.id]) {
|
| 177 |
const ch = document.createElement('button'); ch.type = 'button'; ch.className = 'link small sw-link'; ch.textContent = 'Change account';
|
| 178 |
+
ch.addEventListener('click', () => { startSwitch(a.id); openCards.add(a.id); renderAutomations(); });
|
| 179 |
top.appendChild(ch);
|
| 180 |
}
|
| 181 |
top.appendChild(off);
|
| 182 |
}
|
| 183 |
if (switching[a.id]) { body.appendChild(switchBox(a, info)); list.appendChild(c); continue; }
|
| 184 |
// after Reset: the original setup steps from step 1 (even if the old sign-in still answers), until Done
|
|
|
|
| 185 |
if (st.key === 'ok') {
|
| 186 |
// set up: the useful bits only
|
| 187 |
const row = document.createElement('div'); row.className = 'ad-row';
|
|
|
|
| 210 |
const later = document.createElement('h4'); later.className = 'auto-group'; later.textContent = 'Coming later'; list.appendChild(later);
|
| 211 |
for (const a of AUTO_LATER) {
|
| 212 |
const c = document.createElement('section'); c.className = 'panel plan-card auto-card st-later'; c.dataset.id = a.id;
|
| 213 |
+
c.innerHTML = '<div class="auto-head"><span class="auto-icon"></span><div class="auto-title"><h3></h3><p class="muted small"></p></div><span class="spacer"></span><span class="auto-state">Coming later</span></div><div class="auto-more"><div class="auto-when small"><b>Why not yet:</b> <span></span></div></div>';
|
| 214 |
c.querySelector('.auto-icon').textContent = a.icon; c.querySelector('h3').textContent = a.name;
|
| 215 |
c.querySelector('.auto-title p').textContent = a.does; c.querySelector('.auto-when span').textContent = a.why;
|
| 216 |
list.appendChild(c);
|
|
|
|
| 230 |
$('autoLast').textContent = sent ? `Last sent ${new Date(sent).toLocaleString(undefined, { day: 'numeric', month: 'short', hour: '2-digit', minute: '2-digit' })}: ${plan.automate.posts} posts. Sending again only adds what is new or changed.` : 'Every planned day goes to n8n: a row in your sheet now, a reminder on each post\'s morning, and the LinkedIn posts at their time.';
|
| 231 |
// bring the card that needs attention into view
|
| 232 |
// (the highlight stays until the page is opened again; the scroll happens once)
|
| 233 |
+
// every card starts closed (its head shows the state); a click on the head, or Ora sending you to it, opens it
|
| 234 |
+
if (autoFocus) openCards.add(autoFocus);
|
| 235 |
+
for (const card of list.querySelectorAll('.auto-card')) {
|
| 236 |
+
const id = card.dataset.id, more = card.querySelector('.auto-more'), head = card.querySelector('.auto-head');
|
| 237 |
+
const t = document.createElement('button'); t.type = 'button'; t.className = 'auto-toggle';
|
| 238 |
+
const set = open => { more.hidden = !open; card.classList.toggle('open', open); t.textContent = open ? 'Hide ▴' : 'Show ▾'; t.setAttribute('aria-expanded', open); };
|
| 239 |
+
set(openCards.has(id));
|
| 240 |
+
t.addEventListener('click', () => { const open = !openCards.has(id); if (open) openCards.add(id); else openCards.delete(id); set(open); });
|
| 241 |
+
head.querySelector('.auto-title').addEventListener('click', () => t.click());
|
| 242 |
+
head.appendChild(t);
|
| 243 |
+
}
|
| 244 |
if (autoFocus) {
|
| 245 |
const el = list.querySelector(`[data-id="${autoFocus}"]`) || list.firstElementChild;
|
| 246 |
if (el) { el.classList.add('focus'); if (!autoScrolled) { autoScrolled = true; setTimeout(() => el.scrollIntoView({ behavior: 'smooth', block: 'start' }), 80); } }
|
app/renderer/styles.css
CHANGED
|
@@ -617,3 +617,8 @@ dialog .dlg-actions { position: sticky; bottom: -22px; background: var(--surface
|
|
| 617 |
.camp-tag.li { background: #e8f1fb; color: #0a66c2; }
|
| 618 |
.camp-tag.done { text-decoration: none; opacity: .8; }
|
| 619 |
@media (max-width: 860px) { .camp-day { grid-template-columns: minmax(0, 1fr) auto; } .camp-tags { grid-column: 1 / -1; justify-content: flex-start; } }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 617 |
.camp-tag.li { background: #e8f1fb; color: #0a66c2; }
|
| 618 |
.camp-tag.done { text-decoration: none; opacity: .8; }
|
| 619 |
@media (max-width: 860px) { .camp-day { grid-template-columns: minmax(0, 1fr) auto; } .camp-tags { grid-column: 1 / -1; justify-content: flex-start; } }
|
| 620 |
+
.auto-switch .g-end .g-extra { margin-top: 12px; }
|
| 621 |
+
|
| 622 |
+
.auto-toggle { border: 0; background: none; color: var(--accent); font: 600 13px var(--body); cursor: pointer; padding: 4px 2px; white-space: nowrap; }
|
| 623 |
+
.auto-card .auto-title { cursor: pointer; }
|
| 624 |
+
.auto-card:not(.open) .auto-head { margin-bottom: 0; }
|