Skip to content

Commit

Permalink
Progress bar convenience features
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregor Billing committed Sep 29, 2020
1 parent 047d6d7 commit e4ada4b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 26 deletions.
3 changes: 1 addition & 2 deletions tnoodle-ui/src/main/api/tnoodle.socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ export class ScrambleClient {
}
}

//const BASE_URL = window.location.origin.replace(/^https?:\/\//,'ws://');
const BASE_URL = "ws://localhost:2014/";
const BASE_URL = window.location.origin.replace(/^https?:\/\//,'ws://');

const SCRAMBLING_STATES = {
IDLE: "IDLE",
Expand Down
35 changes: 12 additions & 23 deletions tnoodle-ui/src/main/components/EventPicker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,43 +191,32 @@ const EventPicker = connect(
};

maybeShowProgressBar = (rounds) => {
if (rounds.length === 0) {
return;
}

if (this.props.fileZipBlob != null) {
return (
<ProgressBar striped variant={"success"} now={100}/>
);
}

if (!this.props.generatingScrambles) {
return;
}

let eventId = this.props.event.id;

let current = this.props.scramblingProgressCurrent[eventId] || 0;
let target = this.props.scramblingProgressTarget[eventId];

if (target === undefined) {
if (rounds.length === 0 || !this.props.generatingScrambles || target === undefined) {
return;
}

if (current === 0) {
return (
<ProgressBar animated now={1}/>
);
}

let progress = (current / target) * 100
let miniThreshold = 2;

if (progress === 0) {
progress = miniThreshold;
}

return (
<ProgressBar animated variant={
<ProgressBar animated fade variant={
progress === 100
? "success"
: "info"
} now={progress}/>
} now={progress} label={
progress === 100 || progress < miniThreshold
? ""
: `${current} / ${target}`
}/>
);
};

Expand Down
2 changes: 1 addition & 1 deletion tnoodle-ui/src/main/components/Main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ const Main = connect(
...this.state,
competitionNameFileZip: this.props.wcif.name,
});
this.props.updateGeneratingScrambles(true);
let scrambleClient = new ScrambleClient(this.props.updateScramblingProgressTarget, this.props.updateScramblingProgressCurrentEvent);
fetchZip(
scrambleClient,
Expand All @@ -80,6 +79,7 @@ const Main = connect(
this.props.updateGeneratingScrambles(false);
this.props.resetScramblingProgressCurrent();
});
this.props.updateGeneratingScrambles(true);
};

downloadZip = () => {
Expand Down

0 comments on commit e4ada4b

Please sign in to comment.