SDK updates
This commit is contained in:
+381
-54
@@ -105,6 +105,80 @@
|
||||
h1 {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.sdk-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
|
||||
gap: 14px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.sdk-card {
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 10px;
|
||||
padding: 14px;
|
||||
background: #fafafa;
|
||||
}
|
||||
|
||||
.sdk-card h4 {
|
||||
margin: 0 0 10px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.sdk-card p {
|
||||
margin: 0 0 10px;
|
||||
font-size: 12px;
|
||||
color: #666;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.sdk-stack {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.sdk-stack input,
|
||||
.sdk-stack textarea,
|
||||
.sdk-stack select {
|
||||
width: 100%;
|
||||
padding: 8px 10px;
|
||||
border: 1px solid #d1d5db;
|
||||
border-radius: 6px;
|
||||
font: inherit;
|
||||
box-sizing: border-box;
|
||||
background: white;
|
||||
}
|
||||
|
||||
.sdk-stack textarea {
|
||||
min-height: 74px;
|
||||
resize: vertical;
|
||||
}
|
||||
|
||||
.sdk-inline {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.sdk-inline label {
|
||||
font-size: 12px;
|
||||
color: #444;
|
||||
}
|
||||
|
||||
.sdk-meta {
|
||||
margin-top: 10px;
|
||||
font-size: 12px;
|
||||
color: #555;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.sdk-actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
margin-top: 8px;
|
||||
}
|
||||
</style>
|
||||
<script src="https://cdn.jsdelivr.net/npm/pocketbase/dist/pocketbase.umd.js"></script>
|
||||
</head>
|
||||
@@ -148,22 +222,93 @@
|
||||
<button onclick="loadSpecificNote()" style="padding: 8px 16px; cursor: pointer;">Load Note</button>
|
||||
</div>
|
||||
|
||||
<p style="font-size: 13px; color: #666; margin-top: 20px;"><strong>Test Headless SDK (Centralized
|
||||
Logic):</strong></p>
|
||||
<div style="display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px;">
|
||||
<div style="display: flex; gap: 10px;">
|
||||
<input type="text" id="sdk-task-title" style="flex: 1; padding: 8px;"
|
||||
placeholder="New Task Title...">
|
||||
<button onclick="createTaskViaSDK()"
|
||||
style="padding: 8px 16px; cursor: pointer; background: #6f42c1; color: white; border: none; border-radius: 4px; font-weight: bold;">Create
|
||||
Task via SDK</button>
|
||||
<p style="font-size: 13px; color: #666; margin-top: 20px;"><strong>Test Headless SDK (Current
|
||||
Creation Model):</strong></p>
|
||||
<div class="sdk-grid">
|
||||
<div class="sdk-card">
|
||||
<h4>Task Creation</h4>
|
||||
<p>Creates a task with normalized tags, structured sharing refs, and optional `#note` linkage, then verifies the task is anchored by personal-context refs instead of the legacy direct user link.</p>
|
||||
<div class="sdk-stack">
|
||||
<input type="text" id="sdk-task-title" placeholder="Task title">
|
||||
<input type="text" id="sdk-task-tags"
|
||||
placeholder="Tags CSV, e.g. sdk_test,#sdk-workspace,@Shared Bucket">
|
||||
<textarea id="sdk-task-share-modes"
|
||||
placeholder="Optional share mode overrides, one per line. Example: #sdk-workspace=collaborative @shared bucket=handoff"></textarea>
|
||||
<div class="sdk-inline">
|
||||
<input type="number" id="sdk-task-priority" min="1" max="10" value="8"
|
||||
style="max-width: 90px;" title="Priority">
|
||||
<input type="number" id="sdk-task-urgency" min="1" max="10" value="4"
|
||||
style="max-width: 90px;" title="Urgency">
|
||||
<input type="number" id="sdk-task-size" min="0" max="10" value="3"
|
||||
style="max-width: 90px;" title="Size">
|
||||
</div>
|
||||
<textarea id="sdk-task-content"
|
||||
placeholder="Task content HTML or plain text">This task was created by a sister app using the current TasGrid SDK flow.</textarea>
|
||||
</div>
|
||||
<div class="sdk-actions">
|
||||
<button onclick="createTaskViaSDK()"
|
||||
style="padding: 8px 16px; cursor: pointer; background: #6f42c1; color: white; border: none; border-radius: 4px; font-weight: bold;">Create
|
||||
Task via SDK</button>
|
||||
</div>
|
||||
<div class="sdk-meta" id="sdk-task-meta">Last created task: none</div>
|
||||
</div>
|
||||
<div style="display: flex; gap: 10px;">
|
||||
<input type="text" id="sdk-note-title" style="flex: 1; padding: 8px;"
|
||||
placeholder="New Note Title...">
|
||||
<button onclick="createNoteViaSDK()"
|
||||
style="padding: 8px 16px; cursor: pointer; background: #fd7e14; color: white; border: none; border-radius: 4px; font-weight: bold;">Create
|
||||
Note via SDK</button>
|
||||
|
||||
<div class="sdk-card">
|
||||
<h4>Note Creation</h4>
|
||||
<p>Creates a canonical-key note and can fully link tasks into the note workspace the new way.</p>
|
||||
<div class="sdk-stack">
|
||||
<input type="text" id="sdk-note-title" placeholder="Note title">
|
||||
<input type="text" id="sdk-note-key" placeholder="Optional note key override">
|
||||
<input type="text" id="sdk-note-tags" placeholder="Tags CSV, e.g. sdk_test">
|
||||
<textarea id="sdk-note-content"
|
||||
placeholder="Note HTML content"><p>This note was created by the updated TasGrid SDK.</p></textarea>
|
||||
<input type="text" id="sdk-note-task-ids"
|
||||
placeholder="Task IDs CSV to fully link into this note workspace">
|
||||
<div class="sdk-inline">
|
||||
<label>Share mode
|
||||
<select id="sdk-note-share-mode">
|
||||
<option value="collaborative" selected>collaborative</option>
|
||||
<option value="handoff">handoff</option>
|
||||
</select>
|
||||
</label>
|
||||
<label>Visibility
|
||||
<select id="sdk-note-private">
|
||||
<option value="false" selected>public</option>
|
||||
<option value="true">private</option>
|
||||
</select>
|
||||
</label>
|
||||
<label style="display: flex; align-items: center; gap: 6px;">
|
||||
<input type="checkbox" id="sdk-note-link-tasks" checked>
|
||||
Link tasks via SDK
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sdk-actions">
|
||||
<button onclick="createNoteViaSDK()"
|
||||
style="padding: 8px 16px; cursor: pointer; background: #fd7e14; color: white; border: none; border-radius: 4px; font-weight: bold;">Create
|
||||
Note via SDK</button>
|
||||
<button onclick="createLinkedWorkspaceScenario()"
|
||||
style="padding: 8px 16px; cursor: pointer; background: #0f766e; color: white; border: none; border-radius: 4px; font-weight: bold;">Create
|
||||
Task + Linked Note</button>
|
||||
</div>
|
||||
<div class="sdk-meta" id="sdk-note-meta">Last created note: none</div>
|
||||
</div>
|
||||
|
||||
<div class="sdk-card">
|
||||
<h4>Link Existing Tasks</h4>
|
||||
<p>Calls the SDK's direct note-link helper so you can test current workspace linking without creating a new note.</p>
|
||||
<div class="sdk-stack">
|
||||
<input type="text" id="sdk-link-note-id" placeholder="Target note ID">
|
||||
<input type="text" id="sdk-link-task-ids" placeholder="Task IDs CSV to link">
|
||||
</div>
|
||||
<div class="sdk-actions">
|
||||
<button onclick="linkExistingTasksViaSDK()"
|
||||
style="padding: 8px 16px; cursor: pointer; background: #2563eb; color: white; border: none; border-radius: 4px; font-weight: bold;">Link
|
||||
Tasks to Note</button>
|
||||
<button onclick="loadLastCreatedNote()" style="padding: 8px 16px; cursor: pointer;">Load Last
|
||||
Note Embed</button>
|
||||
</div>
|
||||
<div class="sdk-meta" id="sdk-link-meta">Ready to link existing records.</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -186,7 +331,9 @@
|
||||
|
||||
<p><strong>2. Programmatic Creation (TasGrid SDK):</strong></p>
|
||||
<p>The recommended way to create entries is using the <code>tasgrid-sdk.js</code> module. This
|
||||
ensures all TasGrid-specific defaults and date logic (like urgency decay) are handled correctly.
|
||||
now applies TasGrid's current normalized creation rules, including canonical note keys,
|
||||
structured <code>labelTags</code>/<code>shareRefs</code>/<code>noteRefs</code>, owner-context
|
||||
tagging, and note-linked task metadata.
|
||||
</p>
|
||||
|
||||
<p><em>Setup:</em></p>
|
||||
@@ -205,8 +352,12 @@ const task = await createTasgridTask(pb, {
|
||||
urgency: 10, // Automated: 10=Today, 5=Next Week, 1=Six Months
|
||||
priority: 8, // 1-10
|
||||
size: 3, // Default: 3 (1 hour). Range 0-10.
|
||||
tags: ["external"],
|
||||
owner: "USER_ID" // Optional
|
||||
tags: ["external", "@Shared Bucket", "#project-brief"],
|
||||
shareModeByTag: {
|
||||
"@shared bucket": "handoff",
|
||||
"#project-brief": "collaborative"
|
||||
},
|
||||
owner: "USER_ID" // Optional: target personal-context owner, not a direct task.user link
|
||||
});</pre>
|
||||
</div>
|
||||
|
||||
@@ -220,8 +371,9 @@ const note = await createTasgridNote(pb, {
|
||||
title: "Project Brief",
|
||||
content: "<p>HTML content here...</p>",
|
||||
tags: ["documentation"],
|
||||
noteShareMode: "collaborative",
|
||||
isPrivate: false,
|
||||
tasks: [] // Optional: Array of Task IDs to link
|
||||
tasks: [] // Optional: Task IDs to store and fully link into the note workspace
|
||||
});</pre>
|
||||
</div>
|
||||
|
||||
@@ -278,6 +430,96 @@ function syncAuth(iframe) {
|
||||
const pb = new PocketBase('https://pocketbase.ccllc.pro');
|
||||
const statusEl = document.getElementById('status');
|
||||
let ENV_URL = 'https://tasgrid.ccllc.pro';
|
||||
let lastCreatedTaskId = '';
|
||||
let lastCreatedNoteId = '';
|
||||
|
||||
function setStatus(kind, message) {
|
||||
statusEl.className = kind ? `status ${kind}` : 'status';
|
||||
statusEl.textContent = message;
|
||||
statusEl.style.display = 'block';
|
||||
}
|
||||
|
||||
function parseCsvInput(id) {
|
||||
return (document.getElementById(id)?.value || '')
|
||||
.split(',')
|
||||
.map(value => value.trim())
|
||||
.filter(Boolean);
|
||||
}
|
||||
|
||||
function parseShareModeOverrides(id) {
|
||||
const lines = (document.getElementById(id)?.value || '')
|
||||
.split(/\r?\n/)
|
||||
.map(line => line.trim())
|
||||
.filter(Boolean);
|
||||
const result = {};
|
||||
|
||||
for (const line of lines) {
|
||||
const separatorIndex = line.indexOf('=');
|
||||
if (separatorIndex === -1) continue;
|
||||
const key = line.slice(0, separatorIndex).trim().toLowerCase();
|
||||
const value = line.slice(separatorIndex + 1).trim().toLowerCase();
|
||||
if (!key || (value !== 'collaborative' && value !== 'handoff')) continue;
|
||||
result[key] = value;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function refreshSdkMeta() {
|
||||
document.getElementById('sdk-task-meta').textContent = lastCreatedTaskId
|
||||
? `Last created task: ${lastCreatedTaskId}`
|
||||
: 'Last created task: none';
|
||||
document.getElementById('sdk-note-meta').textContent = lastCreatedNoteId
|
||||
? `Last created note: ${lastCreatedNoteId}`
|
||||
: 'Last created note: none';
|
||||
document.getElementById('sdk-link-meta').textContent = [
|
||||
lastCreatedTaskId ? `task ${lastCreatedTaskId}` : null,
|
||||
lastCreatedNoteId ? `note ${lastCreatedNoteId}` : null
|
||||
].filter(Boolean).join(' | ') || 'Ready to link existing records.';
|
||||
}
|
||||
|
||||
async function loadSdkModule() {
|
||||
return await import(`${ENV_URL}/tasgrid-sdk.js`);
|
||||
}
|
||||
|
||||
function fillLinkingFields() {
|
||||
if (lastCreatedTaskId && !document.getElementById('sdk-note-task-ids').value.trim()) {
|
||||
document.getElementById('sdk-note-task-ids').value = lastCreatedTaskId;
|
||||
}
|
||||
if (lastCreatedTaskId && !document.getElementById('sdk-link-task-ids').value.trim()) {
|
||||
document.getElementById('sdk-link-task-ids').value = lastCreatedTaskId;
|
||||
}
|
||||
if (lastCreatedNoteId && !document.getElementById('sdk-link-note-id').value.trim()) {
|
||||
document.getElementById('sdk-link-note-id').value = lastCreatedNoteId;
|
||||
}
|
||||
}
|
||||
|
||||
function loadLastCreatedNote() {
|
||||
if (!lastCreatedNoteId) {
|
||||
alert('Create a note first.');
|
||||
return;
|
||||
}
|
||||
document.getElementById('note-id-input').value = lastCreatedNoteId;
|
||||
loadSpecificNote();
|
||||
}
|
||||
|
||||
async function inspectTaskContextState(taskId) {
|
||||
const record = await pb.collection('TasGrid').getOne(taskId, {
|
||||
fields: 'id,user,shareRefs,noteRefs,tags,labelTags',
|
||||
requestKey: null
|
||||
});
|
||||
|
||||
const legacyUser = record.user && (typeof record.user === 'string' ? record.user : record.user.id);
|
||||
const shareRefCount = Array.isArray(record.shareRefs) ? record.shareRefs.length : 0;
|
||||
const noteRefCount = Array.isArray(record.noteRefs) ? record.noteRefs.length : 0;
|
||||
|
||||
return {
|
||||
legacyUser: legacyUser || null,
|
||||
shareRefCount,
|
||||
noteRefCount,
|
||||
tags: Array.isArray(record.tags) ? record.tags : []
|
||||
};
|
||||
}
|
||||
|
||||
function updateEnv() {
|
||||
const selected = document.querySelector('input[name="envToggle"]:checked').value;
|
||||
@@ -305,7 +547,7 @@ function syncAuth(iframe) {
|
||||
console.log(`Iframe ${iframe.id} loaded, checking auth sync...`);
|
||||
if (pb.authStore.isValid) {
|
||||
console.log(`Syncing existing auth to ${iframe.id}`);
|
||||
sendAuthToIframes();
|
||||
sendAuth(pb.authStore.token, pb.authStore.model);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -326,26 +568,34 @@ function syncAuth(iframe) {
|
||||
return;
|
||||
}
|
||||
|
||||
statusEl.className = 'status';
|
||||
statusEl.textContent = 'Importing SDK and creating task...';
|
||||
statusEl.style.display = 'block';
|
||||
setStatus('', 'Importing SDK and creating task...');
|
||||
|
||||
try {
|
||||
const { createTasgridTask } = await import(`${ENV_URL}/tasgrid-sdk.js`);
|
||||
const { createTasgridTask, TASGRID_SDK_SIGNATURE } = await loadSdkModule();
|
||||
const priority = parseInt(document.getElementById('sdk-task-priority').value || '8', 10);
|
||||
const urgency = parseInt(document.getElementById('sdk-task-urgency').value || '4', 10);
|
||||
const size = parseInt(document.getElementById('sdk-task-size').value || '3', 10);
|
||||
const tags = parseCsvInput('sdk-task-tags');
|
||||
const shareModeByTag = parseShareModeOverrides('sdk-task-share-modes');
|
||||
|
||||
const record = await createTasgridTask(pb, {
|
||||
title: title,
|
||||
priority: 8,
|
||||
urgency: 4,
|
||||
tags: ["sdk_test"],
|
||||
content: "This task was created by a sister app using the imported Headless SDK!"
|
||||
priority: Number.isFinite(priority) ? priority : 8,
|
||||
urgency: Number.isFinite(urgency) ? urgency : 4,
|
||||
size: Number.isFinite(size) ? size : 3,
|
||||
tags: tags,
|
||||
shareModeByTag,
|
||||
content: document.getElementById('sdk-task-content').value || ""
|
||||
});
|
||||
|
||||
statusEl.className = 'status success';
|
||||
statusEl.textContent = `Task created successfully via SDK (ID: ${record.id})!`;
|
||||
lastCreatedTaskId = record.id;
|
||||
fillLinkingFields();
|
||||
refreshSdkMeta();
|
||||
const inspection = await inspectTaskContextState(record.id);
|
||||
const legacyText = inspection.legacyUser ? `legacy user mirror still present: ${inspection.legacyUser}` : 'no legacy task.user link';
|
||||
setStatus('success', `Task created successfully via SDK ${TASGRID_SDK_SIGNATURE || '(unknown signature)'} (ID: ${record.id}). shareRefs=${inspection.shareRefCount}, noteRefs=${inspection.noteRefCount}, ${legacyText}.`);
|
||||
} catch (err) {
|
||||
statusEl.className = 'status error';
|
||||
statusEl.textContent = 'Failed to create task via SDK: ' + err.message;
|
||||
setStatus('error', 'Failed to create task via SDK: ' + err.message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -356,25 +606,107 @@ function syncAuth(iframe) {
|
||||
return;
|
||||
}
|
||||
|
||||
statusEl.className = 'status';
|
||||
statusEl.textContent = 'Importing SDK and creating note...';
|
||||
statusEl.style.display = 'block';
|
||||
setStatus('', 'Importing SDK and creating note...');
|
||||
|
||||
try {
|
||||
const { createTasgridNote } = await import(`${ENV_URL}/tasgrid-sdk.js`);
|
||||
const { createTasgridNote, TASGRID_SDK_SIGNATURE } = await loadSdkModule();
|
||||
const taskIds = parseCsvInput('sdk-note-task-ids');
|
||||
|
||||
const record = await createTasgridNote(pb, {
|
||||
title: title,
|
||||
content: "<p>This note was created headlessly via the SDK!</p>",
|
||||
tags: ["sdk_test"],
|
||||
isPrivate: false
|
||||
key: document.getElementById('sdk-note-key').value.trim() || undefined,
|
||||
content: document.getElementById('sdk-note-content').value || "",
|
||||
tags: parseCsvInput('sdk-note-tags'),
|
||||
noteShareMode: document.getElementById('sdk-note-share-mode').value,
|
||||
isPrivate: document.getElementById('sdk-note-private').value === 'true',
|
||||
tasks: taskIds,
|
||||
linkTasks: document.getElementById('sdk-note-link-tasks').checked
|
||||
});
|
||||
|
||||
statusEl.className = 'status success';
|
||||
statusEl.textContent = `Note created successfully via SDK (ID: ${record.id})!`;
|
||||
lastCreatedNoteId = record.id;
|
||||
document.getElementById('note-id-input').value = record.id;
|
||||
fillLinkingFields();
|
||||
refreshSdkMeta();
|
||||
loadSpecificNote();
|
||||
setStatus('success', `Note created successfully via SDK ${TASGRID_SDK_SIGNATURE || '(unknown signature)'} (ID: ${record.id}). The notes iframe was pointed at the new note.`);
|
||||
} catch (err) {
|
||||
statusEl.className = 'status error';
|
||||
statusEl.textContent = 'Failed to create note via SDK: ' + err.message;
|
||||
setStatus('error', 'Failed to create note via SDK: ' + err.message);
|
||||
}
|
||||
}
|
||||
|
||||
async function linkExistingTasksViaSDK() {
|
||||
const noteId = document.getElementById('sdk-link-note-id').value.trim();
|
||||
const taskIds = parseCsvInput('sdk-link-task-ids');
|
||||
if (!pb.authStore.isValid) {
|
||||
alert("Please log in first before linking tasks via SDK.");
|
||||
return;
|
||||
}
|
||||
if (!noteId || taskIds.length === 0) {
|
||||
alert("Provide both a target note ID and at least one task ID.");
|
||||
return;
|
||||
}
|
||||
|
||||
setStatus('', 'Importing SDK and linking tasks to note...');
|
||||
|
||||
try {
|
||||
const { linkTasgridTasksToNote, TASGRID_SDK_SIGNATURE } = await loadSdkModule();
|
||||
const records = await linkTasgridTasksToNote(pb, noteId, taskIds);
|
||||
lastCreatedNoteId = noteId;
|
||||
fillLinkingFields();
|
||||
refreshSdkMeta();
|
||||
const inspection = await inspectTaskContextState(taskIds[0]);
|
||||
setStatus('success', `Linked ${records.length} task(s) to note ${noteId} via SDK ${TASGRID_SDK_SIGNATURE || '(unknown signature)'}. First task now has shareRefs=${inspection.shareRefCount} and noteRefs=${inspection.noteRefCount}.`);
|
||||
} catch (err) {
|
||||
setStatus('error', 'Failed to link tasks via SDK: ' + err.message);
|
||||
}
|
||||
}
|
||||
|
||||
async function createLinkedWorkspaceScenario() {
|
||||
if (!pb.authStore.isValid) {
|
||||
alert("Please log in first before creating linked workspace data.");
|
||||
return;
|
||||
}
|
||||
|
||||
setStatus('', 'Creating a task and linked note scenario via the SDK...');
|
||||
|
||||
try {
|
||||
const { createTasgridTask, createTasgridNote, TASGRID_SDK_SIGNATURE } = await loadSdkModule();
|
||||
const timestamp = new Date().toISOString().replace(/[^\d]/g, '').slice(0, 12);
|
||||
const workspaceTag = `#sdk-workspace-${timestamp}`;
|
||||
const taskRecord = await createTasgridTask(pb, {
|
||||
title: `SDK Workspace Task ${timestamp}`,
|
||||
priority: 8,
|
||||
urgency: 4,
|
||||
size: 3,
|
||||
tags: ['sdk_test', workspaceTag],
|
||||
shareModeByTag: {
|
||||
[workspaceTag.toLowerCase()]: 'collaborative'
|
||||
},
|
||||
content: 'Workspace task created by the test simulator.'
|
||||
});
|
||||
|
||||
const noteRecord = await createTasgridNote(pb, {
|
||||
title: `SDK Workspace Note ${timestamp}`,
|
||||
tags: ['sdk_test'],
|
||||
content: `<p>Workspace note for task <code>${taskRecord.id}</code>.</p>`,
|
||||
noteShareMode: 'collaborative',
|
||||
isPrivate: false,
|
||||
tasks: [taskRecord.id],
|
||||
linkTasks: true
|
||||
});
|
||||
|
||||
lastCreatedTaskId = taskRecord.id;
|
||||
lastCreatedNoteId = noteRecord.id;
|
||||
document.getElementById('note-id-input').value = noteRecord.id;
|
||||
document.getElementById('sdk-note-task-ids').value = taskRecord.id;
|
||||
fillLinkingFields();
|
||||
refreshSdkMeta();
|
||||
loadSpecificNote();
|
||||
const inspection = await inspectTaskContextState(taskRecord.id);
|
||||
const legacyText = inspection.legacyUser ? `legacy user mirror still present: ${inspection.legacyUser}` : 'no legacy task.user link';
|
||||
setStatus('success', `Created linked workspace scenario via SDK ${TASGRID_SDK_SIGNATURE || '(unknown signature)'}. Task ${taskRecord.id} and note ${noteRecord.id} were created, loaded into the embed, and verified with shareRefs=${inspection.shareRefCount}, noteRefs=${inspection.noteRefCount}, ${legacyText}.`);
|
||||
} catch (err) {
|
||||
setStatus('error', 'Failed to create linked workspace scenario: ' + err.message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -382,21 +714,17 @@ function syncAuth(iframe) {
|
||||
const email = document.getElementById('email').value;
|
||||
const password = document.getElementById('password').value;
|
||||
|
||||
statusEl.className = 'status';
|
||||
statusEl.textContent = 'Logging in...';
|
||||
statusEl.style.display = 'block';
|
||||
setStatus('', 'Logging in...');
|
||||
|
||||
try {
|
||||
const authData = await pb.collection('users').authWithPassword(email, password);
|
||||
|
||||
statusEl.className = 'status success';
|
||||
statusEl.textContent = `Logged in as ${authData.record.email}! Syncing iframes...`;
|
||||
setStatus('success', `Logged in as ${authData.record.email}! Syncing iframes...`);
|
||||
|
||||
// Automatically send auth to iframes
|
||||
sendAuth(pb.authStore.token, authData.record);
|
||||
} catch (err) {
|
||||
statusEl.className = 'status error';
|
||||
statusEl.textContent = 'Login failed: ' + err.message;
|
||||
setStatus('error', 'Login failed: ' + err.message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -428,12 +756,11 @@ function syncAuth(iframe) {
|
||||
window.addEventListener('load', () => {
|
||||
if (pb.authStore.isValid && pb.authStore.model) {
|
||||
document.getElementById('email').value = pb.authStore.model.email || "";
|
||||
statusEl.className = 'status success';
|
||||
statusEl.textContent = 'Session restored. Click login or send manual token to sync.';
|
||||
statusEl.style.display = 'block';
|
||||
setStatus('success', 'Session restored. Click login or send manual token to sync.');
|
||||
}
|
||||
refreshSdkMeta();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user