Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add code to update scoregraph when active bracket changes #94

Merged
merged 2 commits into from
Sep 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading