-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
190765b
commit 9838b47
Showing
146 changed files
with
1,752 additions
and
1,359 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { Component, onMounted, onWillUnmount, useState } from "@odoo/owl"; | ||
import { SCROLLBAR_WIDTH } from "../../constants"; | ||
import { LongRunner } from "../../helpers/long_runner"; | ||
import { SpreadsheetChildEnv, UID } from "../../types"; | ||
import { css, cssPropertiesToCss } from "../helpers"; | ||
|
||
css/* scss */ ` | ||
.o-progressBar-container { | ||
position: absolute; | ||
right: ${SCROLLBAR_WIDTH}px; | ||
bottom: 52px; | ||
min-width: 200px; | ||
.o-progressBar { | ||
.o-progressBar-text { | ||
text-wrap: nowrap; | ||
text-overflow: ellipsis; | ||
} | ||
} | ||
} | ||
`; | ||
|
||
interface ProgressBarProps { | ||
longRunner: LongRunner; | ||
} | ||
|
||
export class SpreadsheetProgressBar extends Component<ProgressBarProps, SpreadsheetChildEnv> { | ||
static template = "o-spreadsheet-ProgressBar"; | ||
static props = { | ||
longRunner: Object, | ||
}; | ||
private progressBars = useState<{ id: UID; name: string; progress: number }[]>([]); | ||
|
||
setup() { | ||
onMounted(() => { | ||
this.props.longRunner.on("job-queued", this, this.jobQueued); | ||
this.props.longRunner.on("job-started", this, this.jobStarted); | ||
this.props.longRunner.on("job-continued", this, this.jobContinued); | ||
this.props.longRunner.on("job-done", this, this.jobDone); | ||
}); | ||
onWillUnmount(() => { | ||
this.props.longRunner.off("job-queued", this); | ||
this.props.longRunner.off("job-started", this); | ||
this.props.longRunner.off("job-continued", this); | ||
this.props.longRunner.off("job-done", this); | ||
}); | ||
} | ||
|
||
jobQueued(e) { | ||
this.progressBars.push({ id: e.id, name: e.name, progress: 0 }); | ||
} | ||
|
||
jobStarted(e) { | ||
let progress = this.progressBars.find((x) => x.id === e.id); | ||
if (!progress) { | ||
this.progressBars.push({ id: e.id, name: e.name, progress: 0 }); | ||
} | ||
} | ||
|
||
jobContinued(e) { | ||
let progress = this.progressBars.find((x) => x.id === e.id); | ||
if (!progress) { | ||
this.progressBars.push({ id: e.id, name: e.name, progress: e.progress }); | ||
} else { | ||
progress.progress = e.progress; | ||
} | ||
} | ||
|
||
jobDone(e) { | ||
let progressIndex = this.progressBars.findIndex((x) => x.id === e.id); | ||
if (progressIndex !== -1) { | ||
this.progressBars.splice(progressIndex, 1); | ||
} | ||
} | ||
|
||
getStyle(progressBar) { | ||
return cssPropertiesToCss({ | ||
width: progressBar.progress + "%", | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<t t-name="o-spreadsheet-ProgressBar"> | ||
<div class="o-progressBar-container" t-if="progressBars.length"> | ||
<t t-foreach="progressBars" t-as="progressBar" t-key="progressBar.id"> | ||
<div class="o-progressBar"> | ||
<span | ||
class="o-progressBar-text" | ||
t-out="progressBar.name + ' ('+progressBar.progress + ' %)'" | ||
/> | ||
</div> | ||
<div class="progress"> | ||
<div | ||
class="progress-bar" | ||
role="progressbar" | ||
t-att-aria-valuenow="progressBar.progress" | ||
aria-valuemin="0" | ||
aria-valuemax="100" | ||
t-att-style="getStyle(progressBar)" | ||
/> | ||
</div> | ||
</t> | ||
</div> | ||
</t> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.