Commit 2cb66c5c authored by cazenave's avatar cazenave
Browse files

add settings

parent aa838e99
......@@ -6,18 +6,14 @@ export class AppConfiguration {
fdpurl: string;
fdpemail: string;
fdppassword: string;
constructor(private httpClient: HttpClient){};
elasticurl: string;
smartapiurl: string;
constructor(private httpClient: HttpClient){};
public ensureInit(): Promise<any> {
return new Promise((r, e) => {
this.httpClient.get("assets/conf/fdpsetting.json")
.subscribe(
(content: AppConfiguration) => {
Object.assign(this, content);
r(this);
},
reason => e(reason));
this.httpClient.get("http://localhost:8080/api/setting/load").subscribe((content: AppConfiguration) => {Object.assign(this, content);r(this);}, reason => e(reason));
});
};
......
......@@ -11,6 +11,8 @@ import { SettingfdpComponent } from './settingfdp/settingfdp.component';
import { SettingsmartapiComponent } from './settingsmartapi/settingsmartapi.component';
import { RepositoryinfoComponent } from './repositoryinfo/repositoryinfo.component';
import { SwaggereditorComponent } from './swaggereditor/swaggereditor.component';
import { ElasticsearchComponent } from './elasticsearch/elasticsearch.component'
import { PublishapiComponent } from './publishapi/publishapi.component'
const routes: Routes = [
......@@ -24,8 +26,10 @@ const routes: Routes = [
{path: 'publish', component : PublishComponent},
{path: 'settingfdp', component : SettingfdpComponent},
{path: 'settingsmartapi', component : SettingsmartapiComponent},
{path: 'swaggerapi', component : SwaggereditorComponent}
];
{path: 'swaggerapi', component : SwaggereditorComponent},
{path: 'elasticsearch', component : ElasticsearchComponent},
{path: 'publishapi', component : PublishapiComponent}
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
......
......@@ -148,14 +148,20 @@
<button mat-menu-item [matMenuTriggerFor]="subMenuDataset">Describe access to datasets</button>
<mat-menu #subMenuDataset="matMenu">
<button mat-menu-item routerLink="/swaggerapi" routerLinkActive="active">Swagger OpenAPI editor</button>
<button mat-menu-item routerLink="/publishapi" routerLinkActive="active">Publish OpenAPI file in SmartAPI</button>
<mat-divider></mat-divider>
<button mat-menu-item routerLink="/datasets" routerLinkActive="active">Select your datasets to publish</button>
</mat-menu>
<mat-divider></mat-divider>
<button mat-menu-item routerLink="/ontologie" routerLinkActive="active">Metadata mapping</button>
<mat-divider></mat-divider>
<button mat-menu-item routerLink="/settingfdp" routerLinkActive="active">FDP setting</button>
<button mat-menu-item routerLink="/settingsmartapi" routerLinkActive="active">SmartAPI setting</button>
<button mat-menu-item [matMenuTriggerFor]="subMenuSetting">Settings</button>pinel
<mat-menu #subMenuSetting="matMenu">
<button mat-menu-item routerLink="/settingfdp" routerLinkActive="active">FDP setting</button>
<button mat-menu-item routerLink="/settingsmartapi" routerLinkActive="active">SmartAPI setting</button>
<button mat-menu-item routerLink="/elasticsearch" routerLinkActive="active">Elasticsearch setting</button>
</mat-menu>
</mat-menu>
<h3 style="color:#1f77ac; margin-left: auto; margin-right: auto"> <strong>Publish your datasets in the Federated FAIR Data Space</strong></h3>
......
......@@ -30,7 +30,9 @@ import { RepositoryinfoComponent } from './repositoryinfo/repositoryinfo.compone
import { HttpClientModule, HttpClient } from '@angular/common/http';
import { FileSaverModule } from 'ngx-filesaver';
import { SwaggereditorComponent } from './swaggereditor/swaggereditor.component';
import { AppConfiguration } from './AppConfiguration'
import { AppConfiguration } from './AppConfiguration';
import { ElasticsearchComponent } from './elasticsearch/elasticsearch.component';
import { PublishapiComponent } from './publishapi/publishapi.component'
......@@ -47,7 +49,9 @@ import { AppConfiguration } from './AppConfiguration'
SettingsmartapiComponent,
UserComponent,
RepositoryinfoComponent,
SwaggereditorComponent
SwaggereditorComponent,
ElasticsearchComponent,
PublishapiComponent
],
imports: [
BrowserModule,
......
<form [formGroup]="Form" (ngSubmit)="SaveElasticsearchSetting()">
<div class="form-group">
<label>Elasticsearch Url
<input matInput placeholder="url http://" type="text" class="form-control" formControlName="elasticurl" required>
</label>
</div>
<div>
<br>
<button type="submit" class="btn btn-primary">Save elasticsearch setting</button>
</div>
</form>
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ElasticsearchComponent } from './elasticsearch.component';
describe('ElasticsearchComponent', () => {
let component: ElasticsearchComponent;
let fixture: ComponentFixture<ElasticsearchComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ElasticsearchComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ElasticsearchComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core';
import { AppConfiguration } from '../AppConfiguration';
import { HttpClient } from '@angular/common/http';
import { FileSaverService } from 'ngx-filesaver';
import { FormControl} from '@angular/forms';
import { FormGroup} from '@angular/forms';
import { Observable } from 'rxjs';
@Component({
selector: 'app-elasticsearch',
templateUrl: './elasticsearch.component.html',
styleUrls: ['./elasticsearch.component.scss']
})
export class ElasticsearchComponent implements OnInit {
Form = new FormGroup({
elasticurl: new FormControl(),
});
constructor(
private appConfig: AppConfiguration,
private http: HttpClient,
private _FileSaverService: FileSaverService
) {}
ngOnInit() {
this.Form.setValue({
elasticurl: this.appConfig.elasticurl ,
});
}
SaveElasticsearchSetting() {
let data: string;
data ='\
{\n\
"fdpurl": "'+ this.appConfig.fdpurl +'", \n\
"fdpemail": "'+ this.appConfig.fdpemail +'", \n\
"fdppassword": "'+ this.appConfig.fdppassword +'", \n\
"elasticurl": "'+ this.Form.value.elasticurl +'", \n\
"smartapiurl": "'+ this.appConfig.smartapiurl +'" \n\
}'
console.log(data);
return this.http.post("http://localhost:8080/api/setting", data,{responseType: 'text'}).subscribe( (r)=>{console.log(r)}) ;
};
}
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { PublishapiComponent } from './publishapi.component';
describe('PublishapiComponent', () => {
let component: PublishapiComponent;
let fixture: ComponentFixture<PublishapiComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ PublishapiComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(PublishapiComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-publishapi',
templateUrl: './publishapi.component.html',
styleUrls: ['./publishapi.component.scss']
})
export class PublishapiComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}
......@@ -4,6 +4,7 @@ import { HttpClient } from '@angular/common/http';
import { FileSaverService } from 'ngx-filesaver';
import { FormControl} from '@angular/forms';
import { FormGroup} from '@angular/forms';
import { Observable } from 'rxjs';
@Component({
selector: 'app-settingfdp',
......@@ -34,21 +35,18 @@ export class SettingfdpComponent implements OnInit {
}
SaveFdpSetting() {
let data: string;
data ='\
{\n\
fdpurl: "'+ this.appConfig.fdpurl +'" \n\
fdpemail: "'+ this.appConfig.fdpemail +'" \n\
fdppassword: "'+ this.appConfig.fdppassword +'" \n\
"fdpurl": "'+ this.Form.value.fdpurl + '", \n\
"fdpemail": "'+ this.Form.value.fdpemail + '", \n\
"fdppassword": "'+ this.Form.value.fdppassword + '", \n\
"elasticurl": "' + this.appConfig.elasticurl + '", \n\
"smartapiurl": "' + this.appConfig.smartapiurl + '" \n\
}'
console.log(data);
return this.http.post("/api/fdpsetting", data).subscribe( (r)=>{console.log('got r', r)}) ;
console.log(data);
return this.http.post("http://localhost:8080/api/setting", data,{responseType: 'text'}).subscribe( (r)=>{console.log(r)}) ;
};
......
<form [formGroup]="Form" (ngSubmit)="SaveSmartapiSetting()">
<div class="form-group">
<label>SmartApi Url
<input matInput placeholder="url http://" type="text" class="form-control" formControlName="smartapiurl" required>
</label>
</div>
<div>
<br>
<button type="submit" class="btn btn-primary">Save SmartApi setting</button>
</div>
</form>
\ No newline at end of file
import { Component, OnInit } from '@angular/core';
import { AppConfiguration } from '../AppConfiguration';
import { HttpClient } from '@angular/common/http';
import { FileSaverService } from 'ngx-filesaver';
import { FormControl} from '@angular/forms';
import { FormGroup} from '@angular/forms';
import { Observable } from 'rxjs';
@Component({
selector: 'app-settingsmartapi',
......@@ -8,9 +13,36 @@ import { Component, OnInit } from '@angular/core';
})
export class SettingsmartapiComponent implements OnInit {
constructor() { }
Form = new FormGroup({
smartapiurl: new FormControl(),
});
constructor(
private appConfig: AppConfiguration,
private http: HttpClient,
private _FileSaverService: FileSaverService
) {}
ngOnInit() {
this.Form.setValue({
smartapiurl: this.appConfig.smartapiurl
});
}
SaveSmartapiSetting() {
let data: string;
data ='\
{\n\
"fdpurl": "'+ this.appConfig.fdpurl +'", \n\
"fdpemail": "'+ this.appConfig.fdpemail +'", \n\
"fdppassword": "'+ this.appConfig.fdppassword +'", \n\
"elasticurl": "'+ this.appConfig.elasticurl +'", \n\
"smartapiurl": "'+ this.Form.value.smartapiurl +'" \n\
}'
console.log(data);
return this.http.post("http://localhost:8080/api/setting", data,{responseType: 'text'}).subscribe( (r)=>{console.log(r)}) ;
};
}
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