This repository was archived by the owner on Sep 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Add KPI table component #108
Open
HansenSven
wants to merge
23
commits into
develop
Choose a base branch
from
feat/kpi-table
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 8 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
93e456b
Remove unused imports
1fd27fc
Add KPI table data model & component fetcher
27e8512
Add legenda data and frontend component
18d8ce3
Add support for kpi table background color based on kpi level
HansenSven 9015ee5
Add kpi level indicator to kpi table & cleanup code
HansenSven 91858c3
Cleanup kpi table component
HansenSven eb9ed93
Add hyperlink to assignmentName in KpiTable Word Export & Cleanup Kpi…
fc40e1b
Add support for personal development kpi's to KPI Table
d39e859
Move assessmentRating points to grade logic to model
HansenSven c02e970
Remove commented code
HansenSven 22268f9
Use existing records to determine order, color and name & word export…
HansenSven 81832ae
Merge branch 'develop' into feat/kpi-table
HansenSven 8c01c63
Fix lint issues
HansenSven bb6f823
Merge branch 'develop' into feat/kpi-table
HansenSven 96c5206
Fix lint issues
HansenSven 9003e4e
Implemented Select
NealGeilen 72ed003
Set equal order as KPI Matrix
NealGeilen ca0a5ce
Implementation of a dictionary
NealGeilen 6ef160f
Changes in naming grades
NealGeilen 410748d
Merge branch 'develop' into feat/kpi-table
NealGeilen 338ec5b
Bugfix
NealGeilen ff0d3e5
Bug
NealGeilen b96a277
Removed unused code
NealGeilen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,170 @@ | ||
| using DocumentFormat.OpenXml; | ||
| using DocumentFormat.OpenXml.Packaging; | ||
| using DocumentFormat.OpenXml.Wordprocessing; | ||
| using Epsilon.Canvas.Abstractions.Model; | ||
|
|
||
| namespace Epsilon.Abstractions.Component; | ||
|
|
||
| public record KpiTable( | ||
| IEnumerable<KpiTableEntry> Entries, | ||
| IDictionary<OutcomeGradeLevel, KpiTableEntryLevel> GradeStatus | ||
| ) : IWordCompetenceComponent | ||
| { | ||
| public static readonly IDictionary<OutcomeGradeLevel, KpiTableEntryLevel> DefaultGradeStatus = new Dictionary<OutcomeGradeLevel, KpiTableEntryLevel> | ||
| { | ||
| { | ||
| OutcomeGradeLevel.One, new KpiTableEntryLevel("One", "CBF5DD") | ||
| }, | ||
| { | ||
| OutcomeGradeLevel.Two, new KpiTableEntryLevel("Two", "64E3A1") | ||
| }, | ||
| { | ||
| OutcomeGradeLevel.Three, new KpiTableEntryLevel("Three", "27A567") | ||
| }, | ||
| { | ||
| OutcomeGradeLevel.Four, new KpiTableEntryLevel("Four", "198450") | ||
| }, | ||
| }; | ||
|
|
||
| public void AddToWordDocument(MainDocumentPart mainDocumentPart) | ||
| { | ||
| var body = new Body(); | ||
|
|
||
| // Create a table, with columns for the outcomes and corresponding assignments and grades | ||
| var table = new Table(); | ||
|
|
||
| // Columns header texts | ||
| var columnsHeaders = new List<string> { "KPI", "Assignments", "Grades", }; | ||
|
|
||
| // Create the table header row | ||
| var headerRow = new TableRow(); | ||
|
|
||
| // Create the header cells | ||
| foreach (var columnHeader in columnsHeaders) | ||
| { | ||
| headerRow.AppendChild(CreateTableCellWithBorders("3000", new Paragraph(new Run(new Text(columnHeader))))); | ||
| } | ||
|
|
||
| // Add the header row to the table | ||
| table.AppendChild(headerRow); | ||
|
|
||
| // Create the table body rows and cells in which the first cell is the outcome and the rest are the assignments and grades | ||
| foreach (var entry in Entries) | ||
| { | ||
| var tableRow = new TableRow(); | ||
|
|
||
| // KPI column | ||
| tableRow.AppendChild(CreateTableCellWithBorders("3000", new Paragraph(new Run(new Text(entry.Kpi))))); | ||
|
|
||
| // Assignments column | ||
| var aParagraph = new Paragraph(); | ||
| var aRun = aParagraph.AppendChild(new Run()); | ||
|
|
||
| foreach (var assignment in entry.Assignments) | ||
| { | ||
| var rel = mainDocumentPart.AddHyperlinkRelationship(assignment.Link, true); | ||
| var relationshipId = rel.Id; | ||
|
|
||
| var runProperties = new RunProperties( | ||
| new Underline { Val = UnderlineValues.Single, }); | ||
|
|
||
| aRun.AppendChild(new Hyperlink(new Run(runProperties, new Text(assignment.Name))) | ||
| { | ||
| History = OnOffValue.FromBoolean(true), Id = relationshipId, | ||
| }); | ||
|
|
||
| aRun.AppendChild(new Break()); | ||
| } | ||
|
|
||
| tableRow.AppendChild(CreateTableCellWithBorders("3000", aParagraph)); | ||
|
|
||
| // Grades column | ||
| var grades = entry.Assignments.Select(static a => a.Grade); | ||
| var gParagraph = new Paragraph(); | ||
| var gRun = gParagraph.AppendChild(new Run()); | ||
|
|
||
| foreach (var grade in grades) | ||
| { | ||
| gRun.AppendChild(new Text(grade)); | ||
| gRun.AppendChild(new Break()); | ||
| } | ||
|
|
||
| tableRow.AppendChild(CreateTableCellWithBorders("3000", gParagraph)); | ||
|
|
||
| // Add the row to the table | ||
| table.AppendChild(tableRow); | ||
| } | ||
|
|
||
| // body.AppendChild(GetLegend()); | ||
| body.Append(new Paragraph(new Run(new Text("")))); | ||
| body.AppendChild(table); | ||
|
|
||
| mainDocumentPart.Document.AppendChild(body); | ||
| } | ||
|
|
||
| // private OpenXmlElement GetLegend() | ||
| // { | ||
| // var table = new Table(); | ||
| // | ||
| // foreach (var status in GradeStatus) | ||
| // { | ||
| // var row = new TableRow(); | ||
| // var cellName = CreateTableCellWithBorders("200"); | ||
| // cellName.Append(new Paragraph(new Run(new Text(status.Value.Level)))); | ||
| // | ||
| // var cellValue = CreateTableCellWithBorders("200"); | ||
| // cellValue.Append(new Paragraph(new Run(new Text("")))); | ||
| // cellValue.FirstChild?.Append(new Shading | ||
| // { | ||
| // Fill = status.Value.Color, | ||
| // }); | ||
| // row.AppendChild(cellName); | ||
| // row.AppendChild(cellValue); | ||
| // table.AppendChild(row); | ||
| // } | ||
| // | ||
| // return table; | ||
| // } | ||
HansenSven marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| private static TableCell CreateTableCellWithBorders(string? width, params OpenXmlElement[] elements) | ||
| { | ||
| var cell = new TableCell(); | ||
| var cellProperties = new TableCellProperties(); | ||
| var borders = new TableCellBorders( | ||
| new LeftBorder | ||
| { | ||
| Val = BorderValues.Single, | ||
| }, | ||
| new RightBorder | ||
| { | ||
| Val = BorderValues.Single, | ||
| }, | ||
| new TopBorder | ||
| { | ||
| Val = BorderValues.Single, | ||
| }, | ||
| new BottomBorder | ||
| { | ||
| Val = BorderValues.Single, | ||
| }); | ||
|
|
||
| foreach (var element in elements) | ||
| { | ||
| cell.Append(element); | ||
| } | ||
|
|
||
| if (width != null) | ||
| { | ||
| cellProperties.Append(new TableCellWidth | ||
| { | ||
| Type = TableWidthUnitValues.Dxa, | ||
| Width = width, | ||
| }); | ||
| } | ||
|
|
||
| cellProperties.Append(borders); | ||
| cell.PrependChild(cellProperties); | ||
|
|
||
| return cell; | ||
| } | ||
| } | ||
This file contains hidden or 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,7 @@ | ||
| namespace Epsilon.Abstractions.Component; | ||
|
|
||
| public record KpiTableEntry( | ||
| string Kpi, | ||
| KpiTableEntryLevel Level, | ||
| IEnumerable<KpiTableEntryAssignment> Assignments | ||
| ); |
This file contains hidden or 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,7 @@ | ||
| namespace Epsilon.Abstractions.Component; | ||
|
|
||
| public record KpiTableEntryAssignment( | ||
| string Name, | ||
| string Grade, | ||
| Uri Link | ||
| ); |
This file contains hidden or 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,6 @@ | ||
| namespace Epsilon.Abstractions.Component; | ||
|
|
||
| public record KpiTableEntryLevel( | ||
| string Level, | ||
| string Color | ||
| ); |
This file contains hidden or 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 hidden or 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 hidden or 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,9 @@ | ||
| namespace Epsilon.Canvas.Abstractions.Model; | ||
|
|
||
| public enum OutcomeGradeLevel | ||
| { | ||
| One, | ||
| Two, | ||
| Three, | ||
| Four, | ||
| } |
This file contains hidden or 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,67 @@ | ||
| <script lang="ts" setup> | ||
| import { Api } from "../logic/Api" | ||
| import { Ref, ref } from "vue" | ||
|
|
||
| const api = new Api() | ||
| const today = new Date() | ||
| const otherMonth = new Date() | ||
| otherMonth.setMonth(otherMonth.getMonth() - 3) | ||
|
|
||
| const data: Ref<unknown> = ref<unknown>() | ||
| const Kpis: Ref<unknown> = ref<unknown>([]) | ||
|
|
||
| api.component | ||
| .componentDetail("kpi_table", { | ||
| startDate: formatDate(otherMonth), | ||
| endDate: formatDate(today), | ||
| }) | ||
| .then((result) => { | ||
| data.value = result.data | ||
| Kpis.value = result.data.entries | ||
| }) | ||
|
|
||
| function formatDate(date: Date): string { | ||
| const year = date.getFullYear() | ||
| const month = `${date.getMonth() + 1}`.padStart(2, "0") | ||
| const day = date.getDate() | ||
| return `${year}-${month}-${day}` | ||
| } | ||
| </script> | ||
|
|
||
| <template> | ||
| <table v-if="data"> | ||
| <tr> | ||
| <th>KPI</th> | ||
| <th>Assignments</th> | ||
| <th>Grades</th> | ||
| </tr> | ||
| <tr v-for="KPI of Kpis" :key="KPI"> | ||
| <td :style="{ | ||
| border: '3px solid #' + KPI.level.color, | ||
| }"> | ||
| {{ KPI.kpi }} | ||
| </td> | ||
| <td> | ||
| <div | ||
| v-for="assignment of KPI.assignments" | ||
| :style="{ textAlign: 'start' }" | ||
| > | ||
| <a :href="assignment.link">{{ assignment.name }}</a> | ||
| </div> | ||
| </td> | ||
| <td> | ||
| <div v-for="assignment of KPI.assignments"> | ||
| {{ assignment.grade }} | ||
| </div> | ||
| </td> | ||
| </tr> | ||
| </table> | ||
| </template> | ||
|
|
||
| <style scoped> | ||
| td, | ||
| th { | ||
| border: 2px solid; | ||
| padding: 1rem; | ||
| } | ||
| </style> |
This file contains hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.