Progress Bar (Plugin)

name

Progress Bar

description

See some progress happening!

instructions


Make a section anywhere in a note with tasks, call it "Progress" and run the plugin from the Note Options!

A "Section" starts with a Heading and ends with a --- horizontal line break.

=0=0=0=0=0=0=0=0=0=0=

Roadmap

Utilizing Link Option for easier usage.

Support for a tag to provide a list of Projects with their progress πŸ‘

linkVersion History

Version 1.0

Basic Plugin Function


{
async noteOption(app, noteUUID) {
 
const sections = await app.getNoteSections({ uuid: app.context.noteUUID });
const section = sections.find((section) => section.heading?.text === "Progress");
if (section === undefined) {
app.alert(`Please create a 'Progress' section.
""""""
### Progress
---
""""""
- Separate it with a triple line break '---'
(Or else anything under the heading will be erased!)`);
return;
}
 
// Processing the Tasks
const taskR = await app.getNoteTasks({ uuid: noteUUID });
const taskRemain = taskR.length;
const taskT = await app.getNoteTasks({ uuid: noteUUID }, {includeDone: true});
const taskTotal = taskT.length;
console.log(`Note has ${ taskRemain } tasks remaining and ${ taskTotal } in total`);
 
const taskRatio = (taskRemain / taskTotal);
// app.alert(`Tasks Ratio is ${ taskRatio }`);
// console.log(taskRatio);
 
const taskComplete = (1 - taskRatio);
// console.log(`task complete: ${taskComplete}`);
 
const taskPercent = Math.round(taskComplete * 100);
console.log(`Tasks are ${taskPercent}% complete.`);
 
let taskProgress;
 
if (taskPercent < 10){
taskProgress = `[⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛] ${taskPercent}%`;
};
if (taskPercent >= 10 && taskPercent < 20) {
taskProgress = `[πŸŸ©β¬›β¬›β¬›β¬›β¬›β¬›β¬›β¬›β¬›] ${taskPercent}%`;
};
if (taskPercent >= 20 && taskPercent < 30) {
taskProgress = `[πŸŸ©πŸŸ©β¬›β¬›β¬›β¬›β¬›β¬›β¬›β¬›] ${taskPercent}%`;
};
if (taskPercent >= 30 && taskPercent < 40) {
taskProgress = `[πŸŸ©πŸŸ©πŸŸ©β¬›β¬›β¬›β¬›β¬›β¬›β¬›] ${taskPercent}%`;
};
if (taskPercent >= 40 && taskPercent < 50) {
taskProgress = `[πŸŸ©πŸŸ©πŸŸ©πŸŸ©β¬›β¬›β¬›β¬›β¬›β¬›] ${taskPercent}%`;
};
if (taskPercent >= 50 && taskPercent < 60) {
taskProgress = `[πŸŸ©πŸŸ©πŸŸ©πŸŸ©πŸŸ©β¬›β¬›β¬›β¬›β¬›] ${taskPercent}%`;
};
if (taskPercent >= 60 && taskPercent < 70) {
taskProgress = `[πŸŸ©πŸŸ©πŸŸ©πŸŸ©πŸŸ©πŸŸ©β¬›β¬›β¬›β¬›] ${taskPercent}%`;
};
if (taskPercent >= 70 && taskPercent < 80) {
taskProgress = `[πŸŸ©πŸŸ©πŸŸ©πŸŸ©πŸŸ©πŸŸ©πŸŸ©β¬›β¬›β¬›] ${taskPercent}%`;
};
if (taskPercent >= 80 && taskPercent < 90) {
taskProgress = `[πŸŸ©πŸŸ©πŸŸ©πŸŸ©πŸŸ©πŸŸ©πŸŸ©πŸŸ©β¬›β¬›] ${taskPercent}%`;
};
if (taskPercent >= 90 && taskPercent < 100) {
taskProgress = `[πŸŸ©πŸŸ©πŸŸ©πŸŸ©πŸŸ©πŸŸ©πŸŸ©πŸŸ©πŸŸ©β¬›] ${taskPercent}%`;
};
if (taskPercent === 100) {
taskProgress = `[🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩] ${taskPercent}% β€Ό`;
};
 
 
app.replaceNoteContent({ uuid: app.context.noteUUID }, taskProgress, { section });
}
}