From 1291b12cc49f8534e1ad489df81d4492b4ab2143 Mon Sep 17 00:00:00 2001 From: Harpo Date: Mon, 22 Aug 2022 15:40:59 -0700 Subject: [PATCH 1/6] =?UTF-8?q?=E2=9B=B5=20Deploy=20static=20site=20with?= =?UTF-8?q?=20gh-pages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/website.yml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/website.yml diff --git a/.github/workflows/website.yml b/.github/workflows/website.yml new file mode 100644 index 0000000..02a53da --- /dev/null +++ b/.github/workflows/website.yml @@ -0,0 +1,33 @@ +name: website deploy +on: + push: + branches: + - main + - dev + pull_request: + branches: + - main + - dev +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: πŸ“° Checkout + uses: actions/checkout@v3 + + - name: 🚧 Install dependencies + uses: actions/setup-node@v3 + with: + node-version: '18' + + - name: 🧢 Install yarn + run: yarn install + + - name: πŸ—οΈ Build files + run: yarn parcel build --public-url /midiphonor src/index.html + + - name: β›΅ Deploy + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./dist From 6eb39c0415bd8b7102295e7a15369053756857d5 Mon Sep 17 00:00:00 2001 From: Harpo Date: Mon, 22 Aug 2022 15:46:50 -0700 Subject: [PATCH 2/6] Use working-directory to deploy web pages --- .github/workflows/website.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/website.yml b/.github/workflows/website.yml index 02a53da..8b2afd1 100644 --- a/.github/workflows/website.yml +++ b/.github/workflows/website.yml @@ -15,19 +15,22 @@ jobs: - name: πŸ“° Checkout uses: actions/checkout@v3 - - name: 🚧 Install dependencies + - name: Setup node uses: actions/setup-node@v3 with: node-version: '18' - - name: 🧢 Install yarn + - name: 🧢 Install dependencies with yarn run: yarn install + working-directory: web - name: πŸ—οΈ Build files run: yarn parcel build --public-url /midiphonor src/index.html + working-directory: web - name: β›΅ Deploy uses: peaceiris/actions-gh-pages@v3 + working-directory: web with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./dist From c0020a62c322a359a463e4beb6009f5ee73079ec Mon Sep 17 00:00:00 2001 From: Harpo Date: Mon, 22 Aug 2022 15:48:36 -0700 Subject: [PATCH 3/6] Fix deploy step with correct publish_dir --- .github/workflows/website.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/website.yml b/.github/workflows/website.yml index 8b2afd1..d61f87b 100644 --- a/.github/workflows/website.yml +++ b/.github/workflows/website.yml @@ -30,7 +30,6 @@ jobs: - name: β›΅ Deploy uses: peaceiris/actions-gh-pages@v3 - working-directory: web with: github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./dist + publish_dir: web/dist From 460bb935eab5fce90193569c0b286a163462c789 Mon Sep 17 00:00:00 2001 From: Harpo Date: Mon, 22 Aug 2022 15:51:05 -0700 Subject: [PATCH 4/6] Fix frontend name in deploy step --- .github/workflows/website.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/website.yml b/.github/workflows/website.yml index d61f87b..b4ea4a1 100644 --- a/.github/workflows/website.yml +++ b/.github/workflows/website.yml @@ -25,7 +25,7 @@ jobs: working-directory: web - name: πŸ—οΈ Build files - run: yarn parcel build --public-url /midiphonor src/index.html + run: yarn parcel build --public-url /moe src/index.html working-directory: web - name: β›΅ Deploy From 1c06ad7c184c0c3cb439c4c0ffc1009b2b896da3 Mon Sep 17 00:00:00 2001 From: Harpo Date: Mon, 22 Aug 2022 15:54:24 -0700 Subject: [PATCH 5/6] =?UTF-8?q?=F0=9F=95=B8=EF=B8=8F=20Add=20emojis=20to?= =?UTF-8?q?=20names=20=E2=98=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/website.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/website.yml b/.github/workflows/website.yml index b4ea4a1..6408ccd 100644 --- a/.github/workflows/website.yml +++ b/.github/workflows/website.yml @@ -1,4 +1,4 @@ -name: website deploy +name: πŸ•ΈοΈ Website deploy on: push: branches: @@ -15,7 +15,7 @@ jobs: - name: πŸ“° Checkout uses: actions/checkout@v3 - - name: Setup node + - name: ☊ Setup node uses: actions/setup-node@v3 with: node-version: '18' From e95b8f1075439bde37d1bac9f9b533a92243ee4d Mon Sep 17 00:00:00 2001 From: Cameron West Date: Fri, 27 Oct 2023 23:10:24 -0500 Subject: [PATCH 6/6] CodeCarto API Temp solution for calling CodeCarto API to parse url in href --- web/src/Graph.js | 84 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/web/src/Graph.js b/web/src/Graph.js index 25750c6..093a502 100644 --- a/web/src/Graph.js +++ b/web/src/Graph.js @@ -22,6 +22,8 @@ import { testPosition, orderRadially, node, edge, graph } from './Collections' export var cy, eh, elements +let cyGraph +let isReadyToAddNodes = false let sortAlgos = [ 'grid', 'circle', @@ -71,8 +73,56 @@ export function Graph() { }) ) orderRadially() + + //TODO: temp solution for now to get the graph from the url + isReadyToAddNodes = true + urlToGraph(window.location.href).then(urlGraph => { + cyGraph = urlGraph + m.redraw(true) + }) }, view: vnode => { + // Check if cy is ready and if the graph is populated + if (isReadyToAddNodes && cyGraph) { + cy.elements().remove() + // loop through nodes and edges and add them to cy using cy.add + for (let nodeId in cyGraph.nodes) { + let node = cyGraph.nodes[nodeId] + cy.add({ + data: { + id: node.id, + name: node.label.toString(), + x: window.innerWidth / 2, + y: window.innerHeight / 2, + }, + }) + } + console.log('cy number of nodes: ' + cy.nodes().length) + for (let edgeId in cyGraph.edges) { + let edge = cyGraph.edges[edgeId] + cy.add({ + data: { + id: id(), + source: edge.source, + target: edge.target, + }, + }) + } + console.log('cy number of edges: ' + cy.edges().length) + // apply the grid layout + cy.layout({ + name: 'dagre', + padding: 5, + animate: true, + nodeDimensionsIncludeLabels: true, + }).run() + isReadyToAddNodes = false + } else { + // Check which object is not ready + if (!cy) console.log('cy not defined yet') + if (!cyGraph) console.log('cyGraph not populated yet') + } + return m('.graph', {}) }, } @@ -121,3 +171,37 @@ export function GraphSelector() { }, } } + +async function urlToGraph(url) { + console.log('Start urlToGraph:') + + // Get graph from codecarto + let urlAddress = url + urlAddress = urlAddress.replace('http://localhost:5000/#!/graph?url=', '') + console.log(urlAddress) + const codecartoAPI = `http://localhost:2000/polygraph/url_to_json?file_url=${urlAddress}` + console.log(codecartoAPI) + + // Call codecarto API + let CCgraph + const response = await fetch(codecartoAPI) + console.log(response) + + // Check if response is ok + if (response.ok) { + const responseData = await response.json() + console.log(responseData) + if (responseData.status == 200) { + CCgraph = responseData.results + } else { + console.log('Error with response data') + } + } else { + console.log('Error with response') + } + + // Return graph + console.log(CCgraph) + console.log('End urlToGraph:') + return CCgraph +}