Skip to content
Snippets Groups Projects
Commit fb4d0650 authored by David Dorchies's avatar David Dorchies
Browse files

Initial commit with Lechapt & Calmon

parent 4b321d90
No related branches found
No related tags found
No related merge requests found
Showing
with 214 additions and 272 deletions
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"project": {
"name": "ja-lhyd"
},
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": [
"assets",
"favicon.ico"
],
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "app",
"styles": [
"styles.css"
],
"scripts": [],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}
],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"lint": [
{
"project": "src/tsconfig.app.json"
},
{
"project": "src/tsconfig.spec.json"
},
{
"project": "e2e/tsconfig.e2e.json"
}
],
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
"defaults": {
"styleExt": "css",
"component": {}
}
}
# JaLHyd
# JaLHyd : Javascript Library For Hydraulics
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.0.3.
## All the things to know for developping the library
## Development server
The library needs nodeJS installed and the following node packages installed globally: typescript, karma, tslint. This can be done by the command line:
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.
`npm install -g typescript karma tslint`
## Code scaffolding
Then, you can install the necessary packages of the library:
`npm install`
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|module`.
## Build
### For compiling the typescript code
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.
`npm build`
## Running unit tests
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
### For compiling and testing the code with karma
## Running end-to-end tests
`npm test`
Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
Before running the tests make sure you are serving the app via `ng serve`.
## Further help
### For flagging suspicious language usage
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).
`npm lint`
### UML visualisation
The tsviz package can be used for drawing class diagram of the current code.
For installing tsviz: `npm install -g tsviz`
There's currently a bug on debian like distribution due to a wrong declaration of graphviz path in the code: https://github.com/joaompneves/tsviz/issues/5
To work around, you can create a link to the good path: `sudo ln -s /usr/bin/dot /usr/local/bin/dot`
For drawing the diagram: `npm viz`
import { JaLHydPage } from './app.po';
describe('ja-lhyd App', () => {
let page: JaLHydPage;
beforeEach(() => {
page = new JaLHydPage();
});
it('should display message saying app works', () => {
page.navigateTo();
expect(page.getParagraphText()).toEqual('app works!');
});
});
import { browser, by, element } from 'protractor';
export class JaLHydPage {
navigateTo() {
return browser.get('/');
}
getParagraphText() {
return element(by.css('app-root h1')).getText();
}
}
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/e2e",
"module": "commonjs",
"target": "es5",
"types": [
"jasmine",
"node"
]
}
}
jalhyd_class_diagram.png

15.1 KiB

// Karma configuration file, see link for more information
// https://karma-runner.github.io/0.13/config/configuration-file.html
// Karma configuration
// Generated on Sun May 14 2017 18:49:28 GMT+0200 (CEST)
module.exports = function (config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
frameworks: ['jasmine', '@angular/cli'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular/cli/plugins/karma')
],
client:{
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine', 'karma-typescript'],
// list of files / patterns to load in the browser
files: [
{ pattern: './src/test.ts', watched: false }
{ pattern: 'dist/out-tsc/**/*.spec.js', included: false }
],
// list of files to exclude
exclude: [
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'./src/test.ts': ['@angular/cli']
'src/**/*.spec.ts': ['karma-typescript']
},
mime: {
'text/x-typescript': ['ts','tsx']
},
coverageIstanbulReporter: {
reports: [ 'html', 'lcovonly' ],
fixWebpackSourcePaths: true
},
angularCli: {
environment: 'dev'
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress', 'karma-typescript'],
// https://github.com/monounity/karma-typescript/blob/master/cookbook.md#user-content-importing-es2015-aka-es6-modules
karmaTypescriptConfig: {
bundlerOptions: {
transforms: [require("karma-typescript-es6-transform")()]
}
},
reporters: config.angularCli && config.angularCli.codeCoverage
? ['progress', 'coverage-istanbul']
: ['progress', 'kjhtml'],
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['Chrome'],
singleRun: false
});
};
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,
// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity
})
}
{
"name": "ja-lhyd",
"version": "0.0.0",
"name": "jalhyd",
"version": "0.0.1",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
"build": "tsc --p src/tsconfig.app.json",
"test": "./node_modules/karma/bin/karma start",
"lint": "./node_modules/tslint/bin/tslint",
"viz": "tsviz -recursive src/ jalhyd_class_diagram.png"
},
"private": true,
"dependencies": {
"@angular/common": "^4.0.0",
"@angular/compiler": "^4.0.0",
"@angular/core": "^4.0.0",
"@angular/forms": "^4.0.0",
"@angular/http": "^4.0.0",
"@angular/platform-browser": "^4.0.0",
"@angular/platform-browser-dynamic": "^4.0.0",
"@angular/router": "^4.0.0",
"core-js": "^2.4.1",
"rxjs": "^5.1.0",
"zone.js": "^0.8.4"
},
"dependencies": {},
"devDependencies": {
"@angular/cli": "1.0.3",
"@angular/compiler-cli": "^4.0.0",
"@types/jasmine": "2.5.38",
"@types/node": "~6.0.60",
"codelyzer": "~2.0.0",
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~3.2.0",
"karma": "~1.4.1",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^0.2.0",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-coverage-istanbul-reporter": "^0.2.0",
"protractor": "~5.1.0",
"karma-typescript": "^3.0.1",
"karma-typescript-es6-transform": "^1.0.0",
"ts-node": "~2.0.0",
"tslint": "~4.5.0",
"typescript": "~2.2.0"
......
// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts
const { SpecReporter } = require('jasmine-spec-reporter');
exports.config = {
allScriptsTimeout: 11000,
specs: [
'./e2e/**/*.e2e-spec.ts'
],
capabilities: {
'browserName': 'chrome'
},
directConnect: true,
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
},
beforeLaunch: function() {
require('ts-node').register({
project: 'e2e/tsconfig.e2e.json'
});
},
onPrepare() {
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
}
};
<h1>
{{title}}
</h1>
import { TestBed, async } from '@angular/core/testing';
import { AppComponent } from './app.component';
describe('AppComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [
AppComponent
],
}).compileComponents();
}));
it('should create the app', async(() => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
}));
it(`should have as title 'app works!'`, async(() => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app.title).toEqual('app works!');
}));
it('should render title in a h1 tag', async(() => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.debugElement.nativeElement;
expect(compiled.querySelector('h1').textContent).toContain('app works!');
}));
});
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'app works!';
}
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
FormsModule,
HttpModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
import { Nub, Result } from "base";
class NubTest extends Nub {
Equation(): Result {
let res: Result = new Result();
res.varCalc = this.v["A"] + this.v["B"];
return res;
}
}
let nub = new NubTest({ "A": 1, "B": 2, "C": null });
let res = new Result;
describe('Class Nub: ', () => {
beforeEach(() => {
nub.sVarsEq = ["C"];
res.varCalc = 3;
});
describe('Calc(): ', () => {
it('should return a result', () => {
expect(nub.Calc("C")).toBe(res);
});
});
});
/**
* Résultat de calcul comprenant la valeur du résultat et des calculs annexes (flag, calculs intermédiaires...)
*/
export class Result {
public varCalc: number;
public extraVar: {}; /** @todo Comment définit-on un objet dont on ne connait pas le nom des clés mais dont on connait le type ? */
}
/**
* Série de valeurs à calculer définie par le nom de la variable à sérier et le vecteur de valeur
*/
export class Serie {
public name: string;
public values: number[];
constructor(name: string, values: number[]) {
this.name = name;
this.values = values;
}
}
export interface IParametres {
[key: string]: number;
}
/**
* Classe abstraite de Noeud de calcul : classe de base pour tous les calculs
*/
export abstract class Nub {
/// Nom des variables calculées par la méthode Equation
private _varsEq: string[];
public v: IParametres;
constructor(parametres: IParametres) {
this.v = parametres;
}
/**
* Formule utilisée pour le calcul analytique (solution directe ou méthode de résolution spécifique)
*/
abstract Equation(sVarCalc: string): Result;
/**
* Calcul d'une équation quelque soit l'inconnue à calculer
*/
Calc(sVarCalc: string): Result {
for(let sVarEq of this._varsEq) {
if(sVarCalc == sVarEq) {
return this.Equation(sVarCalc);
}
}
return this.Solve(sVarCalc);
}
CalcSerie(svarCalc: string, serie: Serie): Result[] {
/** @todo faire une boucle pour appeler this.Calc avec chaque valeur de serie.values
*
*/
let results = [new (Result)];
return results;
}
get sVarsEq(): string[] {
return this._varsEq;
}
set sVarsEq(sVarsEq: string[]) {
this._varsEq = sVarsEq;
}
AddVarEq(sVarEq: string) {
this._varsEq.push(sVarEq);
}
/**
* Résoud l'équation par une méthode numérique
*/
Solve(sVarCalc: string): Result {
let res: Result;
/** @todo Résolution par méthode numérique (dichotomie...) */
return res;
}
}
export const environment = {
production: true
};
// The file contents for the current environment will overwrite these during build.
// The build system defaults to the dev environment which uses `environment.ts`, but if you do
// `ng build --env=prod` then `environment.prod.ts` will be used instead.
// The list of which env maps to which file can be found in `.angular-cli.json`.
export const environment = {
production: false
};
src/favicon.ico

5.3 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment