Commit 1c14e01a authored by Thodoris Nestoridis's avatar Thodoris Nestoridis

register + bugs

parent 516317e1
...@@ -168,7 +168,7 @@ export class BoilerplateListComponent implements OnInit { ...@@ -168,7 +168,7 @@ export class BoilerplateListComponent implements OnInit {
this.boilerplateService.getAllInfer(this.route.snapshot.params.gb) this.boilerplateService.getAllInfer(this.route.snapshot.params.gb)
.subscribe( .subscribe(
data => { data => {
console.log(data); //console.log(data);
this.currentInfer = data[0]; this.currentInfer = data[0];
this.infer = data; this.infer = data;
if (data[0]) { if (data[0]) {
...@@ -235,7 +235,9 @@ export class BoilerplateListComponent implements OnInit { ...@@ -235,7 +235,9 @@ export class BoilerplateListComponent implements OnInit {
} }
getincreq(): any { getincreq(): any {
return this.get_metrics('IncompleteRequirement').length; if(this.get_metrics('IncompleteRequirement').length>0){
return this.get_metrics('IncompleteRequirement').length;}
else return 0;
} }
} }
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
width: 350px; width: 350px;
height: 250px; height: 250px;
margin-right: 5px; margin-right: 5px;
margin-top: 10px;
} }
.mat-card-content{ .mat-card-content{
height: 100px; height: 100px;
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
<button mat-stroked-button color="primary" class="btn-block" type="submit" (click)="login(email.value, password.value)" >Log in</button> <button mat-stroked-button color="primary" class="btn-block" type="submit" (click)="login(email.value, password.value)" >Log in</button>
<!-- Register --> <!-- Register -->
<p>Not a member? <p>Not a member?
<a href="#">Register</a> <a mat-menu-item (click)="btnRegister()">Register</a>
</p> </p>
</form> </form>
</mat-card> </mat-card>
......
...@@ -40,4 +40,9 @@ export class LoginComponent implements OnInit { ...@@ -40,4 +40,9 @@ export class LoginComponent implements OnInit {
); );
} }
btnRegister () {
this.router.navigate(['signup']);
}
} }
<div style="text-align:center"> <div *ngIf='this.sended' class="alert alert-success" role="alert">Your details have been registered and you will be notified when the user account will be activated</div>
<h1> <div class="main-wrapper" margin fxLayout="row" fxLayoutAlign="center center">
Signup <mat-card class="box">
</h1> <form [formGroup]="form" (ngSubmit)="onSubmit()">
</div> <div class="form-group">
<label>Full Name</label>
<input #username type='text' placeholder='username'> <input
<input #email type='text' placeholder='email'> type="text"
<input #password1 type='password' placeholder='password1'> formControlName="fullname"
<input #password2 type='password' placeholder='password2'> class="form-control"
<button (click)="signup(username.value, email.value, password1.value, password2.value)">signup</button> [ngClass]="{ 'is-invalid': submitted && f.fullname.errors }"
<p>{{ error?.message }}</p> />
<p *ngIf="error">{{ error?.error | json }}</p> <div *ngIf="submitted && f.fullname.errors" class="invalid-feedback">
\ No newline at end of file <div *ngIf="f.fullname.errors.required">Fullname is required</div>
</div>
</div>
<div class="form-group">
<label>Username</label>
<input
type="text"
formControlName="username"
class="form-control"
[ngClass]="{ 'is-invalid': submitted && f.username.errors }"
/>
<div *ngIf="submitted && f.username.errors" class="invalid-feedback">
<div *ngIf="f.username.errors.required">Username is required</div>
<div *ngIf="f.username.errors.minlength">
Username must be at least 6 characters
</div>
<div *ngIf="f.username.errors.maxlength">
Username must not exceed 20 characters
</div>
</div>
</div>
<div class="form-group">
<label>Email</label>
<input
type="text"
formControlName="email"
class="form-control"
[ngClass]="{ 'is-invalid': submitted && f.email.errors }"
/>
<div *ngIf="submitted && f.email.errors" class="invalid-feedback">
<div *ngIf="f.email.errors.required">Email is required</div>
<div *ngIf="f.email.errors.email">Email is invalid</div>
</div>
</div>
<div class="form-group">
<label>Password</label>
<input
type="password"
formControlName="password"
class="form-control"
[ngClass]="{ 'is-invalid': submitted && f.password.errors }"
/>
<div *ngIf="submitted && f.password.errors" class="invalid-feedback">
<div *ngIf="f.password.errors.required">Password is required</div>
<div *ngIf="f.password.errors.minlength">
Password must be at least 8 characters
</div>
<div *ngIf="f.password.errors.maxlength">
Username must not exceed 40 characters
</div>
</div>
</div>
<div class="form-group">
<label>Confirm Password</label>
<input
type="password"
formControlName="confirmPassword"
class="form-control"
[ngClass]="{ 'is-invalid': submitted && f.confirmPassword.errors }"
/>
<div
*ngIf="submitted && f.confirmPassword.errors"
class="invalid-feedback"
>
<div *ngIf="f.confirmPassword.errors.required">
Confirm Password is required
</div>
<div *ngIf="f.confirmPassword.errors.matching">
Confirm Password does not match
</div>
</div>
</div>
<div class="form-group form-check">
<input
type="checkbox"
formControlName="acceptTerms"
class="form-check-input"
[ngClass]="{ 'is-invalid': submitted && f.acceptTerms.errors }"
/>
<label for="acceptTerms" class="form-check-label" matTooltip="Your data will be shared with the team, in order to verify your account." matTooltipPosition="right"
>I have read and agree to the Terms</label
>
<div *ngIf="submitted && f.acceptTerms.errors" class="invalid-feedback" >
Accept Terms is required
</div>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary" [disabled]='this.sended'>Register</button>
<button
type="button"
(click)="onReset()"
class="btn btn-warning float-right"
>
Reset
</button>
</div>
</form>
</mat-card>
</div>
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { AuthService } from './../../services/auth.service';
import { NotifierService } from "angular-notifier";
import { AbstractControl, FormBuilder, FormGroup, Validators, ValidatorFn } from '@angular/forms';
@Component({ @Component({
selector: 'app-signup', selector: 'app-signup',
...@@ -6,16 +10,88 @@ import { Component, OnInit } from '@angular/core'; ...@@ -6,16 +10,88 @@ import { Component, OnInit } from '@angular/core';
styleUrls: ['./singup.component.scss'] styleUrls: ['./singup.component.scss']
}) })
export class SignupComponent implements OnInit { export class SignupComponent implements OnInit {
private readonly notifier: NotifierService;
constructor(
private authService: AuthService,
private router: Router,
notifierService: NotifierService,
private formBuilder: FormBuilder) {this.notifier = notifierService;}
form = new FormGroup({});
submitted = false;
sended = false;
ngOnInit(): void {
this.form = this.formBuilder.group(
{
fullname: ['', Validators.required],
username: [
'',
[
Validators.required,
Validators.minLength(6),
Validators.maxLength(20)
]
],
email: ['', [Validators.required, Validators.email]],
password: [
'',
[
Validators.required,
Validators.minLength(8),
Validators.maxLength(40)
]
],
confirmPassword: ['', Validators.required],
acceptTerms: [false, Validators.requiredTrue]
},
{
validators: [this.match('password', 'confirmPassword')]
}
);
}
error: any; match(controlName: string, checkControlName: string): ValidatorFn {
return (controls: AbstractControl) => {
const control = controls.get(controlName);
const checkControl = controls.get(checkControlName);
if (checkControl?.errors && !checkControl.errors.matching) {
return null;
}
if (control?.value !== checkControl?.value) {
controls.get(checkControlName)?.setErrors({ matching: true });
return { matching: true };
} else {
return null;
}
};
}
constructor() { } get f(): { [key: string]: AbstractControl } {
return this.form.controls;
}
onSubmit(): void {
this.submitted = true
if (this.form.invalid) {
//this.notifier.notify("warning",(JSON.stringify("Invalid form")));
return;
}
this.onSign();
//console.log(JSON.stringify(this.form.value, null, 2));
}
onReset(): void {
ngOnInit() { this.submitted = false;
this.sended = false;
this.form.reset();
} }
signup(username: string, email: string, password1: string, password2: string) { onSign (){
// TODO: call signup this.authService.signup(this.form.value.fullname, this.form.value.username, this.form.value.email, this.form.value.password, this.form.value.confirmPassword).subscribe(
success => {console.log('SUCCESS');},
error => {console.log(error.statusText);
if (error.statusText == 'OK') {this.sended = true}
else{this.notifier.notify("warning",(JSON.stringify("There might be a problem with your registration. Please try again later.")));}
}
);
} }
} }
<mat-nav-list> <mat-nav-list>
<a mat-list-item routerLink="#" (click)="onSidenavClose()"> <a mat-list-item (click)="LogOut()">
<mat-icon>home</mat-icon> <span class="nav-caption">Home</span> <mat-icon>logout</mat-icon> <span class="nav-caption">Log out</span>
</a> </a>
<a mat-list-item routerLink="#" (click)="onSidenavClose()"> <!-- <a mat-list-item routerLink="#" (click)="onSidenavClose()">
<mat-icon>assignment_ind</mat-icon> <span class="nav-caption">Owner Actions</span> <mat-icon>assignment_ind</mat-icon> <span class="nav-caption">Owner Actions</span>
</a> </a>
<a mat-list-item routerLink="#" (click)="onSidenavClose()"> <a mat-list-item routerLink="#" (click)="onSidenavClose()">
...@@ -15,5 +15,5 @@ ...@@ -15,5 +15,5 @@
<mat-menu #menu="matMenu"> <mat-menu #menu="matMenu">
<button mat-menu-item (click)="onSidenavClose()">View profile</button> <button mat-menu-item (click)="onSidenavClose()">View profile</button>
<button mat-menu-item (click)="onSidenavClose()">Add contact</button> <button mat-menu-item (click)="onSidenavClose()">Add contact</button>
</mat-menu> </mat-menu> -->
</mat-nav-list> </mat-nav-list>
\ No newline at end of file
import { Component, OnInit, Output, EventEmitter } from '@angular/core'; import { Component, OnInit, Output, EventEmitter } from '@angular/core';
import { AuthService } from './../../services/auth.service';
@Component({ @Component({
selector: 'app-sidenav-list', selector: 'app-sidenav-list',
...@@ -8,10 +9,14 @@ import { Component, OnInit, Output, EventEmitter } from '@angular/core'; ...@@ -8,10 +9,14 @@ import { Component, OnInit, Output, EventEmitter } from '@angular/core';
export class SidenavListComponent implements OnInit { export class SidenavListComponent implements OnInit {
@Output() sidenavClose = new EventEmitter(); @Output() sidenavClose = new EventEmitter();
constructor() { } constructor(private authService: AuthService){}
ngOnInit() { ngOnInit() {
} }
public onSidenavClose = () => { public onSidenavClose = () => {
this.sidenavClose.emit(); this.sidenavClose.emit();
} }
LogOut() {
return this.authService.logout();
}
} }
...@@ -17,6 +17,8 @@ import { environment } from '../../environments/environment'; ...@@ -17,6 +17,8 @@ import { environment } from '../../environments/environment';
export class AuthService { export class AuthService {
private apiRoot = environment.apiroot +'auth/'; private apiRoot = environment.apiroot +'auth/';
private baseUrlgb = environment.apiroot+'api-auth/signup/'
constructor(private http: HttpClient, private router:Router) { } constructor(private http: HttpClient, private router:Router) { }
...@@ -45,8 +47,16 @@ export class AuthService { ...@@ -45,8 +47,16 @@ export class AuthService {
); );
} }
signup(username: string, email: string, password1: string, password2: string) { signup(fullname: string, username: string, email: string, password1: string, password2: string) {
// TODO: implement signup
return this.http.post(
this.baseUrlgb,
{ fullname, email, username, password1 }
).pipe(
//tap(response => this.setSession(response)),
tap(response => console.log(response)),
);
} }
logout() { logout() {
......
This diff is collapsed.
...@@ -12,6 +12,7 @@ from reqman.apps.reqtool.rest_api.services.parse_ontologies import * ...@@ -12,6 +12,7 @@ from reqman.apps.reqtool.rest_api.services.parse_ontologies import *
from pygments.formatters.html import HtmlFormatter from pygments.formatters.html import HtmlFormatter
from pygments import highlight from pygments import highlight
from subprocess import call from subprocess import call
from reqman.settings.environment import env
#get prefix syntax from the Onotlogy# #get prefix syntax from the Onotlogy#
...@@ -85,15 +86,14 @@ def create_infer_result(instance, destination): ...@@ -85,15 +86,14 @@ def create_infer_result(instance, destination):
def initialize_instances(instance): def initialize_instances(instance):
try : try :
g = Graph() g = Graph()
print(instance.ontology_file)
file_name = instance.title_bgroup.replace('/', '') file_name = instance.title_bgroup.replace('/', '')
save_path = "../../Ontologies/"+file_name+"/" save_path = "../../Ontologies/"+file_name+"/"
if (os.path.exists("../../Ontologies/"+file_name+"/") == False): if (os.path.exists("../../Ontologies/"+file_name+"/") == False):
os.mkdir("../../Ontologies/"+file_name) os.mkdir("../../Ontologies/"+file_name)
completeName = os.path.join(save_path, file_name) completeName = os.path.join(save_path, file_name)
if (instance.ontology_file != '../../Ontologies/Default'): if (instance.ontology_file != '../../Ontologies/Default'):
ont = instance.ontology_file.replace('../../Ontologies/', '') ont = instance.ontology_file.replace('../../Ontologies', '')
call("./../../Ontologies/s-get http://155.207.131.19:3030/"+ont+" default >> ../../Ontologies/"+file_name+'/'+file_name+'.ttl', shell=True) call("./../../Ontologies/s-get "+ env("FUSEKI_URL")+ ont +" default >> ../../Ontologies/"+file_name+'/'+file_name+'.ttl', shell=True)
destination=save_path+file_name+'.ttl' destination=save_path+file_name+'.ttl'
else : else :
g.load('../../Ontologies/2022_AOCS.ttl', format="turtle") g.load('../../Ontologies/2022_AOCS.ttl', format="turtle")
......
...@@ -4,8 +4,6 @@ from rdflib import ConjunctiveGraph, URIRef, RDFS, RDF, Namespace, Literal ...@@ -4,8 +4,6 @@ from rdflib import ConjunctiveGraph, URIRef, RDFS, RDF, Namespace, Literal
#from subprocess import call #from subprocess import call
#call("./../../Ontologies/s-get http://155.207.131.19:3030/Mokos_18_1_7_47/data default >> ../../Ontologies/data.ttl", shell=True)
#HERE #HERE
#list_of_DSO = ["http://delab.csd.auth.gr/ontologies/2018/SAO#","http://delab.csd.auth.gr/ontologies/2018/DSO#", "http://delab.csd.auth.gr/ontologies/2018/DSO-Automotive#", "http://delab.csd.auth.gr/ontologies/2018/DSO-Automotive-AVP#", "http://delab.csd.auth.gr/ontologies/2018/DSO-Automotive-AVP-instances#","http://delab.csd.auth.gr/ontologies/2018/RDO-instances#"] #list_of_DSO = ["http://delab.csd.auth.gr/ontologies/2018/SAO#","http://delab.csd.auth.gr/ontologies/2018/DSO#", "http://delab.csd.auth.gr/ontologies/2018/DSO-Automotive#", "http://delab.csd.auth.gr/ontologies/2018/DSO-Automotive-AVP#", "http://delab.csd.auth.gr/ontologies/2018/DSO-Automotive-AVP-instances#","http://delab.csd.auth.gr/ontologies/2018/RDO-instances#"]
list_of_DSO = [] list_of_DSO = []
......
...@@ -5,6 +5,7 @@ from django.conf.urls import url ...@@ -5,6 +5,7 @@ from django.conf.urls import url
from .views import user_views, requirements_views, main_req_views, suffix_req_views from .views import user_views, requirements_views, main_req_views, suffix_req_views
urlpatterns = [ urlpatterns = [
url(r'^signup/$', user_views.signup, name='signup'),
path('users/', user_views.UserList.as_view(), name='api-user-list'), path('users/', user_views.UserList.as_view(), name='api-user-list'),
path('users/<uuid:pk>/', user_views.UserDetail.as_view(), name='api-post-details'), path('users/<uuid:pk>/', user_views.UserDetail.as_view(), name='api-post-details'),
path('ontologies/', requirements_views.OntologiesChoicesViewSet.as_view(), name='api-get-ontologies'), path('ontologies/', requirements_views.OntologiesChoicesViewSet.as_view(), name='api-get-ontologies'),
......
...@@ -34,7 +34,7 @@ class OntologiesChoicesViewSet(APIView): ...@@ -34,7 +34,7 @@ class OntologiesChoicesViewSet(APIView):
def get(self, request): def get(self, request):
data={'datasets':''} data={'datasets':''}
try : try :
url = requests.get(env("FUSEKI_URL")+"/$/datasets", auth = HTTPBasicAuth('admin', 'pw!!!')) url = requests.get(env("FUSEKI_URL")+"/$/datasets", auth = HTTPBasicAuth(env("FUSEKI_Username"), env("FUSEKI_Password")))
text = url.text text = url.text
data = json.loads(text) data = json.loads(text)
except: except:
......
...@@ -2,6 +2,12 @@ from rest_framework.generics import ListAPIView, RetrieveAPIView ...@@ -2,6 +2,12 @@ from rest_framework.generics import ListAPIView, RetrieveAPIView
from reqman.apps.account.models import User from reqman.apps.account.models import User
from reqman.apps.reqtool.rest_api.serializers import UserSerializer from reqman.apps.reqtool.rest_api.serializers import UserSerializer
from django.http import HttpResponse
from django.views.decorators.csrf import csrf_exempt
import json
from django.core.mail import send_mail
from django.conf import settings
class UserList(ListAPIView): class UserList(ListAPIView):
queryset = User.objects.all() queryset = User.objects.all()
...@@ -11,3 +17,23 @@ class UserList(ListAPIView): ...@@ -11,3 +17,23 @@ class UserList(ListAPIView):
class UserDetail(RetrieveAPIView): class UserDetail(RetrieveAPIView):
queryset = User.objects.all() queryset = User.objects.all()
serializer_class = UserSerializer serializer_class = UserSerializer
@csrf_exempt
def signup(request):
if request.method == 'POST':
data = json.loads(request.body)
mail = data['email']
username = data['username']
password = data['password1']
send_mail(
'New register from Requirement tool',
' Username :'+username+'\n Mail:'+mail+' \n Password:'+password,
settings.EMAIL_HOST_USER,
['nestorid@gapps.auth.gr'],
fail_silently=False,
)
return HttpResponse("OK")
else:
return HttpResponse("Error")
#form = UserCreationForm()
#return render(request, 'signup.html', {'form': form})
\ No newline at end of file
...@@ -30,7 +30,7 @@ def rel(*path): ...@@ -30,7 +30,7 @@ def rel(*path):
# SECURITY WARNING: don't run with debug turned on in production! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = env.bool("REQMAN_DEBUG") DEBUG = env.bool("REQMAN_DEBUG")
ALLOWED_HOSTS = env.list("REQMAN_ALLOWED_HOSTS", default=["127.0.0.1", "155.207.131.19"]) ALLOWED_HOSTS = env.list("REQMAN_ALLOWED_HOSTS")
SECRET_KEY = env.str("REQMAN_SECRET_KEY") SECRET_KEY = env.str("REQMAN_SECRET_KEY")
...@@ -157,8 +157,21 @@ JWT_AUTH = { ...@@ -157,8 +157,21 @@ JWT_AUTH = {
CORS_ORIGIN_ALLOW_ALL = False # If this is used then `CORS_ORIGIN_WHITELIST` will not have any effect CORS_ORIGIN_ALLOW_ALL = False # If this is used then `CORS_ORIGIN_WHITELIST` will not have any effect
CORS_ALLOW_CREDENTIALS = True CORS_ALLOW_CREDENTIALS = True
CORS_ORIGIN_WHITELIST = [ CORS_ORIGIN_WHITELIST = [
'http://155.207.131.19:8081', env('UI_URL'),
] # If this is used, then not need to use `CORS_ORIGIN_ALLOW_ALL = True` ] # If this is used, then not need to use `CORS_ORIGIN_ALLOW_ALL = True`
CORS_ORIGIN_REGEX_WHITELIST = [ CORS_ORIGIN_REGEX_WHITELIST = [
'http://155.207.131.19:8081', env('UI_URL'),
] ]
CSRF_TRUSTED_ORIGINS = [env('UI_URL')]
# Email config
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = env('EMAIL_HOST')
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = env('EMAIL_HOST_USER')
EMAIL_HOST_PASSWORD = env('EMAIL_HOST_PASSWORD')
\ No newline at end of file
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