mirror of https://github.com/dotnet/tye.git
committed by
GitHub
56 changed files with 2823 additions and 4 deletions
@ -0,0 +1,199 @@ |
|||||
|
root = true |
||||
|
|
||||
|
[*] |
||||
|
indent_style = space |
||||
|
|
||||
|
[*.{props,targets,csproj}] |
||||
|
indent_style = space |
||||
|
indent_size = 2 |
||||
|
|
||||
|
[*.{js,json}] |
||||
|
indent_style = space |
||||
|
indent_size = 2 |
||||
|
|
||||
|
[*.{yml,yaml}] |
||||
|
indent_style = space |
||||
|
indent_size = 2 |
||||
|
|
||||
|
[*.{cs,csx}] |
||||
|
indent_size = 4 |
||||
|
insert_final_newline = true |
||||
|
charset = utf-8-bom |
||||
|
|
||||
|
# Code files |
||||
|
[*.{cs,csx,vb,vbx}] |
||||
|
indent_size = 4 |
||||
|
insert_final_newline = true |
||||
|
charset = utf-8-bom |
||||
|
|
||||
|
# Powershell files |
||||
|
[*.ps1] |
||||
|
indent_size = 2 |
||||
|
|
||||
|
# Shell script files |
||||
|
[*.sh] |
||||
|
end_of_line = lf |
||||
|
indent_size = 2 |
||||
|
|
||||
|
# Dotnet code style settings: |
||||
|
[*.{cs,vb}] |
||||
|
# Sort using and Import directives with System.* appearing first |
||||
|
dotnet_sort_system_directives_first = true |
||||
|
# Avoid "this." and "Me." if not necessary |
||||
|
dotnet_style_qualification_for_field = false:refactoring |
||||
|
dotnet_style_qualification_for_property = false:refactoring |
||||
|
dotnet_style_qualification_for_method = false:refactoring |
||||
|
dotnet_style_qualification_for_event = false:refactoring |
||||
|
|
||||
|
# Use language keywords instead of framework type names for type references |
||||
|
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion |
||||
|
dotnet_style_predefined_type_for_member_access = true:suggestion |
||||
|
|
||||
|
# Suggest more modern language features when available |
||||
|
dotnet_style_object_initializer = true:suggestion |
||||
|
dotnet_style_collection_initializer = true:suggestion |
||||
|
dotnet_style_coalesce_expression = true:suggestion |
||||
|
dotnet_style_null_propagation = true:suggestion |
||||
|
dotnet_style_explicit_tuple_names = true:suggestion |
||||
|
|
||||
|
# Non-private static fields are PascalCase |
||||
|
dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.severity = suggestion |
||||
|
dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.symbols = non_private_static_fields |
||||
|
dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.style = non_private_static_field_style |
||||
|
|
||||
|
dotnet_naming_symbols.non_private_static_fields.applicable_kinds = field |
||||
|
dotnet_naming_symbols.non_private_static_fields.applicable_accessibilities = public, protected, internal, protected_internal, private_protected |
||||
|
dotnet_naming_symbols.non_private_static_fields.required_modifiers = static |
||||
|
|
||||
|
dotnet_naming_style.non_private_static_field_style.capitalization = pascal_case |
||||
|
|
||||
|
# Non-private readonly fields are PascalCase |
||||
|
dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.severity = suggestion |
||||
|
dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.symbols = non_private_readonly_fields |
||||
|
dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.style = non_private_readonly_field_style |
||||
|
|
||||
|
dotnet_naming_symbols.non_private_readonly_fields.applicable_kinds = field |
||||
|
dotnet_naming_symbols.non_private_readonly_fields.applicable_accessibilities = public, protected, internal, protected_internal, private_protected |
||||
|
dotnet_naming_symbols.non_private_readonly_fields.required_modifiers = readonly |
||||
|
|
||||
|
dotnet_naming_style.non_private_readonly_field_style.capitalization = pascal_case |
||||
|
|
||||
|
# Constants are PascalCase |
||||
|
dotnet_naming_rule.constants_should_be_pascal_case.severity = suggestion |
||||
|
dotnet_naming_rule.constants_should_be_pascal_case.symbols = constants |
||||
|
dotnet_naming_rule.constants_should_be_pascal_case.style = constant_style |
||||
|
|
||||
|
dotnet_naming_symbols.constants.applicable_kinds = field, local |
||||
|
dotnet_naming_symbols.constants.required_modifiers = const |
||||
|
|
||||
|
dotnet_naming_style.constant_style.capitalization = pascal_case |
||||
|
|
||||
|
# Static fields are camelCase |
||||
|
dotnet_naming_rule.static_fields_should_be_camel_case.severity = suggestion |
||||
|
dotnet_naming_rule.static_fields_should_be_camel_case.symbols = static_fields |
||||
|
dotnet_naming_rule.static_fields_should_be_camel_case.style = static_field_style |
||||
|
|
||||
|
dotnet_naming_symbols.static_fields.applicable_kinds = field |
||||
|
dotnet_naming_symbols.static_fields.required_modifiers = static |
||||
|
|
||||
|
dotnet_naming_style.static_field_style.capitalization = camel_case |
||||
|
|
||||
|
# Instance fields are camelCase |
||||
|
dotnet_naming_rule.instance_fields_should_be_camel_case.severity = suggestion |
||||
|
dotnet_naming_rule.instance_fields_should_be_camel_case.symbols = instance_fields |
||||
|
dotnet_naming_rule.instance_fields_should_be_camel_case.style = instance_field_style |
||||
|
|
||||
|
dotnet_naming_symbols.instance_fields.applicable_kinds = field |
||||
|
|
||||
|
dotnet_naming_style.instance_field_style.capitalization = camel_case |
||||
|
|
||||
|
# Locals and parameters are camelCase |
||||
|
dotnet_naming_rule.locals_should_be_camel_case.severity = suggestion |
||||
|
dotnet_naming_rule.locals_should_be_camel_case.symbols = locals_and_parameters |
||||
|
dotnet_naming_rule.locals_should_be_camel_case.style = camel_case_style |
||||
|
|
||||
|
dotnet_naming_symbols.locals_and_parameters.applicable_kinds = parameter, local |
||||
|
|
||||
|
dotnet_naming_style.camel_case_style.capitalization = camel_case |
||||
|
|
||||
|
# Local functions are PascalCase |
||||
|
dotnet_naming_rule.local_functions_should_be_pascal_case.severity = suggestion |
||||
|
dotnet_naming_rule.local_functions_should_be_pascal_case.symbols = local_functions |
||||
|
dotnet_naming_rule.local_functions_should_be_pascal_case.style = local_function_style |
||||
|
|
||||
|
dotnet_naming_symbols.local_functions.applicable_kinds = local_function |
||||
|
|
||||
|
dotnet_naming_style.local_function_style.capitalization = pascal_case |
||||
|
|
||||
|
# By default, name items with PascalCase |
||||
|
dotnet_naming_rule.members_should_be_pascal_case.severity = suggestion |
||||
|
dotnet_naming_rule.members_should_be_pascal_case.symbols = all_members |
||||
|
dotnet_naming_rule.members_should_be_pascal_case.style = pascal_case_style |
||||
|
|
||||
|
dotnet_naming_symbols.all_members.applicable_kinds = * |
||||
|
|
||||
|
dotnet_naming_style.pascal_case_style.capitalization = pascal_case |
||||
|
|
||||
|
[*.cs] |
||||
|
# Newline settings |
||||
|
csharp_new_line_before_open_brace = all |
||||
|
csharp_new_line_before_else = true |
||||
|
csharp_new_line_before_catch = true |
||||
|
csharp_new_line_before_finally = true |
||||
|
csharp_new_line_before_members_in_object_initializers = true |
||||
|
csharp_new_line_before_members_in_anonymous_types = true |
||||
|
csharp_new_line_between_query_expression_clauses = true |
||||
|
|
||||
|
# Indentation preferences |
||||
|
csharp_indent_block_contents = true |
||||
|
csharp_indent_braces = false |
||||
|
csharp_indent_case_contents = true |
||||
|
csharp_indent_case_contents_when_block = true |
||||
|
csharp_indent_switch_labels = true |
||||
|
csharp_indent_labels = flush_left |
||||
|
|
||||
|
# Prefer "var" everywhere |
||||
|
csharp_style_var_for_built_in_types = true:suggestion |
||||
|
csharp_style_var_when_type_is_apparent = true:suggestion |
||||
|
csharp_style_var_elsewhere = true:suggestion |
||||
|
|
||||
|
# Prefer method-like constructs to have a block body |
||||
|
csharp_style_expression_bodied_methods = false:none |
||||
|
csharp_style_expression_bodied_constructors = false:none |
||||
|
csharp_style_expression_bodied_operators = false:none |
||||
|
|
||||
|
# Prefer property-like constructs to have an expression-body |
||||
|
csharp_style_expression_bodied_properties = true:none |
||||
|
csharp_style_expression_bodied_indexers = true:none |
||||
|
csharp_style_expression_bodied_accessors = true:none |
||||
|
|
||||
|
# Suggest more modern language features when available |
||||
|
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion |
||||
|
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion |
||||
|
csharp_style_inlined_variable_declaration = true:suggestion |
||||
|
csharp_style_throw_expression = true:suggestion |
||||
|
csharp_style_conditional_delegate_call = true:suggestion |
||||
|
|
||||
|
# Space preferences |
||||
|
csharp_space_after_cast = false |
||||
|
csharp_space_after_colon_in_inheritance_clause = true |
||||
|
csharp_space_after_comma = true |
||||
|
csharp_space_after_dot = false |
||||
|
csharp_space_after_keywords_in_control_flow_statements = true |
||||
|
csharp_space_after_semicolon_in_for_statement = true |
||||
|
csharp_space_around_binary_operators = before_and_after |
||||
|
csharp_space_around_declaration_statements = do_not_ignore |
||||
|
csharp_space_before_colon_in_inheritance_clause = true |
||||
|
csharp_space_before_comma = false |
||||
|
csharp_space_before_dot = false |
||||
|
csharp_space_before_open_square_brackets = false |
||||
|
csharp_space_before_semicolon_in_for_statement = false |
||||
|
csharp_space_between_empty_square_brackets = false |
||||
|
csharp_space_between_method_call_empty_parameter_list_parentheses = false |
||||
|
csharp_space_between_method_call_name_and_opening_parenthesis = false |
||||
|
csharp_space_between_method_call_parameter_list_parentheses = false |
||||
|
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false |
||||
|
csharp_space_between_method_declaration_name_and_open_parenthesis = false |
||||
|
csharp_space_between_method_declaration_parameter_list_parentheses = false |
||||
|
csharp_space_between_parentheses = false |
||||
|
csharp_space_between_square_brackets = false |
||||
@ -0,0 +1,19 @@ |
|||||
|
# VotingSample |
||||
|
Voting sample app inspired by https://github.com/dockersamples/example-voting-app with a few different implementation choices. |
||||
|
|
||||
|
## For running |
||||
|
|
||||
|
The project should be immediately runnable by calling `tye run` from the directory. |
||||
|
|
||||
|
## For deployment |
||||
|
|
||||
|
A few things need to be configured before deploying to Kubernetes. |
||||
|
|
||||
|
- Setting up Redis. A connection string needs to be provided to connect to Redis. You can follow our tutorial on [setting up redis in your cluster](../../docs/tutorials/hello-tye/02_add_redis.md). |
||||
|
- Setting up postgresql. A connection string eventually needs to be provided to tye for postgresql. |
||||
|
- Deploying the ingress.yaml by calling: |
||||
|
|
||||
|
``` |
||||
|
kubectl apply -f ingress.yml |
||||
|
``` |
||||
|
|
||||
@ -0,0 +1,70 @@ |
|||||
|
|
||||
|
Microsoft Visual Studio Solution File, Format Version 12.00 |
||||
|
# Visual Studio Version 16 |
||||
|
VisualStudioVersion = 16.0.29806.167 |
||||
|
MinimumVisualStudioVersion = 15.0.26124.0 |
||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "vote", "vote\vote.csproj", "{ADDD778E-3A81-40BA-AA7D-ED290C20BCAB}" |
||||
|
EndProject |
||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "worker", "worker\worker.csproj", "{C480A62F-CB86-4644-92F5-62DB4008F72E}" |
||||
|
EndProject |
||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "results", "results\results.csproj", "{A91BEB44-4543-4634-89CA-B83BB3AF2BFB}" |
||||
|
EndProject |
||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3A01F2F4-824F-494A-ABC9-35C6B7032474}" |
||||
|
ProjectSection(SolutionItems) = preProject |
||||
|
tye.yaml = tye.yaml |
||||
|
EndProjectSection |
||||
|
EndProject |
||||
|
Global |
||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution |
||||
|
Debug|Any CPU = Debug|Any CPU |
||||
|
Debug|x64 = Debug|x64 |
||||
|
Debug|x86 = Debug|x86 |
||||
|
Release|Any CPU = Release|Any CPU |
||||
|
Release|x64 = Release|x64 |
||||
|
Release|x86 = Release|x86 |
||||
|
EndGlobalSection |
||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution |
||||
|
{ADDD778E-3A81-40BA-AA7D-ED290C20BCAB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
||||
|
{ADDD778E-3A81-40BA-AA7D-ED290C20BCAB}.Debug|Any CPU.Build.0 = Debug|Any CPU |
||||
|
{ADDD778E-3A81-40BA-AA7D-ED290C20BCAB}.Debug|x64.ActiveCfg = Debug|Any CPU |
||||
|
{ADDD778E-3A81-40BA-AA7D-ED290C20BCAB}.Debug|x64.Build.0 = Debug|Any CPU |
||||
|
{ADDD778E-3A81-40BA-AA7D-ED290C20BCAB}.Debug|x86.ActiveCfg = Debug|Any CPU |
||||
|
{ADDD778E-3A81-40BA-AA7D-ED290C20BCAB}.Debug|x86.Build.0 = Debug|Any CPU |
||||
|
{ADDD778E-3A81-40BA-AA7D-ED290C20BCAB}.Release|Any CPU.ActiveCfg = Release|Any CPU |
||||
|
{ADDD778E-3A81-40BA-AA7D-ED290C20BCAB}.Release|Any CPU.Build.0 = Release|Any CPU |
||||
|
{ADDD778E-3A81-40BA-AA7D-ED290C20BCAB}.Release|x64.ActiveCfg = Release|Any CPU |
||||
|
{ADDD778E-3A81-40BA-AA7D-ED290C20BCAB}.Release|x64.Build.0 = Release|Any CPU |
||||
|
{ADDD778E-3A81-40BA-AA7D-ED290C20BCAB}.Release|x86.ActiveCfg = Release|Any CPU |
||||
|
{ADDD778E-3A81-40BA-AA7D-ED290C20BCAB}.Release|x86.Build.0 = Release|Any CPU |
||||
|
{C480A62F-CB86-4644-92F5-62DB4008F72E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
||||
|
{C480A62F-CB86-4644-92F5-62DB4008F72E}.Debug|Any CPU.Build.0 = Debug|Any CPU |
||||
|
{C480A62F-CB86-4644-92F5-62DB4008F72E}.Debug|x64.ActiveCfg = Debug|Any CPU |
||||
|
{C480A62F-CB86-4644-92F5-62DB4008F72E}.Debug|x64.Build.0 = Debug|Any CPU |
||||
|
{C480A62F-CB86-4644-92F5-62DB4008F72E}.Debug|x86.ActiveCfg = Debug|Any CPU |
||||
|
{C480A62F-CB86-4644-92F5-62DB4008F72E}.Debug|x86.Build.0 = Debug|Any CPU |
||||
|
{C480A62F-CB86-4644-92F5-62DB4008F72E}.Release|Any CPU.ActiveCfg = Release|Any CPU |
||||
|
{C480A62F-CB86-4644-92F5-62DB4008F72E}.Release|Any CPU.Build.0 = Release|Any CPU |
||||
|
{C480A62F-CB86-4644-92F5-62DB4008F72E}.Release|x64.ActiveCfg = Release|Any CPU |
||||
|
{C480A62F-CB86-4644-92F5-62DB4008F72E}.Release|x64.Build.0 = Release|Any CPU |
||||
|
{C480A62F-CB86-4644-92F5-62DB4008F72E}.Release|x86.ActiveCfg = Release|Any CPU |
||||
|
{C480A62F-CB86-4644-92F5-62DB4008F72E}.Release|x86.Build.0 = Release|Any CPU |
||||
|
{A91BEB44-4543-4634-89CA-B83BB3AF2BFB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
||||
|
{A91BEB44-4543-4634-89CA-B83BB3AF2BFB}.Debug|Any CPU.Build.0 = Debug|Any CPU |
||||
|
{A91BEB44-4543-4634-89CA-B83BB3AF2BFB}.Debug|x64.ActiveCfg = Debug|Any CPU |
||||
|
{A91BEB44-4543-4634-89CA-B83BB3AF2BFB}.Debug|x64.Build.0 = Debug|Any CPU |
||||
|
{A91BEB44-4543-4634-89CA-B83BB3AF2BFB}.Debug|x86.ActiveCfg = Debug|Any CPU |
||||
|
{A91BEB44-4543-4634-89CA-B83BB3AF2BFB}.Debug|x86.Build.0 = Debug|Any CPU |
||||
|
{A91BEB44-4543-4634-89CA-B83BB3AF2BFB}.Release|Any CPU.ActiveCfg = Release|Any CPU |
||||
|
{A91BEB44-4543-4634-89CA-B83BB3AF2BFB}.Release|Any CPU.Build.0 = Release|Any CPU |
||||
|
{A91BEB44-4543-4634-89CA-B83BB3AF2BFB}.Release|x64.ActiveCfg = Release|Any CPU |
||||
|
{A91BEB44-4543-4634-89CA-B83BB3AF2BFB}.Release|x64.Build.0 = Release|Any CPU |
||||
|
{A91BEB44-4543-4634-89CA-B83BB3AF2BFB}.Release|x86.ActiveCfg = Release|Any CPU |
||||
|
{A91BEB44-4543-4634-89CA-B83BB3AF2BFB}.Release|x86.Build.0 = Release|Any CPU |
||||
|
EndGlobalSection |
||||
|
GlobalSection(SolutionProperties) = preSolution |
||||
|
HideSolutionNode = FALSE |
||||
|
EndGlobalSection |
||||
|
GlobalSection(ExtensibilityGlobals) = postSolution |
||||
|
SolutionGuid = {E3B86575-DCBB-4D9F-B308-9DFCEAE52212} |
||||
|
EndGlobalSection |
||||
|
EndGlobal |
||||
@ -0,0 +1,25 @@ |
|||||
|
version: "3" |
||||
|
services: |
||||
|
redis: |
||||
|
image: redis:alpine |
||||
|
ports: |
||||
|
- "6379" |
||||
|
postgres: # TODO needed to switch name here for some reason |
||||
|
image: postgres:9.4 |
||||
|
ports: |
||||
|
- "5432" |
||||
|
environment: |
||||
|
POSTGRES_PASSWORD: "postgres" |
||||
|
vote: |
||||
|
build: |
||||
|
context: ./vote |
||||
|
ports: |
||||
|
- 5000:80 |
||||
|
result: |
||||
|
build: |
||||
|
context: ./results |
||||
|
ports: |
||||
|
- 5001:80 |
||||
|
worker: |
||||
|
build: |
||||
|
context: ./worker |
||||
@ -0,0 +1,21 @@ |
|||||
|
apiVersion: extensions/v1beta1 |
||||
|
kind: Ingress |
||||
|
metadata: |
||||
|
name: ingress-basic |
||||
|
namespace: default |
||||
|
annotations: |
||||
|
kubernetes.io/ingress.class: nginx |
||||
|
nginx.ingress.kubernetes.io/ssl-redirect: "false" |
||||
|
nginx.ingress.kubernetes.io/rewrite-target: /$2 |
||||
|
spec: |
||||
|
rules: |
||||
|
- http: |
||||
|
paths: |
||||
|
- backend: |
||||
|
serviceName: vote |
||||
|
servicePort: 80 |
||||
|
path: /vote(/|$)(.*) |
||||
|
- backend: |
||||
|
serviceName: results |
||||
|
servicePort: 80 |
||||
|
path: /results(/|$)(.*) |
||||
@ -0,0 +1,10 @@ |
|||||
|
<Router AppAssembly="@typeof(Program).Assembly"> |
||||
|
<Found Context="routeData"> |
||||
|
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" /> |
||||
|
</Found> |
||||
|
<NotFound> |
||||
|
<LayoutView Layout="@typeof(MainLayout)"> |
||||
|
<p>Sorry, there's nothing at this address.</p> |
||||
|
</LayoutView> |
||||
|
</NotFound> |
||||
|
</Router> |
||||
@ -0,0 +1,13 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace Results |
||||
|
{ |
||||
|
public class VotingResult |
||||
|
{ |
||||
|
public string Vote { get; set; } |
||||
|
public int Count { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,16 @@ |
|||||
|
@page "/error" |
||||
|
|
||||
|
|
||||
|
<h1 class="text-danger">Error.</h1> |
||||
|
<h2 class="text-danger">An error occurred while processing your request.</h2> |
||||
|
|
||||
|
<h3>Development Mode</h3> |
||||
|
<p> |
||||
|
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred. |
||||
|
</p> |
||||
|
<p> |
||||
|
<strong>The Development environment shouldn't be enabled for deployed applications.</strong> |
||||
|
It can result in displaying sensitive information from exceptions to end users. |
||||
|
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong> |
||||
|
and restarting the app. |
||||
|
</p> |
||||
@ -0,0 +1,129 @@ |
|||||
|
@page "/" |
||||
|
@implements IDisposable |
||||
|
@using System.Threading |
||||
|
@using Microsoft.Extensions.Configuration |
||||
|
@using Microsoft.AspNetCore.SignalR.Client |
||||
|
@using ChartJs.Blazor.Charts |
||||
|
@using ChartJs.Blazor.ChartJS.Common.Properties |
||||
|
@using ChartJs.Blazor.Util |
||||
|
@using ChartJs.Blazor.ChartJS.PieChart |
||||
|
|
||||
|
|
||||
|
@inject IConfiguration Configuration |
||||
|
|
||||
|
@* <div id="result"> |
||||
|
<span>Dog Votes: @DogVotes.Count</span> |
||||
|
<span>Cat Votes: @CatVotes.Count</span> |
||||
|
</div> *@ |
||||
|
|
||||
|
<div id="result"> |
||||
|
<ChartJsPieChart @ref="_pieChartJs" Config="@_config" Width="600" Height="300" /> |
||||
|
</div> |
||||
|
|
||||
|
@code { |
||||
|
private VotingResult DogVotes = new VotingResult { Vote = "a", Count = 0 }; |
||||
|
private VotingResult CatVotes = new VotingResult { Vote = "b", Count = 0 }; |
||||
|
|
||||
|
private PieConfig _config; |
||||
|
private ChartJsPieChart _pieChartJs; |
||||
|
|
||||
|
protected override void OnInitialized() |
||||
|
{ |
||||
|
_config = new PieConfig |
||||
|
{ |
||||
|
Options = new PieOptions |
||||
|
{ |
||||
|
Title = new OptionsTitle |
||||
|
{ |
||||
|
Display = true, |
||||
|
Text = "Dogs vs Cats" |
||||
|
}, |
||||
|
Responsive = true, |
||||
|
Animation = new ArcAnimation |
||||
|
{ |
||||
|
AnimateRotate = true, |
||||
|
AnimateScale = true |
||||
|
} |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
_config.Data.Labels.AddRange(new[] { "Dogs", "Cats" }); |
||||
|
|
||||
|
var pieSet = new PieDataset |
||||
|
{ |
||||
|
BackgroundColor = new[] { ColorUtil.RandomColorString(), ColorUtil.RandomColorString() }, |
||||
|
BorderWidth = 0, |
||||
|
HoverBackgroundColor = ColorUtil.RandomColorString(), |
||||
|
HoverBorderColor = ColorUtil.RandomColorString(), |
||||
|
HoverBorderWidth = 1, |
||||
|
BorderColor = "#ffffff", |
||||
|
}; |
||||
|
|
||||
|
pieSet.Data.AddRange(new double[] { DogVotes.Count, CatVotes.Count }); |
||||
|
_config.Data.Datasets.Add(pieSet); |
||||
|
} |
||||
|
|
||||
|
protected override async Task OnAfterRenderAsync(bool firstRender) |
||||
|
{ |
||||
|
if (firstRender) |
||||
|
{ |
||||
|
_ = Connect(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
async Task Connect() |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
var connection = new HubConnectionBuilder() |
||||
|
.WithUrl(Configuration.GetServiceUri("worker")!.AbsoluteUri + "resultsHub") |
||||
|
.WithAutomaticReconnect() |
||||
|
.Build(); |
||||
|
|
||||
|
var previousResultDog = -1; |
||||
|
var previousResultCat = -1; |
||||
|
connection.On<VotingResult[]>("votesRecieved", async (results) => |
||||
|
{ |
||||
|
//Reset votes because if there are zero votes there will be no entry from the query. |
||||
|
DogVotes = new VotingResult { Vote = "a", Count = 0 }; |
||||
|
CatVotes = new VotingResult { Vote = "b", Count = 0 }; |
||||
|
|
||||
|
foreach (var vote in results) |
||||
|
{ |
||||
|
if (vote.Vote == "a") |
||||
|
{ |
||||
|
DogVotes = vote; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
CatVotes = vote; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
if (previousResultDog == DogVotes.Count && previousResultCat == CatVotes.Count) |
||||
|
{ |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
previousResultDog = DogVotes.Count; |
||||
|
previousResultCat = CatVotes.Count; |
||||
|
|
||||
|
_config.Data.Datasets[0].Data.Clear(); |
||||
|
_config.Data.Datasets[0].Data.Add(DogVotes.Count); |
||||
|
_config.Data.Datasets[0].Data.Add(CatVotes.Count); |
||||
|
await _pieChartJs.Update(); |
||||
|
}); |
||||
|
|
||||
|
await connection.StartAsync(); |
||||
|
|
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
Console.WriteLine(ex.Message); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
void IDisposable.Dispose() |
||||
|
{ |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,51 @@ |
|||||
|
@page "/" |
||||
|
@namespace Results.Pages |
||||
|
@using Microsoft.Extensions.Hosting; |
||||
|
@inject IHostEnvironment env |
||||
|
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers |
||||
|
@{ |
||||
|
Layout = null; |
||||
|
} |
||||
|
|
||||
|
<!DOCTYPE html> |
||||
|
<html lang="en"> |
||||
|
<head> |
||||
|
@if(!env.IsDevelopment()) |
||||
|
{ |
||||
|
<base href="/results/" > |
||||
|
} |
||||
|
<meta charset="utf-8" /> |
||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
||||
|
<title>Results</title> |
||||
|
<base href="~/" /> |
||||
|
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" /> |
||||
|
<link href="css/site.css" rel="stylesheet" /> |
||||
|
<link rel="stylesheet" href="_content/ChartJs.Blazor/ChartJSBlazor.css" /> |
||||
|
</head> |
||||
|
<body> |
||||
|
<app> |
||||
|
<component type="typeof(App)" render-mode="ServerPrerendered" /> |
||||
|
</app> |
||||
|
|
||||
|
<div id="blazor-error-ui"> |
||||
|
<environment include="Staging,Production"> |
||||
|
An error has occurred. This application may no longer respond until reloaded. |
||||
|
</environment> |
||||
|
<environment include="Development"> |
||||
|
An unhandled exception has occurred. See browser dev tools for details. |
||||
|
</environment> |
||||
|
<a href="" class="reload">Reload</a> |
||||
|
<a class="dismiss">🗙</a> |
||||
|
</div> |
||||
|
|
||||
|
<script src="_framework/blazor.server.js"></script> |
||||
|
<!-- Reference the included moment.js javascript file. --> |
||||
|
<script src="_content/ChartJs.Blazor/moment-with-locales.min.js" type="text/javascript" language="javascript"></script> |
||||
|
|
||||
|
<!-- Reference the included ChartJs javascript file. --> |
||||
|
<script src="_content/ChartJs.Blazor/Chart.min.js" type="text/javascript" language="javascript"></script> |
||||
|
|
||||
|
<!-- This is the glue between the C# code and the ChartJs charts --> |
||||
|
<script src="_content/ChartJs.Blazor/ChartJsBlazorInterop.js" type="text/javascript" language="javascript"></script> |
||||
|
</body> |
||||
|
</html> |
||||
@ -0,0 +1,28 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.IO; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore; |
||||
|
using Microsoft.AspNetCore.Hosting; |
||||
|
using Microsoft.Extensions.Configuration; |
||||
|
using Microsoft.Extensions.Hosting; |
||||
|
using Microsoft.Extensions.Logging; |
||||
|
|
||||
|
namespace Results |
||||
|
{ |
||||
|
public class Program |
||||
|
{ |
||||
|
public static void Main(string[] args) |
||||
|
{ |
||||
|
CreateHostBuilder(args).Build().Run(); |
||||
|
} |
||||
|
|
||||
|
public static IHostBuilder CreateHostBuilder(string[] args) => |
||||
|
Host.CreateDefaultBuilder(args) |
||||
|
.ConfigureWebHostDefaults(webBuilder => |
||||
|
{ |
||||
|
webBuilder.UseStartup<Startup>(); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,27 @@ |
|||||
|
{ |
||||
|
"iisSettings": { |
||||
|
"windowsAuthentication": false, |
||||
|
"anonymousAuthentication": true, |
||||
|
"iisExpress": { |
||||
|
"applicationUrl": "http://localhost:41343", |
||||
|
"sslPort": 44346 |
||||
|
} |
||||
|
}, |
||||
|
"profiles": { |
||||
|
"IIS Express": { |
||||
|
"commandName": "IISExpress", |
||||
|
"launchBrowser": true, |
||||
|
"environmentVariables": { |
||||
|
"ASPNETCORE_ENVIRONMENT": "Development" |
||||
|
} |
||||
|
}, |
||||
|
"results": { |
||||
|
"commandName": "Project", |
||||
|
"launchBrowser": true, |
||||
|
"applicationUrl": "http://localhost:5005", |
||||
|
"environmentVariables": { |
||||
|
"ASPNETCORE_ENVIRONMENT": "Development" |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,7 @@ |
|||||
|
@inherits LayoutComponentBase |
||||
|
|
||||
|
<div class="main"> |
||||
|
<div class="content px-4"> |
||||
|
@Body |
||||
|
</div> |
||||
|
</div> |
||||
@ -0,0 +1,55 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Builder; |
||||
|
using Microsoft.AspNetCore.Components; |
||||
|
using Microsoft.AspNetCore.Hosting; |
||||
|
using Microsoft.AspNetCore.HttpsPolicy; |
||||
|
using Microsoft.Extensions.Configuration; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Microsoft.Extensions.Hosting; |
||||
|
|
||||
|
namespace Results |
||||
|
{ |
||||
|
public class Startup |
||||
|
{ |
||||
|
public Startup(IConfiguration configuration) |
||||
|
{ |
||||
|
Configuration = configuration; |
||||
|
} |
||||
|
|
||||
|
public IConfiguration Configuration { get; } |
||||
|
|
||||
|
// This method gets called by the runtime. Use this method to add services to the container.
|
||||
|
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
|
||||
|
public void ConfigureServices(IServiceCollection services) |
||||
|
{ |
||||
|
services.AddRazorPages(); |
||||
|
services.AddServerSideBlazor(); |
||||
|
} |
||||
|
|
||||
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) |
||||
|
{ |
||||
|
if (env.IsDevelopment()) |
||||
|
{ |
||||
|
app.UseDeveloperExceptionPage(); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
app.UseExceptionHandler("/Error"); |
||||
|
} |
||||
|
|
||||
|
app.UseStaticFiles(); |
||||
|
|
||||
|
app.UseRouting(); |
||||
|
|
||||
|
app.UseEndpoints(endpoints => |
||||
|
{ |
||||
|
endpoints.MapBlazorHub(); |
||||
|
endpoints.MapFallbackToPage("/_Host"); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,9 @@ |
|||||
|
@using System.Net.Http |
||||
|
@using Microsoft.AspNetCore.Authorization |
||||
|
@using Microsoft.AspNetCore.Components.Authorization |
||||
|
@using Microsoft.AspNetCore.Components.Forms |
||||
|
@using Microsoft.AspNetCore.Components.Routing |
||||
|
@using Microsoft.AspNetCore.Components.Web |
||||
|
@using Microsoft.JSInterop |
||||
|
@using Results |
||||
|
@using Results.Shared |
||||
@ -0,0 +1,10 @@ |
|||||
|
{ |
||||
|
"DetailedErrors": true, |
||||
|
"Logging": { |
||||
|
"LogLevel": { |
||||
|
"Default": "Information", |
||||
|
"Microsoft": "Warning", |
||||
|
"Microsoft.Hosting.Lifetime": "Information" |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,10 @@ |
|||||
|
{ |
||||
|
"Logging": { |
||||
|
"LogLevel": { |
||||
|
"Default": "Information", |
||||
|
"Microsoft": "Warning", |
||||
|
"Microsoft.Hosting.Lifetime": "Information" |
||||
|
} |
||||
|
}, |
||||
|
"AllowedHosts": "*" |
||||
|
} |
||||
@ -0,0 +1,19 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk.Web"> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFramework>netcoreapp3.1</TargetFramework> |
||||
|
<RootNamespace>Results</RootNamespace> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="ChartJs.Blazor" Version="1.0.3" /> |
||||
|
<PackageReference Include="dapper" Version="2.0.30" /> |
||||
|
<PackageReference Include="microsoft.aspnetcore.signalr.client" Version="3.1.3" /> |
||||
|
<PackageReference Include="npgsql" Version="4.1.3.1" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="$(TyeLibrariesPath)\Microsoft.Tye.Extensions.Configuration\Microsoft.Tye.Extensions.Configuration.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,86 @@ |
|||||
|
SIL OPEN FONT LICENSE Version 1.1 |
||||
|
|
||||
|
Copyright (c) 2014 Waybury |
||||
|
|
||||
|
PREAMBLE |
||||
|
The goals of the Open Font License (OFL) are to stimulate worldwide |
||||
|
development of collaborative font projects, to support the font creation |
||||
|
efforts of academic and linguistic communities, and to provide a free and |
||||
|
open framework in which fonts may be shared and improved in partnership |
||||
|
with others. |
||||
|
|
||||
|
The OFL allows the licensed fonts to be used, studied, modified and |
||||
|
redistributed freely as long as they are not sold by themselves. The |
||||
|
fonts, including any derivative works, can be bundled, embedded, |
||||
|
redistributed and/or sold with any software provided that any reserved |
||||
|
names are not used by derivative works. The fonts and derivatives, |
||||
|
however, cannot be released under any other type of license. The |
||||
|
requirement for fonts to remain under this license does not apply |
||||
|
to any document created using the fonts or their derivatives. |
||||
|
|
||||
|
DEFINITIONS |
||||
|
"Font Software" refers to the set of files released by the Copyright |
||||
|
Holder(s) under this license and clearly marked as such. This may |
||||
|
include source files, build scripts and documentation. |
||||
|
|
||||
|
"Reserved Font Name" refers to any names specified as such after the |
||||
|
copyright statement(s). |
||||
|
|
||||
|
"Original Version" refers to the collection of Font Software components as |
||||
|
distributed by the Copyright Holder(s). |
||||
|
|
||||
|
"Modified Version" refers to any derivative made by adding to, deleting, |
||||
|
or substituting -- in part or in whole -- any of the components of the |
||||
|
Original Version, by changing formats or by porting the Font Software to a |
||||
|
new environment. |
||||
|
|
||||
|
"Author" refers to any designer, engineer, programmer, technical |
||||
|
writer or other person who contributed to the Font Software. |
||||
|
|
||||
|
PERMISSION & CONDITIONS |
||||
|
Permission is hereby granted, free of charge, to any person obtaining |
||||
|
a copy of the Font Software, to use, study, copy, merge, embed, modify, |
||||
|
redistribute, and sell modified and unmodified copies of the Font |
||||
|
Software, subject to the following conditions: |
||||
|
|
||||
|
1) Neither the Font Software nor any of its individual components, |
||||
|
in Original or Modified Versions, may be sold by itself. |
||||
|
|
||||
|
2) Original or Modified Versions of the Font Software may be bundled, |
||||
|
redistributed and/or sold with any software, provided that each copy |
||||
|
contains the above copyright notice and this license. These can be |
||||
|
included either as stand-alone text files, human-readable headers or |
||||
|
in the appropriate machine-readable metadata fields within text or |
||||
|
binary files as long as those fields can be easily viewed by the user. |
||||
|
|
||||
|
3) No Modified Version of the Font Software may use the Reserved Font |
||||
|
Name(s) unless explicit written permission is granted by the corresponding |
||||
|
Copyright Holder. This restriction only applies to the primary font name as |
||||
|
presented to the users. |
||||
|
|
||||
|
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font |
||||
|
Software shall not be used to promote, endorse or advertise any |
||||
|
Modified Version, except to acknowledge the contribution(s) of the |
||||
|
Copyright Holder(s) and the Author(s) or with their explicit written |
||||
|
permission. |
||||
|
|
||||
|
5) The Font Software, modified or unmodified, in part or in whole, |
||||
|
must be distributed entirely under this license, and must not be |
||||
|
distributed under any other license. The requirement for fonts to |
||||
|
remain under this license does not apply to any document created |
||||
|
using the Font Software. |
||||
|
|
||||
|
TERMINATION |
||||
|
This license becomes null and void if any of the above conditions are |
||||
|
not met. |
||||
|
|
||||
|
DISCLAIMER |
||||
|
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF |
||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT |
||||
|
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE |
||||
|
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
||||
|
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL |
||||
|
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
||||
|
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM |
||||
|
OTHER DEALINGS IN THE FONT SOFTWARE. |
||||
@ -0,0 +1,21 @@ |
|||||
|
The MIT License (MIT) |
||||
|
|
||||
|
Copyright (c) 2014 Waybury |
||||
|
|
||||
|
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. |
||||
@ -0,0 +1,114 @@ |
|||||
|
[Open Iconic v1.1.1](http://useiconic.com/open) |
||||
|
=========== |
||||
|
|
||||
|
### Open Iconic is the open source sibling of [Iconic](http://useiconic.com). It is a hyper-legible collection of 223 icons with a tiny footprint—ready to use with Bootstrap and Foundation. [View the collection](http://useiconic.com/open#icons) |
||||
|
|
||||
|
|
||||
|
|
||||
|
## What's in Open Iconic? |
||||
|
|
||||
|
* 223 icons designed to be legible down to 8 pixels |
||||
|
* Super-light SVG files - 61.8 for the entire set |
||||
|
* SVG sprite—the modern replacement for icon fonts |
||||
|
* Webfont (EOT, OTF, SVG, TTF, WOFF), PNG and WebP formats |
||||
|
* Webfont stylesheets (including versions for Bootstrap and Foundation) in CSS, LESS, SCSS and Stylus formats |
||||
|
* PNG and WebP raster images in 8px, 16px, 24px, 32px, 48px and 64px. |
||||
|
|
||||
|
|
||||
|
## Getting Started |
||||
|
|
||||
|
#### For code samples and everything else you need to get started with Open Iconic, check out our [Icons](http://useiconic.com/open#icons) and [Reference](http://useiconic.com/open#reference) sections. |
||||
|
|
||||
|
### General Usage |
||||
|
|
||||
|
#### Using Open Iconic's SVGs |
||||
|
|
||||
|
We like SVGs and we think they're the way to display icons on the web. Since Open Iconic are just basic SVGs, we suggest you display them like you would any other image (don't forget the `alt` attribute). |
||||
|
|
||||
|
``` |
||||
|
<img src="/open-iconic/svg/icon-name.svg" alt="icon name"> |
||||
|
``` |
||||
|
|
||||
|
#### Using Open Iconic's SVG Sprite |
||||
|
|
||||
|
Open Iconic also comes in a SVG sprite which allows you to display all the icons in the set with a single request. It's like an icon font, without being a hack. |
||||
|
|
||||
|
Adding an icon from an SVG sprite is a little different than what you're used to, but it's still a piece of cake. *Tip: To make your icons easily style able, we suggest adding a general class to the* `<svg>` *tag and a unique class name for each different icon in the* `<use>` *tag.* |
||||
|
|
||||
|
``` |
||||
|
<svg class="icon"> |
||||
|
<use xlink:href="open-iconic.svg#account-login" class="icon-account-login"></use> |
||||
|
</svg> |
||||
|
``` |
||||
|
|
||||
|
Sizing icons only needs basic CSS. All the icons are in a square format, so just set the `<svg>` tag with equal width and height dimensions. |
||||
|
|
||||
|
``` |
||||
|
.icon { |
||||
|
width: 16px; |
||||
|
height: 16px; |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
Coloring icons is even easier. All you need to do is set the `fill` rule on the `<use>` tag. |
||||
|
|
||||
|
``` |
||||
|
.icon-account-login { |
||||
|
fill: #f00; |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
To learn more about SVG Sprites, read [Chris Coyier's guide](http://css-tricks.com/svg-sprites-use-better-icon-fonts/). |
||||
|
|
||||
|
#### Using Open Iconic's Icon Font... |
||||
|
|
||||
|
|
||||
|
##### …with Bootstrap |
||||
|
|
||||
|
You can find our Bootstrap stylesheets in `font/css/open-iconic-bootstrap.{css, less, scss, styl}` |
||||
|
|
||||
|
|
||||
|
``` |
||||
|
<link href="/open-iconic/font/css/open-iconic-bootstrap.css" rel="stylesheet"> |
||||
|
``` |
||||
|
|
||||
|
|
||||
|
``` |
||||
|
<span class="oi oi-icon-name" title="icon name" aria-hidden="true"></span> |
||||
|
``` |
||||
|
|
||||
|
##### …with Foundation |
||||
|
|
||||
|
You can find our Foundation stylesheets in `font/css/open-iconic-foundation.{css, less, scss, styl}` |
||||
|
|
||||
|
``` |
||||
|
<link href="/open-iconic/font/css/open-iconic-foundation.css" rel="stylesheet"> |
||||
|
``` |
||||
|
|
||||
|
|
||||
|
``` |
||||
|
<span class="fi-icon-name" title="icon name" aria-hidden="true"></span> |
||||
|
``` |
||||
|
|
||||
|
##### …on its own |
||||
|
|
||||
|
You can find our default stylesheets in `font/css/open-iconic.{css, less, scss, styl}` |
||||
|
|
||||
|
``` |
||||
|
<link href="/open-iconic/font/css/open-iconic.css" rel="stylesheet"> |
||||
|
``` |
||||
|
|
||||
|
``` |
||||
|
<span class="oi" data-glyph="icon-name" title="icon name" aria-hidden="true"></span> |
||||
|
``` |
||||
|
|
||||
|
|
||||
|
## License |
||||
|
|
||||
|
### Icons |
||||
|
|
||||
|
All code (including SVG markup) is under the [MIT License](http://opensource.org/licenses/MIT). |
||||
|
|
||||
|
### Fonts |
||||
|
|
||||
|
All fonts are under the [SIL Licensed](http://scripts.sil.org/cms/scripts/page.php?item_id=OFL_web). |
||||
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 54 KiB |
Binary file not shown.
Binary file not shown.
@ -0,0 +1,183 @@ |
|||||
|
@import url('open-iconic/font/css/open-iconic-bootstrap.min.css'); |
||||
|
|
||||
|
html, body { |
||||
|
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; |
||||
|
} |
||||
|
|
||||
|
a, .btn-link { |
||||
|
color: #0366d6; |
||||
|
} |
||||
|
|
||||
|
.btn-primary { |
||||
|
color: #fff; |
||||
|
background-color: #1b6ec2; |
||||
|
border-color: #1861ac; |
||||
|
} |
||||
|
|
||||
|
app { |
||||
|
position: relative; |
||||
|
display: flex; |
||||
|
flex-direction: column; |
||||
|
} |
||||
|
|
||||
|
.top-row { |
||||
|
height: 3.5rem; |
||||
|
display: flex; |
||||
|
align-items: center; |
||||
|
} |
||||
|
|
||||
|
.main { |
||||
|
flex: 1; |
||||
|
} |
||||
|
|
||||
|
.main .top-row { |
||||
|
background-color: #f7f7f7; |
||||
|
border-bottom: 1px solid #d6d5d5; |
||||
|
justify-content: flex-end; |
||||
|
} |
||||
|
|
||||
|
.main .top-row > a, .main .top-row .btn-link { |
||||
|
white-space: nowrap; |
||||
|
margin-left: 1.5rem; |
||||
|
} |
||||
|
|
||||
|
.main .top-row a:first-child { |
||||
|
overflow: hidden; |
||||
|
text-overflow: ellipsis; |
||||
|
} |
||||
|
|
||||
|
.sidebar { |
||||
|
background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%); |
||||
|
} |
||||
|
|
||||
|
.sidebar .top-row { |
||||
|
background-color: rgba(0,0,0,0.4); |
||||
|
} |
||||
|
|
||||
|
.sidebar .navbar-brand { |
||||
|
font-size: 1.1rem; |
||||
|
} |
||||
|
|
||||
|
.sidebar .oi { |
||||
|
width: 2rem; |
||||
|
font-size: 1.1rem; |
||||
|
vertical-align: text-top; |
||||
|
top: -2px; |
||||
|
} |
||||
|
|
||||
|
.sidebar .nav-item { |
||||
|
font-size: 0.9rem; |
||||
|
padding-bottom: 0.5rem; |
||||
|
} |
||||
|
|
||||
|
.sidebar .nav-item:first-of-type { |
||||
|
padding-top: 1rem; |
||||
|
} |
||||
|
|
||||
|
.sidebar .nav-item:last-of-type { |
||||
|
padding-bottom: 1rem; |
||||
|
} |
||||
|
|
||||
|
.sidebar .nav-item a { |
||||
|
color: #d7d7d7; |
||||
|
border-radius: 4px; |
||||
|
height: 3rem; |
||||
|
display: flex; |
||||
|
align-items: center; |
||||
|
line-height: 3rem; |
||||
|
} |
||||
|
|
||||
|
.sidebar .nav-item a.active { |
||||
|
background-color: rgba(255,255,255,0.25); |
||||
|
color: white; |
||||
|
} |
||||
|
|
||||
|
.sidebar .nav-item a:hover { |
||||
|
background-color: rgba(255,255,255,0.1); |
||||
|
color: white; |
||||
|
} |
||||
|
|
||||
|
.content { |
||||
|
padding-top: 1.1rem; |
||||
|
} |
||||
|
|
||||
|
.navbar-toggler { |
||||
|
background-color: rgba(255, 255, 255, 0.1); |
||||
|
} |
||||
|
|
||||
|
.valid.modified:not([type=checkbox]) { |
||||
|
outline: 1px solid #26b050; |
||||
|
} |
||||
|
|
||||
|
.invalid { |
||||
|
outline: 1px solid red; |
||||
|
} |
||||
|
|
||||
|
.validation-message { |
||||
|
color: red; |
||||
|
} |
||||
|
|
||||
|
#blazor-error-ui { |
||||
|
background: lightyellow; |
||||
|
bottom: 0; |
||||
|
box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); |
||||
|
display: none; |
||||
|
left: 0; |
||||
|
padding: 0.6rem 1.25rem 0.7rem 1.25rem; |
||||
|
position: fixed; |
||||
|
width: 100%; |
||||
|
z-index: 1000; |
||||
|
} |
||||
|
|
||||
|
#blazor-error-ui .dismiss { |
||||
|
cursor: pointer; |
||||
|
position: absolute; |
||||
|
right: 0.75rem; |
||||
|
top: 0.5rem; |
||||
|
} |
||||
|
|
||||
|
@media (max-width: 767.98px) { |
||||
|
.main .top-row:not(.auth) { |
||||
|
display: none; |
||||
|
} |
||||
|
|
||||
|
.main .top-row.auth { |
||||
|
justify-content: space-between; |
||||
|
} |
||||
|
|
||||
|
.main .top-row a, .main .top-row .btn-link { |
||||
|
margin-left: 0; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@media (min-width: 768px) { |
||||
|
app { |
||||
|
flex-direction: row; |
||||
|
} |
||||
|
|
||||
|
.sidebar { |
||||
|
width: 250px; |
||||
|
height: 100vh; |
||||
|
position: sticky; |
||||
|
top: 0; |
||||
|
} |
||||
|
|
||||
|
.main .top-row { |
||||
|
position: sticky; |
||||
|
top: 0; |
||||
|
} |
||||
|
|
||||
|
.main > div { |
||||
|
padding-left: 2rem !important; |
||||
|
padding-right: 1.5rem !important; |
||||
|
} |
||||
|
|
||||
|
.navbar-toggler { |
||||
|
display: none; |
||||
|
} |
||||
|
|
||||
|
.sidebar .collapse { |
||||
|
/* Never collapse the sidebar for wide screens */ |
||||
|
display: block; |
||||
|
} |
||||
|
} |
||||
|
After Width: | Height: | Size: 31 KiB |
@ -0,0 +1,60 @@ |
|||||
|
@page |
||||
|
@model IndexModel |
||||
|
@using Microsoft.Extensions.Hosting; |
||||
|
@inject IHostEnvironment env |
||||
|
|
||||
|
<!DOCTYPE html> |
||||
|
<html lang="en"> |
||||
|
<head> |
||||
|
@if(!env.IsDevelopment()) |
||||
|
{ |
||||
|
<base href="/vote/" > |
||||
|
} |
||||
|
<meta charset="utf-8" /> |
||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
||||
|
<title>@Model.Configuration["OptionA"] vs @Model.Configuration["OptionB"]</title> |
||||
|
<link rel="stylesheet" href="site.css" /> |
||||
|
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css"> |
||||
|
</head> |
||||
|
<body> |
||||
|
<header> |
||||
|
</header> |
||||
|
|
||||
|
<div id="content-container"> |
||||
|
<div id="content-container-center"> |
||||
|
<h3>@Model.Configuration["OptionA"] vs @Model.Configuration["OptionB"]!</h3> |
||||
|
<form id="choice" name='form' method="POST"> |
||||
|
<button id="a" type="submit" name="vote" class="a" value="a" disabled=@(Model.Vote == "a" ? "disabled" : null) style=@(Model.Vote == "a" ? "opacity:0.5;" : null)> |
||||
|
@if (Model.Vote == "a") |
||||
|
{ |
||||
|
<i class="fa fa-check-circle"></i> |
||||
|
} |
||||
|
@Model.Configuration["OptionA"] |
||||
|
</button> |
||||
|
<button id="b" type="submit" name="vote" class="b" value="b" disabled=@(Model.Vote == "b" ? "disabled" : null) style=@(Model.Vote == "b" ? "opacity:0.5;" : null)> |
||||
|
@if (Model.Vote == "b") |
||||
|
{ |
||||
|
<i class="fa fa-check-circle"></i> |
||||
|
} |
||||
|
@Model.Configuration["OptionB"] |
||||
|
</button> |
||||
|
</form> |
||||
|
<div id="tip"> |
||||
|
(Tip: you can change your vote) |
||||
|
</div> |
||||
|
<div id="hostname"> |
||||
|
Processed by container ID @Environment.MachineName |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
<footer class="footer"> |
||||
|
<div class="container-content-center"> |
||||
|
<span class="text-nowrap"> |
||||
|
Like Tye? Please take our <a target="_blank" class="font-weight-bold" href="https://aka.ms/AA7q20u">brief survey</a> and tell us what you think. |
||||
|
</span> |
||||
|
</div> |
||||
|
</footer> |
||||
|
|
||||
|
</body> |
||||
|
</html> |
||||
@ -0,0 +1,51 @@ |
|||||
|
using System; |
||||
|
using System.Text.Json; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Microsoft.AspNetCore.Mvc.RazorPages; |
||||
|
using Microsoft.Extensions.Configuration; |
||||
|
using Microsoft.Extensions.Logging; |
||||
|
using StackExchange.Redis; |
||||
|
|
||||
|
namespace Vote.Pages |
||||
|
{ |
||||
|
public class IndexModel : PageModel |
||||
|
{ |
||||
|
private readonly ILogger<IndexModel> _logger; |
||||
|
private IConnectionMultiplexer _redisConnection; |
||||
|
public IConfiguration Configuration { get; set; } |
||||
|
|
||||
|
[BindProperty()] |
||||
|
public string Vote {get;set;} |
||||
|
|
||||
|
public IndexModel(ILogger<IndexModel> logger, IConfiguration configuration, IConnectionMultiplexer redisConnection) |
||||
|
{ |
||||
|
_logger = logger; |
||||
|
Configuration = configuration; |
||||
|
_redisConnection = redisConnection; |
||||
|
} |
||||
|
|
||||
|
public async Task OnPost() |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
var voterId = TempData.Peek("VoterId"); |
||||
|
if (voterId == null) |
||||
|
{ |
||||
|
voterId = Guid.NewGuid(); |
||||
|
TempData["VoterId"] = voterId; |
||||
|
} |
||||
|
|
||||
|
var data = JsonSerializer.Serialize(new { voterId = voterId, vote = Vote }); |
||||
|
|
||||
|
var database = _redisConnection.GetDatabase(); |
||||
|
_logger.LogInformation($"pushing {data}"); |
||||
|
await database.ListRightPushAsync("votes", data); |
||||
|
} |
||||
|
catch(Exception ex) |
||||
|
{ |
||||
|
_logger.LogError(ex, "Error submitting vote."); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,4 @@ |
|||||
|
@using Vote |
||||
|
@using Microsoft.Extensions.Configuration |
||||
|
@namespace Vote.Pages |
||||
|
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers |
||||
@ -0,0 +1,34 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.IO; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Hosting; |
||||
|
using Microsoft.Extensions.Configuration; |
||||
|
using Microsoft.Extensions.Hosting; |
||||
|
using Microsoft.Extensions.Logging; |
||||
|
|
||||
|
namespace Vote |
||||
|
{ |
||||
|
public class Program |
||||
|
{ |
||||
|
public static void Main(string[] args) |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
CreateHostBuilder(args).Build().Run(); |
||||
|
} |
||||
|
catch (Exception x) |
||||
|
{ |
||||
|
Console.WriteLine(x.Message); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public static IHostBuilder CreateHostBuilder(string[] args) => |
||||
|
Host.CreateDefaultBuilder(args) |
||||
|
.ConfigureWebHostDefaults(webBuilder => |
||||
|
{ |
||||
|
webBuilder.UseStartup<Startup>(); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,27 @@ |
|||||
|
{ |
||||
|
"iisSettings": { |
||||
|
"windowsAuthentication": false, |
||||
|
"anonymousAuthentication": true, |
||||
|
"iisExpress": { |
||||
|
"applicationUrl": "http://localhost:14422", |
||||
|
"sslPort": 44382 |
||||
|
} |
||||
|
}, |
||||
|
"profiles": { |
||||
|
"IIS Express": { |
||||
|
"commandName": "IISExpress", |
||||
|
"launchBrowser": true, |
||||
|
"environmentVariables": { |
||||
|
"ASPNETCORE_ENVIRONMENT": "Development" |
||||
|
} |
||||
|
}, |
||||
|
"vote": { |
||||
|
"commandName": "Project", |
||||
|
"launchBrowser": true, |
||||
|
"applicationUrl": "https://localhost:5006;http://localhost:5007", |
||||
|
"environmentVariables": { |
||||
|
"ASPNETCORE_ENVIRONMENT": "Development" |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,53 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Builder; |
||||
|
using Microsoft.AspNetCore.Hosting; |
||||
|
using Microsoft.AspNetCore.HttpsPolicy; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Microsoft.Extensions.Configuration; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Microsoft.Extensions.Hosting; |
||||
|
using StackExchange.Redis; |
||||
|
|
||||
|
namespace Vote |
||||
|
{ |
||||
|
public class Startup |
||||
|
{ |
||||
|
public Startup(IConfiguration configuration) |
||||
|
{ |
||||
|
Configuration = configuration; |
||||
|
} |
||||
|
|
||||
|
public IConfiguration Configuration { get; } |
||||
|
|
||||
|
// This method gets called by the runtime. Use this method to add services to the container.
|
||||
|
public void ConfigureServices(IServiceCollection services) |
||||
|
{ |
||||
|
var connectionString = Configuration.GetConnectionString("redis"); |
||||
|
services.AddRazorPages(); |
||||
|
services.AddSingleton<IConnectionMultiplexer>(ConnectionMultiplexer.Connect(connectionString)); |
||||
|
} |
||||
|
|
||||
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) |
||||
|
{ |
||||
|
if (env.IsDevelopment()) |
||||
|
{ |
||||
|
app.UseDeveloperExceptionPage(); |
||||
|
} |
||||
|
|
||||
|
app.UseStaticFiles(); |
||||
|
|
||||
|
app.UseRouting(); |
||||
|
|
||||
|
app.UseAuthorization(); |
||||
|
|
||||
|
app.UseEndpoints(endpoints => |
||||
|
{ |
||||
|
endpoints.MapRazorPages(); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,9 @@ |
|||||
|
{ |
||||
|
"Logging": { |
||||
|
"LogLevel": { |
||||
|
"Default": "Information", |
||||
|
"Microsoft": "Information", |
||||
|
"Microsoft.Hosting.Lifetime": "Information" |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,12 @@ |
|||||
|
{ |
||||
|
"Logging": { |
||||
|
"LogLevel": { |
||||
|
"Default": "Information", |
||||
|
"Microsoft": "Information", |
||||
|
"Microsoft.Hosting.Lifetime": "Information" |
||||
|
} |
||||
|
}, |
||||
|
"AllowedHosts": "*", |
||||
|
"OptionA": "Dogs", |
||||
|
"OptionB": "Cats" |
||||
|
} |
||||
@ -0,0 +1,16 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk.Web"> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFramework>netcoreapp3.1</TargetFramework> |
||||
|
<RootNamespace>Vote</RootNamespace> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="$(TyeLibrariesPath)\Microsoft.Tye.Extensions.Configuration\Microsoft.Tye.Extensions.Configuration.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Stackexchange.Redis" Version="2.0.601" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
|
After Width: | Height: | Size: 31 KiB |
@ -0,0 +1,129 @@ |
|||||
|
@import url(//fonts.googleapis.com/css?family=Open+Sans:400,700,600); |
||||
|
|
||||
|
*{ |
||||
|
box-sizing:border-box; |
||||
|
} |
||||
|
html,body{ |
||||
|
margin: 0; |
||||
|
padding: 0; |
||||
|
background-color: #F7F8F9; |
||||
|
height: 100vh; |
||||
|
font-family: 'Open Sans'; |
||||
|
} |
||||
|
|
||||
|
button{ |
||||
|
border-radius: 0; |
||||
|
width: 100%; |
||||
|
height: 50%; |
||||
|
} |
||||
|
|
||||
|
button[type="submit"] { |
||||
|
-webkit-appearance:none; -webkit-border-radius:0; |
||||
|
} |
||||
|
|
||||
|
button i{ |
||||
|
float: right; |
||||
|
padding-right: 30px; |
||||
|
margin-top: 3px; |
||||
|
} |
||||
|
|
||||
|
button.a{ |
||||
|
background-color: #1aaaf8; |
||||
|
} |
||||
|
|
||||
|
button.b{ |
||||
|
background-color: #00cbca; |
||||
|
} |
||||
|
|
||||
|
#tip{ |
||||
|
text-align: left; |
||||
|
color: #c0c9ce; |
||||
|
font-size: 14px; |
||||
|
} |
||||
|
|
||||
|
#hostname{ |
||||
|
position: absolute; |
||||
|
bottom: 100px; |
||||
|
right: 0; |
||||
|
left: 0; |
||||
|
color: #8f9ea8; |
||||
|
font-size: 24px; |
||||
|
} |
||||
|
|
||||
|
#content-container{ |
||||
|
z-index: 2; |
||||
|
position: relative; |
||||
|
margin: 0 auto; |
||||
|
display: table; |
||||
|
padding: 10px; |
||||
|
max-width: 940px; |
||||
|
height: 100%; |
||||
|
} |
||||
|
#content-container-center{ |
||||
|
display: table-cell; |
||||
|
text-align: center; |
||||
|
} |
||||
|
|
||||
|
#content-container-center h3{ |
||||
|
color: #254356; |
||||
|
} |
||||
|
|
||||
|
#choice{ |
||||
|
transition: all 300ms linear; |
||||
|
line-height: 1.3em; |
||||
|
display: inline; |
||||
|
vertical-align: middle; |
||||
|
font-size: 3em; |
||||
|
} |
||||
|
#choice a{ |
||||
|
text-decoration:none; |
||||
|
} |
||||
|
#choice a:hover, #choice a:focus{ |
||||
|
outline:0; |
||||
|
text-decoration:underline; |
||||
|
} |
||||
|
|
||||
|
#choice button{ |
||||
|
display: block; |
||||
|
height: 80px; |
||||
|
width: 330px; |
||||
|
border: none; |
||||
|
color: white; |
||||
|
text-transform: uppercase; |
||||
|
font-size:18px; |
||||
|
font-weight: 700; |
||||
|
margin-top: 10px; |
||||
|
margin-bottom: 10px; |
||||
|
text-align: left; |
||||
|
padding-left: 50px; |
||||
|
} |
||||
|
|
||||
|
#choice button.a:hover{ |
||||
|
background-color: #1488c6; |
||||
|
} |
||||
|
|
||||
|
#choice button.b:hover{ |
||||
|
background-color: #00a2a1; |
||||
|
} |
||||
|
|
||||
|
#choice button.a:focus{ |
||||
|
background-color: #1488c6; |
||||
|
} |
||||
|
|
||||
|
#choice button.b:focus{ |
||||
|
background-color: #00a2a1; |
||||
|
} |
||||
|
|
||||
|
#background-stats{ |
||||
|
z-index:1; |
||||
|
height:100%; |
||||
|
width:100%; |
||||
|
position:absolute; |
||||
|
} |
||||
|
#background-stats div{ |
||||
|
transition: width 400ms ease-in-out; |
||||
|
display:inline-block; |
||||
|
margin-bottom:-4px; |
||||
|
width:50%; |
||||
|
height:100%; |
||||
|
} |
||||
@ -0,0 +1,26 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Microsoft.Extensions.Hosting; |
||||
|
using Microsoft.Extensions.Configuration; |
||||
|
using Microsoft.AspNetCore.Hosting; |
||||
|
|
||||
|
namespace Worker |
||||
|
{ |
||||
|
public class Program |
||||
|
{ |
||||
|
public static void Main(string[] args) |
||||
|
{ |
||||
|
CreateHostBuilder(args).Build().Run(); |
||||
|
} |
||||
|
|
||||
|
public static IHostBuilder CreateHostBuilder(string[] args) => |
||||
|
Host.CreateDefaultBuilder(args) |
||||
|
.ConfigureWebHostDefaults(webBuilder => |
||||
|
{ |
||||
|
webBuilder.UseStartup<Startup>(); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,10 @@ |
|||||
|
{ |
||||
|
"profiles": { |
||||
|
"worker": { |
||||
|
"commandName": "Project", |
||||
|
"environmentVariables": { |
||||
|
"DOTNET_ENVIRONMENT": "Development" |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,33 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Dapper; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Microsoft.Extensions.Configuration; |
||||
|
using Npgsql; |
||||
|
|
||||
|
namespace Worker |
||||
|
{ |
||||
|
[ApiController] |
||||
|
public class ResultsController : ControllerBase |
||||
|
{ |
||||
|
private IConfiguration _configuration; |
||||
|
|
||||
|
public ResultsController(IConfiguration configuration) |
||||
|
{ |
||||
|
_configuration = configuration; |
||||
|
} |
||||
|
|
||||
|
[HttpGet("/results")] |
||||
|
public async Task<IEnumerable<VoteCount>> Get() |
||||
|
{ |
||||
|
using (var connection = new NpgsqlConnection(_configuration.GetConnectionString("postgres"))) |
||||
|
{ |
||||
|
connection.Open(); |
||||
|
|
||||
|
return await connection.QueryAsync<VoteCount>("SELECT Vote, COUNT(Id) AS Count FROM votes GROUP BY Vote ORDER BY Vote"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
using Microsoft.AspNetCore.SignalR; |
||||
|
|
||||
|
namespace Worker |
||||
|
{ |
||||
|
public class ResultsHub : Hub |
||||
|
{ |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,48 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Builder; |
||||
|
using Microsoft.AspNetCore.Hosting; |
||||
|
using Microsoft.Extensions.Configuration; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Microsoft.Extensions.Hosting; |
||||
|
|
||||
|
namespace Worker |
||||
|
{ |
||||
|
public class Startup |
||||
|
{ |
||||
|
public Startup(IConfiguration configuration) |
||||
|
{ |
||||
|
Configuration = configuration; |
||||
|
} |
||||
|
|
||||
|
public IConfiguration Configuration { get; } |
||||
|
|
||||
|
// This method gets called by the runtime. Use this method to add services to the container.
|
||||
|
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
|
||||
|
public void ConfigureServices(IServiceCollection services) |
||||
|
{ |
||||
|
services.AddSignalR(); |
||||
|
services.AddControllers(); |
||||
|
services.AddHostedService<Worker>(); |
||||
|
} |
||||
|
|
||||
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) |
||||
|
{ |
||||
|
if (env.IsDevelopment()) |
||||
|
{ |
||||
|
app.UseDeveloperExceptionPage(); |
||||
|
} |
||||
|
|
||||
|
app.UseRouting(); |
||||
|
|
||||
|
app.UseEndpoints(endpoints => |
||||
|
{ |
||||
|
endpoints.MapHub<ResultsHub>("/resultsHub"); |
||||
|
endpoints.MapControllers(); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,13 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace Worker |
||||
|
{ |
||||
|
public class VoteCount |
||||
|
{ |
||||
|
public string Vote { get; set; } |
||||
|
public int Count { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,104 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Data; |
||||
|
using System.Linq; |
||||
|
using System.Threading; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.Extensions.Configuration; |
||||
|
using Microsoft.Extensions.Hosting; |
||||
|
using Microsoft.Extensions.Logging; |
||||
|
using StackExchange.Redis; |
||||
|
using Dapper; |
||||
|
using System.Text.Json; |
||||
|
using Npgsql; |
||||
|
using Microsoft.AspNetCore.SignalR; |
||||
|
|
||||
|
namespace Worker |
||||
|
{ |
||||
|
public class Worker : BackgroundService |
||||
|
{ |
||||
|
private readonly ILogger<Worker> _logger; |
||||
|
private readonly IConfiguration _configuration; |
||||
|
private readonly IHubContext<ResultsHub> _hubContext; |
||||
|
|
||||
|
public Worker(ILogger<Worker> logger, IConfiguration configuration, IHubContext<ResultsHub> hubContext) |
||||
|
{ |
||||
|
_logger = logger; |
||||
|
_configuration = configuration; |
||||
|
_hubContext = hubContext; |
||||
|
} |
||||
|
|
||||
|
protected override async Task ExecuteAsync(CancellationToken stoppingToken) |
||||
|
{ |
||||
|
_logger.LogInformation("Worker started running at: {time}", DateTimeOffset.Now); |
||||
|
|
||||
|
try |
||||
|
{ |
||||
|
using (var connection = new NpgsqlConnection(_configuration.GetConnectionString("postgres"))) |
||||
|
using (var redisConnection = ConnectionMultiplexer.Connect(_configuration.GetConnectionString("redis"))) |
||||
|
{ |
||||
|
await Task.Delay(1000); |
||||
|
|
||||
|
connection.Open(); |
||||
|
var redis = redisConnection.GetDatabase(); |
||||
|
|
||||
|
await CreateTable(connection); |
||||
|
|
||||
|
while (!stoppingToken.IsCancellationRequested) |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
var data = await redis.ListRightPopAsync("votes"); |
||||
|
|
||||
|
if (data.HasValue) |
||||
|
{ |
||||
|
var vote = JsonSerializer.Deserialize<Vote>(data); |
||||
|
|
||||
|
_logger.LogInformation($"Got new vote from redis {vote.vote} {vote.voterId}"); |
||||
|
|
||||
|
var command = @"INSERT INTO votes (Id, Vote) VALUES (@voterId, @vote)
|
||||
|
ON CONFLICT (Id) |
||||
|
DO UPDATE SET Vote = @vote";
|
||||
|
|
||||
|
await connection.ExecuteAsync(command, vote); |
||||
|
|
||||
|
var newResults = await connection.QueryAsync<VoteCount>("SELECT Vote, COUNT(Id) AS Count FROM votes GROUP BY Vote ORDER BY Vote"); |
||||
|
|
||||
|
_logger.LogInformation("Wrote results to postgres, calling other clients with updated results."); |
||||
|
await _hubContext.Clients.All.SendAsync("votesRecieved", newResults); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
var newResults = await connection.QueryAsync<VoteCount>("SELECT Vote, COUNT(Id) AS Count FROM votes GROUP BY Vote ORDER BY Vote"); |
||||
|
await _hubContext.Clients.All.SendAsync("votesRecieved", newResults); |
||||
|
} |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
_logger.LogError(ex, "error processing vote."); |
||||
|
} |
||||
|
|
||||
|
await Task.Delay(100, stoppingToken); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
catch(Exception ex) |
||||
|
{ |
||||
|
_logger.LogError(ex, "Exception starting worker"); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private class Vote |
||||
|
{ |
||||
|
public Guid voterId { get; set; } |
||||
|
public string vote { get; set; } |
||||
|
} |
||||
|
|
||||
|
private async Task CreateTable(IDbConnection connection) |
||||
|
{ |
||||
|
await connection.ExecuteAsync(@"CREATE TABLE IF NOT EXISTS votes (
|
||||
|
Id VARCHAR(255) NOT NULL UNIQUE, |
||||
|
Vote VARCHAR(255) NOT NULL);");
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,9 @@ |
|||||
|
{ |
||||
|
"Logging": { |
||||
|
"LogLevel": { |
||||
|
"Default": "Information", |
||||
|
"Microsoft": "Warning", |
||||
|
"Microsoft.Hosting.Lifetime": "Information" |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,9 @@ |
|||||
|
{ |
||||
|
"Logging": { |
||||
|
"LogLevel": { |
||||
|
"Default": "Information", |
||||
|
"Microsoft": "Warning", |
||||
|
"Microsoft.Hosting.Lifetime": "Information" |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,18 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk.Web"> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFramework>netcoreapp3.1</TargetFramework> |
||||
|
<UserSecretsId>dotnet-worker-A47A7C4B-4BF2-4243-9BBE-E6B3CB3E9C6F</UserSecretsId> |
||||
|
<RootNamespace>Worker</RootNamespace> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="$(TyeLibrariesPath)\Microsoft.Tye.Extensions.Configuration\Microsoft.Tye.Extensions.Configuration.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="dapper" Version="2.0.30" /> |
||||
|
<PackageReference Include="npgsql" Version="4.1.3.1" /> |
||||
|
<PackageReference Include="StackExchange.Redis" Version="2.0.601" /> |
||||
|
</ItemGroup> |
||||
|
</Project> |
||||
@ -0,0 +1,454 @@ |
|||||
|
// Licensed to the .NET Foundation under one or more agreements.
|
||||
|
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
// See the LICENSE file in the project root for more information.
|
||||
|
|
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.IO; |
||||
|
using Microsoft.Tye.ConfigModel; |
||||
|
using Tye.Serialization; |
||||
|
using YamlDotNet.Core; |
||||
|
using YamlDotNet.RepresentationModel; |
||||
|
|
||||
|
namespace Tye.DockerCompose |
||||
|
{ |
||||
|
public class DockerComposeParser : IDisposable |
||||
|
{ |
||||
|
private YamlStream _yamlStream; |
||||
|
private FileInfo? _fileInfo; |
||||
|
private TextReader _reader; |
||||
|
|
||||
|
public DockerComposeParser(string yamlContent, FileInfo? fileInfo = null) |
||||
|
: this(new StringReader(yamlContent), fileInfo) |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
public DockerComposeParser(FileInfo fileInfo) |
||||
|
: this(fileInfo.OpenText(), fileInfo) |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
internal DockerComposeParser(TextReader reader, FileInfo? fileInfo = null) |
||||
|
{ |
||||
|
_reader = reader; |
||||
|
_yamlStream = new YamlStream(); |
||||
|
_fileInfo = fileInfo; |
||||
|
} |
||||
|
|
||||
|
public ConfigApplication ParseConfigApplication() |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
_yamlStream.Load(_reader); |
||||
|
} |
||||
|
catch (YamlException ex) |
||||
|
{ |
||||
|
throw new TyeYamlException(ex.Start, "Unable to parse tye.yaml. See inner exception.", ex); |
||||
|
} |
||||
|
|
||||
|
var app = new ConfigApplication(); |
||||
|
|
||||
|
// TODO assuming first document.
|
||||
|
var document = _yamlStream.Documents[0]; |
||||
|
var node = document.RootNode; |
||||
|
ThrowIfNotYamlMapping(node); |
||||
|
|
||||
|
app.Source = _fileInfo!; |
||||
|
|
||||
|
Parse((YamlMappingNode)node, app); |
||||
|
|
||||
|
app.Name ??= NameInferer.InferApplicationName(_fileInfo!); |
||||
|
|
||||
|
// TODO confirm if these are ever null.
|
||||
|
foreach (var service in app.Services) |
||||
|
{ |
||||
|
service.Bindings ??= new List<ConfigServiceBinding>(); |
||||
|
service.Configuration ??= new List<ConfigConfigurationSource>(); |
||||
|
service.Volumes ??= new List<ConfigVolume>(); |
||||
|
service.Tags ??= new List<string>(); |
||||
|
} |
||||
|
|
||||
|
foreach (var ingress in app.Ingress) |
||||
|
{ |
||||
|
ingress.Bindings ??= new List<ConfigIngressBinding>(); |
||||
|
ingress.Rules ??= new List<ConfigIngressRule>(); |
||||
|
ingress.Tags ??= new List<string>(); |
||||
|
} |
||||
|
|
||||
|
return app; |
||||
|
} |
||||
|
|
||||
|
public static string GetScalarValue(YamlNode node) |
||||
|
{ |
||||
|
if (node.NodeType != YamlNodeType.Scalar) |
||||
|
{ |
||||
|
throw new TyeYamlException(node.Start, |
||||
|
CoreStrings.FormatUnexpectedType(YamlNodeType.Scalar.ToString(), node.NodeType.ToString())); |
||||
|
} |
||||
|
|
||||
|
return ((YamlScalarNode)node).Value!; |
||||
|
} |
||||
|
|
||||
|
public static string GetScalarValue(string key, YamlNode node) |
||||
|
{ |
||||
|
if (node.NodeType != YamlNodeType.Scalar) |
||||
|
{ |
||||
|
throw new TyeYamlException(node.Start, CoreStrings.FormatExpectedYamlScalar(key)); |
||||
|
} |
||||
|
|
||||
|
return ((YamlScalarNode)node).Value!; |
||||
|
} |
||||
|
|
||||
|
public static void ThrowIfNotYamlSequence(string key, YamlNode node) |
||||
|
{ |
||||
|
if (node.NodeType != YamlNodeType.Sequence) |
||||
|
{ |
||||
|
throw new TyeYamlException(node.Start, CoreStrings.FormatExpectedYamlSequence(key)); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public static void ThrowIfNotYamlMapping(YamlNode node) |
||||
|
{ |
||||
|
if (node.NodeType != YamlNodeType.Mapping) |
||||
|
{ |
||||
|
throw new TyeYamlException(node.Start, |
||||
|
CoreStrings.FormatUnexpectedType(YamlNodeType.Mapping.ToString(), node.NodeType.ToString())); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public void Dispose() |
||||
|
{ |
||||
|
_reader.Dispose(); |
||||
|
} |
||||
|
|
||||
|
internal static void Parse(YamlMappingNode node, ConfigApplication app) |
||||
|
{ |
||||
|
foreach (var child in node.Children) |
||||
|
{ |
||||
|
var key = YamlParser.GetScalarValue(child.Key); |
||||
|
|
||||
|
switch (key) |
||||
|
{ |
||||
|
case "version": |
||||
|
break; |
||||
|
case "volumes": |
||||
|
break; |
||||
|
case "services": |
||||
|
ParseServiceList((child.Value as YamlMappingNode)!, app); |
||||
|
break; |
||||
|
case "networks": |
||||
|
break; |
||||
|
case "configs": |
||||
|
break; |
||||
|
case "secrets": |
||||
|
break; |
||||
|
default: |
||||
|
throw new TyeYamlException(child.Key.Start, CoreStrings.FormatUnrecognizedKey(key)); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private static void ParseServiceList(YamlMappingNode node, ConfigApplication app) |
||||
|
{ |
||||
|
foreach (var child in node.Children) |
||||
|
{ |
||||
|
var service = new ConfigService(); |
||||
|
service.Name = YamlParser.GetScalarValue(child.Key); |
||||
|
ParseService((child.Value as YamlMappingNode)!, service); |
||||
|
app.Services.Add(service); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private static void ParseService(YamlMappingNode node, ConfigService service) |
||||
|
{ |
||||
|
foreach (var child in node.Children) |
||||
|
{ |
||||
|
var key = YamlParser.GetScalarValue(child.Key); |
||||
|
|
||||
|
switch (key) |
||||
|
{ |
||||
|
case "build": |
||||
|
ParseBuild((child.Value as YamlMappingNode)!, service); |
||||
|
break; |
||||
|
case "cap_add": |
||||
|
break; |
||||
|
case "cap_drop": |
||||
|
break; |
||||
|
case "cgroup_parent": |
||||
|
break; |
||||
|
case "command": |
||||
|
break; |
||||
|
case "configs": |
||||
|
break; |
||||
|
case "container_name": |
||||
|
break; |
||||
|
case "credential_spec": |
||||
|
break; |
||||
|
case "depends_on": |
||||
|
break; |
||||
|
case "deploy": |
||||
|
break; |
||||
|
case "devices": |
||||
|
break; |
||||
|
case "dns": |
||||
|
break; |
||||
|
case "dns_search": |
||||
|
break; |
||||
|
case "endpoint": |
||||
|
break; |
||||
|
case "env_file": |
||||
|
break; |
||||
|
case "environment": |
||||
|
ParseEnvironment(child.Value, service); |
||||
|
break; |
||||
|
case "expose": |
||||
|
break; |
||||
|
case "external_links": |
||||
|
break; |
||||
|
case "extra_hosts": |
||||
|
break; |
||||
|
case "healthcheck": |
||||
|
break; |
||||
|
case "image": |
||||
|
service.Image = YamlParser.GetScalarValue(child.Value); |
||||
|
break; |
||||
|
case "init": |
||||
|
break; |
||||
|
case "isolation": |
||||
|
break; |
||||
|
case "labels": |
||||
|
break; |
||||
|
case "links": |
||||
|
break; |
||||
|
case "logging": |
||||
|
break; |
||||
|
case "network_mode": |
||||
|
break; |
||||
|
case "networks": |
||||
|
break; |
||||
|
case "pid": |
||||
|
break; |
||||
|
case "ports": |
||||
|
ParsePortSequence((child.Value as YamlSequenceNode)!, service); |
||||
|
break; |
||||
|
case "restart": |
||||
|
break; |
||||
|
case "secrets": |
||||
|
break; |
||||
|
case "security_opt": |
||||
|
break; |
||||
|
case "stop_grace_period": |
||||
|
break; |
||||
|
case "stop_signal": |
||||
|
break; |
||||
|
case "sysctls": |
||||
|
break; |
||||
|
case "tmpfs": |
||||
|
break; |
||||
|
case "ulimits": |
||||
|
break; |
||||
|
case "userns_mode": |
||||
|
break; |
||||
|
case "volumes": |
||||
|
break; |
||||
|
case "user": |
||||
|
break; |
||||
|
case "working_dir": |
||||
|
break; |
||||
|
case "domainname": |
||||
|
break; |
||||
|
case "hostname": |
||||
|
break; |
||||
|
case "ipc": |
||||
|
break; |
||||
|
case "mac_address": |
||||
|
break; |
||||
|
case "privileged": |
||||
|
break; |
||||
|
case "read_only": |
||||
|
break; |
||||
|
case "shm_size": |
||||
|
break; |
||||
|
case "stdin_open": |
||||
|
break; |
||||
|
case "tty": |
||||
|
break; |
||||
|
default: |
||||
|
throw new TyeYamlException(child.Key.Start, CoreStrings.FormatUnrecognizedKey(key)); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private static void ParseEnvironment(YamlNode node, ConfigService service) |
||||
|
{ |
||||
|
if (node is YamlSequenceNode sequenceNode) |
||||
|
{ |
||||
|
foreach (var arg in sequenceNode) |
||||
|
{ |
||||
|
var configItem = new ConfigConfigurationSource(); |
||||
|
var argString = YamlParser.GetScalarValue(arg); |
||||
|
if (argString.Contains('=')) |
||||
|
{ |
||||
|
var parts = argString.Split('='); |
||||
|
configItem.Name = parts[0]; |
||||
|
configItem.Value = parts[1]; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
configItem.Name = argString; |
||||
|
} |
||||
|
service.Configuration.Add(configItem); |
||||
|
} |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
var mappingNode = (node as YamlMappingNode)!; |
||||
|
foreach (var arg in mappingNode) |
||||
|
{ |
||||
|
var configItem = new ConfigConfigurationSource(); |
||||
|
configItem.Name = YamlParser.GetScalarValue(arg.Key); |
||||
|
configItem.Value = YamlParser.GetScalarValue(arg.Value); |
||||
|
|
||||
|
service.Configuration.Add(configItem); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private static void ParsePortSequence(YamlSequenceNode portSequence, ConfigService service) |
||||
|
{ |
||||
|
foreach (var port in portSequence) |
||||
|
{ |
||||
|
var portString = YamlParser.GetScalarValue(port); |
||||
|
var binding = new ConfigServiceBinding(); |
||||
|
if (portString.Contains(':')) |
||||
|
{ |
||||
|
var ports = portString.Split(':'); |
||||
|
binding.Port = int.Parse(ports[0]); |
||||
|
binding.ContainerPort = int.Parse(ports[1]); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
binding.Port = int.Parse(portString); |
||||
|
binding.ContainerPort = int.Parse(portString); |
||||
|
} |
||||
|
|
||||
|
// TODO how to specify protocol with docker compose. Using http for now.
|
||||
|
binding.Protocol = "http"; |
||||
|
service.Bindings.Add(binding); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private static void ParseVolumes(YamlMappingNode node, ConfigApplication app) |
||||
|
{ |
||||
|
foreach (var child in node.Children) |
||||
|
{ |
||||
|
var key = YamlParser.GetScalarValue(child.Key); |
||||
|
|
||||
|
switch (key) |
||||
|
{ |
||||
|
case "driver": |
||||
|
break; |
||||
|
case "driver_opts": |
||||
|
break; |
||||
|
case "external": |
||||
|
break; |
||||
|
case "labels": |
||||
|
break; |
||||
|
case "name": |
||||
|
break; |
||||
|
default: |
||||
|
throw new TyeYamlException(child.Key.Start, CoreStrings.FormatUnrecognizedKey(key)); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private static void ParseNetworks(YamlMappingNode node, ConfigApplication app) |
||||
|
{ |
||||
|
foreach (var child in node.Children) |
||||
|
{ |
||||
|
var key = YamlParser.GetScalarValue(child.Key); |
||||
|
|
||||
|
switch (key) |
||||
|
{ |
||||
|
case "driver": |
||||
|
break; |
||||
|
case "driver_opts": |
||||
|
break; |
||||
|
case "attachable": |
||||
|
break; |
||||
|
case "enable_ipv6": |
||||
|
break; |
||||
|
case "ipam": |
||||
|
break; |
||||
|
case "internal": |
||||
|
break; |
||||
|
case "external": |
||||
|
break; |
||||
|
case "labels": |
||||
|
break; |
||||
|
case "name": |
||||
|
break; |
||||
|
default: |
||||
|
throw new TyeYamlException(child.Key.Start, CoreStrings.FormatUnrecognizedKey(key)); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private static readonly string[] FileFormats = new[] { "*.csproj", "*.fsproj" }; |
||||
|
|
||||
|
// Build seems like it would just work, context would just point to the csproj if no dockerfile is present.
|
||||
|
private static void ParseBuild(YamlMappingNode node, ConfigService service) |
||||
|
{ |
||||
|
foreach (var child in node.Children) |
||||
|
{ |
||||
|
var key = YamlParser.GetScalarValue(child.Key); |
||||
|
|
||||
|
switch (key) |
||||
|
{ |
||||
|
case "context": |
||||
|
// Potentially find project or context based on that.
|
||||
|
// could potentially specify a project here instead?
|
||||
|
var folder = new DirectoryInfo(YamlParser.GetScalarValue(child.Value)); |
||||
|
foreach (var format in FileFormats) |
||||
|
{ |
||||
|
var projs = Directory.GetFiles(folder.FullName, format); |
||||
|
if (projs.Length == 1) |
||||
|
{ |
||||
|
service.Project = projs[0]; |
||||
|
break; |
||||
|
} |
||||
|
if (projs.Length > 1) |
||||
|
{ |
||||
|
throw new TyeYamlException("Multiple proj files found in directory, have only a single proj file in the context directory."); |
||||
|
} |
||||
|
} |
||||
|
// check if folder has proj file, and use that.
|
||||
|
break; |
||||
|
case "dockerfile": |
||||
|
service.DockerFile = YamlParser.GetScalarValue(child.Value); |
||||
|
break; |
||||
|
case "args": |
||||
|
//service.Configuration = ParseDockerBuildArgs((child.Value as YamlSequenceNode)!, service);
|
||||
|
break; |
||||
|
case "cache_from": |
||||
|
break; |
||||
|
case "labels": |
||||
|
break; |
||||
|
case "network": |
||||
|
break; |
||||
|
case "shm_size": |
||||
|
break; |
||||
|
case "target": |
||||
|
break; |
||||
|
default: |
||||
|
throw new TyeYamlException(child.Key.Start, CoreStrings.FormatUnrecognizedKey(key)); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
//private static List<ConfigConfigurationSource> ParseDockerBuildArgs(YamlSequenceNode node, ConfigService service)
|
||||
|
//{
|
||||
|
|
||||
|
//}
|
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue