Commit 2df07227 authored by Gonzalo Fabian Cameto Hernandez's avatar Gonzalo Fabian Cameto Hernandez
Browse files

Elimino carpeta functions no utilizada

parent 7f27693c
export class FunctionServicesResult {
code: number;
msg: string;
}
\ No newline at end of file
export class Function {
id: number;
name: string;
str: string;
}
\ No newline at end of file
<div class="panel panel-success">
<div class="card">
<h4 class="card-header">Mis funciones</h4>
<div class="card-block">
<ul class="list-group list-group-flush">
<li *ngFor="let f of _funcs" class="list-group-item">
<div class="card-block">
<div class="checkbox">
<label for="checkbox">
{{f.str}}
</label>
</div>
<div class="pull-right action-buttons">
<button (click)="modifyFunc(f.name)" class="btn btn-success">
<i class="fa fa-pencil" ></i>
</button>
<button (click)="removeFunc(f.name)" class="btn btn-success">
<i class="fa fa-remove" ></i>
</button>
</div>
</div>
</li>
</ul>
</div>
</div>
<div class="panel-footer">
<div class="row">
<div class="col-md-12">
<div class="input-group input-group">
<input [(ngModel)]="_newFunction.str" placeholder="nueva función" class="form-control" >
<span class="input-group-btn">
<button class="btn btn-primary" [disabled]="this._newFunction.str==''" type="button" (click)="handleAddFunction()">Cargar función</button>
</span>
</div>
</div>
</div>
<!-- <button (click)="popToast()">pop toast</button> -->
</div>
</div>
import { Component, OnInit } from '@angular/core';
import { Function } from './function';
import { FunctionServices } from './functions.service';
import { FunctionServicesResult } from './function.services.result';
//import {ToasterModule, ToasterService,ToasterConfig} from 'angular2-toaster';
@Component({
selector: 'functions',
templateUrl: './functions.component.html',
styleUrls: ['./functions.css'],
providers: []
})
export class FunctionsComponent implements OnInit {
title = 'Módulo de funciones';
_funcs: Function[];
_newFunction :Function = {'id':2,'name':'g','str':'g(x)=x+41'};
//_toasterService: ToasterService;
//
constructor(private functionServices: FunctionServices) {
// this._toasterService = toasterService;
}
getFuncs(): void {
this.functionServices.getAll().then(result => this._funcs = result);
}
removeFunc(name:string): void{
this.functionServices.delete(name);
this.getFuncs();
}
modifyFunc(name:string): void{
var f = this.functionServices.get(name);
console.log(f);
this._newFunction = f;
}
ngOnInit(): void {
this.getFuncs();
}
handleAddFunction(): void{
if(this._newFunction.str.length>4){
this._newFunction.id =1;
}
var _f:Function = {'id':this._newFunction.id,'name':this._newFunction.str.split('(')[0], 'str':this._newFunction.str};
var response = this.functionServices.add(_f);
this._newFunction.id=0;
this._newFunction.name='';
this._newFunction.str = '';
}
}
.trash {
color:rgb(209, 91, 71);
}
.flag {
color:rgb(248, 148, 6);
}
.panel-body { padding:0px; }
.panel-footer .pagination { margin: 0; }
.panel .glyphicon,.list-group-item .glyphicon { margin-right:5px; }
.panel-body .radio, .checkbox { display:inline-block;margin:0px; }
.panel-body input[type=checkbox]:checked + label { text-decoration: line-through;color: rgb(128, 144, 160); }
.list-group-item:hover, a.list-group-item:focus {text-decoration: none;background-color: rgb(245, 245, 245);}
.list-group { margin-bottom:0px; }
\ No newline at end of file
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { FunctionsComponent } from './functions.component';
//import {ToasterModule, ToasterService} from 'angular2-toaster';
@NgModule({
imports: [
CommonModule,
FormsModule
//,ToasterModule
],
declarations: [
FunctionsComponent
],
exports:[FunctionsComponent]
})
export class FunctionsModule { }
import { Route } from '@angular/router';
import { FunctionsComponent } from './index';
export const FunctionsRoutes: Route[] = [
{
path: 'functions',
component: FunctionsComponent
}
];
import { Injectable } from '@angular/core';
import { Function } from './function';
import { FunctionServicesResult }from './function.services.result';
const regex = /^\w+\(((\w+(\s)*)?|((\w+(\s)*),(\s)*)*(\w+(\s)*))\)(\s)*=(\s)*$/g;
@Injectable()
export class FunctionServices {
getAll(): Promise<Function[]>{
return Promise.resolve(this.allfunctions);
};
delete(functionName:String):void{
console.log("deleting" + functionName);
this.allfunctions = this.allfunctions.filter(function(f){return f.name!=functionName});
};
add(f: Function): FunctionServicesResult{
console.log(f);
if(f.id!=0){
this.allfunctions.push(f);
var result : FunctionServicesResult = {'code':200,'msg':'' };
} else {
var result : FunctionServicesResult = {'code':500,'msg':'Función no válida' };
}
return result;
};
get(name:string){
try{
return this.allfunctions.filter(function(f){return f.name===name})[0];
} catch(err){
return null;
}
};
getToPlot(name:string){
console.log("Functions: ");
console.log(this.allfunctions);
try{
return this.allfunctions.filter(function(f){return f.name===name})[0].str.split("=")[1];
} catch(err){
return null;
}
};
private allfunctions : Function[] = [{'id':12,'name':'f', 'str':'f(x)=x+5'}];
}
\ No newline at end of file
/**
* This barrel file provides the export for the lazy loaded BlankpageComponent.
*/
export * from './functions.component';
export * from './functions.routes';
......@@ -2,7 +2,6 @@ import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { CanvasModule } from '../canvas/canvas.module'
import { MateFunComponent } from './matefun.component';
import { FunctionsModule } from '../functions/functions.module'
import { BootstrapModalModule } from 'ng2-bootstrap-modal';
import { ConfirmComponent } from './confirm.component';
import { SeleccionarDirectorioComp } from './seleccionarDirectorio.component';
......@@ -17,7 +16,6 @@ import { NotificacionModule } from '../../notificacion/notificacion.module';
FormsModule,
CanvasModule,
NotificacionModule,
FunctionsModule,
MateFunRoutingModule,
CodemirrorModule,
NgbModule,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment