From 1cc3e67923ba34a6dc5d01a501d492c27e2374c1 Mon Sep 17 00:00:00 2001 From: Marcus Tang <50147457+MarcusTXK@users.noreply.github.com> Date: Sun, 30 Apr 2023 10:11:04 +0800 Subject: [PATCH] [#1894] Add embeddable ramp widget (#1988) The ability to copy a link for an embeddable ramp widget with the click of a button and embed the ramp widget into any existing website will be a useful feature. This allows users who intend to feature any contributions made to a repository/projects in their portfolio/any website, especially as I feel it is both eye-catching and provides a lot of useful information. The embedded ramps should follow any filters configured by the users above so that the information displayed by the ramps can be customized. Let's add a button to allow users to copy and embed widgets. --- docs/dg/report.md | 20 +- docs/ug/sharingReports.md | 17 +- .../tests/zoomView/zoomView_switchZoom.cy.js | 2 + frontend/src/app.vue | 229 +++++++++++++++- frontend/src/components/c-ramp.vue | 37 ++- frontend/src/components/c-summary-charts.vue | 191 ++++++++++++-- frontend/src/router/index.ts | 7 + frontend/src/styles/style.scss | 4 + frontend/src/styles/summary-chart.scss | 228 ++++++++++++++++ frontend/src/utils/load-font-awesome-icons.js | 4 +- frontend/src/views/c-home.vue | 228 +++------------- frontend/src/views/c-summary.vue | 249 ++---------------- frontend/src/views/c-widget.vue | 66 +++++ 13 files changed, 809 insertions(+), 473 deletions(-) create mode 100644 frontend/src/styles/summary-chart.scss create mode 100644 frontend/src/views/c-widget.vue diff --git a/docs/dg/report.md b/docs/dg/report.md index 1fa6baad75..6a8d9436c0 100644 --- a/docs/dg/report.md +++ b/docs/dg/report.md @@ -34,8 +34,10 @@ The tabbed interface is responsible for loading various modules such as authorsh ## Javascript and Vue files - **main.js** - sets up plugins and 3rd party components used in the report -- [**app.vue**](#app-app-vue) - module that supports the report interface +- [**app.vue**](#app-app-vue) - module that renders the `router-view` - [**api.js**](#data-loader-api-js) - loading and parsing of the report content +- [**c_home.vue**](#home-view-c-home-vue) - module that supports the report interface +- [**c_widget.vue**](#widget-view-c-widget-vue) - module that supports the widget interface - [**c_summary.vue**](#summary-view-c-summary-vue) - module that supports the summary view - [**c_authorship.vue**](#authorship-view-c-authorship-vue) - module that supports the authorship tab view - [**c_zoom.vue**](#zoom-view-c-zoom-vue) - module that supports the zoom tab view @@ -58,7 +60,7 @@ This contains the logic for the main VueJS object, `app.vue`, which is the entry Vuex in `store.js` is used to pass the necessary data into the relevant modules. -`c_summary`, `c_authorship`, `c_zoom`, `c_segment`, and `c_ramp` are components embedded into the report and will render the corresponding content based on the data passed into it from Vuex. +`c_home`, `c_widget`, `c_summary`, `c_authorship`, `c_zoom`, `c_segment`, and `c_ramp` are components embedded into the report and will render the corresponding content based on the data passed into it from Vuex. ### Loading of report information The main Vue object depends on the `summary.json` data to determine the right `commits.json` files to load into memory. This is handled by `api.js`, which loads the relevant file information from the network files if available; otherwise, a report archive, `archive.zip`, has to be used. @@ -86,6 +88,20 @@ After the JSON files are loaded from their respective sources, the data will be For the basic skeleton of `window.REPOS`, refer to the generated `summary.json` file in the report for more details. + + +## Home view ([c-home.vue](https://github.com/reposense/RepoSense/blob/master/frontend/src/views/c-home.vue)) + +The `c_home` module is in charge of rendering the main report, and renders `c_resizer`, `c_summary`, `c_authorship` and `c_zoom`. + + + +## Widget view ([c-widget.vue](https://github.com/reposense/RepoSense/blob/master/frontend/src/views/c-widget.vue)) + +The `c_widget` module is in charge of rendering the widget from the `iframe` and only renders `c_summary`. An additional prop, `isWidgetMode`, is passed to `c_summary` so it knows to render as a widget and omit unnecessary elements. + + + ## Summary view ([c-summary.vue](https://github.com/reposense/RepoSense/blob/master/frontend/src/views/c-summary.vue)) diff --git a/docs/ug/sharingReports.md b/docs/ug/sharingReports.md index 339567552c..c532e83e10 100644 --- a/docs/ug/sharingReports.md +++ b/docs/ug/sharingReports.md @@ -1,7 +1,7 @@ {% set title = "Sharing reports" %} - title: "{{ title | safe }}" - pageNav: 3 +title: "{{ title | safe }}" +pageNav: 3 {% from 'scripts/macros.njk' import embed with context %} @@ -11,6 +11,7 @@
**Often, you would want to share the RepoSense report with others.** For example, a teacher using RepoSense for a programming class might want to share the report privately with tutors or publish it so that everyone can see it. +
The sections below explain various ways of sharing a RepoSense report. @@ -35,4 +36,16 @@ As RepoSense reports are in a web page format, you can publish a report by simpl {{ embed("Appendix: **Using RepoSense with Netlify**", "withNetlify.md") }} + + +### Embeddable Widgets + +Published reports can additionally be embedded in other websites through `iframes`. Simply click the clipboard icon to generate and copy the iframe for your desired section of the report for either a single ramp chart or a group of ramp charts. Paste the iframe in any HTML supported document to render it. + +A sample iframe would look like: + +```html + +``` +Adjust the width and height to the desired dimensions as required. diff --git a/frontend/cypress/tests/zoomView/zoomView_switchZoom.cy.js b/frontend/cypress/tests/zoomView/zoomView_switchZoom.cy.js index 415515ca80..00127f933b 100644 --- a/frontend/cypress/tests/zoomView/zoomView_switchZoom.cy.js +++ b/frontend/cypress/tests/zoomView/zoomView_switchZoom.cy.js @@ -27,6 +27,8 @@ describe('switch zoom', () => { .last() .click(); + cy.get('#tabs-wrapper').scrollTo('top'); + // check default controls cy.get('#tab-zoom > .sorting > .sort-by > select:visible') .should('not.have.value', 'linesOfCode') diff --git a/frontend/src/app.vue b/frontend/src/app.vue index 25ac6de6f6..b167450c7c 100644 --- a/frontend/src/app.vue +++ b/frontend/src/app.vue @@ -1,13 +1,240 @@ diff --git a/frontend/src/components/c-summary-charts.vue b/frontend/src/components/c-summary-charts.vue index 8b7b0cde4f..27c026baaa 100644 --- a/frontend/src/components/c-summary-charts.vue +++ b/frontend/src/components/c-summary-charts.vue @@ -1,13 +1,20 @@