diff --git a/src/lib/extension/entities/MaintenanceProfile.js b/src/lib/extension/entities/MaintenanceProfile.js index 0e0e59f..0f9a637 100644 --- a/src/lib/extension/entities/MaintenanceProfile.js +++ b/src/lib/extension/entities/MaintenanceProfile.js @@ -1,6 +1,5 @@ import StorageEntity from "$lib/extension/base/StorageEntity.js"; import EntitiesController from "$lib/extension/EntitiesController.js"; -import {compressToEncodedURIComponent, decompressFromEncodedURIComponent} from "lz-string"; /** * @typedef {Object} MaintenanceProfileSettings @@ -30,26 +29,6 @@ class MaintenanceProfile extends StorageEntity { return super.settings; } - /** - * Export the profile to the formatted JSON. - * - * @type {string} - */ - toJSON() { - return JSON.stringify({ - v: 1, - id: this.id, - name: this.settings.name, - tags: this.settings.tags, - }, null, 2); - } - - toCompressedJSON() { - return compressToEncodedURIComponent( - this.toJSON() - ); - } - static _entityName = "profiles"; /** @@ -79,62 +58,6 @@ class MaintenanceProfile extends StorageEntity { callback ); } - - /** - * Validate and import the profile from the JSON. - * @param {string} exportedString JSON for profile. - * @return {MaintenanceProfile} Maintenance profile imported from the JSON. Note that profile is not automatically - * saved. - * @throws {Error} When version is unsupported or format is invalid. - */ - static importFromJSON(exportedString) { - let importedObject; - - try { - importedObject = JSON.parse(exportedString); - } catch (e) { - // Error will be sent later, since empty string could be parsed as nothing without raising the error. - } - - if (!importedObject) { - throw new Error('Invalid JSON!'); - } - - if (importedObject.v !== 1) { - throw new Error('Unsupported version!'); - } - - if ( - !importedObject.id - || typeof importedObject.id !== "string" - || !importedObject.name - || typeof importedObject.name !== "string" - || !importedObject.tags - || !Array.isArray(importedObject.tags) - ) { - throw new Error('Invalid profile format detected!'); - } - - return new MaintenanceProfile( - importedObject.id, - { - name: importedObject.name, - tags: importedObject.tags, - } - ); - } - - /** - * Validate and import the profile from the compressed JSON string. - * @param {string} compressedString - * @return {MaintenanceProfile} - * @throws {Error} When version is unsupported or format is invalid. - */ - static importFromCompressedJSON(compressedString) { - return this.importFromJSON( - decompressFromEncodedURIComponent(compressedString) - ); - } } export default MaintenanceProfile; diff --git a/src/routes/features/maintenance/[id]/export/+page.svelte b/src/routes/features/maintenance/[id]/export/+page.svelte index e533014..d4e2191 100644 --- a/src/routes/features/maintenance/[id]/export/+page.svelte +++ b/src/routes/features/maintenance/[id]/export/+page.svelte @@ -1,11 +1,13 @@