Skip to content
Snippets Groups Projects
Commit 2df07227 authored by Gonzalo Fabian Cameto Hernandez's avatar Gonzalo Fabian Cameto Hernandez
Browse files

Elimino carpeta functions no utilizada

parent 7f27693c
No related branches found
No related tags found
No related merge requests found
Showing
with 372 additions and 601 deletions
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';
import { Component, NgModule, ViewChild, HostListener, ElementRef, ComponentRef, TemplateRef } from '@angular/core';
import { CanvasModule} from '../canvas/canvas.module';
import { CanvasComponent } from '../canvas/canvas.component';
import { FunctionsModule } from '../functions/functions.module';
import { FunctionsComponent } from '../functions/functions.component';
import { Http, JsonpModule } from '@angular/http';
import { Headers, RequestOptions } from '@angular/http';
import { HaskellService } from '../../shared/services/haskell.service';
import { FunctionServices } from '../functions/functions.service';
import { WebsocketService } from '../../shared/services/websocket.service';
import { UsuarioService } from '../../shared/services/usuario.service';
import { SessionService } from '../../shared/services/session.service';
......@@ -47,7 +44,7 @@ var focus: any;
selector: 'matefun',
templateUrl: './matefun.component.html',
styleUrls: ['./matefun.component.scss'],
providers: [ WebsocketService, FunctionServices, NgbPopoverConfig, UsuarioService ]
providers: [ WebsocketService, NgbPopoverConfig, UsuarioService ]
})
......@@ -92,7 +89,6 @@ export class MateFunComponent {
private ghciService: GHCIService,
private elRef: ElementRef,
private notifService: NotificacionService,
private functionServices: FunctionServices,
private sessionService: SessionService,
private dialogService:DialogService,
private usuarioService: UsuarioService) {
......@@ -150,11 +146,6 @@ export class MateFunComponent {
componentRef.editDialogFired = true;
}
});
//We can close dialog calling disposable.unsubscribe();
//If dialog was not closed manually close it by timeout
/* setTimeout(()=>{
disposable.unsubscribe();
},10000);*/
}
/* Panel para la posición del cursor */
......@@ -190,21 +181,6 @@ export class MateFunComponent {
that.saveConfig();
}
});
/*
this.codemirror.instance.on("gutterClick", function(cm, n) {
var info = cm.lineInfo(n);
var makeMarker = function() {
var marker = document.createElement("div");
marker.style.width = "15px";
marker.style.height = "15px";
marker.style.marginLeft = "-5px";
marker.style.cursor = "pointer";
marker.style["background-image"] = "url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAANlBMVEX/uwDvrwD/uwD/uwD/uwD/uwD/uwD/uwD/uwD6twD/uwAAAADurwD2tQD7uAD+ugAAAAD/uwDhmeTRAAAADHRSTlMJ8mN1EYcbmiixgACm7WbuAAAAVklEQVR42n3PUQqAIBBFUU1LLc3u/jdbOJoW1P08DA9Gba8+YWJ6gNJoNYIBzAA2chBth5kLmG9YUoG0NHAUwFXwO9LuBQL1giCQb8gC9Oro2vp5rncCIY8L8uEx5ZkAAAAASUVORK5CYII=')";
marker.innerHTML = "<a href='@' title='cuidado , advertencia matefun'></a>";
return marker;
}
cm.setGutterMarker(n, "breakpoints", info.gutterMarkers ? null : makeMarker());
});*/
this.codemirror.instance.on("keypress",function(cm,name,evt){
......@@ -336,6 +312,7 @@ export class MateFunComponent {
}
document.onkeydown = KeyPress;
}
ngAfterViewInit() {
componentRef = this;
if(this.codemirror.instance!=null && !this.cursorLabelInit){
......@@ -357,6 +334,7 @@ export class MateFunComponent {
}
}
htmlEncode(value:string){
return value
.replace('Prelude> ','')
......
......@@ -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,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment