Skip to content

Commit

Permalink
Merge pull request #54 from Novacer/ace-editor
Browse files Browse the repository at this point in the history
Add code editor with auto-complete
  • Loading branch information
Novacer committed Aug 14, 2019
2 parents 2e13f56 + cbb0aea commit 7a5a169
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 5 deletions.
5 changes: 4 additions & 1 deletion frontend/angular-src/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@
"styles": [
"src/styles.css"
],
"scripts": ["node_modules/chart.js/dist/Chart.bundle.js"]
"scripts": ["node_modules/chart.js/dist/Chart.bundle.js",
"node_modules/ace-builds/src-min/ace.js",
"node_modules/ace-builds/src-min/ext-searchbox.js",
"node_modules/ace-builds/src-min/ext-language_tools.js"]
},
"configurations": {
"production": {
Expand Down
19 changes: 19 additions & 0 deletions frontend/angular-src/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/angular-src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"chart.js": "^2.7.2",
"core-js": "^2.5.4",
"hammerjs": "^2.0.8",
"ng2-ace-editor": "^0.3.9",
"ng2-charts": "^1.6.0",
"rxjs": "^6.0.0",
"zone.js": "^0.8.26"
Expand Down
6 changes: 5 additions & 1 deletion frontend/angular-src/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import { BuilderComponent } from './builder/builder.component';
import { RsiDivergenceComponent } from './algorithms/rsi-divergence/rsi-divergence.component';
import { TrendFollowComponent } from './algorithms/trend-follow/trend-follow.component';
import { RegimesClusteringComponent } from './algorithms/regimes-clustering/regimes-clustering.component';
import { CodeEditorComponent } from './editor/code-editor/code-editor.component';
import { AceEditorModule } from "ng2-ace-editor";

const appRoutes : Routes = [
{ path: '', component: IntroComponent, pathMatch: 'full'},
Expand Down Expand Up @@ -57,10 +59,12 @@ const appRoutes : Routes = [
BuilderComponent,
RsiDivergenceComponent,
TrendFollowComponent,
RegimesClusteringComponent
RegimesClusteringComponent,
CodeEditorComponent
],
imports: [
BrowserModule,
AceEditorModule,
HttpClientModule,
ChartsModule,
FormsModule,
Expand Down
5 changes: 2 additions & 3 deletions frontend/angular-src/src/app/builder/builder.component.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<div class="container-fluid">
<div class="body">
<h5>
Coming Soon!
</h5>
<h5 style="padding-top: 2%; padding-bottom: 1%">Write code here! (WIP)</h5>
<code-editor></code-editor>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.code-editor {
z-index: 1;
min-height: 300px;
width:100%;
overflow: auto;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<ace-editor class="code-editor" [(text)]="code"
#editor></ace-editor>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { CodeEditorComponent } from './code-editor.component';

describe('CodeEditorComponent', () => {
let component: CodeEditorComponent;
let fixture: ComponentFixture<CodeEditorComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ CodeEditorComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(CodeEditorComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import {AfterViewInit, Component, ViewChild} from '@angular/core';
import "ace-builds/webpack-resolver";
import "brace/mode/python";
import "brace/theme/monokai";

@Component({
selector: 'code-editor',
templateUrl: './code-editor.component.html',
styleUrls: ['./code-editor.component.css']
})
export class CodeEditorComponent implements AfterViewInit {
@ViewChild('editor') editor;
code = 'print("Hello World!")';

private readonly options = {
enableBasicAutocompletion: true,
enableLiveAutocompletion: true,
fontSize: 18,
};

constructor() { }

ngAfterViewInit() {
this.editor.setTheme('monokai');
this.editor.setMode('python');

this.editor.getEditor().setOptions(this.options);
}

}

0 comments on commit 7a5a169

Please sign in to comment.