Skip to content

Commit

Permalink
Merge pull request #89 from feup-infolab/lazaroDevelop
Browse files Browse the repository at this point in the history
alternative interface finished
  • Loading branch information
lazarocosta committed Jul 9, 2020
2 parents d4a9764 + f354bac commit a3fce53
Show file tree
Hide file tree
Showing 34 changed files with 286 additions and 160 deletions.
8 changes: 8 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"@angular/platform-browser": "^7.0.0",
"@angular/platform-browser-dynamic": "^7.0.0",
"@angular/router": "^7.0.0",
"angular-notifier": "^6.0.1",
"angular7-json-schema-form": "^1.0.4",
"bootstrap": "^4.4.1",
"brace": "^0.11.1",
Expand Down
84 changes: 66 additions & 18 deletions frontend/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import {CUSTOM_ELEMENTS_SCHEMA, NgModule} from '@angular/core';
import { MyServiceService } from './service/my-service.service';
import {MyServiceService} from './service/service-service';
import {Bootstrap4FrameworkModule, MaterialDesignFrameworkModule} from 'angular7-json-schema-form';
import { AppComponent } from './app.component';
import {AppComponent} from './app.component';
import {HttpClientModule} from '@angular/common/http';
import {SearchComponent} from './components/search.component';
import {SearchComponent} from './components/search-component/search-component';
import {BrowserModule} from '@angular/platform-browser';
import {BrowserAnimationsModule, NoopAnimationsModule} from '@angular/platform-browser/animations';
import { FlexLayoutModule } from '@angular/flex-layout';
import {FlexLayoutModule} from '@angular/flex-layout';
import {CommonModule} from '@angular/common';
import {FormsModule} from '@angular/forms';
import {ComboBoxComponent} from './combo-box/combo-box.component';
import { RouterModule, Routes } from '@angular/router';
import { EditEntityComponent } from './components/edit-entity.component';
import {RouterModule, Routes} from '@angular/router';
import {EditEntityComponent} from './components/edit/edit-entity/edit-entity.component';
import {MatIconModule} from '@angular/material/icon';
import {
MatButtonModule,
Expand All @@ -22,19 +22,64 @@ import {
MatSelectModule,
MatSliderModule
} from '@angular/material';
import { EditTemplateComponent } from './edit-template/edit-template.component';
import { ViewTemplateComponent } from './components/view-template.component';
import { LayoutComponent } from './components/layout.component';
import { DocumentComponentComponent } from './document-component/document-component.component';
import {EditTemplateComponent} from './components/edit/edit-template/edit-template.component';
import {ViewTemplateComponent} from './components/view/view-template/view-template.component';
import {LayoutComponent} from './components/view/layout-component/layout-component';
import {DocumentComponentComponent} from './components/view/document-component/document-component.component';
import {MatCardModule} from "@angular/material/card";
import {NotifierModule, NotifierOptions} from 'angular-notifier';

const appRoutes: Routes = [
{ path: 'edit-template/:id', component: EditTemplateComponent },
{ path: ':uid', component: EditEntityComponent },
{ path: '', component: SearchComponent },
{ path: 'viewtemplate/:uid', component: ViewTemplateComponent },
{ path: 'uidglab/:uid', component: DocumentComponentComponent}
{path: 'edit-template/:id', component: EditTemplateComponent},
{path: ':uid', component: EditEntityComponent},
{path: '', component: SearchComponent},
{path: 'viewtemplate/:uid', component: ViewTemplateComponent},
{path: 'uidglab/:uid', component: DocumentComponentComponent}

];
/**
* Custom angular notifier options
*/
const customNotifierOptions: NotifierOptions = {
position: {
horizontal: {
position: 'right',
distance: 20
},
vertical: {
position: 'top',
distance: 20,
gap: 20
}
},
theme: 'material',
behaviour: {
autoHide: 5000,
onClick: 'hide',
onMouseover: 'pauseAutoHide',
showDismissButton: true,
stacking: 4
},
animations: {
enabled: true,
show: {
preset: 'slide',
speed: 300,
easing: 'ease'
},
hide: {
preset: 'fade',
speed: 300,
easing: 'ease',
offset: 50
},
shift: {
speed: 300,
easing: 'ease'
},
overlap: 150
}
};


@NgModule({
Expand All @@ -53,6 +98,7 @@ const appRoutes: Routes = [
appRoutes,
{enableTracing: true} // <-- debugging purposes only
),
NotifierModule.withConfig(customNotifierOptions),
BrowserModule,
HttpClientModule,
MaterialDesignFrameworkModule,
Expand All @@ -70,11 +116,13 @@ const appRoutes: Routes = [
MatInputModule,
MatOptionModule,
MatSelectModule,
MatListModule
MatListModule,
MatCardModule
],
providers: [MyServiceService],
bootstrap: [ AppComponent ],
bootstrap: [AppComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class AppModule { }
export class AppModule {
}

10 changes: 8 additions & 2 deletions frontend/src/app/combo-box/combo-box.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Component, OnInit, Input, Output} from '@angular/core';
import { MyServiceService} from '../service/my-service.service';
import {MyServiceService} from '../service/service-service';

@Component({
selector: 'app-combo-box',
Expand All @@ -9,9 +9,11 @@ import { MyServiceService} from '../service/my-service.service';
export class ComboBoxComponent implements OnInit {
constructor() {
}

get inputIt() {
return this.inputItem;
}

@Input() list: string[];
// two way binding for input text
@Input() inputItem = '';
Expand All @@ -25,20 +27,23 @@ export class ComboBoxComponent implements OnInit {
ngOnInit() {
this.filteredList = this.list;
}

// modifies the filtered list as per input
getFilteredList() {
this.listHidden = false;
if (!this.listHidden && this.inputItem !== undefined) {
this.filteredList = this.list.filter((item) => item.toLowerCase().startsWith(this.inputItem.toLowerCase()));
this.filteredList = this.list.filter((item) => item.toLowerCase().startsWith(this.inputItem.toLowerCase()));
}
}

// select highlighted item when enter is pressed or any item that is clicked
selectItem(ind) {
this.inputItem = this.filteredList[ind];
this.listHidden = true;
this.selectedIndex = ind;
console.log(this.inputItem);
}

// navigate through the list of items
onKeyPress(event) {
if (!this.listHidden) {
Expand All @@ -65,6 +70,7 @@ export class ComboBoxComponent implements OnInit {
}
}
}

// show or hide the dropdown list when input is focused or moves out of focus
toggleListDisplay(sender: number) {
if (sender === 1) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<a class="navbar-brand" href="#">
Archgraph Backend Demo
Expand All @@ -24,7 +23,7 @@

<json-schema-form
*ngIf="load"
[form]= "form"
[form]="form"
[options]='jsonFormOptions'
[framework]="'bootstrap-4'"
(onSubmit)="onSubmit($event)"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import {async, ComponentFixture, TestBed} from '@angular/core/testing';

import { EditEntityComponent } from './edit-entity.component';
import {EditEntityComponent} from './edit-entity.component';

describe('EditEntityComponent', () => {
let component: EditEntityComponent;
let fixture: ComponentFixture<EditEntityComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ EditEntityComponent ]
declarations: [EditEntityComponent]
})
.compileComponents();
.compileComponents();
}));

beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Component, OnInit} from '@angular/core';
import {MyServiceService} from '../service/my-service.service';
import {MyServiceService} from '../../../service/service-service';
import {ActivatedRoute} from '@angular/router';
import {Location} from '@angular/common';

Expand Down Expand Up @@ -46,7 +46,7 @@ export class EditEntityComponent implements OnInit {
this.template = JSON.parse(query.get('template'));
console.log(this.template)
this.getSchemaNodeWithTemplate(this.uid, this.template)
});
});

});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
<div *ngIf="load" style="margin: 35px">
<json-schema-form
*ngIf="load"
[form]= "form"
[form]="form"
[options]='jsonFormOptions'
[framework]="'bootstrap-4'"
[widgets]= "yourWidgets">
[widgets]="yourWidgets">
</json-schema-form>
</div>


<div style="margin: 35px">
<app-combo-box [list]="props" class="form-control"></app-combo-box>
<button type="btn btn-primary" (click)="addProp()"> Create Field </button>
<button type="btn btn-primary" (click)="sendProps()"> Send Properties </button>
<button type="btn btn-primary" (click)="addProp()"> Create Field</button>
<button type="btn btn-primary" (click)="sendProps()"> Send Properties</button>
</div>



<!--
<json-schema-form
loadExternalAssets="true"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import {async, ComponentFixture, TestBed} from '@angular/core/testing';

import { EditTemplateComponent } from './edit-template.component';
import {EditTemplateComponent} from './edit-template.component';

describe('EditTemplateComponent', () => {
let component: EditTemplateComponent;
let fixture: ComponentFixture<EditTemplateComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ EditTemplateComponent ]
declarations: [EditTemplateComponent]
})
.compileComponents();
.compileComponents();
}));

beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {Component, OnInit, ViewChild} from '@angular/core';
import {MyServiceService} from '../service/my-service.service';
import {MyServiceService} from '../../../service/service-service';
import {ActivatedRoute} from '@angular/router';
import {Location} from '@angular/common';
import {ComboBoxComponent} from '../combo-box/combo-box.component';
import {ComboBoxComponent} from '../../../combo-box/combo-box.component';
import {NoneComponent} from 'angular7-json-schema-form';

@Component({
Expand Down Expand Up @@ -69,7 +69,7 @@ export class EditTemplateComponent implements OnInit {
.subscribe(returnedTemplate => {
this.template = returnedTemplate[0];
this.getSchemaNodeWithTemplate(uid, returnedTemplate[0]);
});
});
}

getSchemaNodeWithTemplate(uid, template) {
Expand All @@ -87,7 +87,7 @@ export class EditTemplateComponent implements OnInit {
}

getDataNodeWithTemplate(uid, template) {
this.service.getDataNodeWithTemplate(uid , template)
this.service.getDataNodeWithTemplate(uid, template)
.subscribe(result => {
this.form.data[this.uid] = result;
console.log(result);
Expand Down Expand Up @@ -175,7 +175,7 @@ export class EditTemplateComponent implements OnInit {
this.load = false;
this.chosenprops.push(this.comboBoxReference.inputItem);
this.form.data[this.uid][this.comboBoxReference.inputItem] = [];
this.form.data[this.uid][this.comboBoxReference.inputItem][0] = {name: '1', uid: '1' };
this.form.data[this.uid][this.comboBoxReference.inputItem][0] = {name: '1', uid: '1'};
const schemaEntity = this.schemaname.replace('Schema', '');
this.template[schemaEntity][this.comboBoxReference.inputItem] = this.allprops[this.comboBoxReference.inputItem].items.$ref
.replace('Schema', '').replace('#/definitions/', '');
Expand All @@ -186,7 +186,7 @@ export class EditTemplateComponent implements OnInit {

sendProps() {
this.service.sendTemplate(this.uid, this.template)
.subscribe( result => {
.subscribe(result => {
this.load = true;
});
}
Expand Down
15 changes: 0 additions & 15 deletions frontend/src/app/components/layout.component.ts

This file was deleted.

Loading

0 comments on commit a3fce53

Please sign in to comment.