UNPKG

graphdb-workbench

Version:
2 lines 8.19 kB
export const __webpack_esm_id__=56636;export const __webpack_esm_ids__=[25387,28847,46993,56636,57436];export const __webpack_esm_modules__={28847:(e,t,s)=>{s.d(t,{I:()=>i});const i={NONE:"NONE",UPLOADING:"UPLOADING",UPLOAD_ERROR:"UPLOAD_ERROR",UPLOADED:"UPLOADED",PENDING:"PENDING",IMPORTING:"IMPORTING",DONE:"DONE",ERROR:"ERROR",INTERRUPTING:"INTERRUPTING"}},46993:(e,t,s)=>{s.d(t,{o:()=>i});const i={DIRECTORY:"directory",FILE:"file",URL:"url",TEXT:"text"}},56636:(e,t,s)=>{s.d(t,{Fp:()=>a});var i=s(46993),r=s(57436),o=s(28847);const c=new Map;c.set(i.o.DIRECTORY,"ri-folder-3-line"),c.set(i.o.FILE,"ri-file-line");const n=new Map;n.set(i.o.DIRECTORY,"ri-folder-3-line"),n.set(i.o.FILE,"ri-upload-2-line"),n.set(i.o.URL,"ri-links-line"),n.set(i.o.TEXT,"icon-sparql");class a{static toImportResourceTree(e,t){const s=new r.k;return e.forEach(e=>{a.addResourceToTree(s,e,t)}),s}static mergeResourceTree(e,t,s){e.getRoot().toList().forEach(e=>{t.find(t=>t.name===e.importResource.name)||e.remove()}),t.forEach(t=>{const i=e.getResourceByName(t.name);i?i.importResource=t:a.addResourceToTree(e,t,s)})}static addResourceToTree(e,t,s){const i=a.getPath(t);let o;o=t.isDirectory()?i:i.slice(0,i.length-1);const c=a.getOrCreateParent(e,o);if(t.isFile()){const e=new r.k;return e.parent=c,e.importResource=t,e.path=i.join("/"),e.name=i[i.length-1],c.addResource(e),a.setIcon(e,s),e}return c.importResource=t,c.path=i.join("/"),a.setIcon(c,s),c}static setIcon(e,t){e.iconClass=t?n.get(e.importResource.type):c.get(e.importResource.type)}static getOrCreateParent(e,t){let s=e;return t.forEach(e=>{const t=s.getOrCreateDirectory(e);t.parent=s,s=t}),s}static getPath(e){if(e.isURL())return[e.name];const t=/[/\\]/;return t.test(e.name)?e.name.split(t):[e.name]}static calculateElementIndent(e){e.indent=8+30*a.getParentsCount(e)+"px",e.directories.forEach(e=>a.calculateElementIndent(e)),e.files.forEach(e=>a.calculateElementIndent(e))}static setupAfterTreeInitProperties(e){e.isRoot()||(e.isImportable=a.isImportable(e.importResource),e.hasOngoingImport=a.hasOngoingImport(e.importResource),e.canResetStatus=a.canResetStatus(e.importResource),e.hasStatusInfo="DONE"===e.importResource.status||"ERROR"===e.importResource.status,e.isEditable=e.importResource.isText(),a.setupShortenedMessage(e),a.setupShortenedContext(e),a.setupShortenedName(e),a.setupImportedAndModifiedComparableProperties(e)),e.directories.forEach(e=>a.setupAfterTreeInitProperties(e)),e.files.forEach(e=>a.setupAfterTreeInitProperties(e))}static setupShortenedMessage(e){const t=e.importResource?e.importResource.message:"";t&&t.length>150&&(e.shortenedMessage=t.substring(0,150)+"...")}static setupShortenedContext(e){const t=e.importResource?e.importResource.context:"";t.length>63&&(e.shortenedContext=t.substring(0,30)+"..."+t.substring(t.length-30))}static setupShortenedName(e){const t=e.name||"";t.length>123&&(e.shortenedName=t.substring(0,30)+"..."+t.substring(t.length-30))}static setupImportedAndModifiedComparableProperties(e){const t=e.importResource;if(t){if(0===t.importedOn||0===t.modifiedOn||t.importedOn===t.modifiedOn)return;e.isImportedBiggerThanModified=t.importedOn>t.modifiedOn,e.isModifiedBiggerThanImported=!e.isImportedBiggerThanModified}}static isImportable(e){return e.status!==o.I.IMPORTING&&e.status!==o.I.UPLOADING&&e.status!==o.I.PENDING&&e.status!==o.I.INTERRUPTING&&e.status!==o.I.UPLOADING&&e.status!==o.I.UPLOADED&&e.status!==o.I.UPLOAD_ERROR}static hasOngoingImport(e){return e.status===o.I.IMPORTING||e.status===o.I.UPLOADING||e.status===o.I.PENDING||e.status===o.I.INTERRUPTING}static canResetStatus(e){return e.status===o.I.DONE||e.status===o.I.ERROR}static getParentsCount(e){let t=0;if(void 0===e.parent)return t;let s=e.parent;for(;s;)s=s.parent,t++;return t-1}}},57436:(e,t,s)=>{s.d(t,{k:()=>o});var i=s(28847),r=s(98980);class o{constructor(){this.importResource=void 0,this.parent=void 0,this.partialSelected=!1,this.indent=0,this.isImportable=!1,this.hasOngoingImport=!1,this.hasStatusInfo=!1,this.canResetStatus=!1,this.name="",this.shortenedName="",this.path="",this.shortenedContext="",this.selected=!1,this.directories=[],this.files=[],this.isImportedBiggerThanModified=!1,this.isModifiedBiggerThanImported=!1,this.isEditable=!1,this.iconClass="",this.shortenedMessage=""}addResource(e){if(e.isFile())this.files.push(e);else{if(!e.isDirectory())throw new Error("Unsupported resource type!");this.directories.push(e)}}removeResource(e){e.isFile()?this.files=this.files.filter(t=>e.importResource.name!==t.importResource.name):this.directories=this.directories.filter(t=>e.importResource.name!==t.importResource.name)}remove(){this.isRoot()||this.parent.removeResource(this)}getOrCreateDirectory(e){let t=this.directories.find(t=>t.name===e);return t||(t=new o,t.name=e,this.directories.push(t)),t}getRoot(){return this.isRoot()?this:this.parent.getRoot()}isRoot(){return void 0===this.parent}isDirectory(){return this.importResource.isDirectory()}isFile(){return!this.isRoot()&&this.importResource.isFile()}isEmpty(){return 0===this.directories.length&&0===this.files.length}toList(){const e=[];return this.parent&&e.push(this),this.directories.forEach(t=>{e.push(...t.toList())}),e.push(...this.files),e}setSelection(e,t=!0){this.selected=e,this.files.forEach(t=>t.setSelection(e,!1)),this.directories.forEach(t=>t.setSelection(e,!1)),t&&this.getRoot().updateSelectionState()}updateSelectionState(){if(this.directories.forEach(e=>e.updateSelectionState()),this.parent&&this.isDirectory()){const e=this.hasUnselectedChildren(),t=this.hasSelectedChildren();this.selected=t&&!e,this.partialSelected=t&&e}}hasUnselectedChildren(){return this.files.some(e=>!e.selected)||this.directories.some(e=>!e.selected||e.hasUnselectedChildren())}hasSelectedChildren(){return this.files.some(e=>e.selected)||this.directories.some(e=>e.selected||e.hasSelectedChildren())}selectAllWithStatus(e){this.importResource&&e.indexOf(this.importResource.status)>-1&&(this.selected=!0),this.files.forEach(t=>t.selectAllWithStatus(e)),this.directories.forEach(t=>t.selectAllWithStatus(e))}getAllSelectedForImport(){const e=[],t=this.isRoot();return!t&&this.selected&&e.push(this),(t||this.isDirectory()&&!this.selected)&&(this.files.forEach(t=>e.push(...t.getAllSelectedForImport())),this.directories.forEach(t=>e.push(...t.getAllSelectedForImport()))),(0,r.cloneDeep)(e)}getAllSelected(){const e=[];return!this.isRoot()&&this.selected&&e.push(this),this.files.forEach(t=>e.push(...t.getAllSelected())),this.directories.forEach(t=>e.push(...t.getAllSelected())),(0,r.cloneDeep)(e)}getSelectedImportedResources(){return this.getAllSelected().some(e=>e.importResource.status===i.I.DONE)}deselectAll(){this.files.forEach(e=>e.deselectAll()),this.directories.forEach(e=>e.deselectAll()),this.selected=!1,this.partialSelected=!1}getAllSelectedFiles(){const e=[];return!this.isRoot()&&this.selected&&e.push(this.importResource),this.files.forEach(t=>e.push(...t.getAllSelectedFiles())),this.directories.forEach(t=>e.push(...t.getAllSelectedFiles())),e}getAllSelectedFilesNames(){return this.getAllSelectedFiles().map(e=>e.name)}getResourceByName(e){if(this.importResource&&this.importResource.name===e)return this;const t=this.files.find(t=>t.importResource.name===e);if(t)return t;for(const t of this.directories){const s=t.getResourceByName(e);if(s)return s}return null}hasTextInResourcesName(e){return!!this.importResource.name.toLowerCase().includes(e.toLowerCase())||!!this.files.some(t=>t.importResource.name.toLowerCase().includes(e.toLowerCase()))||this.directories.some(t=>t.hasTextInDirectoriesName(e))}hasTextInDirectoriesName(e){return!(!this.isDirectory()||!this.name.toLowerCase().includes(e.toLowerCase()))||this.directories.some(t=>t.hasTextInDirectoriesName(e))}hasTextInFilesName(e){return!(!this.isFile()||!this.name.toLowerCase().includes(e.toLowerCase()))||!!this.files.some(t=>t.importResource.name.toLowerCase().includes(e.toLowerCase()))||this.directories.some(t=>t.hasTextInFilesName(e))}sort(e){this.directories.sort(e),this.files.sort(e),this.directories.forEach(t=>t.sort(e))}getSize(){return this.toList().length}}}}; //# sourceMappingURL=56636.00abee0c86373ac53df1.bundle.js.map