Skip to content

Commit

Permalink
Add Angular Materia
Browse files Browse the repository at this point in the history
  • Loading branch information
nunofreitas96 committed Jun 15, 2020
1 parent 49feae1 commit a931048
Show file tree
Hide file tree
Showing 14 changed files with 162 additions and 16 deletions.
4 changes: 3 additions & 1 deletion frontend/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"src/assets"
],
"styles": [
"./node_modules/@angular/material/prebuilt-themes/deeppurple-amber.css",
"src/styles.css",
"src/bootstrap.min.css"
],
Expand Down Expand Up @@ -84,6 +85,7 @@
"src/assets"
],
"styles": [
"./node_modules/@angular/material/prebuilt-themes/deeppurple-amber.css",
"src/styles.css",
"node_modules/bootstrap/dist/css/bootstrap.min.css"
],
Expand Down Expand Up @@ -126,4 +128,4 @@
"cli": {
"analytics": "8728f218-4469-4108-bde8-2ff93325bc72"
}
}
}
14 changes: 8 additions & 6 deletions frontend/package-lock.json

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

3 changes: 2 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"e2e": "ng e2e"
},
"dependencies": {
"@angular/animations": "^7.0.0",
"@angular/animations": "^9.1.11",
"@angular/cdk": "^7.0.1",
"@angular/common": "^7.0.0",
"@angular/compiler": "^7.0.0",
Expand All @@ -57,6 +57,7 @@
"bootstrap": "^4.4.1",
"brace": "^0.11.1",
"core-js": "^2.5.4",
"hammerjs": "^2.0.8",
"jquery": "^3.5.1",
"jsonpath": "^1.0.2",
"node-gyp": "^6.1.0",
Expand Down
10 changes: 7 additions & 3 deletions frontend/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,18 @@ import {ComboBoxComponent} from './combo-box/combo-box.component';
import { RouterModule, Routes } from '@angular/router';
import { EditEntityComponent } from './components/edit-entity.component';
import {MatIconModule} from '@angular/material/icon';
import {MatButtonModule} from '@angular/material';
import {MatButtonModule, 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';

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

];

Expand All @@ -35,7 +37,8 @@ const appRoutes: Routes = [
EditEntityComponent,
ViewTemplateComponent,
LayoutComponent,
EditTemplateComponent
EditTemplateComponent,
DocumentComponentComponent
],
imports: [
RouterModule.forRoot(
Expand All @@ -52,7 +55,8 @@ const appRoutes: Routes = [
NoopAnimationsModule,
FlexLayoutModule,
MatButtonModule,
MatIconModule
MatIconModule,
MatSliderModule
],
providers: [MyServiceService],
bootstrap: [ AppComponent ],
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

<mat-slider min="1" max="100" step="1" value="1"></mat-slider>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { DocumentComponentComponent } from './document-component.component';

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

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

beforeEach(() => {
fixture = TestBed.createComponent(DocumentComponentComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import {Component, NgModule, OnInit, ViewChild} from '@angular/core';
import {Location} from '@angular/common';
import {ActivatedRoute} from '@angular/router';
import {MyServiceService} from '../service/my-service.service';
import {ComboBoxComponent} from '../combo-box/combo-box.component';
import {NoneComponent} from 'angular7-json-schema-form';
import { MatSliderModule } from '@angular/material/slider';

@Component({
selector: 'app-document-component',
templateUrl: './document-component.component.html',
styleUrls: ['./document-component.component.css']
})
export class DocumentComponentComponent implements OnInit {

constructor(
private location: Location,
private route: ActivatedRoute,
private service: MyServiceService
) { }

@NgModule ({
imports: [
MatSliderModule,
]
})

@ViewChild(ComboBoxComponent) comboBoxReference;
uid = '';
name = 'Angular 7';
jsonFormOptions = {
loadExternalAssets: true,
};
schemaname = '';
schema = {};
data = {};
load = false;
form = {
schema: {},
data: {},
layout: []
};
props = [];
allprops = {};

template = {};

chosenprops = [];

yourWidgets = {
submit: NoneComponent,
};
copyProp;


ngOnInit() {
this.route.paramMap.subscribe(params => {
this.uid = params.get('uid');
this.load = false;
// this.getSchemaNode(this.uid);
this.route.queryParamMap.subscribe(query => {
this.template = JSON.parse(query.get('template'));
this.getNodeTemplate(this.uid);
});
// this.getNodeTemplate(this.uid);

});
}

getNodeTemplate(uid) {
this.service.getDocTemplate(uid)
.subscribe(returnedTemplate => {
this.template = returnedTemplate;
console.log(returnedTemplate);
});
}

}
4 changes: 4 additions & 0 deletions frontend/src/app/service/my-service.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ export class MyServiceService {
return this.http.post<any>(this.baseUrl + 'post_template' , template);
}

getDocTemplate(uid): Observable<any> {
return this.http.post<any>(this.baseUrl + 'eva' + '/' + uid, uid);
}

constructor(private http: HttpClient) {

this.shareMethod$ = this.shareMethodSubject.asObservable();
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
</head>
<body>
<app-root></app-root>
Expand Down
1 change: 1 addition & 0 deletions frontend/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'hammerjs';
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

Expand Down
3 changes: 3 additions & 0 deletions frontend/src/styles.css
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
/* You can add global styles to this file, and also import other style files */

html, body { height: 100%; }
body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif; }
1 change: 1 addition & 0 deletions frontend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"moduleResolution": "node",
"importHelpers": true,
"target": "es2015",
"skipLibCheck": true,
"lib": [
"es2018",
"dom"
Expand Down
31 changes: 26 additions & 5 deletions src/Routes/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ def get_project_root():
print("Archgraph running at " + get_project_root().as_posix())
sys.path.append(get_project_root().as_posix())


from flask import Flask, Response, jsonify, make_response, request, send_from_directory

from flask_cors import CORS, cross_origin
Expand All @@ -24,14 +23,16 @@ def get_project_root():
from src.Utils.Utils import get_node_by_uid, build_next_json, updated_node, make_result

import src.Utils.ArgParser as ArgParser

args = ArgParser.parse()

if args.neo4j and args.neo4j != "":
config.DATABASE_URL = args.neo4j
else:
config.DATABASE_URL = "bolt://neo4j:password@localhost:7687"

from src.Routes.mongo import insert_template_in_mongo, get_all_records_from_collection, get_schema_from_mongo, get_templates_from_mongo_by_classes_name
from src.Routes.mongo import insert_template_in_mongo, get_all_records_from_collection, get_schema_from_mongo, \
get_templates_from_mongo_by_classes_name

app = Flask(__name__)

Expand All @@ -41,11 +42,13 @@ def get_project_root():
app.config['JSON_SORT_KEYS'] = False
app.debug = True


@app.before_request
def log_request_info():
app.logger.debug('Headers: %s', request.headers)
app.logger.debug('Body: %s', request.get_data())


@app.after_request
def after(response):
# todo with response
Expand All @@ -54,6 +57,7 @@ def after(response):
print(response.get_data())
return response


@app.route("/favicon.ico")
def favicon():
return send_from_directory(
Expand Down Expand Up @@ -135,11 +139,11 @@ def insert_template_in_mongodb(uid):
# "E52_Time_Span": {
# "P86_falls_within": "E52_Time_Span"}
# }
#template = {
# template = {
# "E52_Time_Span": {
# "has_value": "DataObject",
# }
#}
# }
if node is not None:
schema_of_node = node.get_schema_with_template(template)
classes_name = node.get_superclasses_name()
Expand Down Expand Up @@ -208,7 +212,6 @@ def get_template():
return make_response(jsonify(template), 201)



@app.route("/schemawithtemplate/<uid>", methods=["POST"])
@cross_origin()
def get_schema(uid):
Expand Down Expand Up @@ -310,6 +313,24 @@ def search_specific(class_name, query):
return make_response(jsonify(message="Failed Search"), 404)


@app.route("/eva/<uid>", methods=["POST"])
@cross_origin()
def get_doc(uid):
#node = get_node_by_uid(uid)
template = {
"E22_Human_Made_Object": {
"P102_has_title": ["ARE2_formal_title", "Título"],
"P1_is_identified_by ": ["Código de Referência", "PT/ADPRT"]
}
}

print(template)
if template is not None:
return make_response(jsonify(template), 201)
else:
make_response(jsonify(message="Template doesn't exists"), 404)


# delete_collection("defaultTemplate")
# json = read_file("../Utils/defaultTemplates.json")
# populate_template_collection(json)
Expand Down

0 comments on commit a931048

Please sign in to comment.