UNPKG

graphdb-workbench

Version:
2 lines 8.78 kB
export const __webpack_id__=56636;export const __webpack_ids__=[25387,28847,46993,56636,57436];export const __webpack_modules__={28847:(e,t,s)=>{s.r(t),s.d(t,{ImportResourceStatus:()=>r});const r={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.r(t),s.d(t,{ImportResourceType:()=>r});const r={DIRECTORY:"directory",FILE:"file",URL:"url",TEXT:"text"}},56636:(e,t,s)=>{s.r(t),s.d(t,{INDENT:()=>c,ImportResourceTreeService:()=>h,serverImportResourceTypeToIconMapping:()=>n,userImportResourceTypeToIconMapping:()=>a});var r=s(46993),i=s(57436),o=s(28847);const c=30,n=new Map;n.set(r.ImportResourceType.DIRECTORY,"icon-folder"),n.set(r.ImportResourceType.FILE,"icon-file");const a=new Map;a.set(r.ImportResourceType.DIRECTORY,"icon-folder"),a.set(r.ImportResourceType.FILE,"icon-upload"),a.set(r.ImportResourceType.URL,"icon-link"),a.set(r.ImportResourceType.TEXT,"icon-sparql");class h{static toImportResourceTree(e,t){const s=new i.ImportResourceTreeElement;return e.forEach(e=>{h.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 r=e.getResourceByName(t.name);r?r.importResource=t:h.addResourceToTree(e,t,s)})}static addResourceToTree(e,t,s){const r=h.getPath(t);let o;o=t.isDirectory()?r:r.slice(0,r.length-1);const c=h.getOrCreateParent(e,o);if(t.isFile()){const e=new i.ImportResourceTreeElement;return e.parent=c,e.importResource=t,e.path=r.join("/"),e.name=r[r.length-1],c.addResource(e),h.setIcon(e,s),e}return c.importResource=t,c.path=r.join("/"),h.setIcon(c,s),c}static setIcon(e,t){e.iconClass=t?a.get(e.importResource.type):n.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+h.getParentsCount(e)*c+"px",e.directories.forEach(e=>h.calculateElementIndent(e)),e.files.forEach(e=>h.calculateElementIndent(e))}static setupAfterTreeInitProperties(e){e.isRoot()||(e.isImportable=h.isImportable(e.importResource),e.hasOngoingImport=h.hasOngoingImport(e.importResource),e.canResetStatus=h.canResetStatus(e.importResource),e.hasStatusInfo="DONE"===e.importResource.status||"ERROR"===e.importResource.status,e.isEditable=e.importResource.isText(),h.setupShortenedMessage(e),h.setupShortenedContext(e),h.setupShortenedName(e),h.setupImportedAndModifiedComparableProperties(e)),e.directories.forEach(e=>h.setupAfterTreeInitProperties(e)),e.files.forEach(e=>h.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.ImportResourceStatus.IMPORTING&&e.status!==o.ImportResourceStatus.UPLOADING&&e.status!==o.ImportResourceStatus.PENDING&&e.status!==o.ImportResourceStatus.INTERRUPTING&&e.status!==o.ImportResourceStatus.UPLOADING&&e.status!==o.ImportResourceStatus.UPLOADED&&e.status!==o.ImportResourceStatus.UPLOAD_ERROR}static hasOngoingImport(e){return e.status===o.ImportResourceStatus.IMPORTING||e.status===o.ImportResourceStatus.UPLOADING||e.status===o.ImportResourceStatus.PENDING||e.status===o.ImportResourceStatus.INTERRUPTING}static canResetStatus(e){return e.status===o.ImportResourceStatus.DONE||e.status===o.ImportResourceStatus.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.r(t),s.d(t,{ImportResourceTreeElement:()=>o});var r=s(28847),i=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,i.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,i.cloneDeep)(e)}getSelectedImportedResources(){return this.getAllSelected().some(e=>e.importResource.status===r.ImportResourceStatus.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.37df902f179eee35dcca.bundle.js.map