34 |
--------------------------------------------------------------------------------
/src/app/app.component.spec.ts:
--------------------------------------------------------------------------------
1 | /* tslint:disable:no-unused-variable */
2 |
3 | import { TestBed, async } from '@angular/core/testing';
4 | import { AppComponent } from './app.component';
5 |
6 | describe('App: JuliaApiDemo', () => {
7 | beforeEach(() => {
8 | TestBed.configureTestingModule({
9 | declarations: [
10 | AppComponent
11 | ],
12 | });
13 | });
14 |
15 | it('should create the app', async(() => {
16 | let fixture = TestBed.createComponent(AppComponent);
17 | let app = fixture.debugElement.componentInstance;
18 | expect(app).toBeTruthy();
19 | }));
20 |
21 | it(`should have as title 'app works!'`, async(() => {
22 | let fixture = TestBed.createComponent(AppComponent);
23 | let app = fixture.debugElement.componentInstance;
24 | expect(app.title).toEqual('app works!');
25 | }));
26 |
27 | it('should render title in a h1 tag', async(() => {
28 | let fixture = TestBed.createComponent(AppComponent);
29 | fixture.detectChanges();
30 | let compiled = fixture.debugElement.nativeElement;
31 | expect(compiled.querySelector('h1').textContent).toContain('app works!');
32 | }));
33 | });
34 |
--------------------------------------------------------------------------------
/src/app/app.module.ts:
--------------------------------------------------------------------------------
1 | import { BrowserModule } from '@angular/platform-browser';
2 | import { NgModule } from '@angular/core';
3 | import { FormsModule } from '@angular/forms';
4 | import { HttpModule } from '@angular/http';
5 | import { RouterModule } from '@angular/router';
6 | import { ClarityModule } from 'clarity-angular';
7 | import { AppComponent } from './app.component';
8 | import { OdeComponent } from './ode/ode.component';
9 | import { SdeComponent } from './sde/sde.component';
10 | import { HomeComponent } from './home/home.component';
11 |
12 | const routing = RouterModule.forRoot([
13 | { path: '', component: HomeComponent },
14 | { path: 'ode', component: OdeComponent },
15 | { path: 'sde', component: SdeComponent }
16 |
17 | // { path: 'radios', component: RadiosComponent }
18 | ]);
19 |
20 | @NgModule({
21 | declarations: [
22 | AppComponent,
23 | OdeComponent,
24 | SdeComponent,
25 | HomeComponent
26 | ],
27 | imports: [
28 | BrowserModule,
29 | FormsModule,
30 | HttpModule,
31 | routing,
32 | ClarityModule
33 | ],
34 | providers: [],
35 | bootstrap: [AppComponent]
36 | })
37 | export class AppModule { }
38 |
--------------------------------------------------------------------------------
/karma.conf.js:
--------------------------------------------------------------------------------
1 | // Karma configuration file, see link for more information
2 | // https://karma-runner.github.io/0.13/config/configuration-file.html
3 |
4 | module.exports = function (config) {
5 | config.set({
6 | basePath: '',
7 | frameworks: ['jasmine', 'angular-cli'],
8 | plugins: [
9 | require('karma-jasmine'),
10 | require('karma-chrome-launcher'),
11 | require('karma-remap-istanbul'),
12 | require('angular-cli/plugins/karma')
13 | ],
14 | files: [
15 | { pattern: './src/test.ts', watched: false }
16 | ],
17 | preprocessors: {
18 | './src/test.ts': ['angular-cli']
19 | },
20 | remapIstanbulReporter: {
21 | reports: {
22 | html: 'coverage',
23 | lcovonly: './coverage/coverage.lcov'
24 | }
25 | },
26 | angularCli: {
27 | config: './angular-cli.json',
28 | environment: 'dev'
29 | },
30 | reporters: config.angularCli && config.angularCli.codeCoverage
31 | ? ['progress', 'karma-remap-istanbul']
32 | : ['progress'],
33 | port: 9876,
34 | colors: true,
35 | logLevel: config.LOG_INFO,
36 | autoWatch: true,
37 | browsers: ['Chrome'],
38 | singleRun: false
39 | });
40 | };
41 |
--------------------------------------------------------------------------------
/src/test.ts:
--------------------------------------------------------------------------------
1 | import './polyfills.ts';
2 |
3 | import 'zone.js/dist/long-stack-trace-zone';
4 | import 'zone.js/dist/proxy.js';
5 | import 'zone.js/dist/sync-test';
6 | import 'zone.js/dist/jasmine-patch';
7 | import 'zone.js/dist/async-test';
8 | import 'zone.js/dist/fake-async-test';
9 |
10 | // Unfortunately there's no typing for the `__karma__` variable. Just declare it as any.
11 | declare var __karma__: any;
12 | declare var require: any;
13 |
14 | // Prevent Karma from running prematurely.
15 | __karma__.loaded = function () {};
16 |
17 |
18 | Promise.all([
19 | System.import('@angular/core/testing'),
20 | System.import('@angular/platform-browser-dynamic/testing')
21 | ])
22 | // First, initialize the Angular testing environment.
23 | .then(([testing, testingBrowser]) => {
24 | testing.getTestBed().initTestEnvironment(
25 | testingBrowser.BrowserDynamicTestingModule,
26 | testingBrowser.platformBrowserDynamicTesting()
27 | );
28 | })
29 | // Then we find all the tests.
30 | .then(() => require.context('./', true, /\.spec\.ts/))
31 | // And load the modules.
32 | .then(context => context.keys().map(context))
33 | // Finally, start Karma to run the tests.
34 | .then(__karma__.start, __karma__.error);
35 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | The DiffEqOnline package is licensed under the MIT "Expat" License:
2 |
3 | > Copyright (c) 2016: ChrisRackauckas and Alex Mellnik
4 | >
5 | > Permission is hereby granted, free of charge, to any person obtaining a copy
6 | > of this software and associated documentation files (the "Software"), to deal
7 | > in the Software without restriction, including without limitation the rights
8 | > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | > copies of the Software, and to permit persons to whom the Software is
10 | > furnished to do so, subject to the following conditions:
11 | >
12 | > The above copyright notice and this permission notice shall be included in all
13 | > copies or substantial portions of the Software.
14 | >
15 | > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | > SOFTWARE.
22 | >
23 |
--------------------------------------------------------------------------------
/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | DifferentialEquations.jl on the web, powered by Mux.jl and Plots.jl
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
27 |
28 |
29 |
30 | Loading...
31 |
32 |
33 |
If this message doesn't go away, it may be because you are using an older browser. Try it with a newer version of Chrome, Firefox, Opera or Edge.
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/angular-cli.json:
--------------------------------------------------------------------------------
1 | {
2 | "project": {
3 | "version": "1.0.0-beta.19-3",
4 | "name": "julia-api-demo"
5 | },
6 | "apps": [
7 | {
8 | "root": "src",
9 | "outDir": "dist",
10 | "assets": [
11 | "assets",
12 | "favicon.ico"
13 | ],
14 | "index": "index.html",
15 | "main": "main.ts",
16 | "test": "test.ts",
17 | "tsconfig": "tsconfig.json",
18 | "prefix": "app",
19 | "mobile": false,
20 | "styles": [
21 | "../node_modules/clarity-icons/clarity-icons.min.css",
22 | "../node_modules/clarity-ui/clarity-ui.min.css",
23 | "styles.css"
24 | ],
25 | "scripts": [
26 | "../node_modules/mutationobserver-shim/dist/mutationobserver.min.js",
27 | "../node_modules/@webcomponents/custom-elements/custom-elements.min.js",
28 | "../node_modules/clarity-icons/clarity-icons.min.js"
29 | ],
30 | "environments": {
31 | "source": "environments/environment.ts",
32 | "dev": "environments/environment.ts",
33 | "prod": "environments/environment.prod.ts"
34 | }
35 | }
36 | ],
37 | "addons": [],
38 | "packages": [],
39 | "e2e": {
40 | "protractor": {
41 | "config": "./protractor.conf.js"
42 | }
43 | },
44 | "test": {
45 | "karma": {
46 | "config": "./karma.conf.js"
47 | }
48 | },
49 | "defaults": {
50 | "styleExt": "css",
51 | "prefixInterfaces": false,
52 | "inline": {
53 | "style": false,
54 | "template": false
55 | },
56 | "spec": {
57 | "class": false,
58 | "component": true,
59 | "directive": true,
60 | "module": false,
61 | "pipe": true,
62 | "service": true
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "julia-api-demo",
3 | "version": "0.0.0",
4 | "license": "MIT",
5 | "angular-cli": {},
6 | "scripts": {
7 | "start": "ng serve",
8 | "lint": "tslint \"src/**/*.ts\"",
9 | "test": "ng test",
10 | "pree2e": "webdriver-manager update",
11 | "e2e": "protractor",
12 | "prodbuild": "ng build --prod --base-href=http://app.juliadiffeq.org/"
13 | },
14 | "private": true,
15 | "dependencies": {
16 | "@angular/common": "~2.1.0",
17 | "@angular/compiler": "~2.1.0",
18 | "@angular/core": "~2.1.0",
19 | "@angular/forms": "~2.1.0",
20 | "@angular/http": "~2.1.0",
21 | "@angular/platform-browser": "~2.1.0",
22 | "@angular/platform-browser-dynamic": "~2.1.0",
23 | "@angular/router": "~3.1.0",
24 | "@webcomponents/custom-elements": "^1.0.0-alpha.3",
25 | "clarity-angular": "^0.7.5-dev",
26 | "clarity-icons": "^0.7.5-dev",
27 | "clarity-ui": "^0.7.5-dev",
28 | "core-js": "^2.4.1",
29 | "file-saver": "^1.3.3",
30 | "mutationobserver-shim": "^0.3.2",
31 | "plotly": "^1.0.6",
32 | "rxjs": "5.0.0-beta.12",
33 | "ts-helpers": "^1.1.1",
34 | "zone.js": "^0.6.23"
35 | },
36 | "devDependencies": {
37 | "@types/jasmine": "^2.2.30",
38 | "@types/node": "^6.0.42",
39 | "angular-cli": "1.0.0-beta.19-3",
40 | "codelyzer": "1.0.0-beta.1",
41 | "jasmine-core": "2.4.1",
42 | "jasmine-spec-reporter": "2.5.0",
43 | "karma": "1.2.0",
44 | "karma-chrome-launcher": "^2.0.0",
45 | "karma-cli": "^1.0.1",
46 | "karma-jasmine": "^1.0.2",
47 | "karma-remap-istanbul": "^0.2.1",
48 | "protractor": "4.0.9",
49 | "ts-node": "1.2.1",
50 | "tslint": "3.13.0",
51 | "typescript": "~2.0.3",
52 | "webdriver-manager": "10.2.5"
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/app/api.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 | import { Http, Headers, RequestOptions, Response } from '@angular/http';
3 | import { Observable } from 'rxjs/Observable';
4 |
5 | import 'rxjs/add/operator/map';
6 | import 'rxjs/add/operator/catch';
7 |
8 | @Injectable()
9 | export class ApiService {
10 |
11 | private headers = new Headers({ 'Content-Type': 'application/json', 'charset': 'UTF-8' });
12 | private options = new RequestOptions({ headers: this.headers });
13 |
14 | constructor(private http: Http) { }
15 |
16 | passDiffEq(apiUrl:string, model:any) {
17 | // Encode the array string as a base64 string to make sure we don't have any crazy characters
18 | return this.http.get(apiUrl + '/solveit/' + btoa(JSON.stringify(model)))
19 | .map(res => res.json().data)
20 | .catch(this.handleError);
21 | }
22 |
23 | wakeUp(apiUrl:string) {
24 | return this.http.get(apiUrl + '/wakeup')
25 | .map(res => res.json().data)
26 | .catch(this.handleError);
27 | }
28 |
29 | private handleError (error: Response | any) {
30 | // In a real world app, we might use a remote logging infrastructure
31 | let errMsg: string;
32 | var err = '';
33 | if (error instanceof Response) {
34 | // Normally errors come in as response objects
35 | const body = error.json() || '';
36 | err = body.message || JSON.stringify(body);
37 | errMsg = `${error.status} - ${error.statusText || ''}: ${err}`;
38 | console.error(errMsg);
39 | // Check for timeout errors. The 0 status is what appears since the Access-Control-Allow-Origin headers are not set by Heroku when it times out.
40 | if ((error.status==503)||(error.status==0)) {
41 | err = 'The server timed out trying to calculate your response. Try reloading, and if that doesn\'t work try DifferentialEquations.jl!';
42 | }
43 | return Observable.throw(err);
44 | } else {
45 | // A generic error fallback
46 | errMsg = error.message ? error.message : error.toString();
47 | console.error(errMsg);
48 | return Observable.throw(errMsg);
49 | }
50 | }
51 |
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # DifferentialEquations.jl Online
2 |
3 | This is the front-end of [http://app.juliadiffeq.org/](http://app.juliadiffeq.org/), a website that solves differential equations in your browser using the power of [DifferentialEquations.jl](https://github.com/JuliaDiffEq/DifferentialEquations.jl).
4 |
5 | ## Installation
6 |
7 | First, make sure you have node installed. You can download it [here](https://nodejs.org) or with something like
8 |
9 | ```
10 | sudo yum install nodejs
11 | ```
12 |
13 | and install angular-cli using the instructions [here](https://github.com/angular/angular-cli).
14 |
15 | Clone the repo and navigate to it. Then run
16 |
17 | ```
18 | sudo npm install
19 | ```
20 |
21 | to install all the dependencies.
22 |
23 | ## Local development
24 |
25 | Run `ng serve` for a dev server.
26 | Navigate a browser to `http://localhost:4200/`.
27 | The app will automatically reload if you change any of the source files.
28 |
29 | The development build of the website allows you to select the url of the API, so you can test it with a local instance of the API. To setup the backend API and run it locally, see [the repository for the backend](https://github.com/JuliaDiffEq/DiffEqOnlineServer).
30 |
31 | # Development notes for the angular-cli front end
32 |
33 | Everything that follows was automatically generated by angular-cli.
34 |
35 | This project was generated with [angular-cli](https://github.com/angular/angular-cli) version 1.0.0-beta.19-3.
36 |
37 | ## Development server
38 | Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
39 |
40 | ## Code scaffolding
41 |
42 | Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive/pipe/service/class`.
43 |
44 | ## Build
45 |
46 | Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `-prod` flag for a production build.
47 |
48 | ## Running unit tests
49 |
50 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
51 |
52 | ## Running end-to-end tests
53 |
54 | Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
55 | Before running the tests make sure you are serving the app via `ng serve`.
56 |
57 | ## Deploying to Github Pages
58 |
59 | Run `ng github-pages:deploy` to deploy to Github Pages.
60 |
61 | ## Further help
62 |
63 | To get more help on the `angular-cli` use `ng --help` or go check out the [Angular-CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
64 |
--------------------------------------------------------------------------------
/src/app/home/home.component.html:
--------------------------------------------------------------------------------
1 |
DifferentialEquations.jl Online
2 |
This page allows you to use some of the functionality of
3 | DifferentialEquations.jl in
4 | your browser. To get started, click on one of the tools above.
DifferentialEquations.jl
12 | is a package written in Julia, a high-performance
13 | language for technical computing. A web interface frontend was built using Angular
14 | and was linked to Julia via Mux.jl. The
15 | results are parsed via ParameterizedFunctions.jl,
16 | a component of the DifferentialEquations.jl ecosystem which performs conversions
17 | between natrual syntax to Julia code for parameterized differential equations.
18 | The end result is a clean interface for users to explore some of the functionality
19 | of a performant Julia library directly from their browser.
20 |
21 |
Supporting and Citing
22 |
The software in this ecosystem was developed as part of academic research. If
23 | you would like to help support it,
24 | please star the repository
25 | as such metrics may help us secure funding in the future. If you use JuliaDiffEq
26 | software as part of your research, teaching, or other activities, we would be grateful
27 | if you could cite our (and others!) work. Please see our
28 | citation page for guidelines.
29 |
30 |
More Information
31 |
For more information on about DifferentialEquations.jl, please
32 | see the documentation. For more
33 | information on JuliaDiffEq, please visit our website.
34 |
35 |
Contributing
36 |
If you would like to help contribute to DifferentialEquations.jl Online, please
37 | let us know at the DiffEqOnline Github repository.
38 | If you are interested in participating in the Google Summer of Code, please let
39 | us know and we can help you find an interesting and impactful project in the
40 | JuliaDiffEq ecosystem.