From 7807588b881d4a2eae22e9a0aee7b9da238ea4ae Mon Sep 17 00:00:00 2001 From: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com> Date: Tue, 5 Jul 2022 11:38:19 +0600 Subject: [PATCH] Dashboards (#2208) Signed-off-by: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com> --- models/lead/src/index.ts | 7 + models/recruit/src/index.ts | 7 + models/task/src/index.ts | 11 ++ models/task/src/plugin.ts | 3 +- packages/theme/styles/_layouts.scss | 1 + .../ui/src/components/BarDashboard.svelte | 47 ++++++ .../ui/src/components/MultiProgress.svelte | 94 +++++++++++ packages/ui/src/components/Progress.svelte | 11 +- packages/ui/src/index.ts | 1 + packages/ui/src/types.ts | 11 ++ plugins/task-assets/assets/icons.svg | 6 + plugins/task-assets/lang/en.json | 6 +- plugins/task-assets/lang/ru.json | 4 +- plugins/task-assets/src/index.ts | 3 +- .../src/components/CreateFilter.svelte | 62 +++++++ .../src/components/CreateFilterPopup.svelte | 68 ++++++++ .../src/components/Dashboard.svelte | 153 ++++++++++++++++++ plugins/task-resources/src/index.ts | 2 + plugins/task-resources/src/plugin.ts | 3 +- plugins/task/src/index.ts | 7 +- plugins/view-resources/src/index.ts | 3 +- 21 files changed, 495 insertions(+), 15 deletions(-) create mode 100644 packages/ui/src/components/BarDashboard.svelte create mode 100644 packages/ui/src/components/MultiProgress.svelte create mode 100644 plugins/task-resources/src/components/CreateFilter.svelte create mode 100644 plugins/task-resources/src/components/CreateFilterPopup.svelte create mode 100644 plugins/task-resources/src/components/Dashboard.svelte diff --git a/models/lead/src/index.ts b/models/lead/src/index.ts index 23368bf94c..4d0a6d4a75 100644 --- a/models/lead/src/index.ts +++ b/models/lead/src/index.ts @@ -155,6 +155,13 @@ export function createModel (builder: Builder): void { lead.app.Lead ) + builder.createDoc(view.class.Viewlet, core.space.Model, { + attachTo: lead.class.Lead, + descriptor: task.viewlet.Dashboard, + options: {}, + config: [] + }) + createAction(builder, { ...actionTemplates.archiveSpace, target: lead.class.Funnel }) createAction(builder, { ...actionTemplates.unarchiveSpace, target: lead.class.Funnel }) diff --git a/models/recruit/src/index.ts b/models/recruit/src/index.ts index 5fccaacc81..988bd24bb4 100644 --- a/models/recruit/src/index.ts +++ b/models/recruit/src/index.ts @@ -364,6 +364,13 @@ export function createModel (builder: Builder): void { config: [] }) + builder.createDoc(view.class.Viewlet, core.space.Model, { + attachTo: recruit.class.Applicant, + descriptor: task.viewlet.Dashboard, + options: {}, + config: [] + }) + builder.mixin(recruit.class.Applicant, core.class.Class, task.mixin.KanbanCard, { card: recruit.component.KanbanCard }) diff --git a/models/task/src/index.ts b/models/task/src/index.ts index 45722829f0..bd0e9d5895 100644 --- a/models/task/src/index.ts +++ b/models/task/src/index.ts @@ -467,6 +467,17 @@ export function createModel (builder: Builder): void { task.viewlet.Kanban ) + builder.createDoc( + view.class.ViewletDescriptor, + core.space.Model, + { + label: task.string.Dashboard, + icon: task.icon.Dashboard, + component: task.component.Dashboard + }, + task.viewlet.Dashboard + ) + builder.mixin(task.class.TodoItem, core.class.Class, view.mixin.CollectionEditor, { editor: task.component.Todos }) diff --git a/models/task/src/plugin.ts b/models/task/src/plugin.ts index 4b748f07d5..a70c4b5024 100644 --- a/models/task/src/plugin.ts +++ b/models/task/src/plugin.ts @@ -56,7 +56,8 @@ export default mergeIds(taskId, task, { Todos: '' as AnyComponent, TodoItemPresenter: '' as AnyComponent, StatusTableView: '' as AnyComponent, - TaskHeader: '' as AnyComponent + TaskHeader: '' as AnyComponent, + Dashboard: '' as AnyComponent }, space: { TasksPublic: '' as Ref diff --git a/packages/theme/styles/_layouts.scss b/packages/theme/styles/_layouts.scss index f9383011a7..1684479f36 100644 --- a/packages/theme/styles/_layouts.scss +++ b/packages/theme/styles/_layouts.scss @@ -502,6 +502,7 @@ input.search { .max-h-125 { max-height: 31.25rem; } .max-h-60 { max-height: 15rem; } .max-w-60 { max-width: 15rem; } +.max-w-240 { max-width: 60rem; } .clear-mins { min-width: 0; min-height: 0; diff --git a/packages/ui/src/components/BarDashboard.svelte b/packages/ui/src/components/BarDashboard.svelte new file mode 100644 index 0000000000..5083a82fff --- /dev/null +++ b/packages/ui/src/components/BarDashboard.svelte @@ -0,0 +1,47 @@ + + + +
+ {#each items as item (item.label)} +
+ {item.label} +
+
+ +
+ {/each} +
+ + diff --git a/packages/ui/src/components/MultiProgress.svelte b/packages/ui/src/components/MultiProgress.svelte new file mode 100644 index 0000000000..68aed8379b --- /dev/null +++ b/packages/ui/src/components/MultiProgress.svelte @@ -0,0 +1,94 @@ + + + +
+ {#each filtred as item, i} +
+ {item.value} +
+ {/each} +
+ + diff --git a/packages/ui/src/components/Progress.svelte b/packages/ui/src/components/Progress.svelte index ce9f8302b1..c4687a386d 100644 --- a/packages/ui/src/components/Progress.svelte +++ b/packages/ui/src/components/Progress.svelte @@ -1,14 +1,14 @@ @@ -25,12 +25,11 @@ if (value < min) value = min function click (e: MouseEvent) { + if (!editable) return const rect = (e.target as HTMLElement).getBoundingClientRect() const x = e.clientX - rect.left const pos = x / rect.width value = (max - min) * pos - console.log(`set value to ${value}`) - console.log(`max value ${max}`) } diff --git a/packages/ui/src/index.ts b/packages/ui/src/index.ts index e819f6e951..fdd2bb1887 100644 --- a/packages/ui/src/index.ts +++ b/packages/ui/src/index.ts @@ -143,6 +143,7 @@ export { default as FocusHandler } from './components/FocusHandler.svelte' export { default as ListView } from './components/ListView.svelte' export { default as ToggleButton } from './components/ToggleButton.svelte' export { default as ExpandCollapse } from './components/ExpandCollapse.svelte' +export { default as BarDashboard } from './components/BarDashboard.svelte' export * from './types' export * from './location' diff --git a/packages/ui/src/types.ts b/packages/ui/src/types.ts index 6411ae54bf..da6fa53b9c 100644 --- a/packages/ui/src/types.ts +++ b/packages/ui/src/types.ts @@ -188,3 +188,14 @@ export interface PopupOptions { direction: string fullSize?: boolean } + +export interface DashboardItem { + label: string + values: DashboardGroup[] + tooltip?: LabelAndProps +} + +export interface DashboardGroup { + value: number + color: number +} diff --git a/plugins/task-assets/assets/icons.svg b/plugins/task-assets/assets/icons.svg index e5307dfdde..e74d522661 100644 --- a/plugins/task-assets/assets/icons.svg +++ b/plugins/task-assets/assets/icons.svg @@ -28,4 +28,10 @@ + + + + + + diff --git a/plugins/task-assets/lang/en.json b/plugins/task-assets/lang/en.json index b9e41f9bf1..b3a876bd48 100644 --- a/plugins/task-assets/lang/en.json +++ b/plugins/task-assets/lang/en.json @@ -62,7 +62,7 @@ "DoneStatesLost": "Done status / Lost", "AllStates": "All states", "DoneStates": "Done states", - "States": "States", + "States": "States", "NoDoneState": "Not done", "ManageStatusesWithin": "Manage application statuses within", "ManageProjectStatues": "Manage project statues", @@ -74,6 +74,8 @@ "CantStatusDeleteError": "There are objects in the given state. Move or delete them first.", "Tasks": "Tasks", "Assigned": "Assigned to me", - "TodoItems": "Todos" + "TodoItems": "Todos", + "Dashboard": "Dashboard", + "AllTime": "All time" } } \ No newline at end of file diff --git a/plugins/task-assets/lang/ru.json b/plugins/task-assets/lang/ru.json index 7dd97e5b81..d207c866a5 100644 --- a/plugins/task-assets/lang/ru.json +++ b/plugins/task-assets/lang/ru.json @@ -74,6 +74,8 @@ "CantStatusDeleteError": "Есть объекты с данным статусом. Сначала переместите или удалите их. ", "Tasks": "Задачи", "Assigned": "Назначения", - "TodoItems": "Todos" + "TodoItems": "Todos", + "Dashboard": "Дашборд", + "AllTime": "Все время" } } \ No newline at end of file diff --git a/plugins/task-assets/src/index.ts b/plugins/task-assets/src/index.ts index 8f668a0405..ce423463a4 100644 --- a/plugins/task-assets/src/index.ts +++ b/plugins/task-assets/src/index.ts @@ -23,7 +23,8 @@ loadMetadata(task.icon, { TodoCheck: `${icons}#todo-check`, TodoUnCheck: `${icons}#todo-uncheck`, ManageStatuses: `${icons}#manage-statuses`, - TaskState: `${icons}#task-state` + TaskState: `${icons}#task-state`, + Dashboard: `${icons}#dashboard` }) addStringsLoader(taskId, async (lang: string) => await import(`../lang/${lang}.json`)) diff --git a/plugins/task-resources/src/components/CreateFilter.svelte b/plugins/task-resources/src/components/CreateFilter.svelte new file mode 100644 index 0000000000..e4d70ec7ed --- /dev/null +++ b/plugins/task-resources/src/components/CreateFilter.svelte @@ -0,0 +1,62 @@ + + + + + + diff --git a/plugins/task-resources/src/components/CreateFilterPopup.svelte b/plugins/task-resources/src/components/CreateFilterPopup.svelte new file mode 100644 index 0000000000..cc54d206b9 --- /dev/null +++ b/plugins/task-resources/src/components/CreateFilterPopup.svelte @@ -0,0 +1,68 @@ + + + +
+
+
+ + {#each values as value, i} + + {/each} +
+
+
diff --git a/plugins/task-resources/src/components/Dashboard.svelte b/plugins/task-resources/src/components/Dashboard.svelte new file mode 100644 index 0000000000..2985e71c87 --- /dev/null +++ b/plugins/task-resources/src/components/Dashboard.svelte @@ -0,0 +1,153 @@ + + + + + (resultQuery = e.detail)} /> + +
+ +
diff --git a/plugins/task-resources/src/index.ts b/plugins/task-resources/src/index.ts index 8442a6d564..e591f2c565 100644 --- a/plugins/task-resources/src/index.ts +++ b/plugins/task-resources/src/index.ts @@ -37,6 +37,7 @@ import TodoItemPresenter from './components/todos/TodoItemPresenter.svelte' import TodoItemsPopup from './components/todos/TodoItemsPopup.svelte' import Todos from './components/todos/Todos.svelte' import TodoStatePresenter from './components/todos/TodoStatePresenter.svelte' +import Dashboard from './components/Dashboard.svelte' export { default as AssigneePresenter } from './components/AssigneePresenter.svelte' @@ -52,6 +53,7 @@ export default async (): Promise => ({ TaskPresenter, EditIssue, KanbanCard, + Dashboard, TemplatesIcon, KanbanView, StatePresenter, diff --git a/plugins/task-resources/src/plugin.ts b/plugins/task-resources/src/plugin.ts index be6d8d2020..e5fa1e0059 100644 --- a/plugins/task-resources/src/plugin.ts +++ b/plugins/task-resources/src/plugin.ts @@ -70,7 +70,8 @@ export default mergeIds(taskId, task, { Tasks: '' as IntlString, Assigned: '' as IntlString, - Task: '' as IntlString + Task: '' as IntlString, + AllTime: '' as IntlString }, status: { AssigneeRequired: '' as IntlString diff --git a/plugins/task/src/index.ts b/plugins/task/src/index.ts index 6b6e929855..256e6949f4 100644 --- a/plugins/task/src/index.ts +++ b/plugins/task/src/index.ts @@ -222,7 +222,8 @@ const task = plugin(taskId, { ApplicationLabelTask: '' as IntlString, Projects: '' as IntlString, ManageProjectStatues: '' as IntlString, - TodoItems: '' as IntlString + TodoItems: '' as IntlString, + Dashboard: '' as IntlString }, class: { Issue: '' as Ref>, @@ -245,6 +246,7 @@ const task = plugin(taskId, { }, viewlet: { Kanban: '' as Ref, + Dashboard: '' as Ref, StatusTable: '' as Ref }, icon: { @@ -253,7 +255,8 @@ const task = plugin(taskId, { TodoCheck: '' as Asset, TodoUnCheck: '' as Asset, ManageStatuses: '' as Asset, - TaskState: '' as Asset + TaskState: '' as Asset, + Dashboard: '' as Asset }, global: { // Global task root, if not attached to some other object. diff --git a/plugins/view-resources/src/index.ts b/plugins/view-resources/src/index.ts index 2f4f78bcbb..6bcc2e8e27 100644 --- a/plugins/view-resources/src/index.ts +++ b/plugins/view-resources/src/index.ts @@ -105,7 +105,8 @@ export { BooleanEditor, BooleanPresenter, NumberEditor, - NumberPresenter + NumberPresenter, + TimestampPresenter } export default async (): Promise => ({