Skip to content

Commit

Permalink
Fix #32 transformering og fixer for påvirkningsfaktorer
Browse files Browse the repository at this point in the history
Visning gjenstår
  • Loading branch information
steinho committed Sep 12, 2021
1 parent af1a739 commit bcca466
Show file tree
Hide file tree
Showing 5 changed files with 351 additions and 8 deletions.
16 changes: 16 additions & 0 deletions Assessments.Frontend.Web/Assessments.Frontend.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
<None Remove="Views\Test\**" />
</ItemGroup>

<ItemGroup>
<Content Remove="Views\Redlist\Assessment\partials\_ImpactFactors.cshtml" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="ClosedXML" Version="0.95.4" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="5.0.9" />
Expand All @@ -39,5 +43,17 @@
<ItemGroup>
<ProjectReference Include="..\Assessments.Mapping\Assessments.Mapping.csproj" />
</ItemGroup>

<ItemGroup>
<UpToDateCheckInput Remove="Views\Redlist\Assessment\partials\_ImpactFactors.cshtml" />
</ItemGroup>

<ItemGroup>
<_ContentIncludedByDefault Remove="Views\Redlist\Assessment\partials\_ImpactFactors.cshtml" />
</ItemGroup>

<ItemGroup>
<None Include="Views\Redlist\Assessment\partials\_ImpactFactors.cshtml" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<partial name="/Views/Redlist/Assessment/partials/_Bestand.cshtml" />
<partial name="/Views/Redlist/Assessment/partials/_Fylkesforekomster.cshtml" />
<partial name="/Views/Redlist/Assessment/partials/_Habitat.cshtml" />

<partial name="/Views/Redlist/Assessment/partials/_ImpactFactors.cshtml" />
@*
@if (Model.Påvirkningsfaktorer != null && Model.Påvirkningsfaktorer.Count > 0)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,228 @@
@model SpeciesAssessment2021
@functions{

// Snatched and shortened from 2018 nature red list,
// Not yet ready for use.
// https://github.com/Artsdatabanken/RodlisteNaturtyper2018visning/blob/2019update/Views/Home/Partials/impact-factors.cshtml
string ImpactIcon(string mainTitle, string subtitle)
{

// 0. ingen trussel / no factor has no image, as it is never displayed.
if (mainTitle == "Forurensing")
{ // 2
return "https://artsdatabanken.no/RLN2018/media/impact/" + "forurensing" + ".png";
}
else if (mainTitle == "Høsting")
{ // 3
return "https://artsdatabanken.no/RLN2018/media/impact/" + "høsting" + ".png";
}
else if (mainTitle == "Tilfeldig mortalitet")
{ // 4
return "https://artsdatabanken.no/RLN2018/media/impact/" + "ukjent" + ".png"; // TODO - MISSING
}
else if (mainTitle == "Fremmede arter")
{ // 5
return "https://artsdatabanken.no/RLN2018/media/impact/" + "fremmedarter" + ".png";
}
else if (subtitle != null && subtitle.Contains("stedegne"))
{ // 6 "påvirkning fra stedegne arter"
return "https://artsdatabanken.no/RLN2018/media/impact/" + "stedegne" + ".png";
}
else if (mainTitle == "Klimatiske endringer")
{ // 7
return "https://artsdatabanken.no/RLN2018/media/impact/" + "klima" + ".png";
}
else if (mainTitle == "Naturkatastrofer")
{ // 8
return "https://artsdatabanken.no/RLN2018/media/impact/" + "naturkatastrofe" + ".png";
}
else if (mainTitle == "Menneskelig forstyrrelse")
{ // 9
return "https://artsdatabanken.no/RLN2018/media/impact/" + "menneske" + ".png";
}
else if (mainTitle == "Andre")
{ // 10
return "https://artsdatabanken.no/RLN2018/media/impact/" + "andre" + ".png";
}
else if (subtitle != null && subtitle.Contains("Ukjent"))
{ // 11 ukjent
return "https://artsdatabanken.no/RLN2018/media/impact/" + "ukjent" + ".png";
}
else if (subtitle != null && subtitle.Contains("Påvirkning utenfor Norge"))
{ // 12
return "https://artsdatabanken.no/RLN2018/media/impact/" + "ukjent" + ".png"; // TODO - MISSING
}
else if (subtitle != null && subtitle.Contains("Landbruk"))
{ // 1.1 habitat
return "https://artsdatabanken.no/RLN2018/media/impact/" + "landbruk" + ".png";
}
else if (subtitle != null && subtitle.Contains("terrestrisk"))
{ // 1.2 habitat
return "https://artsdatabanken.no/RLN2018/media/impact/" + "terrestisk" + ".png";
}
else if (subtitle != null && subtitle.Contains("limnisk"))
{ // 1.3 habitat
return "https://artsdatabanken.no/RLN2018/media/impact/" + "limnisk" + ".png";
}
else if (subtitle != null && subtitle.Contains("marine"))
{// 1.4 habitat
return "https://artsdatabanken.no/RLN2018/media/impact/" + "marint" + ".png";
}
else
{
return "https://artsdatabanken.no/RLN2018/media/impact/" + "ukjent" + ".png";
}
}

public string iconfinder(string factor)
{
@if (factor == "Ingen trussel")
{
return "delete_sweep";
}
else if (factor == "Påvirkning på habitat")
{
return "nature";
}
else if (factor == "Forurensning")
{
return "recycling";
}
else if (factor == "Høsting")
{
return "gradient";
}
else if (factor == "Tilfeldig mortalitet")
{
return "close";
}
else if (factor == "Fremmede arter")
{
return "pest_control";
}
else if (factor == "Påvirkning fra stedegne arter")
{
return "nature";
}
else if (factor == "Klimatiske endringer")
{
return "cloud";
}
else if (factor == "Naturkatastrofer")
{
return "air";
}
else if (factor == "Menneskelig forstyrrelse")
{
return "engineering";
}
else if (factor == "Andre")
{
return "lens_blur";
}
else if (factor == "Ukjent")
{
return "lens_blur";
}
else if (factor == "Påvirkning utenfor Norge")
{
return "public";
}
else
{
return "delete";
}
}
}


<div class="page_section">
<h2>Påvirkningsfaktorer </h2>

<p class="fact_box"> @ViewBag.glossary["oneliners"]["Påvirkningsfaktorer"]</p>

<div class="factors">
@{foreach (var pfaktor in Model.ImpactFactors)
{
<div class="fake_table_header">
<div class="stats_element_container">
<img src="@ImpactIcon(@pfaktor.GroupingFactor,@pfaktor.Factor)" class="paavirk" />
</div>
<div class="stats_element_text topalign">
<h3>@pfaktor.GroupingFactor</h3>
@* todo: se om stien skal brukes, inneholder også toppnivå - kan fjernes under ved å skrive pfaktor.FactorPath.Skip(1) *@
<h5> Sti: @string.Join(" > ", pfaktor.FactorPath.Skip(1))</h5>
<b>@pfaktor.Id - @pfaktor.Factor</b>

</div>
</div>
<div class="fake_table">
<div>
<h3>Omfang</h3>

@{

var omfang_text = @pfaktor.PopulationScope;
var omfang_numbers = "";

if (omfang_text.Contains("("))
{
// Split out the percentages etc. from the main string.
// Percentages appear to always be enclosed in "()".
omfang_text = omfang_text.Split("(")[0];
omfang_numbers = @pfaktor.PopulationScope.Split("(")[1].Replace(")", "");
}

}
<span>@omfang_text</span><br />
@if (omfang_text.Contains("("))
{
<span class="stats_element">
<span>@omfang_numbers</span>
</span>
}


</div>
<div class="sideborders">
<h3>Alvorlighetsgrad</h3>

@{
var alv_text = @pfaktor.Severity;
var alv_perc = "";
var alv_numbers = "";

if (alv_text.Contains("("))
{
// Split out the percentages etc. from the main string.
// Percentages appear to always be enclosed in "()".
alv_text = alv_text.Split("(")[0];
alv_perc = @pfaktor.Severity.Split("(")[1].Replace(")", "");
if (@pfaktor.Severity.Contains("%"))
{
alv_numbers = alv_perc.Split("%")[1];
alv_perc = alv_perc.Split("%")[0] + "%";
}
}
}
<span>@alv_text</span><br />
@if (@pfaktor.Severity.Contains("("))
{
<span class="stats_element">
<span>@alv_perc</span>
</span>
<span>@alv_numbers</span>
}

</div>
<div>
<h3>Tidspunkt</h3>
@pfaktor.TimeScope
</div>
</div>
}
}

</div> <!-- end pavirkningsboks -->
</div> <!-- end factors -->
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,40 @@ public class SpeciesAssessment2021ImpactFactor
/// </summary>
public string Severity { get; set; } // Alvorlighetsgrad

public string Beskrivelse { get; set; }
//public string Beskrivelse { get; set; }

public string Forkortelse { get; set; }
//public string Forkortelse { get; set; }

/// <summary>
/// Hierarchical id of impactfactor
/// </summary>
public string Id { get; set; }

/// <summary>
/// Proportion of the population size that is affected by the threat
/// </summary>
public string PopulationScope { get; set; } // Omfang

public string OverordnetTittel { get; set; }
//public string OverordnetTittel { get; set; }

/// <summary>
/// Timing of the threat
/// </summary>
public string TimeScope { get; set; } // Tidspunkt

public string Tittel { get; set; }
/// <summary>
/// The ImpackFactor
/// </summary>
public string Factor { get; set; } // Tittel

/// <summary>
/// Hierarchical classification of impactfactor. eg. ["top GroupingFactor","subgroup","factor"]
/// </summary>
public string[] FactorPath { get; set; } // Tittel

public string ØversteTittel { get; set; }
/// <summary>
/// Top grouping of factor
/// </summary>
public string GroupingFactor { get; set; } // ØversteTittel
}
}
Loading

0 comments on commit bcca466

Please sign in to comment.