|
@@ -71,13 +71,10 @@
|
|
|
|
|
|
const tab = await window.open(`${url}/tools/create`, '_blank');
|
|
const tab = await window.open(`${url}/tools/create`, '_blank');
|
|
|
|
|
|
- // Define the event handler function
|
|
|
|
const messageHandler = (event) => {
|
|
const messageHandler = (event) => {
|
|
if (event.origin !== url) return;
|
|
if (event.origin !== url) return;
|
|
if (event.data === 'loaded') {
|
|
if (event.data === 'loaded') {
|
|
tab.postMessage(JSON.stringify(item), '*');
|
|
tab.postMessage(JSON.stringify(item), '*');
|
|
-
|
|
|
|
- // Remove the event listener after handling the message
|
|
|
|
window.removeEventListener('message', messageHandler);
|
|
window.removeEventListener('message', messageHandler);
|
|
}
|
|
}
|
|
};
|
|
};
|
|
@@ -124,8 +121,7 @@
|
|
|
|
|
|
if (res) {
|
|
if (res) {
|
|
toast.success($i18n.t('Tool deleted successfully'));
|
|
toast.success($i18n.t('Tool deleted successfully'));
|
|
-
|
|
|
|
- init();
|
|
|
|
|
|
+ await init();
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
@@ -398,39 +394,41 @@
|
|
</div>
|
|
</div>
|
|
</button>
|
|
</button>
|
|
|
|
|
|
- <button
|
|
|
|
- class="flex text-xs items-center space-x-1 px-3 py-1.5 rounded-xl bg-gray-50 hover:bg-gray-100 dark:bg-gray-800 dark:hover:bg-gray-700 dark:text-gray-200 transition"
|
|
|
|
- on:click={async () => {
|
|
|
|
- const _tools = await exportTools(localStorage.token).catch((error) => {
|
|
|
|
- toast.error(`${error}`);
|
|
|
|
- return null;
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- if (_tools) {
|
|
|
|
- let blob = new Blob([JSON.stringify(_tools)], {
|
|
|
|
- type: 'application/json'
|
|
|
|
|
|
+ {#if tools.length}
|
|
|
|
+ <button
|
|
|
|
+ class="flex text-xs items-center space-x-1 px-3 py-1.5 rounded-xl bg-gray-50 hover:bg-gray-100 dark:bg-gray-800 dark:hover:bg-gray-700 dark:text-gray-200 transition"
|
|
|
|
+ on:click={async () => {
|
|
|
|
+ const _tools = await exportTools(localStorage.token).catch((error) => {
|
|
|
|
+ toast.error(`${error}`);
|
|
|
|
+ return null;
|
|
});
|
|
});
|
|
- saveAs(blob, `tools-export-${Date.now()}.json`);
|
|
|
|
- }
|
|
|
|
- }}
|
|
|
|
- >
|
|
|
|
- <div class=" self-center mr-2 font-medium line-clamp-1">{$i18n.t('Export Tools')}</div>
|
|
|
|
|
|
|
|
- <div class=" self-center">
|
|
|
|
- <svg
|
|
|
|
- xmlns="http://www.w3.org/2000/svg"
|
|
|
|
- viewBox="0 0 16 16"
|
|
|
|
- fill="currentColor"
|
|
|
|
- class="w-4 h-4"
|
|
|
|
- >
|
|
|
|
- <path
|
|
|
|
- fill-rule="evenodd"
|
|
|
|
- d="M4 2a1.5 1.5 0 0 0-1.5 1.5v9A1.5 1.5 0 0 0 4 14h8a1.5 1.5 0 0 0 1.5-1.5V6.621a1.5 1.5 0 0 0-.44-1.06L9.94 2.439A1.5 1.5 0 0 0 8.878 2H4Zm4 3.5a.75.75 0 0 1 .75.75v2.69l.72-.72a.75.75 0 1 1 1.06 1.06l-2 2a.75.75 0 0 1-1.06 0l-2-2a.75.75 0 0 1 1.06-1.06l.72.72V6.25A.75.75 0 0 1 8 5.5Z"
|
|
|
|
- clip-rule="evenodd"
|
|
|
|
- />
|
|
|
|
- </svg>
|
|
|
|
- </div>
|
|
|
|
- </button>
|
|
|
|
|
|
+ if (_tools) {
|
|
|
|
+ let blob = new Blob([JSON.stringify(_tools)], {
|
|
|
|
+ type: 'application/json'
|
|
|
|
+ });
|
|
|
|
+ saveAs(blob, `tools-export-${Date.now()}.json`);
|
|
|
|
+ }
|
|
|
|
+ }}
|
|
|
|
+ >
|
|
|
|
+ <div class=" self-center mr-2 font-medium line-clamp-1">{$i18n.t('Export Tools')}</div>
|
|
|
|
+
|
|
|
|
+ <div class=" self-center">
|
|
|
|
+ <svg
|
|
|
|
+ xmlns="http://www.w3.org/2000/svg"
|
|
|
|
+ viewBox="0 0 16 16"
|
|
|
|
+ fill="currentColor"
|
|
|
|
+ class="w-4 h-4"
|
|
|
|
+ >
|
|
|
|
+ <path
|
|
|
|
+ fill-rule="evenodd"
|
|
|
|
+ d="M4 2a1.5 1.5 0 0 0-1.5 1.5v9A1.5 1.5 0 0 0 4 14h8a1.5 1.5 0 0 0 1.5-1.5V6.621a1.5 1.5 0 0 0-.44-1.06L9.94 2.439A1.5 1.5 0 0 0 8.878 2H4Zm4 3.5a.75.75 0 0 1 .75.75v2.69l.72-.72a.75.75 0 1 1 1.06 1.06l-2 2a.75.75 0 0 1-1.06 0l-2-2a.75.75 0 0 1 1.06-1.06l.72.72V6.25A.75.75 0 0 1 8 5.5Z"
|
|
|
|
+ clip-rule="evenodd"
|
|
|
|
+ />
|
|
|
|
+ </svg>
|
|
|
|
+ </div>
|
|
|
|
+ </button>
|
|
|
|
+ {/if}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{/if}
|
|
{/if}
|