Skip to content

Commit

Permalink
Add code to update scoregraph when active bracket changes (#94)
Browse files Browse the repository at this point in the history
* Update top scoregraph when active bracket changes
* Closes #91. Thanks @reteps!
  • Loading branch information
ColdHeat authored Sep 7, 2024
1 parent dbc603a commit 266251e
Show file tree
Hide file tree
Showing 26 changed files with 70 additions and 65 deletions.
13 changes: 7 additions & 6 deletions assets/js/scoreboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ const scoreboardUpdateInterval = window.scoreboardUpdateInterval || 300000;
Alpine.data("ScoreboardDetail", () => ({
data: {},
show: true,
activeBracket: null,

async update() {
this.data = await CTFd.pages.scoreboard.getScoreboardDetail(10);
this.data = await CTFd.pages.scoreboard.getScoreboardDetail(10, this.activeBracket);

let optionMerge = window.scoreboardChartOptions;
let option = getOption(CTFd.config.userMode, this.data, optionMerge);
Expand All @@ -38,15 +39,15 @@ Alpine.data("ScoreboardList", () => ({
activeBracket: null,

async update() {
let response = await CTFd.fetch(`/api/v1/brackets?type=${CTFd.config.userMode}`, {
method: "GET",
});
const body = await response.json();
this.brackets = body["data"];
this.brackets = await CTFd.pages.scoreboard.getBrackets(CTFd.config.userMode);
this.standings = await CTFd.pages.scoreboard.getScoreboard();
},

async init() {
this.$watch("activeBracket", value => {
this.$dispatch("bracket-change", value);
});

this.update();

setInterval(() => {
Expand Down
6 changes: 5 additions & 1 deletion assets/js/utils/graphs/echarts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ echarts.use([

export function embed(target, option) {
let chart = echarts.init(target);
chart.setOption(option);

// https://echarts.apache.org/en/api.html#echartsInstance.setOption
// https://github.com/apache/echarts/issues/6202#issuecomment-315054637
// https://stackoverflow.com/a/72211534
chart.setOption(option, true);

window.addEventListener("resize", () => {
if (chart) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"verify": "vite build; git diff --quiet --exit-code"
},
"dependencies": {
"@ctfdio/ctfd-js": "^0.0.12",
"@ctfdio/ctfd-js": "^0.0.14",
"@fontsource/lato": "^4.5.3",
"@fontsource/raleway": "^4.5.3",
"@fortawesome/fontawesome-free": "6.5.1",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion static/assets/page.328a4621.js

This file was deleted.

1 change: 1 addition & 0 deletions static/assets/page.3c5083de.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import{C as o,m as d}from"./index.2e31e3b8.js";window.CTFd=o;window.Alpine=d;d.start();
1 change: 0 additions & 1 deletion static/assets/scoreboard.3f07d373.js

This file was deleted.

1 change: 1 addition & 0 deletions static/assets/scoreboard.b1c04d97.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 266251e

Please sign in to comment.