Skip to content

Commit

Permalink
Move files around to group by feature area
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveSandersonMS committed Oct 29, 2020
1 parent 3820be7 commit d657f4b
Show file tree
Hide file tree
Showing 19 changed files with 136 additions and 135 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
@code {
[Parameter]
public string NotebookId { get; set; }
private Notebook notebook;
private blazoract.Shared.Notebook notebook;

protected override async Task OnInitializedAsync()
{
Expand Down
File renamed without changes.
130 changes: 65 additions & 65 deletions Client/Shared/CodeCell.razor → Client/Pages/Notebook/CodeCell.razor
Original file line number Diff line number Diff line change
@@ -1,65 +1,65 @@
@using System.Net.Http
@using MonacoRazor

@inject HttpClient Http

<div class="code-cell">
<div class="top">
<div class="toolbar">
<button @onclick="RunCell">&#x25BA;</button>
</div>
<CodeEditor @bind-Code="CellContent" OnCompletionsRequested="GetCompletionsAsync" />
</div>
<div class="output @(isEvaluating ? "loading" : "")">
<OutputDisplay @key="result" Result="result" />
</div>
</div>

@code {
[Parameter]
public Cell Cell { get; set; }

[Parameter]
public Func<Task> OnCodeChange { get; set; }

private ExecuteResult result;
private bool isEvaluating;

private string CellContent
{
get => Cell.Content;
set
{
Cell.Content = value;
OnCodeChange();
}
}

private async Task RunCell()
{
try
{
isEvaluating = true;
var request = new ExecuteRequest(Cell.NotebookId, Cell.Content);
var response = await Http.PostAsJsonAsync("api/code/run", request);
result = await response.Content.ReadFromJsonAsync<ExecuteResult>();
}
finally
{
isEvaluating = false;
}
}

private async Task<Suggestion[]> GetCompletionsAsync(string value, Position position)
{
var response = await Http.PostAsJsonAsync("api/code/completions", new GetCompletionsRequest
{
NotebookId = Cell.NotebookId,
Code = value,
Column = position.Column,
LineNumber = position.LineNumber
});

return await response.Content.ReadFromJsonAsync<Suggestion[]>();
}
}
@using System.Net.Http
@using MonacoRazor

@inject HttpClient Http

<div class="code-cell">
<div class="top">
<div class="toolbar">
<button @onclick="RunCell">&#x25BA;</button>
</div>
<CodeEditor @bind-Code="CellContent" OnCompletionsRequested="GetCompletionsAsync" />
</div>
<div class="output @(isEvaluating ? "loading" : "")">
<OutputDisplay @key="result" Result="result" />
</div>
</div>

@code {
[Parameter]
public Cell Cell { get; set; }

[Parameter]
public Func<Task> OnCodeChange { get; set; }

private ExecuteResult result;
private bool isEvaluating;

private string CellContent
{
get => Cell.Content;
set
{
Cell.Content = value;
OnCodeChange();
}
}

private async Task RunCell()
{
try
{
isEvaluating = true;
var request = new ExecuteRequest(Cell.NotebookId, Cell.Content);
var response = await Http.PostAsJsonAsync("api/code/run", request);
result = await response.Content.ReadFromJsonAsync<ExecuteResult>();
}
finally
{
isEvaluating = false;
}
}

private async Task<Suggestion[]> GetCompletionsAsync(string value, Position position)
{
var response = await Http.PostAsJsonAsync("api/code/completions", new GetCompletionsRequest
{
NotebookId = Cell.NotebookId,
Code = value,
Column = position.Column,
LineNumber = position.LineNumber
});

return await response.Content.ReadFromJsonAsync<Suggestion[]>();
}
}
Original file line number Diff line number Diff line change
@@ -1,63 +1,63 @@
.code-cell {
margin: 10px;
border: 1px solid #bfbfbf;
}

.top {
display: flex;
}

input {
flex-grow: 1;
padding: 10px;
border: 0;
outline: 0;
font-family: monospace;
}

::deep .editor {
flex-grow: 1;
border: none;
margin: 0;
min-height: 150px;
}

.output {
background-color: #eee;
min-height: 20px;
transition: filter 0.5s ease-in-out;
}
.output > ::deep div {
padding: 10px;
animation-name: yellowfade;
animation-duration: 1s;
background-color: var(--bgcol);
}

@keyframes yellowfade {
from {
background-color: #f5ea7f;
}

to {
background-color: var(--bgcol);
}
}

.loading {
filter: brightness(0.5);
}

.toolbar {
flex-grow: 0;
padding: 0 10px;
}

button {
border: none;
background: white;
}

button:hover {
color: #19b5fe;
}
.code-cell {
margin: 10px;
border: 1px solid #bfbfbf;
}

.top {
display: flex;
}

input {
flex-grow: 1;
padding: 10px;
border: 0;
outline: 0;
font-family: monospace;
}

::deep .editor {
flex-grow: 1;
border: none;
margin: 0;
min-height: 150px;
}

.output {
background-color: #eee;
min-height: 20px;
transition: filter 0.5s ease-in-out;
}
.output > ::deep div {
padding: 10px;
animation-name: yellowfade;
animation-duration: 1s;
background-color: var(--bgcol);
}

@keyframes yellowfade {
from {
background-color: #f5ea7f;
}

to {
background-color: var(--bgcol);
}
}

.loading {
filter: brightness(0.5);
}

.toolbar {
flex-grow: 0;
padding: 0 10px;
}

button {
border: none;
background: white;
}

button:hover {
color: #19b5fe;
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
{
if (Result.OutputType == "error")
{
<ErrorDisplay Result="Result" />
<ErrorDisplay Result="Result"></ErrorDisplay>
}
else if (_deserializedOutput is ICollection<object> objectCollection)
{
<ArrayDisplay Data="@objectCollection" />
<ArrayDisplay Data="@objectCollection"></ArrayDisplay>
}
else if (_deserializedOutput is IEnumerable enumerable)
{
<ArrayDisplay Data="@(enumerable.Cast<object>().ToList())" />
<ArrayDisplay Data="@(enumerable.Cast<object>().ToList())"></ArrayDisplay>
}
else
{
<FallbackDisplay OutputToString="@Result.OutputToString" />
<FallbackDisplay OutputToString="@Result.OutputToString"></FallbackDisplay>
}
}

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 3 additions & 2 deletions Client/_Imports.razor
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
@using Microsoft.JSInterop
@using blazoract
@using blazoract.Client.Shared
@using blazoract.Client.Shared.OutputDisplays
@using blazoract.Client.Pages.Notebook.OutputDisplays
@using blazoract.Shared
@using blazoract.Client.Shared.Toolbar
@using System.Threading
@using blazoract.Client.Data
@using Blazored.LocalStorage
@using System.Threading.Tasks
@using System.Threading.Tasks

0 comments on commit d657f4b

Please sign in to comment.