Fix toolbar and reformat backend code
This commit is contained in:
parent
30433e5985
commit
2a7aa2a65a
18 changed files with 729 additions and 728 deletions
|
@ -19,12 +19,13 @@ import {
|
||||||
Course,
|
Course,
|
||||||
Requirement,
|
Requirement,
|
||||||
} from '../models';
|
} from '../models';
|
||||||
import {CourseRepository} from '../repositories';
|
import { CourseRepository } from '../repositories';
|
||||||
|
|
||||||
export class CourseRequirementController {
|
export class CourseRequirementController {
|
||||||
constructor(
|
constructor(
|
||||||
@repository(CourseRepository) protected courseRepository: CourseRepository,
|
@repository(CourseRepository) protected courseRepository: CourseRepository,
|
||||||
) { }
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
@get('/courses/{id}/requirements', {
|
@get('/courses/{id}/requirements', {
|
||||||
responses: {
|
responses: {
|
||||||
|
|
|
@ -10,13 +10,14 @@ import {
|
||||||
Course,
|
Course,
|
||||||
Subject,
|
Subject,
|
||||||
} from '../models';
|
} from '../models';
|
||||||
import {CourseRepository} from '../repositories';
|
import { CourseRepository } from '../repositories';
|
||||||
|
|
||||||
export class CourseSubjectController {
|
export class CourseSubjectController {
|
||||||
constructor(
|
constructor(
|
||||||
@repository(CourseRepository)
|
@repository(CourseRepository)
|
||||||
public courseRepository: CourseRepository,
|
public courseRepository: CourseRepository,
|
||||||
) { }
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
@get('/courses/{id}/subject', {
|
@get('/courses/{id}/subject', {
|
||||||
responses: {
|
responses: {
|
||||||
|
|
|
@ -5,7 +5,7 @@ import {
|
||||||
repository,
|
repository,
|
||||||
Where,
|
Where,
|
||||||
} from '@loopback/repository';
|
} from '@loopback/repository';
|
||||||
import {
|
import {
|
||||||
del,
|
del,
|
||||||
get,
|
get,
|
||||||
getModelSchemaRef,
|
getModelSchemaRef,
|
||||||
|
@ -16,15 +16,16 @@ import {
|
||||||
requestBody,
|
requestBody,
|
||||||
} from '@loopback/rest';
|
} from '@loopback/rest';
|
||||||
import {
|
import {
|
||||||
Course,
|
Course,
|
||||||
User,
|
User,
|
||||||
} from '../models';
|
} from '../models';
|
||||||
import {CourseRepository} from '../repositories';
|
import { CourseRepository } from '../repositories';
|
||||||
|
|
||||||
export class CourseUserController {
|
export class CourseUserController {
|
||||||
constructor(
|
constructor(
|
||||||
@repository(CourseRepository) protected courseRepository: CourseRepository,
|
@repository(CourseRepository) protected courseRepository: CourseRepository,
|
||||||
) { }
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
@get('/courses/{id}/users', {
|
@get('/courses/{id}/users', {
|
||||||
responses: {
|
responses: {
|
||||||
|
|
|
@ -19,12 +19,13 @@ import {
|
||||||
Subject,
|
Subject,
|
||||||
Course,
|
Course,
|
||||||
} from '../models';
|
} from '../models';
|
||||||
import {SubjectRepository} from '../repositories';
|
import { SubjectRepository } from '../repositories';
|
||||||
|
|
||||||
export class SubjectCourseController {
|
export class SubjectCourseController {
|
||||||
constructor(
|
constructor(
|
||||||
@repository(SubjectRepository) protected subjectRepository: SubjectRepository,
|
@repository(SubjectRepository) protected subjectRepository: SubjectRepository,
|
||||||
) { }
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
@get('/subjects/{id}/courses', {
|
@get('/subjects/{id}/courses', {
|
||||||
responses: {
|
responses: {
|
||||||
|
|
|
@ -5,7 +5,7 @@ import {
|
||||||
repository,
|
repository,
|
||||||
Where,
|
Where,
|
||||||
} from '@loopback/repository';
|
} from '@loopback/repository';
|
||||||
import {
|
import {
|
||||||
del,
|
del,
|
||||||
get,
|
get,
|
||||||
getModelSchemaRef,
|
getModelSchemaRef,
|
||||||
|
@ -16,15 +16,16 @@ import {
|
||||||
requestBody,
|
requestBody,
|
||||||
} from '@loopback/rest';
|
} from '@loopback/rest';
|
||||||
import {
|
import {
|
||||||
User,
|
User,
|
||||||
Course,
|
Course,
|
||||||
} from '../models';
|
} from '../models';
|
||||||
import {UserRepository} from '../repositories';
|
import { UserRepository } from '../repositories';
|
||||||
|
|
||||||
export class UserCourseController {
|
export class UserCourseController {
|
||||||
constructor(
|
constructor(
|
||||||
@repository(UserRepository) protected userRepository: UserRepository,
|
@repository(UserRepository) protected userRepository: UserRepository,
|
||||||
) { }
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
@get('/users/{id}/courses', {
|
@get('/users/{id}/courses', {
|
||||||
responses: {
|
responses: {
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
import {Count, CountSchema, Filter, FilterExcludingWhere, repository, Where,} from '@loopback/repository';
|
import { Count, CountSchema, Filter, FilterExcludingWhere, repository, Where, } from '@loopback/repository';
|
||||||
import { del, get, getModelSchemaRef, HttpErrors, param, patch, post, Request, requestBody, response, RestBindings, } from '@loopback/rest';
|
import { del, get, getModelSchemaRef, HttpErrors, param, patch, post, Request, requestBody, response, RestBindings, } from '@loopback/rest';
|
||||||
import {User} from '../models';
|
import { User } from '../models';
|
||||||
import {UserRepository} from '../repositories';
|
import { UserRepository } from '../repositories';
|
||||||
import {
|
import {
|
||||||
TokenServiceBindings,
|
TokenServiceBindings,
|
||||||
UserServiceBindings
|
UserServiceBindings
|
||||||
} from '@loopback/authentication-jwt';
|
} from '@loopback/authentication-jwt';
|
||||||
import {inject} from '@loopback/core';
|
import { inject } from '@loopback/core';
|
||||||
import {authenticate, TokenService} from '@loopback/authentication';
|
import { authenticate, TokenService } from '@loopback/authentication';
|
||||||
import {SecurityBindings, UserProfile} from '@loopback/security';
|
import { SecurityBindings, UserProfile } from '@loopback/security';
|
||||||
import {genSalt, hash} from 'bcryptjs';
|
import { genSalt, hash } from 'bcryptjs';
|
||||||
import {SzakdolgozatUserService} from '../services';
|
import { SzakdolgozatUserService } from '../services';
|
||||||
|
|
||||||
export class UserController {
|
export class UserController {
|
||||||
constructor(
|
constructor(
|
||||||
|
@ -197,11 +197,12 @@ export class UserController {
|
||||||
})
|
})
|
||||||
user: User,
|
user: User,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
if(id === +this.user.id) {
|
if (id === +this.user.id) {
|
||||||
const loggedInUser = await this.userService.findUserById(this.user.id);
|
const loggedInUser = await this.userService.findUserById(this.user.id);
|
||||||
if(user.isAdmin !== undefined && loggedInUser.isAdmin !== user.isAdmin)
|
if (user.isAdmin !== undefined && loggedInUser.isAdmin !== user.isAdmin) {
|
||||||
throw new HttpErrors.BadRequest('Cannot change admin status of self');
|
throw new HttpErrors.BadRequest('Cannot change admin status of self');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
await this.userRepository.updateById(id, user);
|
await this.userRepository.updateById(id, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import {Entity, model, property} from '@loopback/repository';
|
import { Entity, model, property } from '@loopback/repository';
|
||||||
|
|
||||||
@model()
|
@model()
|
||||||
export class CourseUser extends Entity {
|
export class CourseUser extends Entity {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import {Entity, model, property, belongsTo, hasMany} from '@loopback/repository';
|
import { Entity, model, property, belongsTo, hasMany } from '@loopback/repository';
|
||||||
import {Subject} from './subject.model';
|
import { Subject } from './subject.model';
|
||||||
import {User} from './user.model';
|
import { User } from './user.model';
|
||||||
import {CourseUser} from './course-user.model';
|
import { CourseUser } from './course-user.model';
|
||||||
import {Requirement} from './requirement.model';
|
import { Requirement } from './requirement.model';
|
||||||
|
|
||||||
@model()
|
@model()
|
||||||
export class Course extends Entity {
|
export class Course extends Entity {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import {Entity, model, property} from '@loopback/repository';
|
import { Entity, model, property } from '@loopback/repository';
|
||||||
|
|
||||||
@model()
|
@model()
|
||||||
export class Requirement extends Entity {
|
export class Requirement extends Entity {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import {Entity, model, property, hasMany} from '@loopback/repository';
|
import { Entity, model, property, hasMany } from '@loopback/repository';
|
||||||
import {Course} from './course.model';
|
import { Course } from './course.model';
|
||||||
|
|
||||||
@model()
|
@model()
|
||||||
export class Subject extends Entity {
|
export class Subject extends Entity {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import {Entity, model, property, hasMany} from '@loopback/repository';
|
import { Entity, model, property, hasMany } from '@loopback/repository';
|
||||||
import {Course} from './course.model';
|
import { Course } from './course.model';
|
||||||
import {CourseUser} from './course-user.model';
|
import { CourseUser } from './course-user.model';
|
||||||
|
|
||||||
@model()
|
@model()
|
||||||
export class User extends Entity {
|
export class User extends Entity {
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
import {inject} from '@loopback/core';
|
import { inject } from '@loopback/core';
|
||||||
import {DefaultCrudRepository} from '@loopback/repository';
|
import { DefaultCrudRepository } from '@loopback/repository';
|
||||||
import {DatabaseDataSource} from '../datasources';
|
import { DatabaseDataSource } from '../datasources';
|
||||||
import {CourseUser, CourseUserRelations} from '../models';
|
import { CourseUser, CourseUserRelations } from '../models';
|
||||||
|
|
||||||
export class CourseUserRepository extends DefaultCrudRepository<
|
export class CourseUserRepository extends DefaultCrudRepository<CourseUser,
|
||||||
CourseUser,
|
|
||||||
typeof CourseUser.prototype.id,
|
typeof CourseUser.prototype.id,
|
||||||
CourseUserRelations
|
CourseUserRelations> {
|
||||||
> {
|
|
||||||
constructor(
|
constructor(
|
||||||
@inject('datasources.database') dataSource: DatabaseDataSource,
|
@inject('datasources.database') dataSource: DatabaseDataSource,
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -1,24 +1,27 @@
|
||||||
import {inject, Getter} from '@loopback/core';
|
import { inject, Getter } from '@loopback/core';
|
||||||
import {DefaultCrudRepository, repository, BelongsToAccessor, HasManyThroughRepositoryFactory, HasManyRepositoryFactory} from '@loopback/repository';
|
import {
|
||||||
import {DatabaseDataSource} from '../datasources';
|
DefaultCrudRepository,
|
||||||
import {Course, CourseRelations, Subject, User, CourseUser, Requirement} from '../models';
|
repository,
|
||||||
import {SubjectRepository} from './subject.repository';
|
BelongsToAccessor,
|
||||||
import {CourseUserRepository} from './course-user.repository';
|
HasManyThroughRepositoryFactory,
|
||||||
import {UserRepository} from './user.repository';
|
HasManyRepositoryFactory
|
||||||
import {RequirementRepository} from './requirement.repository';
|
} from '@loopback/repository';
|
||||||
|
import { DatabaseDataSource } from '../datasources';
|
||||||
|
import { Course, CourseRelations, Subject, User, CourseUser, Requirement } from '../models';
|
||||||
|
import { SubjectRepository } from './subject.repository';
|
||||||
|
import { CourseUserRepository } from './course-user.repository';
|
||||||
|
import { UserRepository } from './user.repository';
|
||||||
|
import { RequirementRepository } from './requirement.repository';
|
||||||
|
|
||||||
export class CourseRepository extends DefaultCrudRepository<
|
export class CourseRepository extends DefaultCrudRepository<Course,
|
||||||
Course,
|
|
||||||
typeof Course.prototype.id,
|
typeof Course.prototype.id,
|
||||||
CourseRelations
|
CourseRelations> {
|
||||||
> {
|
|
||||||
|
|
||||||
public readonly subject: BelongsToAccessor<Subject, typeof Course.prototype.id>;
|
public readonly subject: BelongsToAccessor<Subject, typeof Course.prototype.id>;
|
||||||
|
|
||||||
public readonly users: HasManyThroughRepositoryFactory<User, typeof User.prototype.id,
|
public readonly users: HasManyThroughRepositoryFactory<User, typeof User.prototype.id,
|
||||||
CourseUser,
|
CourseUser,
|
||||||
typeof Course.prototype.id
|
typeof Course.prototype.id>;
|
||||||
>;
|
|
||||||
|
|
||||||
public readonly requirements: HasManyRepositoryFactory<Requirement, typeof Course.prototype.id>;
|
public readonly requirements: HasManyRepositoryFactory<Requirement, typeof Course.prototype.id>;
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
import {inject} from '@loopback/core';
|
import { inject } from '@loopback/core';
|
||||||
import {DefaultCrudRepository} from '@loopback/repository';
|
import { DefaultCrudRepository } from '@loopback/repository';
|
||||||
import {DatabaseDataSource} from '../datasources';
|
import { DatabaseDataSource } from '../datasources';
|
||||||
import {Requirement, RequirementRelations} from '../models';
|
import { Requirement, RequirementRelations } from '../models';
|
||||||
|
|
||||||
export class RequirementRepository extends DefaultCrudRepository<
|
export class RequirementRepository extends DefaultCrudRepository<Requirement,
|
||||||
Requirement,
|
|
||||||
typeof Requirement.prototype.id,
|
typeof Requirement.prototype.id,
|
||||||
RequirementRelations
|
RequirementRelations> {
|
||||||
> {
|
|
||||||
constructor(
|
constructor(
|
||||||
@inject('datasources.database') dataSource: DatabaseDataSource,
|
@inject('datasources.database') dataSource: DatabaseDataSource,
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
import {inject, Getter} from '@loopback/core';
|
import { inject, Getter } from '@loopback/core';
|
||||||
import {DefaultCrudRepository, repository, HasManyRepositoryFactory} from '@loopback/repository';
|
import { DefaultCrudRepository, repository, HasManyRepositoryFactory } from '@loopback/repository';
|
||||||
import {DatabaseDataSource} from '../datasources';
|
import { DatabaseDataSource } from '../datasources';
|
||||||
import {Subject, SubjectRelations, Course} from '../models';
|
import { Subject, SubjectRelations, Course } from '../models';
|
||||||
import {UserRepository} from './user.repository';
|
import { UserRepository } from './user.repository';
|
||||||
import {CourseRepository} from './course.repository';
|
import { CourseRepository } from './course.repository';
|
||||||
|
|
||||||
export class SubjectRepository extends DefaultCrudRepository<
|
export class SubjectRepository extends DefaultCrudRepository<Subject,
|
||||||
Subject,
|
|
||||||
typeof Subject.prototype.id,
|
typeof Subject.prototype.id,
|
||||||
SubjectRelations
|
SubjectRelations> {
|
||||||
> {
|
|
||||||
|
|
||||||
public readonly courses: HasManyRepositoryFactory<Course, typeof Subject.prototype.id>;
|
public readonly courses: HasManyRepositoryFactory<Course, typeof Subject.prototype.id>;
|
||||||
|
|
||||||
|
|
|
@ -1,21 +1,18 @@
|
||||||
import {inject, Getter} from '@loopback/core';
|
import { inject, Getter } from '@loopback/core';
|
||||||
import { repository, HasManyThroughRepositoryFactory, DefaultTransactionalRepository } from '@loopback/repository';
|
import { repository, HasManyThroughRepositoryFactory, DefaultTransactionalRepository } from '@loopback/repository';
|
||||||
import {DatabaseDataSource} from '../datasources';
|
import { DatabaseDataSource } from '../datasources';
|
||||||
import {User, UserRelations, Course, CourseUser} from '../models';
|
import { User, UserRelations, Course, CourseUser } from '../models';
|
||||||
import {SubjectRepository} from './subject.repository';
|
import { SubjectRepository } from './subject.repository';
|
||||||
import {CourseUserRepository} from './course-user.repository';
|
import { CourseUserRepository } from './course-user.repository';
|
||||||
import {CourseRepository} from './course.repository';
|
import { CourseRepository } from './course.repository';
|
||||||
|
|
||||||
export class UserRepository extends DefaultTransactionalRepository<
|
export class UserRepository extends DefaultTransactionalRepository<User,
|
||||||
User,
|
|
||||||
typeof User.prototype.id,
|
typeof User.prototype.id,
|
||||||
UserRelations
|
UserRelations> {
|
||||||
> {
|
|
||||||
|
|
||||||
public readonly courses: HasManyThroughRepositoryFactory<Course, typeof Course.prototype.id,
|
public readonly courses: HasManyThroughRepositoryFactory<Course, typeof Course.prototype.id,
|
||||||
CourseUser,
|
CourseUser,
|
||||||
typeof User.prototype.id
|
typeof User.prototype.id>;
|
||||||
>;
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@inject('datasources.database') dataSource: DatabaseDataSource, @repository.getter('SubjectRepository') protected subjectRepositoryGetter: Getter<SubjectRepository>, @repository.getter('CourseUserRepository') protected courseUserRepositoryGetter: Getter<CourseUserRepository>, @repository.getter('CourseRepository') protected courseRepositoryGetter: Getter<CourseRepository>,
|
@inject('datasources.database') dataSource: DatabaseDataSource, @repository.getter('SubjectRepository') protected subjectRepositoryGetter: Getter<SubjectRepository>, @repository.getter('CourseUserRepository') protected courseUserRepositoryGetter: Getter<CourseUserRepository>, @repository.getter('CourseRepository') protected courseRepositoryGetter: Getter<CourseRepository>,
|
||||||
|
|
|
@ -3,13 +3,13 @@
|
||||||
// This file is licensed under the MIT License.
|
// This file is licensed under the MIT License.
|
||||||
// License text available at https://opensource.org/licenses/MIT
|
// License text available at https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
import {UserService} from '@loopback/authentication';
|
import { UserService } from '@loopback/authentication';
|
||||||
import {repository} from '@loopback/repository';
|
import { repository } from '@loopback/repository';
|
||||||
import {HttpErrors} from '@loopback/rest';
|
import { HttpErrors } from '@loopback/rest';
|
||||||
import {securityId, UserProfile} from '@loopback/security';
|
import { securityId, UserProfile } from '@loopback/security';
|
||||||
import {compare} from 'bcryptjs';
|
import { compare } from 'bcryptjs';
|
||||||
import {User, UserWithRelations} from '../models';
|
import { User, UserWithRelations } from '../models';
|
||||||
import {UserRepository} from '../repositories';
|
import { UserRepository } from '../repositories';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A pre-defined type for user credentials. It assumes a user logs in
|
* A pre-defined type for user credentials. It assumes a user logs in
|
||||||
|
@ -23,7 +23,8 @@ export type Credentials = {
|
||||||
export class SzakdolgozatUserService implements UserService<User, Credentials> {
|
export class SzakdolgozatUserService implements UserService<User, Credentials> {
|
||||||
constructor(
|
constructor(
|
||||||
@repository(UserRepository) public userRepository: UserRepository,
|
@repository(UserRepository) public userRepository: UserRepository,
|
||||||
) { }
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
async verifyCredentials(credentials: Credentials): Promise<User> {
|
async verifyCredentials(credentials: Credentials): Promise<User> {
|
||||||
const invalidCredentialsError = 'Invalid email or password.';
|
const invalidCredentialsError = 'Invalid email or password.';
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
</mat-nav-list>
|
</mat-nav-list>
|
||||||
</mat-sidenav>
|
</mat-sidenav>
|
||||||
<mat-sidenav-content>
|
<mat-sidenav-content>
|
||||||
<mat-toolbar color="primary">
|
<mat-toolbar color="primary" style="z-index: 1000">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
aria-label="Oldalsáv"
|
aria-label="Oldalsáv"
|
||||||
|
|
Loading…
Reference in a new issue