diff --git a/dashboard/src/components/projects.js b/dashboard/src/components/projects.js index a074df7..b0746e8 100644 --- a/dashboard/src/components/projects.js +++ b/dashboard/src/components/projects.js @@ -521,7 +521,7 @@ const ProjectComponent = { const toolbar = m("div.d-sm-flex.mb-4", [ m( "h1.h3.mb-0.mr-auto.text-gray-800", - LocalState.currentProject ? LocalState.currentProject : "Projects" + LocalState.currentProject ? LocalState.currentProject.name : "Projects" ), m("div.autoComplete_wrapper", [ m( @@ -546,9 +546,9 @@ const ProjectComponent = { return m( "a.btn.dropdown-item", { - onclick: LocalState.fetchProjectStats + onclick: () => { LocalState.fetchProjectStats(project) } }, - project + project.name ); }) ) diff --git a/dashboard/src/models/ProjectState.js b/dashboard/src/models/ProjectState.js index bf109fa..39856aa 100644 --- a/dashboard/src/models/ProjectState.js +++ b/dashboard/src/models/ProjectState.js @@ -3,8 +3,17 @@ import utils from "../utils.js"; import * as auth from "../auth"; import * as api from "../api"; +/** + * @typedef {Object} Project + * @property {string} name + * @property {string} desc + * @property {number} totalSeconds +*/ + const Model = { + /** @type {Project[]} */ projects: [], + /** @type {Project?} */ currentProject: null, dates: null, obj: null, @@ -14,8 +23,11 @@ const Model = { Model.dates = null; Model.obj = null; }, + /** @param {Project[]} projects */ initProjectList: projects => { - Model.projects = projects; + Model.projects = _.orderBy(projects, ["totalSeconds", "name"], ["desc", "asc"]) + .filter(n => n.name !== "Other") + .sort((a, b) => a.name.localeCompare(b.name)); if (Model.projects.length > 0) { Model.currentProject = Model.projects[0];