pptb-standard-sample-tool 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.js +50 -57
- package/dist/index.html +10 -6
- package/package.json +1 -1
package/dist/app.js
CHANGED
|
@@ -16,7 +16,7 @@ const dataverse = window.dataverseAPI;
|
|
|
16
16
|
// Application state
|
|
17
17
|
let currentConnection = null;
|
|
18
18
|
let currentTerminal = null;
|
|
19
|
-
let
|
|
19
|
+
let createdId = null;
|
|
20
20
|
/**
|
|
21
21
|
* Initialize the application
|
|
22
22
|
*/
|
|
@@ -128,11 +128,11 @@ function setupEventHandlers() {
|
|
|
128
128
|
// Dataverse query button
|
|
129
129
|
document.getElementById('query-accounts-btn')?.addEventListener('click', queryAccounts);
|
|
130
130
|
// CRUD buttons
|
|
131
|
-
document.getElementById('create-account-btn')?.addEventListener('click',
|
|
132
|
-
document.getElementById('update-account-btn')?.addEventListener('click',
|
|
133
|
-
document.getElementById('delete-account-btn')?.addEventListener('click',
|
|
131
|
+
document.getElementById('create-account-btn')?.addEventListener('click', createContact);
|
|
132
|
+
document.getElementById('update-account-btn')?.addEventListener('click', updateContact);
|
|
133
|
+
document.getElementById('delete-account-btn')?.addEventListener('click', deleteContact);
|
|
134
134
|
// Metadata button
|
|
135
|
-
document.getElementById('get-metadata-btn')?.addEventListener('click',
|
|
135
|
+
document.getElementById('get-metadata-btn')?.addEventListener('click', getContactMetadata);
|
|
136
136
|
// Clear log button
|
|
137
137
|
document.getElementById('clear-log-btn')?.addEventListener('click', clearLog);
|
|
138
138
|
}
|
|
@@ -351,116 +351,116 @@ async function queryAccounts() {
|
|
|
351
351
|
/**
|
|
352
352
|
* Create a new account
|
|
353
353
|
*/
|
|
354
|
-
async function
|
|
354
|
+
async function createContact() {
|
|
355
355
|
if (!currentConnection) {
|
|
356
356
|
await showNotification('No Connection', 'Please connect to a Dataverse environment', 'warning');
|
|
357
357
|
return;
|
|
358
358
|
}
|
|
359
359
|
try {
|
|
360
|
-
const
|
|
361
|
-
const
|
|
360
|
+
const firstnameInput = document.getElementById('contact-firstname');
|
|
361
|
+
const lastnameInput = document.getElementById('contact-lastname');
|
|
362
362
|
const output = document.getElementById('crud-output');
|
|
363
363
|
if (output)
|
|
364
|
-
output.textContent = 'Creating
|
|
365
|
-
const result = await dataverse.create('
|
|
366
|
-
|
|
367
|
-
|
|
364
|
+
output.textContent = 'Creating contact...\n';
|
|
365
|
+
const result = await dataverse.create('contact', {
|
|
366
|
+
firstname: firstnameInput.value,
|
|
367
|
+
lastname: lastnameInput.value,
|
|
368
368
|
telephone1: '555-0100',
|
|
369
369
|
description: 'Created by HTML Sample Tool'
|
|
370
370
|
});
|
|
371
|
-
|
|
371
|
+
createdId = result.id;
|
|
372
372
|
if (output) {
|
|
373
|
-
output.textContent = `
|
|
373
|
+
output.textContent = `Contact created successfully!\n\n`;
|
|
374
374
|
output.textContent += `ID: ${result.id}\n`;
|
|
375
|
-
output.textContent += `Name: ${
|
|
375
|
+
output.textContent += `Name: ${firstnameInput.value} ${lastnameInput.value}\n`;
|
|
376
376
|
}
|
|
377
377
|
// Enable update and delete buttons
|
|
378
|
-
const updateBtn = document.getElementById('update-
|
|
379
|
-
const deleteBtn = document.getElementById('delete-
|
|
378
|
+
const updateBtn = document.getElementById('update-contact-btn');
|
|
379
|
+
const deleteBtn = document.getElementById('delete-contact-btn');
|
|
380
380
|
if (updateBtn)
|
|
381
381
|
updateBtn.disabled = false;
|
|
382
382
|
if (deleteBtn)
|
|
383
383
|
deleteBtn.disabled = false;
|
|
384
|
-
await showNotification('
|
|
385
|
-
log(`
|
|
384
|
+
await showNotification('Contact Created', `Contact "${firstnameInput.value} ${lastnameInput.value}" created successfully`, 'success');
|
|
385
|
+
log(`Contact created: ${result.id}`, 'success');
|
|
386
386
|
}
|
|
387
387
|
catch (error) {
|
|
388
388
|
const output = document.getElementById('crud-output');
|
|
389
389
|
if (output)
|
|
390
390
|
output.textContent = `Error: ${error.message}`;
|
|
391
|
-
log(`Error creating
|
|
391
|
+
log(`Error creating contact: ${error.message}`, 'error');
|
|
392
392
|
}
|
|
393
393
|
}
|
|
394
394
|
/**
|
|
395
|
-
* Update the created
|
|
395
|
+
* Update the created contact
|
|
396
396
|
*/
|
|
397
|
-
async function
|
|
398
|
-
if (!
|
|
399
|
-
await showNotification('No
|
|
397
|
+
async function updateContact() {
|
|
398
|
+
if (!createdId) {
|
|
399
|
+
await showNotification('No Contact', 'Please create a contact first', 'warning');
|
|
400
400
|
return;
|
|
401
401
|
}
|
|
402
402
|
try {
|
|
403
403
|
const output = document.getElementById('crud-output');
|
|
404
404
|
if (output)
|
|
405
|
-
output.textContent = 'Updating
|
|
406
|
-
await dataverse.update('
|
|
405
|
+
output.textContent = 'Updating contact...\n';
|
|
406
|
+
await dataverse.update('contact', createdId, {
|
|
407
407
|
description: 'Updated by HTML Sample Tool at ' + new Date().toISOString(),
|
|
408
408
|
telephone1: '555-0200'
|
|
409
409
|
});
|
|
410
410
|
if (output) {
|
|
411
|
-
output.textContent = `
|
|
412
|
-
output.textContent += `ID: ${
|
|
411
|
+
output.textContent = `Contact updated successfully!\n\n`;
|
|
412
|
+
output.textContent += `ID: ${createdId}\n`;
|
|
413
413
|
output.textContent += `Updated fields: description, telephone1\n`;
|
|
414
414
|
}
|
|
415
|
-
await showNotification('
|
|
416
|
-
log(`
|
|
415
|
+
await showNotification('Contact Updated', 'Contact updated successfully', 'success');
|
|
416
|
+
log(`Contact updated: ${createdId}`, 'success');
|
|
417
417
|
}
|
|
418
418
|
catch (error) {
|
|
419
419
|
const output = document.getElementById('crud-output');
|
|
420
420
|
if (output)
|
|
421
421
|
output.textContent = `Error: ${error.message}`;
|
|
422
|
-
log(`Error updating
|
|
422
|
+
log(`Error updating contact: ${error.message}`, 'error');
|
|
423
423
|
}
|
|
424
424
|
}
|
|
425
425
|
/**
|
|
426
|
-
* Delete the created
|
|
426
|
+
* Delete the created contact
|
|
427
427
|
*/
|
|
428
|
-
async function
|
|
429
|
-
if (!
|
|
430
|
-
await showNotification('No
|
|
428
|
+
async function deleteContact() {
|
|
429
|
+
if (!createdId) {
|
|
430
|
+
await showNotification('No Contact', 'Please create a contact first', 'warning');
|
|
431
431
|
return;
|
|
432
432
|
}
|
|
433
433
|
try {
|
|
434
434
|
const output = document.getElementById('crud-output');
|
|
435
435
|
if (output)
|
|
436
|
-
output.textContent = 'Deleting
|
|
437
|
-
await dataverse.delete('
|
|
436
|
+
output.textContent = 'Deleting contact...\n';
|
|
437
|
+
await dataverse.delete('contact', createdId);
|
|
438
438
|
if (output) {
|
|
439
|
-
output.textContent = `
|
|
440
|
-
output.textContent += `ID: ${
|
|
439
|
+
output.textContent = `Contact deleted successfully!\n\n`;
|
|
440
|
+
output.textContent += `ID: ${createdId}\n`;
|
|
441
441
|
}
|
|
442
442
|
// Disable update and delete buttons
|
|
443
|
-
const updateBtn = document.getElementById('update-
|
|
444
|
-
const deleteBtn = document.getElementById('delete-
|
|
443
|
+
const updateBtn = document.getElementById('update-contact-btn');
|
|
444
|
+
const deleteBtn = document.getElementById('delete-contact-btn');
|
|
445
445
|
if (updateBtn)
|
|
446
446
|
updateBtn.disabled = true;
|
|
447
447
|
if (deleteBtn)
|
|
448
448
|
deleteBtn.disabled = true;
|
|
449
|
-
await showNotification('
|
|
450
|
-
log(`
|
|
451
|
-
|
|
449
|
+
await showNotification('Contact Deleted', 'Contact deleted successfully', 'success');
|
|
450
|
+
log(`Contact deleted: ${createdId}`, 'success');
|
|
451
|
+
createdId = null;
|
|
452
452
|
}
|
|
453
453
|
catch (error) {
|
|
454
454
|
const output = document.getElementById('crud-output');
|
|
455
455
|
if (output)
|
|
456
456
|
output.textContent = `Error: ${error.message}`;
|
|
457
|
-
log(`Error deleting
|
|
457
|
+
log(`Error deleting contact: ${error.message}`, 'error');
|
|
458
458
|
}
|
|
459
459
|
}
|
|
460
460
|
/**
|
|
461
|
-
* Get
|
|
461
|
+
* Get contact metadata
|
|
462
462
|
*/
|
|
463
|
-
async function
|
|
463
|
+
async function getContactMetadata() {
|
|
464
464
|
if (!currentConnection) {
|
|
465
465
|
await showNotification('No Connection', 'Please connect to a Dataverse environment', 'warning');
|
|
466
466
|
return;
|
|
@@ -469,21 +469,14 @@ async function getAccountMetadata() {
|
|
|
469
469
|
const output = document.getElementById('metadata-output');
|
|
470
470
|
if (output)
|
|
471
471
|
output.textContent = 'Retrieving metadata...\n';
|
|
472
|
-
const metadata = await dataverse.getEntityMetadata('
|
|
472
|
+
const metadata = await dataverse.getEntityMetadata('contact');
|
|
473
473
|
if (output) {
|
|
474
|
-
output.textContent = '
|
|
474
|
+
output.textContent = 'Contact Entity Metadata:\n\n';
|
|
475
475
|
output.textContent += `Logical Name: ${metadata.LogicalName}\n`;
|
|
476
476
|
output.textContent += `Metadata ID: ${metadata.MetadataId}\n`;
|
|
477
477
|
output.textContent += `Display Name: ${metadata.DisplayName?.LocalizedLabels?.[0]?.Label || 'N/A'}\n`;
|
|
478
|
-
output.textContent += `Attributes: ${metadata.Attributes?.length || 0}\n`;
|
|
479
|
-
if (metadata.Attributes && metadata.Attributes.length > 0) {
|
|
480
|
-
output.textContent += '\nSample Attributes:\n';
|
|
481
|
-
metadata.Attributes.slice(0, 5).forEach((attr) => {
|
|
482
|
-
output.textContent += ` - ${attr.LogicalName} (${attr.AttributeType})\n`;
|
|
483
|
-
});
|
|
484
|
-
}
|
|
485
478
|
}
|
|
486
|
-
log('
|
|
479
|
+
log('Contact metadata retrieved', 'success');
|
|
487
480
|
}
|
|
488
481
|
catch (error) {
|
|
489
482
|
const output = document.getElementById('metadata-output');
|
package/dist/index.html
CHANGED
|
@@ -68,20 +68,24 @@
|
|
|
68
68
|
<div class="example-group">
|
|
69
69
|
<h3>CRUD Operations</h3>
|
|
70
70
|
<div class="input-group">
|
|
71
|
-
<label for="
|
|
72
|
-
<input type="text" id="
|
|
71
|
+
<label for="contact-firstname">Contact First Name:</label>
|
|
72
|
+
<input type="text" id="contact-firstname" placeholder="Enter contact first name" value="Sample Contact">
|
|
73
|
+
</div>
|
|
74
|
+
<div class="input-group">
|
|
75
|
+
<label for="contact-lastname">Contact Last Name:</label>
|
|
76
|
+
<input type="text" id="contact-lastname" placeholder="Enter contact last name" value="Tool Box">
|
|
73
77
|
</div>
|
|
74
78
|
<div class="button-group">
|
|
75
|
-
<button id="create-
|
|
76
|
-
<button id="update-
|
|
77
|
-
<button id="delete-
|
|
79
|
+
<button id="create-contact-btn" class="btn btn-primary">Create Contact</button>
|
|
80
|
+
<button id="update-contact-btn" class="btn" disabled>Update Contact</button>
|
|
81
|
+
<button id="delete-contact-btn" class="btn btn-error" disabled>Delete Contact</button>
|
|
78
82
|
</div>
|
|
79
83
|
<div id="crud-output" class="output"></div>
|
|
80
84
|
</div>
|
|
81
85
|
|
|
82
86
|
<div class="example-group">
|
|
83
87
|
<h3>Metadata</h3>
|
|
84
|
-
<button id="get-metadata-btn" class="btn">Get
|
|
88
|
+
<button id="get-metadata-btn" class="btn">Get Contact Metadata</button>
|
|
85
89
|
<div id="metadata-output" class="output"></div>
|
|
86
90
|
</div>
|
|
87
91
|
</section>
|
package/package.json
CHANGED