in modules/frontend/app/configuration/components/modal-preview-project/controller.ts [88:144]
doStuff(cluster: CluserLike, isDemo: boolean) {
this.IgniteLoading.start('projectStructurePreview');
return this.PageConfigure.getClusterConfiguration({clusterID: cluster._id, isDemo})
.then((data) => {
return this.IgniteConfigurationResource.populate(data);
})
.then(({clusters}) => {
return clusters.find(({_id}) => _id === cluster._id);
})
.then((cluster) => {
return this.summaryZipper({
cluster,
data: {},
IgniteDemoMode: isDemo,
targetVer: this.IgniteVersion.currentSbj.getValue()
});
})
.then(JSZip.loadAsync)
.then((val) => {
const convert = (files) => {
return Object.keys(files)
.map((path, i, paths) => ({
fullPath: path,
path: path.replace(/\/$/, ''),
file: files[path],
parent: files[paths.filter((p) => path.startsWith(p) && p !== path).sort((a, b) => b.length - a.length)[0]]
}))
.map((node, i, nodes) => Object.assign(node, {
path: node.parent ? node.path.replace(node.parent.name, '') : node.path,
children: nodes.filter((n) => n.parent && n.parent.name === node.file.name)
}));
};
const nodes = convert(val.files);
this.data = [{
path: this.ConfigurationDownload.nameFile(cluster),
file: {dir: true},
children: nodes.filter((n) => !n.parent)
}];
this.selectedNode = nodes.find((n) => n.path.includes('server.xml'));
this.expandedNodes = [
...this.data,
...nodes.filter((n) => {
return !n.fullPath.startsWith('src/main/java/')
|| /src\/main\/java(\/(config|load|startup))?\/$/.test(n.fullPath);
})
];
this.showPreview(this.selectedNode);
this.IgniteLoading.finish('projectStructurePreview');
})
.catch((e) => {
this.IgniteMessages.showError('Failed to generate project preview: ', e);
this.onHide({});
});
}