Skip to content

Commit

Permalink
#81 qo-section
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Jul 30, 2024
1 parent eb42a0e commit 3d30881
Show file tree
Hide file tree
Showing 9 changed files with 155 additions and 247 deletions.
13 changes: 9 additions & 4 deletions js/qod.js → js/qo-section.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,18 @@
* SOFTWARE.
*/

$(function() {
const ctx = document.getElementById('qod');
/**
* Render QO canvas.
* @param canvas The ID of "canvas" element in HTML
* @param data Hash with data for the Chart
*/
function qo_render(canvas, data) {
const ctx = document.getElementById(canvas);
new Chart(ctx, {
type: 'line',
data: qod_data,
data: data,
options: {
responsive: false,
}
});
});
}
34 changes: 0 additions & 34 deletions js/qos.js

This file was deleted.

5 changes: 1 addition & 4 deletions tests/empty.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,4 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
---
-
what: pmp
area: hr
days_of_running_balance: 28
[]
25 changes: 25 additions & 0 deletions tests/single-qos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# MIT License
#
# Copyright (c) 2024 Zerocracy
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
---
-
when: 2024-07-03T22:22:22.8492Z
what: quality-of-service
2 changes: 1 addition & 1 deletion xsl/awards.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:z="https://www.zerocracy.com" version="2.0" exclude-result-prefixes="xs">
<xsl:variable name="days" select="z:pmp(/fb, 'hr', 'days_of_running_balance')"/>
<xsl:variable name="days" select="z:pmp(/fb, 'hr', 'days_of_running_balance', 28)"/>
<xsl:variable name="weeks" select="xs:integer(ceiling(xs:float($days) div 7))"/>
<xsl:variable name="since" select="xs:dateTime($today) - xs:dayTimeDuration(concat('P', $days, 'D'))"/>
<xsl:variable name="facts" select="/fb/f[award and xs:dateTime(when) &gt; $since and is_human = 1]"/>
Expand Down
50 changes: 26 additions & 24 deletions xsl/index.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -33,33 +33,29 @@ SOFTWARE.
<xsl:param name="fbe"/>
<xsl:import href="awards.xsl"/>
<xsl:import href="policy.xsl"/>
<xsl:import href="qod.xsl"/>
<xsl:import href="qos.xsl"/>
<xsl:import href="qo-section.xsl"/>
<xsl:function name="z:pmp">
<xsl:param name="fb"/>
<xsl:param name="area"/>
<xsl:param name="param"/>
<xsl:param name="default"/>
<xsl:variable name="a" select="$fb/f[what='pmp' and area=$area]"/>
<xsl:if test="not($a)">
<xsl:message terminate="yes">
<xsl:text>There is no PMP fact for the area '</xsl:text>
<xsl:value-of select="$area"/>
<xsl:text>', can't read '</xsl:text>
<xsl:value-of select="$param"/>
<xsl:text>' from it :(</xsl:text>
</xsl:message>
</xsl:if>
<xsl:variable name="v" select="$a/*[name()=$param]/text()"/>
<xsl:if test="not($v)">
<xsl:message terminate="yes">
<xsl:text>There is no parameter '</xsl:text>
<xsl:value-of select="$param"/>
<xsl:text>' in the PMP artifact for the '</xsl:text>
<xsl:value-of select="$area"/>
<xsl:text>' area</xsl:text>
</xsl:message>
</xsl:if>
<xsl:value-of select="$v"/>
<xsl:choose>
<xsl:when test="$a">
<xsl:variable name="v" select="$a/*[name()=$param]/text()"/>
<xsl:choose>
<xsl:when test="$v">
<xsl:value-of select="$v"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$default"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$default"/>
</xsl:otherwise>
</xsl:choose>
</xsl:function>
<xsl:template name="javascript">
<xsl:param name="url"/>
Expand Down Expand Up @@ -121,8 +117,14 @@ SOFTWARE.
<article>
<xsl:apply-templates select="/" mode="awards"/>
<xsl:apply-templates select="/fb/f[what='hr-policy']"/>
<xsl:apply-templates select="/fb" mode="qos"/>
<xsl:apply-templates select="/fb" mode="qod"/>
<xsl:call-template name="qo-section">
<xsl:with-param name="what" select="'quality-of-service'"/>
<xsl:with-param name="title" select="'Quality of Service'"/>
</xsl:call-template>
<xsl:call-template name="qo-section">
<xsl:with-param name="what" select="'quantity-of-deliverables'"/>
<xsl:with-param name="title" select="'Quantity of Deliverables'"/>
</xsl:call-template>
</article>
<footer>
<p>
Expand Down
93 changes: 93 additions & 0 deletions xsl/qo-section.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
MIT License
Copyright (c) 2024 Zerocracy
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to who_namem the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs">
<xsl:template name="qo-section">
<xsl:param name="what" as="xs:string"/>
<xsl:param name="title" as="xs:string"/>
<xsl:variable name="facts" select="/fb/f[what=$what and xs:dateTime(when) &gt; (xs:dateTime($today) - xs:dayTimeDuration('P180D'))]"/>
<xsl:choose>
<xsl:when test="empty($facts)">
<p class="darkred">
<xsl:text>There is no information about the </xsl:text>
<xsl:value-of select="$title"/>
<xsl:text>.</xsl:text>
</p>
</xsl:when>
<xsl:otherwise>
<div>
<h2>
<xsl:value-of select="$title"/>
</h2>
<div style="width: 800px;">
<canvas id="{$what}" style="width: 100%">
<xsl:text> </xsl:text>
</canvas>
</div>
</div>
<script type="text/javascript">
<xsl:text>$(function() { qo_render('</xsl:text>
<xsl:value-of select="$what"/>
<xsl:text>', { labels: [</xsl:text>
<xsl:for-each select="$facts">
<xsl:sort select="when" data-type="text" order="ascending"/>
<xsl:if test="position() &gt; 1">
<xsl:text>, </xsl:text>
</xsl:if>
<xsl:text>'</xsl:text>
<xsl:value-of select="format-date(xs:date(xs:dateTime(when)), '[M1]/[D1]')"/>
<xsl:text>'</xsl:text>
</xsl:for-each>
<xsl:text>],</xsl:text>
<xsl:text>datasets: [</xsl:text>
<xsl:for-each select="distinct-values($facts/*[starts-with(name(), 'n_')]/name())">
<xsl:variable name="metric" select="."/>
<xsl:if test="position() &gt; 1">
<xsl:text>, </xsl:text>
</xsl:if>
<xsl:text>{ label: '</xsl:text>
<xsl:value-of select="$metric"/>
<xsl:text>', data: [</xsl:text>
<xsl:for-each select="$facts">
<xsl:sort select="when" data-type="text" order="ascending"/>
<xsl:if test="position() &gt; 1">
<xsl:text>, </xsl:text>
</xsl:if>
<xsl:choose>
<xsl:when test="*[name()=$metric]">
<xsl:value-of select="*[name()=$metric]/text()"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>null</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
<xsl:text>] }</xsl:text>
</xsl:for-each>
<xsl:text>] });})</xsl:text>
</script>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
90 changes: 0 additions & 90 deletions xsl/qod.xsl

This file was deleted.

Loading

0 comments on commit 3d30881

Please sign in to comment.