From abef34ecb3beb469946a08b5295c08792f1ee4c7 Mon Sep 17 00:00:00 2001 From: Nikolaos Laskaris Date: Wed, 8 Nov 2017 12:35:56 +0200 Subject: [PATCH] fixing --- dmp-frontend/src/app/app.module.ts | 4 +- .../autocomplete-remote.component.css | 0 .../autocomplete-remote.component.html | 9 +++ .../autocomplete-remote.component.spec.ts | 25 ++++++++ .../autocomplete-remote.component.ts | 39 ++++++++++++ dmp-frontend/src/app/services/rest-base.ts | 2 +- .../src/app/services/server.service.ts | 63 ++----------------- .../jquery-editable-select.min.css | 2 + .../jquery-editable-select.min.js | 2 + dmp-frontend/src/index.html | 4 ++ 10 files changed, 90 insertions(+), 60 deletions(-) create mode 100644 dmp-frontend/src/app/form/fields/autocomplete-remote/autocomplete-remote.component.css create mode 100644 dmp-frontend/src/app/form/fields/autocomplete-remote/autocomplete-remote.component.html create mode 100644 dmp-frontend/src/app/form/fields/autocomplete-remote/autocomplete-remote.component.spec.ts create mode 100644 dmp-frontend/src/app/form/fields/autocomplete-remote/autocomplete-remote.component.ts create mode 100644 dmp-frontend/src/assets/editable-select/jquery-editable-select.min.css create mode 100644 dmp-frontend/src/assets/editable-select/jquery-editable-select.min.js diff --git a/dmp-frontend/src/app/app.module.ts b/dmp-frontend/src/app/app.module.ts index 726c68d97..c2d51affb 100644 --- a/dmp-frontend/src/app/app.module.ts +++ b/dmp-frontend/src/app/app.module.ts @@ -67,6 +67,7 @@ import { NgDatepickerModule } from 'ng2-datepicker'; import { StatusToString } from './pipes/various/status-to-string'; import { SidebarModule } from 'ng-sidebar'; import { UserWorkspaceComponent } from './user-workspace/user-workspace.component'; +import { AutocompleteRemoteComponent } from './form/fields/autocomplete-remote/autocomplete-remote.component'; @@ -90,7 +91,8 @@ import { UserWorkspaceComponent } from './user-workspace/user-workspace.componen DatasetsComponent, UserWorkspaceComponent, ConfirmationComponent, - + AutocompleteRemoteComponent, + ProjectTableFilterPipe, DmpVersionFilterPipe, DmpStatusFilterPipe, diff --git a/dmp-frontend/src/app/form/fields/autocomplete-remote/autocomplete-remote.component.css b/dmp-frontend/src/app/form/fields/autocomplete-remote/autocomplete-remote.component.css new file mode 100644 index 000000000..e69de29bb diff --git a/dmp-frontend/src/app/form/fields/autocomplete-remote/autocomplete-remote.component.html b/dmp-frontend/src/app/form/fields/autocomplete-remote/autocomplete-remote.component.html new file mode 100644 index 000000000..e9216b64d --- /dev/null +++ b/dmp-frontend/src/app/form/fields/autocomplete-remote/autocomplete-remote.component.html @@ -0,0 +1,9 @@ +
+ + +
\ No newline at end of file diff --git a/dmp-frontend/src/app/form/fields/autocomplete-remote/autocomplete-remote.component.spec.ts b/dmp-frontend/src/app/form/fields/autocomplete-remote/autocomplete-remote.component.spec.ts new file mode 100644 index 000000000..b49ca7112 --- /dev/null +++ b/dmp-frontend/src/app/form/fields/autocomplete-remote/autocomplete-remote.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { AutocompleteRemoteComponent } from './autocomplete-remote.component'; + +describe('AutocompleteRemoteComponent', () => { + let component: AutocompleteRemoteComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ AutocompleteRemoteComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(AutocompleteRemoteComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should be created', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/dmp-frontend/src/app/form/fields/autocomplete-remote/autocomplete-remote.component.ts b/dmp-frontend/src/app/form/fields/autocomplete-remote/autocomplete-remote.component.ts new file mode 100644 index 000000000..fa319177d --- /dev/null +++ b/dmp-frontend/src/app/form/fields/autocomplete-remote/autocomplete-remote.component.ts @@ -0,0 +1,39 @@ +import { Component, OnInit,Input, Output } from '@angular/core'; + +declare var $: any; + + +@Component({ + selector: 'autocomplete-remote', + templateUrl: './autocomplete-remote.component.html', + styleUrls: ['./autocomplete-remote.component.css'] +}) + +export class AutocompleteRemoteComponent implements OnInit { + + constructor() { + + } + + @Input() id : string = "test-field-123"; + @Input() label : string = "Test"; + @Input() url : string = "Test"; + @Output() selectedValue : string; + + allValues : string[]; + + query : string = null; + + ngOnInit() { + $('#'+this.id).editableSelect(); + + } + + updateByQuery(query){ + if(query){ + + } + } + + +} diff --git a/dmp-frontend/src/app/services/rest-base.ts b/dmp-frontend/src/app/services/rest-base.ts index a73c4f70a..b2cb5b57b 100644 --- a/dmp-frontend/src/app/services/rest-base.ts +++ b/dmp-frontend/src/app/services/rest-base.ts @@ -33,7 +33,7 @@ export class RestBase { webappname: string = "dmp-backend"; - + proxyPath : string = this.protocol+"://"+this.hostname+":"+this.port+"/"+this.webappname+"/proxy/"; loginPath : string = this.protocol+"://"+this.hostname+":"+this.port+"/"+this.webappname+"/login/"; restPath: string = this.protocol+"://"+this.hostname+":"+this.port+"/"+this.webappname+"/rest/"; diff --git a/dmp-frontend/src/app/services/server.service.ts b/dmp-frontend/src/app/services/server.service.ts index 008ca71c5..bd1d19db6 100644 --- a/dmp-frontend/src/app/services/server.service.ts +++ b/dmp-frontend/src/app/services/server.service.ts @@ -1,12 +1,10 @@ import {Injectable, ReflectiveInjector, Injector} from '@angular/core'; -import { HttpClient , HttpHeaders, HttpParams} from '@angular/common/http'; import {FieldBase} from '../../app/form/fields/field-base'; import {JsonObjest} from '../../app/entities/JsonObject.class'; import {dataModelBuilder} from '../../app/services/dataModelBuilder.service'; import { DatasetProfile } from '../entities/datasetprofile'; import {DataModel} from '../entities/DataModel'; import {Project} from '../entities/model/project'; -import { TokenService, TokenProvider } from './login/token.service'; import {RestBase} from './rest-base'; import 'rxjs/Rx'; @@ -18,7 +16,7 @@ export class ServerService { xml2jsonOBJ: any; - constructor(private httpClient: HttpClient, private tokenService: TokenService, private restBase: RestBase) { //private http: Http + constructor(private restBase: RestBase) { this.xml2jsonOBJ = new X2JS(); } @@ -143,68 +141,17 @@ public deleteDataset(dataset: any){ } - +/* logOut() { this.tokenService.logout(); } - - - getData() { - - //let headers = new HttpHeaders(); - - // let headers = new HttpHeaders().set("google-token", this.tokenService.getToken()); - - // console.log("google-token: "+ this.tokenService.getToken()); - - // return this.httpClient.get(this.fetchURL); - return this.restBase.get("dmps/9a4a4a57-4d01-465e-9887-254534f31600"); - -/* - return this.http.get(this.fetchURL) - .map( - (response: Response) => { - console.log("response"); - console.log(response); - const data = response.json(); - - //replace the xmls {model,view,rule} definitions with json -- https://github.com/abdmob/x2js library - data.dataset.profile.definition = this.xml2jsonOBJ.xml_str2json(data.dataset.profile.definition); - data.dataset.profile.ruleset.definition = this.xml2jsonOBJ.xml_str2json(data.dataset.profile.ruleset.definition); - data.dataset.profile.viewstyle.definition = this.xml2jsonOBJ.xml_str2json(data.dataset.profile.viewstyle.definition); - //can be converted back to xml (which shouldn't be needed) with this.xml2jsonOBJ.json2xml_str - - this.data = data; //cache it for subsequent calls - return data; - } - ); */ + + getThroughProxy(url : string){ } - getProjects(){ - let headers = new HttpHeaders().set("google-token", this.tokenService.getToken()); - - console.log("google-token: "+ this.tokenService.getToken()); - - return this.httpClient.get("http://dl010.madgik.di.uoa.gr:8080/dmp-backend-no-sec/rest/project/getAll"); - - // let projects :Project[] =[]; - - // let project = new Project; - // project.name = "Project1"; - // project.id = "Project1Id"; - - // projects.push(project); - - // let project2 = new Project; - // project2.name = "Project2"; - // project2.id = "Project2Id"; - - // projects.push(project2); - - // return projects; - } + } \ No newline at end of file diff --git a/dmp-frontend/src/assets/editable-select/jquery-editable-select.min.css b/dmp-frontend/src/assets/editable-select/jquery-editable-select.min.css new file mode 100644 index 000000000..89638ea25 --- /dev/null +++ b/dmp-frontend/src/assets/editable-select/jquery-editable-select.min.css @@ -0,0 +1,2 @@ +/*! jQuery Editable Select - v2.2.5 - https://github.com/indrimuska/jquery-editable-select - (c) 2016 Indri Muska - MIT */ +input.es-input{padding-right:20px!important;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAICAYAAADJEc7MAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAIGNIUk0AAG2YAABzjgAA4DIAAIM2AAB5CAAAxgwAADT6AAAgbL5TJ5gAAABGSURBVHjaYvz//z8DOYCJgUzA0tnZidPK8vJyRpw24pLEpwnuVHRFhDQxMDAwMPz//x+OOzo6/iPz8WFGuocqAAAA//8DAD/sORHYg7kaAAAAAElFTkSuQmCC) right center no-repeat}input.es-input.open{-webkit-border-bottom-left-radius:0;-moz-border-radius-bottomleft:0;border-bottom-left-radius:0;-webkit-border-bottom-right-radius:0;-moz-border-radius-bottomright:0;border-bottom-right-radius:0}.es-list{position:absolute;padding:0;margin:0;border:1px solid #d1d1d1;display:none;z-index:1000;background:#fff;max-height:160px;overflow-y:auto;-moz-box-shadow:0 2px 3px #ccc;-webkit-box-shadow:0 2px 3px #ccc;box-shadow:0 2px 3px #ccc}.es-list li{display:block;padding:5px 10px;margin:0}.es-list li.selected{background:#f3f3f3}.es-list li[disabled]{opacity:.5} \ No newline at end of file diff --git a/dmp-frontend/src/assets/editable-select/jquery-editable-select.min.js b/dmp-frontend/src/assets/editable-select/jquery-editable-select.min.js new file mode 100644 index 000000000..bba09fa2b --- /dev/null +++ b/dmp-frontend/src/assets/editable-select/jquery-editable-select.min.js @@ -0,0 +1,2 @@ +/*! jQuery Editable Select - v2.2.5 - https://github.com/indrimuska/jquery-editable-select - (c) 2016 Indri Muska - MIT */ ++function(a){EditableSelect=function(b,c){this.options=c,this.$select=a(b),this.$input=a(''),this.$list=a('
    '),this.utility=new EditableSelectUtility(this),["focus","manual"].indexOf(this.options.trigger)<0&&(this.options.trigger="focus"),["default","fade","slide"].indexOf(this.options.effects)<0&&(this.options.effects="default"),isNaN(this.options.duration)&&["fast","slow"].indexOf(this.options.duration)<0&&(this.options.duration="fast"),this.$select.replaceWith(this.$input),this.$list.appendTo(this.options.appendTo||this.$input.parent()),this.utility.initialize(),this.utility.initializeList(),this.utility.initializeInput(),this.utility.trigger("created")},EditableSelect.DEFAULTS={filter:!0,effects:"default",duration:"fast",trigger:"focus"},EditableSelect.prototype.filter=function(){var b=0,c=this.$input.val().toLowerCase().trim();this.$list.find("li").addClass("es-visible").show(),this.options.filter&&(b=this.$list.find("li").filter(function(b,d){return a(d).text().toLowerCase().indexOf(c)<0}).hide().removeClass("es-visible").length,this.$list.find("li").length==b&&this.hide())},EditableSelect.prototype.show=function(){if(this.$list.css({top:this.$input.position().top+this.$input.outerHeight()-1,left:this.$input.position().left,width:this.$input.outerWidth()}),!this.$list.is(":visible")&&this.$list.find("li.es-visible").length>0){var b={"default":"show",fade:"fadeIn",slide:"slideDown"},c=b[this.options.effects];this.utility.trigger("show"),this.$input.addClass("open"),this.$list[c](this.options.duration,a.proxy(this.utility.trigger,this.utility,"shown"))}},EditableSelect.prototype.hide=function(){var b={"default":"hide",fade:"fadeOut",slide:"slideUp"},c=b[this.options.effects];this.utility.trigger("hide"),this.$input.removeClass("open"),this.$list[c](this.options.duration,a.proxy(this.utility.trigger,this.utility,"hidden"))},EditableSelect.prototype.select=function(a){this.$list.has(a)&&a.is("li.es-visible:not([disabled])")&&(this.$input.val(a.text()),this.options.filter&&this.hide(),this.filter(),this.utility.trigger("select",a))},EditableSelect.prototype.add=function(b,c,d,e){var f=a("
  • ").html(b),g=a("