-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
144 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ node_modules/ | |
.vscode | ||
yarn-error.log | ||
dst/ | ||
dist/ | ||
dist/ | ||
module/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const path = require('path'); | ||
|
||
module.exports = { | ||
entry: path.resolve(__dirname, '../src/index.ts'), | ||
devtool: 'inline-source-map', | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.tsx?$/, | ||
use: 'ts-loader', | ||
exclude: /node_modules/, | ||
}, | ||
], | ||
}, | ||
resolve: { | ||
extensions: [ '.ts', '.tsx', '.js' ], | ||
}, | ||
output: { | ||
filename: 'facetTree.js', | ||
path: path.resolve(__dirname, '../module'), | ||
libraryTarget: "umd", | ||
library: 'facetTree', | ||
} | ||
}; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import axios from 'axios'; | ||
|
||
import {drawTree} from './module/facetTree'; | ||
import { data } from './data'; | ||
|
||
const svg = document.getElementById('mysvg'); | ||
|
||
async function clickFacet(facetId: number) { | ||
|
||
try { | ||
const res = await axios.get('http://yotta.xjtushilei.com:8083/facet/getFacetNameAndParentFacetNameByFacetId', { | ||
params: { | ||
facetId, | ||
} | ||
}); | ||
if ((res as any).data.code === 200) { | ||
document.getElementById('facet').innerHTML = (res.data.data.parentFacetName ? res.data.data.parentFacetName + ' - ' : '') + res.data.data.facetName; | ||
} else { | ||
throw(res.data) | ||
} | ||
} catch (e) { | ||
console.log(e); | ||
document.getElementById('facet').innerHTML = ''; | ||
} | ||
|
||
// empty list | ||
const list = document.getElementById('list'); | ||
const children = list.childNodes; | ||
for (let i = 0; i < children.length; i++) { | ||
list.removeChild(children[i]); | ||
} | ||
|
||
const ul = document.createElement('ul'); | ||
let assembleNumber = 0; | ||
|
||
try { | ||
const res = await axios.get('http://yotta.xjtushilei.com:8083/assemble/getAssemblesByFacetId', { | ||
params: { | ||
facetId: facetId, | ||
}, | ||
}); | ||
|
||
if ((res as any).data.code === 200) { | ||
const assembleList = res.data.data; | ||
(assembleList as any).forEach(element => { | ||
const li = document.createElement('li'); | ||
li.className = 'assemble'; | ||
if (element.type === 'video') { | ||
const regex = new RegExp('https://.*mp4'); | ||
li.innerHTML = `<video src='${regex.exec(element.assembleContent as string)[0]}' controls height="280"></video>` | ||
} else { | ||
li.innerHTML = element.assembleContent; | ||
} | ||
ul.appendChild(li); | ||
}); | ||
assembleNumber = assembleList.length; | ||
list.appendChild(ul); | ||
document.getElementById('assembleNumber').innerHTML = assembleNumber.toString(); | ||
} else { | ||
throw ('api error'); | ||
} | ||
} catch (e) { | ||
console.log(e); | ||
document.getElementById('assembleNumber').innerHTML = ''; | ||
} | ||
|
||
} | ||
|
||
drawTree(svg, data, clickFacet); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,4 @@ | ||
import * as d3 from 'd3'; | ||
import axios from 'axios'; | ||
|
||
|
||
import { buildTree, FacetData } from './facet-tree-ng'; | ||
import { data } from './data'; | ||
import { drawFacetPieChart } from './facet-pie-chart'; | ||
import { drawFacetForceLayout } from './facet-force-layout'; | ||
|
||
const svg = document.getElementById('mysvg'); | ||
|
||
let currentFacetId = -1; | ||
|
||
async function clickFacet(facetId: number, facetName: string, parentFacetId = -2) { | ||
// return when facetId not change | ||
if (currentFacetId === facetId) return; | ||
|
||
// save facetId | ||
currentFacetId = facetId; | ||
|
||
// empty list | ||
const list = document.getElementById('list'); | ||
const children = list.childNodes; | ||
for (let i = 0; i < children.length; i++) { | ||
list.removeChild(children[i]); | ||
} | ||
|
||
const ul = document.createElement('ul'); | ||
let assembleNumber = 0; | ||
|
||
try { | ||
const res = await axios.get('http://yotta.xjtushilei.com:8083/assemble/getAssemblesByFacetId', { | ||
params: { | ||
facetId: facetId, | ||
}, | ||
}); | ||
|
||
if ((res as any).data.code === 200) { | ||
const assembleList = res.data.data; | ||
(assembleList as any).forEach(element => { | ||
const li = document.createElement('li'); | ||
li.className = 'assemble'; | ||
if (element.type === 'video') { | ||
const regex = new RegExp('https://.*mp4'); | ||
li.innerHTML = `<video src='${regex.exec(element.assembleContent as string)[0]}' controls height="280"></video>` | ||
} else { | ||
li.innerHTML = element.assembleContent; | ||
} | ||
ul.appendChild(li); | ||
}); | ||
assembleNumber = assembleList.length; | ||
} else { | ||
throw ('api error'); | ||
} | ||
} catch (e) { | ||
console.log(e); | ||
} | ||
// whether current facet has changed or not | ||
if (currentFacetId === facetId) { | ||
list.appendChild(ul); | ||
document.getElementById('facet').innerHTML = facetName; | ||
document.getElementById('assembleNumber').innerHTML = assembleNumber.toString(); | ||
} | ||
} | ||
export * from './draw-tree'; | ||
export * from './facet-tree-ng'; | ||
export * from './facet-force-layout'; | ||
export * from './facet-pie-chart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters