diff options
39 files changed, 751 insertions, 308 deletions
diff --git a/backend/api/api/Controllers/AuthController.cs b/backend/api/api/Controllers/AuthController.cs index 6dfe483a..7167d1bf 100644 --- a/backend/api/api/Controllers/AuthController.cs +++ b/backend/api/api/Controllers/AuthController.cs @@ -49,8 +49,6 @@ namespace api.Controllers return Ok(newToken); - - } diff --git a/backend/api/api/Controllers/DatasetController.cs b/backend/api/api/Controllers/DatasetController.cs index fcebc4b0..3d008744 100644 --- a/backend/api/api/Controllers/DatasetController.cs +++ b/backend/api/api/Controllers/DatasetController.cs @@ -18,32 +18,32 @@ namespace api.Controllers } - // GET: api/<DatasetController>/{id}/datasets - [HttpGet("{id}/datasets")] - public ActionResult<List<Dataset>> Get(string id) + // GET: api/<DatasetController>/{username}/datasets + [HttpGet("{username}/datasets")] + public ActionResult<List<Dataset>> Get(string username) { - return _datasetService.GetAllDatesets(id); + return _datasetService.GetAllDatesets(username); } - // GET api/<DatasetController>/{id}/{name} - [HttpGet("{id}/{name}")] - public ActionResult<Dataset> Get(string id, string name) + // GET api/<DatasetController>/{username}/{name} + [HttpGet("{username}/{name}")] + public ActionResult<Dataset> Get(string username, string name) { - var dataset = _datasetService.GetOneDataset(id, name); + var dataset = _datasetService.GetOneDataset(username, name); if (dataset == null) - return NotFound($"Dataset with name = {name} or user with id = {id} not found"); + return NotFound($"Dataset with name = {name} or user with username = {username} not found"); return dataset; } - // POST api/<DatasetController>/post - [HttpPost("post")] + // POST api/<DatasetController>/add + [HttpPost("add")] public ActionResult<Dataset> Post([FromBody] Dataset dataset) { - var existingUser = _datasetService.GetOneDataset(dataset.uploaderId,dataset.name); + var existingDataset = _datasetService.GetOneDataset(dataset.username, dataset.name); - if (existingUser != null) + if (existingDataset != null) return NotFound($"Dateset with name = {dataset.name} exisits"); else { @@ -53,30 +53,30 @@ namespace api.Controllers } } - // PUT api/<DatasetController>/{id}/{name} - [HttpPut("{id}/{name}")] - public ActionResult Put(string id, string name, [FromBody] Dataset dataset) + // PUT api/<DatasetController>/{username}/{name} + [HttpPut("{username}/{name}")] + public ActionResult Put(string username, string name, [FromBody] Dataset dataset) { - var existingDataset = _datasetService.GetOneDataset(id, name); + var existingDataset = _datasetService.GetOneDataset(username, name); //ne mora da se proverava if (existingDataset == null) - return NotFound($"Dataset with name = {name} or user with id = {id} not found"); + return NotFound($"Dataset with name = {name} or user with username = {username} not found"); - _datasetService.Update(id, name, dataset); + _datasetService.Update(username, name, dataset); return NoContent(); } - // DELETE api/<DatasetController>/5 - [HttpDelete("{id}")] - public ActionResult Delete(string id, string name) + // DELETE api/<DatasetController>/username/name + [HttpDelete("{username}/{name}")] + public ActionResult Delete(string username, string name) { - var dataset = _datasetService.GetOneDataset(id, name); + var dataset = _datasetService.GetOneDataset(username, name); if (dataset == null) - return NotFound($"Dataset with name = {name} or user with id = {id} not found"); + return NotFound($"Dataset with name = {name} or user with username = {username} not found"); - _datasetService.Delete(dataset.uploaderId,dataset.name); + _datasetService.Delete(dataset.username, dataset.name); return Ok($"Dataset with name = {name} deleted"); diff --git a/backend/api/api/Controllers/FileUploadController.cs b/backend/api/api/Controllers/FileController.cs index 68ab814d..3bfdad93 100644 --- a/backend/api/api/Controllers/FileUploadController.cs +++ b/backend/api/api/Controllers/FileController.cs @@ -1,5 +1,6 @@ using System.Net.Http.Headers; using api.Models; +using api.Services; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.Net.Http.Headers; @@ -7,15 +8,17 @@ namespace api.Controllers { [Route("api/[controller]")] [ApiController] - public class FileUploadController : ControllerBase + public class FileController : ControllerBase { private string[] permittedExtensions = { ".csv" }; private readonly IConfiguration _configuration; private JwtToken _token; - public FileUploadController(IConfiguration configuration) + private IFileService _fileservice; + public FileController(IConfiguration configuration,IFileService fileService) { _configuration = configuration; _token = new JwtToken(configuration); + _fileservice = fileService; } @@ -68,9 +71,42 @@ namespace api.Controllers { await file.CopyToAsync(stream); } + FileModel fileModel= new FileModel(); + fileModel.path=fullPath; + fileModel.username=username; + fileModel=_fileservice.Create(fileModel); - return Ok(fullPath); + return Ok(fileModel); } + + [HttpGet("Download")] + [Authorize(Roles = "User")] + public async Task<ActionResult> DownloadFile(string id) + { + //Get Username + string username; + var header = Request.Headers[HeaderNames.Authorization]; + if (AuthenticationHeaderValue.TryParse(header, out var headerValue)) + { + + var scheme = headerValue.Scheme; + var parameter = headerValue.Parameter; + username = _token.TokenToUsername(parameter); + if (username == null) + return null; + } + else + return BadRequest(); + + string filePath = _fileservice.GetFilePath(id, username); + if (filePath == null) + return BadRequest(); + + return File(System.IO.File.ReadAllBytes(filePath),"application/octet-stream", Path.GetFileName(filePath)); + + } + + + } } - diff --git a/backend/api/api/Controllers/ModelController.cs b/backend/api/api/Controllers/ModelController.cs new file mode 100644 index 00000000..deb622b8 --- /dev/null +++ b/backend/api/api/Controllers/ModelController.cs @@ -0,0 +1,97 @@ +using api.Models; +using api.Services; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; + +namespace api.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class ModelController : ControllerBase + { + + private IMlConnectionService _mlService; + private readonly IModelService _modelService; + + + public ModelController(IMlConnectionService mlService, IModelService modelService) + { + _mlService = mlService; + _modelService = modelService; + } + + [HttpPost("sendModel")] + [Authorize(Roles = "User")] + public async Task<ActionResult<string>> Test([FromBody] object model) + { + var result = await _mlService.SendModelAsync(model); + return Ok(result); + } + + // GET: api/<ModelController>/{username}/models + [HttpGet("{username}/models")] + public ActionResult<List<Model>> Get(string username) + { + return _modelService.GetAllModels(username); + } + + //id korisnika, name modela + // GET api/<ModelController>/{username}/{name} + [HttpGet("{username}/{name}")] + public ActionResult<Model> Get(string username, string name) + { + var model = _modelService.GetOneModel(username, name); + + if (model == null) + return NotFound($"Model with name = {name} or user with username = {username} not found"); + + return model; + } + + // POST api/<ModelController>/add + [HttpPost("add")] + public ActionResult<Model> Post([FromBody] Model model) + { + var existingModel = _modelService.GetOneModel(model.username, model.name); + + if (existingModel != null) + return NotFound($"Model with name = {model.name} exisits"); + else + { + _modelService.Create(model); + + return CreatedAtAction(nameof(Get), new { id = model._id }, model); + } + } + + // PUT api/<ModelController>/{username}/{name} + [HttpPut("{username}/{name}")] + public ActionResult Put(string username, string name, [FromBody] Model model) + { + var existingModel = _modelService.GetOneModel(username, name); + + if (existingModel == null) + return NotFound($"Model with name = {name} or user with username = {username} not found"); + + _modelService.Update(username, name, model); + return NoContent(); + } + + // DELETE api/<ModelController>/username + [HttpDelete("{username}/{name}")] + public ActionResult Delete(string username, string name) + { + var model = _modelService.GetOneModel(username, name); + + if (model == null) + return NotFound($"Model with name = {name} or user with username = {username} not found"); + + _modelService.Delete(model.username, model.name); + + return Ok($"Model with name = {name} deleted"); + + } + + } +} diff --git a/backend/api/api/Controllers/UserController.cs b/backend/api/api/Controllers/UserController.cs index d41a42e3..58121656 100644 --- a/backend/api/api/Controllers/UserController.cs +++ b/backend/api/api/Controllers/UserController.cs @@ -1,5 +1,6 @@ using api.Models; using api.Services; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using System.Diagnostics; @@ -72,6 +73,7 @@ namespace api.Controllers // PUT api/<UserController>/5 [HttpPut("{id}")] + [Authorize(Roles = "User")] public ActionResult Put(string id, [FromBody] User user) { var existingUser = userService.Get(id); @@ -86,6 +88,7 @@ namespace api.Controllers // DELETE api/<UserController>/5 [HttpDelete("{id}")] + [Authorize(Roles = "User")] public ActionResult Delete(string id) { var user = userService.Get(id); diff --git a/backend/api/api/Data/UserStoreDatabaseSettings.cs b/backend/api/api/Data/UserStoreDatabaseSettings.cs index 0d923fc7..6416ab05 100644 --- a/backend/api/api/Data/UserStoreDatabaseSettings.cs +++ b/backend/api/api/Data/UserStoreDatabaseSettings.cs @@ -10,5 +10,7 @@ namespace api.Data public string DatabaseName { get; set; } = String.Empty; public string CollectionName { get; set; } = String.Empty; public string DatasetCollectionName { get; set; } = String.Empty; + public string ModelCollectionName { get; set; } = String.Empty; + public string FilesCollectionName { get; set; } = String.Empty; } } diff --git a/backend/api/api/Interfaces/IUserStoreDatabaseSettings.cs b/backend/api/api/Interfaces/IUserStoreDatabaseSettings.cs index 8d2a175f..82312649 100644 --- a/backend/api/api/Interfaces/IUserStoreDatabaseSettings.cs +++ b/backend/api/api/Interfaces/IUserStoreDatabaseSettings.cs @@ -6,5 +6,7 @@ string DatabaseName { get; set; } string CollectionName { get; set; } string DatasetCollectionName { get; set; } + string ModelCollectionName { get; } + string FilesCollectionName { get; set; } } } diff --git a/backend/api/api/Models/Dataset.cs b/backend/api/api/Models/Dataset.cs index 0dc87f40..6cb0b1e9 100644 --- a/backend/api/api/Models/Dataset.cs +++ b/backend/api/api/Models/Dataset.cs @@ -1,46 +1,25 @@ -using MongoDB.Bson; +using System; +using MongoDB.Bson; using MongoDB.Bson.Serialization.Attributes; namespace api.Models { - public class Dataset - { - internal string uploaderId; + public class Dataset + { + public string username; [BsonId] [BsonRepresentation(BsonType.ObjectId)]//mongo data type to .net public string _id { get; set; } - [BsonElement("uploaderId")] - public string UploaderId { get; set; } - [BsonElement("name")] public string name { get; set; } - public string description { get; set; } - //datetime - public string dateCreated { get; set; } - - public int[] inputColumns { get; set; } - public int columnToPredict { get; set; } - public bool randomTestSet { get; set; } - public int randomTestSetDistribution { get; set; } - - - public string type { get; set; } - public string encoding { get; set; } - public string optimizer { get; set; } - public string lossFunction { get; set; } - public int inputNeurons { get; set; } - public int hiddenLayerNeurons { get; set; } - public int hiddenLayers { get; set; } - public int batchSize { get; set; } - public string inputLayerActivationFunction { get; set; } - public string hiddenLayerActivationFunction { get; set; } - public string outputLayerActivationFunction { get; set; } - - - [BsonElement("extension")] + public string[] header { get; set; } + public int fileId { get; set; } public string extension { get; set; } - - + public bool isPublic { get; set; } + public bool accessibleByLink { get; set; } + public string dateCreated { get; set; } + public string lastUpdated { get; set; } } } + diff --git a/backend/api/api/Models/FileModel.cs b/backend/api/api/Models/FileModel.cs new file mode 100644 index 00000000..9e7c8b5d --- /dev/null +++ b/backend/api/api/Models/FileModel.cs @@ -0,0 +1,14 @@ +using MongoDB.Bson; +using MongoDB.Bson.Serialization.Attributes; + +namespace api.Models +{ + public class FileModel + { + [BsonId] + [BsonRepresentation(BsonType.ObjectId)] + public string _id { get; set; } + public string username { get; set; } + public string path { get; set; } + } +} diff --git a/backend/api/api/Models/JwtToken.cs b/backend/api/api/Models/JwtToken.cs index 7cbd6f54..a98d1967 100644 --- a/backend/api/api/Models/JwtToken.cs +++ b/backend/api/api/Models/JwtToken.cs @@ -23,7 +23,7 @@ namespace api.Models { Subject = new ClaimsIdentity(new[] { new Claim("name", user.UserName), new Claim("role", "User")}), - Expires = DateTime.UtcNow.AddDays(1), + Expires = DateTime.UtcNow.AddMinutes(20), SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha256Signature) }; var token = tokenHandler.CreateToken(tokenDescriptor); diff --git a/backend/api/api/Models/Model.cs b/backend/api/api/Models/Model.cs new file mode 100644 index 00000000..7b22ded8 --- /dev/null +++ b/backend/api/api/Models/Model.cs @@ -0,0 +1,45 @@ +using MongoDB.Bson; +using MongoDB.Bson.Serialization.Attributes; + +namespace api.Models +{ + public class Model + { + + [BsonId] + [BsonRepresentation(BsonType.ObjectId)]//mongo data type to .net + public string _id { get; set; } + public string username { get; set; } + + + public string name { get; set; } + public string description { get; set; } + //datetime + public string dateCreated { get; set; } + public string lastUpdated { get; set; } + //proveriti id + public string datasetId { get; set; } + + //Test set settings + public int[] inputColumns { get; set; } + public int columnToPredict { get; set; } + public bool radnomOrder {get;set;} + public bool randomTestSet { get; set; } + public int randomTestSetDistribution { get; set; } + + //Neural net training + public string type { get; set; } + public string encoding { get; set; } + public string optimizer { get; set; } + public string lossFunction { get; set; } + public int inputNeurons { get; set; } + public int hiddenLayerNeurons { get; set; } + public int hiddenLayers { get; set; } + public int batchSize { get; set; } + public string inputLayerActivationFunction { get; set; } + public string hiddenLayerActivationFunction { get; set; } + public string outputLayerActivationFunction { get; set; } + + + } +} diff --git a/backend/api/api/Program.cs b/backend/api/api/Program.cs index 2c569daf..f3287b4c 100644 --- a/backend/api/api/Program.cs +++ b/backend/api/api/Program.cs @@ -28,6 +28,10 @@ builder.Services.AddSingleton<IMongoClient>(s => builder.Services.AddScoped<IDatasetService, DatasetService>(); builder.Services.AddScoped<IUserService, UserService>(); builder.Services.AddScoped<IAuthService, AuthService>(); +builder.Services.AddScoped<IMlConnectionService, MlConnectionService>(); +builder.Services.AddScoped<IModelService, ModelService>(); +builder.Services.AddScoped<IFileService, FileService>(); + //Add Authentication builder.Services.AddAuthentication( diff --git a/backend/api/api/Services/DatasetService.cs b/backend/api/api/Services/DatasetService.cs index 1b6d22be..80c31758 100644 --- a/backend/api/api/Services/DatasetService.cs +++ b/backend/api/api/Services/DatasetService.cs @@ -21,23 +21,25 @@ namespace api.Services } //brisanje odredjenog name-a - public void Delete(string uploaderId, string name) + public void Delete(string username, string name) { - _dataset.DeleteOne(dataset => (dataset.UploaderId == uploaderId && dataset.name == name)); + _dataset.DeleteOne(dataset => (dataset.username == username && dataset.name == name)); } - public List<Dataset> GetAllDatesets(string uploaderId) + + public List<Dataset> GetAllDatesets(string username) { - return _dataset.Find(dataset => dataset.uploaderId == uploaderId).ToList(); + return _dataset.Find(dataset => dataset.username == username).ToList(); } - public Dataset GetOneDataset(string uploaderId, string name) + + public Dataset GetOneDataset(string username, string name) { - return _dataset.Find(dataset => dataset.UploaderId == uploaderId && dataset.name == name).FirstOrDefault(); + return _dataset.Find(dataset => dataset.username == username && dataset.name == name).FirstOrDefault(); } //ako je potrebno da se zameni name ili ekstenzija - public void Update(string uploaderId, string name, Dataset dataset) + public void Update(string username, string name, Dataset dataset) { - _dataset.ReplaceOne(dataset => dataset.UploaderId == uploaderId && dataset.name == name, dataset); + _dataset.ReplaceOne(dataset => dataset.username == username && dataset.name == name, dataset); } } } diff --git a/backend/api/api/Services/FileService.cs b/backend/api/api/Services/FileService.cs new file mode 100644 index 00000000..e68a0fe3 --- /dev/null +++ b/backend/api/api/Services/FileService.cs @@ -0,0 +1,34 @@ +using api.Interfaces; +using api.Models; +using MongoDB.Driver; + +namespace api.Services +{ + public class FileService : IFileService + { + + private readonly IMongoCollection<FileModel> _file; + + public FileService(IUserStoreDatabaseSettings settings, IMongoClient mongoClient) + { + var database = mongoClient.GetDatabase(settings.DatabaseName); + _file = database.GetCollection<FileModel>(settings.FilesCollectionName); + } + + public FileModel Create(FileModel file) + { + if (file == null) + return null; + _file.InsertOne(file); + return file; + + } + public string GetFilePath(string id, string username) + { + FileModel file = _file.Find(x => x._id == id && x.username == username).FirstOrDefault(); + if (file == null) + return null; + return file.path; + } + } +} diff --git a/backend/api/api/Services/IDatasetService.cs b/backend/api/api/Services/IDatasetService.cs index 9cf8c3cb..49013e29 100644 --- a/backend/api/api/Services/IDatasetService.cs +++ b/backend/api/api/Services/IDatasetService.cs @@ -5,10 +5,10 @@ namespace api.Services { public interface IDatasetService { - Dataset GetOneDataset(string uploaderId, string name); - List<Dataset> GetAllDatesets(string uploaderId); + Dataset GetOneDataset(string username, string name); + List<Dataset> GetAllDatesets(string username); Dataset Create(Dataset dataset); - void Update(string uploaderId, string name, Dataset dataset); - void Delete(string uploaderId, string name); + void Update(string username, string name, Dataset dataset); + void Delete(string username, string name); } } diff --git a/backend/api/api/Services/IFileService.cs b/backend/api/api/Services/IFileService.cs new file mode 100644 index 00000000..7446e283 --- /dev/null +++ b/backend/api/api/Services/IFileService.cs @@ -0,0 +1,10 @@ +using api.Models; + +namespace api.Services +{ + public interface IFileService + { + FileModel Create(FileModel file); + string GetFilePath(string id, string username); + } +}
\ No newline at end of file diff --git a/backend/api/api/Services/IMlConnectionService.cs b/backend/api/api/Services/IMlConnectionService.cs new file mode 100644 index 00000000..f38fb50a --- /dev/null +++ b/backend/api/api/Services/IMlConnectionService.cs @@ -0,0 +1,8 @@ + +namespace api.Services +{ + public interface IMlConnectionService + { + Task<string> SendModelAsync(object model); + } +}
\ No newline at end of file diff --git a/backend/api/api/Services/IModelService.cs b/backend/api/api/Services/IModelService.cs new file mode 100644 index 00000000..149afd4a --- /dev/null +++ b/backend/api/api/Services/IModelService.cs @@ -0,0 +1,15 @@ +using System; +using api.Models; + +namespace api.Services +{ + public interface IModelService + { + Model GetOneModel(string username, string name); + List<Model> GetAllModels(string username); + Model Create(Model model); + void Update(string username, string name, Model model); + void Delete(string username, string name); + } +} + diff --git a/backend/api/api/Services/MlConnectionService.cs b/backend/api/api/Services/MlConnectionService.cs new file mode 100644 index 00000000..7adade0c --- /dev/null +++ b/backend/api/api/Services/MlConnectionService.cs @@ -0,0 +1,17 @@ +using RestSharp; + +namespace api.Services +{ + public class MlConnectionService : IMlConnectionService + { + public async Task<string> SendModelAsync(object model) + { + RestClient client = new RestClient("http://localhost:5000"); + var request = new RestRequest("data", Method.Post); + request.AddJsonBody(model); + var result = await client.ExecuteAsync(request); + return result.Content;//Response od ML microservisa + + } + } +} diff --git a/backend/api/api/Services/ModelService.cs b/backend/api/api/Services/ModelService.cs new file mode 100644 index 00000000..33dea30e --- /dev/null +++ b/backend/api/api/Services/ModelService.cs @@ -0,0 +1,47 @@ +using System; +using api.Interfaces; +using api.Models; +using MongoDB.Driver; + +namespace api.Services +{ + public class ModelService : IModelService + { + + private readonly IMongoCollection<Model> _model; + + public ModelService(IUserStoreDatabaseSettings settings, IMongoClient mongoClient) + { + var database = mongoClient.GetDatabase(settings.DatabaseName); + _model = database.GetCollection<Model>(settings.ModelCollectionName); + } + + public Model Create(Model model) + { + _model.InsertOne(model); + return model; + } + + public void Delete(string username, string name) + { + _model.DeleteOne(model => (model.username == username && model.name == name)); + } + + public List<Model> GetAllModels(string username) + { + return _model.Find(model => model.username == username).ToList(); + } + + public Model GetOneModel(string username, string name) + { + return _model.Find(model => model.username == username && model.name == name).FirstOrDefault(); + } + + public void Update(string username, string name, Model model) + { + _model.ReplaceOne(model => model.username == username && model.name == name, model); + } + + } +} + diff --git a/backend/api/api/api.csproj b/backend/api/api/api.csproj index 46842c3e..f38621ca 100644 --- a/backend/api/api/api.csproj +++ b/backend/api/api/api.csproj @@ -10,6 +10,8 @@ <PackageReference Include="BCrypt.Net-Next" Version="4.0.3" /> <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.3" /> <PackageReference Include="Microsoft.IdentityModel.Tokens" Version="6.16.0" /> + <PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> + <PackageReference Include="RestSharp" Version="107.3.0" /> <PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.16.0" /> </ItemGroup> diff --git a/backend/api/api/appsettings.json b/backend/api/api/appsettings.json index 9b4f00a3..86363075 100644 --- a/backend/api/api/appsettings.json +++ b/backend/api/api/appsettings.json @@ -9,16 +9,19 @@ } }, "AllowedHosts": "*", - "UserStoreDatabaseSettings": { - /* LocalHost + "UserStoreDatabaseSettings": { + /* LocalHost "ConnectionString": "mongodb://127.0.0.1:27017/", "DatabaseName": "si_project", "CollectionName": "User", - "DatasetCollectionName" : "Dataset" + "DatasetCollectionName" : "Dataset", + "ModelCollectionName" : "Model" */ - "ConnectionString": "mongodb+srv://si_user:si_user@sidatabase.twtfm.mongodb.net/myFirstDatabase?retryWrites=true&w=majority", - "DatabaseName": "si_db", - "CollectionName": "users", - "DatasetCollectionName": "Dataset" - } + "ConnectionString": "mongodb+srv://si_user:si_user@sidatabase.twtfm.mongodb.net/myFirstDatabase?retryWrites=true&w=majority", + "DatabaseName": "si_db", + "CollectionName": "users", + "DatasetCollectionName": "Dataset", + "ModelCollectionName": "Model", + "FilesCollectionName": "Files" + } } diff --git a/frontend/src/app/_data/Model.ts b/frontend/src/app/_data/Model.ts index 1a120ca7..43342fb0 100644 --- a/frontend/src/app/_data/Model.ts +++ b/frontend/src/app/_data/Model.ts @@ -7,8 +7,8 @@ export default class Model { public datasetId?: number, // Test set settings - public inputColumns: number[] = [0], - public columnToPredict: number = 1, + public inputColumns: string[] = [], + public columnToPredict: string = '', public randomOrder: boolean = true, public randomTestSet: boolean = true, public randomTestSetDistribution: number = 0.10, //0.1-0.9 (10% - 90%) diff --git a/frontend/src/app/_elements/dataset-load/dataset-load.component.css b/frontend/src/app/_elements/dataset-load/dataset-load.component.css index e69de29b..05819702 100644 --- a/frontend/src/app/_elements/dataset-load/dataset-load.component.css +++ b/frontend/src/app/_elements/dataset-load/dataset-load.component.css @@ -0,0 +1,6 @@ +#divInputs { + margin-left: 20px; +} +#divOutputs { + margin-left: 20px; +}
\ No newline at end of file diff --git a/frontend/src/app/_elements/dataset-load/dataset-load.component.html b/frontend/src/app/_elements/dataset-load/dataset-load.component.html index c89add43..2a611a96 100644 --- a/frontend/src/app/_elements/dataset-load/dataset-load.component.html +++ b/frontend/src/app/_elements/dataset-load/dataset-load.component.html @@ -1,19 +1,32 @@ <div> - <input style="display: inline-block; width:350px;" list=delimiterOptions + <div class="mb-4"> + <label for="name" class="col-form-label">Naziv dataseta:</label> + <input type="text" class="form-control" name="name" placeholder="Naziv..." + [(ngModel)]="dataset.name"> + </div> + <label for="desc" class="col-sm-2 col-form-label">Opis:</label> + <div> + <textarea class="form-control" name="desc" rows="3" [(ngModel)]="dataset.description"></textarea> + </div> + + + <div class="d-flex justify-content-center"> + <input style="display: inline-block; width:350px;" list=delimiterOptions placeholder="Izaberite ili ukucajte delimiter za .csv fajl" class="form-control" [(ngModel)]="delimiter" (input)="update()"> - <datalist id=delimiterOptions> - <option *ngFor="let option of delimiterOptions">{{option}}</option> - </datalist> - - <label for="checkboxHeader">Da li .csv ima header?</label> - <input (input)="update()" [(ngModel)]="hasHeader" type="checkbox" value="" id="checkboxHeader" checked> - <br><br> + <datalist id=delimiterOptions> + <option *ngFor="let option of delimiterOptions">{{option}}</option> + </datalist> + + <label for="type" class="form-check-label">Da li .csv ima header? + <input class="mx-3 form-check-input" type="checkbox" (input)="update()" [(ngModel)]="hasHeader" type="checkbox" value="" id="checkboxHeader" checked> + </label> - <input id="fileInput" class="form-control mb-5" type="file" class="upload" (change)="changeListener($event)" accept=".csv"> - - <table *ngIf="csvRecords.length > 0 && hasHeader" class="table table-bordered table-light mt-5"> + <input id="fileInput" class="form-control" type="file" class="upload" (change)="changeListener($event)" accept=".csv"> + </div> + + <table *ngIf="csvRecords.length > 0 && hasHeader" class="table table-bordered table-light my-4"> <thead> <tr> <th *ngFor="let item of csvRecords[0]; let i = index">{{item}}</th> @@ -26,7 +39,7 @@ </tbody> </table> - <table *ngIf="csvRecords.length > 0 && !hasHeader" class="table table-bordered table-light mt-5"> + <table *ngIf="csvRecords.length > 0 && !hasHeader" class="table table-bordered table-light mt-4"> <tbody> <tr *ngFor="let row of csvRecords | slice:0:10"> <td *ngFor="let col of row">{{col}}</td> @@ -39,4 +52,6 @@ {{rowsNumber}} x {{colsNumber}} </div> + + </div>
\ No newline at end of file diff --git a/frontend/src/app/_elements/dataset-load/dataset-load.component.ts b/frontend/src/app/_elements/dataset-load/dataset-load.component.ts index cde3e8b1..8465c3d6 100644 --- a/frontend/src/app/_elements/dataset-load/dataset-load.component.ts +++ b/frontend/src/app/_elements/dataset-load/dataset-load.component.ts @@ -1,5 +1,6 @@ -import { Component, ViewChild } from '@angular/core'; +import { Component, EventEmitter, Output, ViewChild } from '@angular/core'; import { NgxCsvParser, NgxCSVParserError } from 'ngx-csv-parser'; +import Dataset from 'src/app/_data/Dataset'; @Component({ selector: 'app-dataset-load', @@ -8,6 +9,8 @@ import { NgxCsvParser, NgxCSVParserError } from 'ngx-csv-parser'; }) export class DatasetLoadComponent { + @Output() loaded = new EventEmitter<string>(); + delimiter: string = ""; delimiterOptions: Array<string> = [",", ";", "\t", "razmak", "|"]; //podrazumevano "," @@ -20,7 +23,10 @@ export class DatasetLoadComponent { rowsNumber: number = 0; colsNumber: number = 0; + dataset: Dataset; + constructor(private ngxCsvParser: NgxCsvParser) { + this.dataset = new Dataset(); } @ViewChild('fileImportInput', { static: false }) fileImportInput: any; @@ -46,9 +52,14 @@ export class DatasetLoadComponent { else this.rowsNumber = this.csvRecords.length; this.colsNumber = this.csvRecords[0].length; + + this.dataset.header = this.csvRecords[0]; + + this.loaded.emit("loaded"); } }, (error: NgxCSVParserError) => { console.log('Error', error); }); } + } diff --git a/frontend/src/app/_modals/login-modal/login-modal.component.ts b/frontend/src/app/_modals/login-modal/login-modal.component.ts index 87686f10..d17d7017 100644 --- a/frontend/src/app/_modals/login-modal/login-modal.component.ts +++ b/frontend/src/app/_modals/login-modal/login-modal.component.ts @@ -25,13 +25,16 @@ export class LoginModalComponent implements OnInit { } doLogin() { - this.authService.login(this.username, this.password).subscribe((response) => { //ako nisu ok podaci, ne ide hide nego mora opet da ukucava!!!!podesi - console.log(response); - this.authService.authenticate(response); - (<HTMLSelectElement>document.getElementById('closeButton')).click(); - }, error => { - console.warn(error); //NETACNI PODACI - }); + if (this.username.length > 0 && this.password.length > 0) { + this.authService.login(this.username, this.password).subscribe((response) => { //ako nisu ok podaci, ne ide hide nego mora opet da ukucava!!!!podesi + console.log(response); + this.authService.authenticate(response); + (<HTMLSelectElement>document.getElementById('closeButton')).click(); + }, error => { + console.warn(error); //NETACNI PODACI + }); + } + } resetData() { this.username = ''; diff --git a/frontend/src/app/_pages/add-model/add-model.component.css b/frontend/src/app/_pages/add-model/add-model.component.css index e69de29b..5184733d 100644 --- a/frontend/src/app/_pages/add-model/add-model.component.css +++ b/frontend/src/app/_pages/add-model/add-model.component.css @@ -0,0 +1,14 @@ +#header { + background-color: #003459; + padding-top: 25px; + padding-bottom: 20px; +} +#header h1 { + font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif; + text-align: center; + color: white; +} + +#container { + border-radius: 8px; +}
\ No newline at end of file diff --git a/frontend/src/app/_pages/add-model/add-model.component.html b/frontend/src/app/_pages/add-model/add-model.component.html index 08e27dd7..f5270127 100644 --- a/frontend/src/app/_pages/add-model/add-model.component.html +++ b/frontend/src/app/_pages/add-model/add-model.component.html @@ -1,190 +1,177 @@ -<div class="container p-3" style="background-color: rgb(249, 251, 253); min-height: 100%;"> - - <h2 class="my-4 text-primary"> Nov model: </h2> - <div class="form-group row align-items-center"> - <label for="name" class="col-sm-2 col-form-label col-form-label-lg">Naziv</label> - <div class="col-sm-7"> - <input type="text" class="form-control form-control-lg" name="name" placeholder="Naziv..." - [(ngModel)]="newModel.name"> - </div> - - <div class="col-sm-3"> - <input type="text" class="form-control-plaintext text-center" id="dateCreated" placeholder="--/--/--" - value="{{newModel.dateCreated | date: 'dd/MM/yyyy'}}" readonly> - </div> - </div> - - <div class="form-group row my-2"> - <label for="desc" class="col-sm-2 col-form-label">Opis</label> - <div class="col-sm-10"> - <textarea class="form-control" name="desc" rows="3" [(ngModel)]="newModel.description"></textarea> - </div> - </div> - - <!--<div class="form-group row"> - <label for="value" class="col-4">Vrednost</label> - <div class="input-group"> - <input type="number" min="0" class="form-control" name="value" placeholder="Vrednost..." - [(ngModel)]="newModel.value"> - <div class="input-group-prepend"> - <span class="input-group-text">#</span> - </div> - <input type="number" min="1" class="form-control" name="count" placeholder="Br." [(ngModel)]="newModel.count"> - <input type="text" class="form-control" name="sum" placeholder="Suma" - value="=({{newModel.value * newModel.count}})" readonly> - </div> - </div>--> - - <div class="my-4"> - <label for="dataset">Izvor podataka:</label> - <app-dataset-load id="dataset"></app-dataset-load> - </div> - - <div class="form-group row my-2"> - <div class="col-sm-2 col-form-label"> - <label for="type" class="form-check-label">Automatska podela test skupa: - <input class="mx-3 form-check-input" type="checkbox" [checked]="newModel.randomTestSet" - (change)="newModel.randomTestSet = !newModel.randomTestSet"> - </label> - - </div> - <div> - <mat-slider min="0.1" max="0.9" step="0.1" value="0.2" name="randomTestSetDistribution" thumbLabel - class="w-50" [disabled]="!newModel.randomTestSet" [(ngModel)]="newModel.randomTestSetDistribution"> - </mat-slider> - </div> - </div> - - <h3> Parametri treniranja </h3> - - <div class="form-group row my-2"> - <label for="type" class="col-sm-2 col-form-label">Tip mreže: </label> - <div class="col-sm-10"> - <select id=typeOptions class="form-control" name="type" [(ngModel)]="newModel.type"> - <option *ngFor="let option of Object.keys(ANNType); let optionName of Object.values(ANNType)" - [value]="option"> - {{ optionName }} - </option> - </select> - </div> - </div> - - <div class="form-group row my-2"> - <label for="encoding" class="col-sm-2 col-form-label">Enkoding: </label> - <div class="col-sm-10"> - <select id=encodingOptions class="form-control" name="encoding" [(ngModel)]="newModel.encoding"> - <option *ngFor="let option of Object.keys(Encoding); let optionName of Object.values(Encoding)" - [value]="option"> - {{ optionName }} +<div id="header"> + <h1>Napravite svoj model veštačke neuronske mreže</h1> +</div> + +<div id="wrapper"> + + <div id="container" class="container p-5" style="background-color: white; min-height: 100%;"> + + <div class="form-group row mb-4 d-flex"> <!--justify-content-center--> + <h2 class="col-sm-2" style="color: #00171f"> Nov model: </h2> + <div class="col-sm-3"> + <div class="mb-4"> + <label for="name" class="col-form-label">Naziv modela:</label> + <input type="text" class="form-control" name="name" placeholder="Naziv..." + [(ngModel)]="newModel.name"> + </div> + <div class="d-inline-flex align-items-center"> + <label for="dateCreated" class="col-form-label">Datum:</label> + <input type="text" class="form-control-plaintext" id="dateCreated" placeholder="--/--/--" + value="{{newModel.dateCreated | date: 'dd/MM/yyyy'}}" readonly> + </div> + </div> + <div class="col-sm-5"> + <label for="desc" class="col-sm-2 col-form-label">Opis:</label> + <div> + <textarea class="form-control" name="desc" rows="3" [(ngModel)]="newModel.description"></textarea> + </div> + </div> + </div> + + <div class="my-5 justify-content-center"> + <h2>Izvor podataka:</h2> + <app-dataset-load id="dataset" (loaded)="datasetLoaded = true"></app-dataset-load> + </div> + + <div *ngIf="datasetLoaded" class="mt-2"> + <div *ngIf="datasetLoadComponent" class="row"> + <div class="col d-flex justify-content-center"> + <h3>Izaberite ulazne kolone:</h3> + <div id="divInputs" class="form-check"> + <br> + <div *ngFor="let item of datasetLoadComponent.dataset.header; let i = index"> + <input *ngIf="i == 0" class="form-check-input" type="checkbox" value="{{item}}" id="cb_{{item}}" name="cbs" checked> + <input *ngIf="i != 0" class="form-check-input" type="checkbox" value="{{item}}" id="cb_{{item}}" name="cbs"> + <label class="form-check-label" for="cb_{{item}}"> + {{item}} + </label> + </div> + </div> + </div> + <div class="col d-flex justify-content-left"> + <h3>Izaberite izlaznu kolonu:</h3> + <div id="divOutputs" class="form-check"> + <br> + <div *ngFor="let item of datasetLoadComponent.dataset.header; let i = index"> + <input *ngIf="i == 0" class="form-check-input" type="radio" value="{{item}}" id="rb_{{item}}" name="rbs" checked> + <input *ngIf="i != 0" class="form-check-input" type="radio" value="{{item}}" id="rb_{{item}}" name="rbs"> + <label class="form-check-label" for="rb_{{item}}"> + {{item}} + </label> + </div> + </div> + </div> + </div> + </div> + + <h2>Parametri treniranja:</h2> + + <div class="row"> + <div class="col-2 mt-4"> + <label for="type" class="col-form-label">Tip mreže: </label> + <select id=typeOptions class="form-control" name="type" [(ngModel)]="newModel.type"> + <option *ngFor="let option of Object.keys(ANNType); let optionName of Object.values(ANNType)" + [value]="option"> + {{ optionName }} + </option> + </select> + </div> + <div class="col-1 mt-4"> + <label for="encoding" class="col-form-label">Enkoding: </label> + <select id=encodingOptions class="form-control" name="encoding" [(ngModel)]="newModel.encoding"> + <option *ngFor="let option of Object.keys(Encoding); let optionName of Object.values(Encoding)" + [value]="option"> + {{ optionName }} + </option> + </select> + </div> + <div class="col-1 mt-4"> + <label for="optimizer" class="col-form-label">Optimizacija: </label> + <select id=optimizerOptions class="form-control" name="optimizer" [(ngModel)]="newModel.optimizer"> + <option *ngFor="let option of Object.keys(Optimizer); let optionName of Object.values(Optimizer)" + [value]="option"> + {{ optionName }} + </option> + </select> + </div> + <div class="col mt-4"> + <label for="lossFunction" class="col-form-label">Funkcija obrade gubitka: </label> + <select id=lossFunctionOptions class="form-control" name="lossFunction" [(ngModel)]="newModel.lossFunction"> + <option *ngFor="let option of Object.keys(LossFunction); let optionName of Object.values(LossFunction)" + [value]="option"> + {{ optionName }} + </option> + </select> + </div> + <div class="col-2"> + <label for="inputLayerActivationFunction" class="col-form-label">Funkcija aktivacije<br>ulaznog sloja:</label> + <select id=inputLayerActivationFunctionOptions class="form-control" name="inputLayerActivationFunction" + [(ngModel)]="newModel.inputLayerActivationFunction"> + <option + *ngFor="let option of Object.keys(ActivationFunction); let optionName of Object.values(ActivationFunction)" + [value]="option"> + {{ optionName }} + </option> + </select> + </div> + <div class="col"> + <label for="hiddenLayerActivationFunction" class="col-form-label">Funkcija aktivacije<br>skrivenih slojeva:</label> + <select id=hiddenLayerActivationFunctionOptions class="form-control" name="hiddenLayerActivationFunction" + [(ngModel)]="newModel.hiddenLayerActivationFunction"> + <option + *ngFor="let option of Object.keys(ActivationFunction); let optionName of Object.values(ActivationFunction)" + [value]="option"> + {{ optionName }} </option> - </select> - </div> - </div> - - <div class="form-group row my-2"> - <label for="optimizer" class="col-sm-2 col-form-label">Optimizacija: </label> - <div class="col-sm-10"> - <select id=optimizerOptions class="form-control" name="optimizer" [(ngModel)]="newModel.optimizer"> - <option *ngFor="let option of Object.keys(Optimizer); let optionName of Object.values(Optimizer)" - [value]="option"> - {{ optionName }} - </option> - </select> - </div> - </div> - - <div class="form-group row my-2"> - <label for="lossFunction" class="col-sm-2 col-form-label">Funkcija obrade gubitka: </label> - <div class="col-sm-10"> - <select id=lossFunctionOptions class="form-control" name="lossFunction" [(ngModel)]="newModel.lossFunction"> - <option *ngFor="let option of Object.keys(LossFunction); let optionName of Object.values(LossFunction)" - [value]="option"> - {{ optionName }} - </option> - </select> - </div> - </div> - - <div class="form-group row my-2"> - <label for="inputNeurons" class="col-sm-2 col-form-label">Broj ulaznih neurona: </label> - <div class="col-sm-10"> - <input type="number" min="1" class="form-control" name="inputNeurons" [(ngModel)]="newModel.inputNeurons"> - </div> - </div> - - <div class="form-group row my-2"> - <label for="inputLayerActivationFunction" class="col-sm-2 col-form-label">Funkcija aktivacije ulaznog sloja: - </label> - <div class="col-sm-10"> - <select id=inputLayerActivationFunctionOptions class="form-control" name="inputLayerActivationFunction" - [(ngModel)]="newModel.inputLayerActivationFunction"> - <option - *ngFor="let option of Object.keys(ActivationFunction); let optionName of Object.values(ActivationFunction)" - [value]="option"> - {{ optionName }} - </option> - </select> - </div> - </div> - - <div class="form-group row my-2"> - <label for="hiddenLayerNeurons" class="col-sm-2 col-form-label">Broj neurona skrivenih slojeva: </label> - <div class="col-sm-10"> - <input type="number" min="1" class="form-control" name="hiddenLayerNeurons" - [(ngModel)]="newModel.hiddenLayerNeurons"> - </div> - </div> - - <div class="form-group row my-2"> - <label for="hiddenLayerActivationFunction" class="col-sm-2 col-form-label">Funkcija aktivacije skrivenih - slojeva: - </label> - <div class="col-sm-10"> - <select id=hiddenLayerActivationFunctionOptions class="form-control" name="hiddenLayerActivationFunction" - [(ngModel)]="newModel.hiddenLayerActivationFunction"> - <option - *ngFor="let option of Object.keys(ActivationFunction); let optionName of Object.values(ActivationFunction)" - [value]="option"> - {{ optionName }} - </option> - </select> - </div> - </div> - - <div class="form-group row my-2"> - <label for="hiddenLayers" class="col-sm-2 col-form-label">Broj skrivenih slojeva: </label> - <div class="col-sm-10"> - <input type="number" min="1" class="form-control" name="hiddenLayers" [(ngModel)]="newModel.hiddenLayers"> - </div> - </div> - - <div class="form-group row my-2"> - <label for="outputLayerActivationFunction" class="col-sm-2 col-form-label">Funkcija aktivacije izlaznog - sloja: - </label> - <div class="col-sm-10"> - <select id=outputLayerActivationFunctionOptions class="form-control" name="outputLayerActivationFunction" - [(ngModel)]="newModel.outputLayerActivationFunction"> - <option - *ngFor="let option of Object.keys(ActivationFunction); let optionName of Object.values(ActivationFunction)" - [value]="option"> - {{ optionName }} - </option> - </select> - </div> - </div> - - <div class="form-group row my-2"> - <label for="batchSize" class="col-sm-2 col-form-label">Broj uzorka po iteraciji: </label> - <div class="col-sm-10"> - <input type="number" min="1" class="form-control" name="batchSize" [(ngModel)]="newModel.batchSize"> - </div> - </div> - - <div class=" form-group row my-4"> - <div class="col-4"></div> - <button class="btn btn-lg btn-primary col-4" (click)="addModel();">Dodaj</button> - <div class="col-4"></div> - </div> - -</div>
\ No newline at end of file + </select> + </div> + <div class="col"> + <label for="outputLayerActivationFunction" class="col-form-label">Funkcija aktivacije<br>izlaznog sloja:</label> + <select id=outputLayerActivationFunctionOptions class="form-control" name="outputLayerActivationFunction" + [(ngModel)]="newModel.outputLayerActivationFunction"> + <option + *ngFor="let option of Object.keys(ActivationFunction); let optionName of Object.values(ActivationFunction)" + [value]="option"> + {{ optionName }} + </option> + </select> + </div> + </div> + + <div class="row mt-5"> + <div class="col-2"> + <label for="inputNeurons" class="col-form-label">Broj ulaznih neurona: </label> <!--UMESTO OVOGA IDE NASUMICAN REDOSLED? YES/NO--> + <input type="number" min="1" class="form-control" name="inputNeurons" [(ngModel)]="newModel.inputNeurons"> + </div> + <div class="col-2"> + <label for="hiddenLayers" class="col-form-label">Broj skrivenih slojeva: </label> + <input type="number" min="1" class="form-control" name="hiddenLayers" [(ngModel)]="newModel.hiddenLayers"> + </div> + <div class="col-3 "> + <label for="hiddenLayerNeurons" class="col-form-label">Broj neurona skrivenih slojeva: </label> + <input type="number" min="1" class="form-control" name="hiddenLayerNeurons" [(ngModel)]="newModel.hiddenLayerNeurons"> + </div> + <div class="col-2"> + <label for="batchSize" class="col-form-label">Broj uzorka po iteraciji: </label> + <input type="number" min="1" class="form-control" name="batchSize" [(ngModel)]="newModel.batchSize"> + </div> + <div class="col-3 mt-1"> + <label for="type" class="form-check-label mb-3"> Podela test skupa: + <input class="mx-3 form-check-input" type="checkbox" [checked]="newModel.randomTestSet" + (change)="newModel.randomTestSet = !newModel.randomTestSet"> + </label> + <mat-slider min="0.1" max="0.9" step="0.1" value="0.2" name="randomTestSetDistribution" thumbLabel + [disabled]="!newModel.randomTestSet" [(ngModel)]="newModel.randomTestSetDistribution"> + </mat-slider> + </div> + </div> + + <br><br> + <div class="form-group row mt-5"> + <div class="col-4"></div> + <button class="btn btn-lg col-4" style="background-color:#003459; color:white;" (click)="addModel();">Napravi model</button> + <div class="col-4"></div> + </div> + + </div> +</div> diff --git a/frontend/src/app/_pages/add-model/add-model.component.ts b/frontend/src/app/_pages/add-model/add-model.component.ts index 3cb47d61..c18ad324 100644 --- a/frontend/src/app/_pages/add-model/add-model.component.ts +++ b/frontend/src/app/_pages/add-model/add-model.component.ts @@ -1,6 +1,9 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, ViewChild } from '@angular/core'; import Model from 'src/app/_data/Model'; import { ANNType, Encoding, ActivationFunction, LossFunction, Optimizer } from 'src/app/_data/Model'; +import { DatasetLoadComponent } from 'src/app/_elements/dataset-load/dataset-load.component'; +import { ModelsService } from 'src/app/_services/models.service'; + @Component({ selector: 'app-add-model', @@ -9,7 +12,10 @@ import { ANNType, Encoding, ActivationFunction, LossFunction, Optimizer } from ' }) export class AddModelComponent implements OnInit { - newModel: Model + @ViewChild(DatasetLoadComponent) datasetLoadComponent?: DatasetLoadComponent; + datasetLoaded: boolean = false; + + newModel: Model; ANNType = ANNType; Encoding = Encoding; @@ -18,7 +24,7 @@ export class AddModelComponent implements OnInit { Optimizer = Optimizer; Object = Object; - constructor() { + constructor(private models: ModelsService) { this.newModel = new Model(); } @@ -26,7 +32,54 @@ export class AddModelComponent implements OnInit { } addModel() { - //TODO + if (this.datasetLoadComponent) + this.models.addDataset(this.datasetLoadComponent?.dataset); + + this.getCheckedInputCols(); + this.getCheckedOutputCol(); + if (this.validationInputsOutput()) + this.models.addModel(this.newModel).subscribe((response) => { + console.log(response); + }); + } + + getCheckedInputCols() { + this.newModel.inputColumns = []; + let checkboxes = document.getElementsByName("cbs"); + + for (let i = 0; i < checkboxes.length; i++) { + let thatCb = <HTMLInputElement>checkboxes[i]; + if (thatCb.checked) + this.newModel.inputColumns.push(thatCb.value); + } + //console.log(this.checkedInputCols); + } + getCheckedOutputCol() { + this.newModel.columnToPredict = ''; + let radiobuttons = document.getElementsByName("rbs"); + + for (let i = 0; i < radiobuttons.length; i++) { + let thatRb = <HTMLInputElement>radiobuttons[i]; + if (thatRb.checked) { + this.newModel.columnToPredict = thatRb.value; + break; + } + } + //console.log(this.checkedOutputCol); + } + validationInputsOutput() : boolean { + if (this.newModel.inputColumns.length == 0) { + alert("Molimo Vas da izaberete ulaznu kolonu/kolone za mrežu.") + return false; + } + for (let i = 0; i < this.newModel.inputColumns.length; i++) { + if (this.newModel.inputColumns[i] == this.newModel.columnToPredict) { + let colName = this.newModel.columnToPredict; + alert("Izabrali ste istu kolonu (" + colName + ") kao ulaznu i izlaznu iz mreže. Korigujte izbor."); + return false; + } + } + return true; } } diff --git a/frontend/src/app/_pages/home/home.component.html b/frontend/src/app/_pages/home/home.component.html index b17b9a56..274f0fd8 100644 --- a/frontend/src/app/_pages/home/home.component.html +++ b/frontend/src/app/_pages/home/home.component.html @@ -1,4 +1,4 @@ -<div class="d-flex flex-column align-items-center"> +<div class="d-flex flex-column align-items-center bg-light"> <img src="../../../assets/svg/logo.svg" class="bi me-2" width="256" height="256" role="img"> <div *ngIf="shared.loggedIn" class="d-flex flex-column align-items-center"> <h2 class="my-4">Započnite sa treniranjem!</h2> diff --git a/frontend/src/app/_services/auth-guard.service.ts b/frontend/src/app/_services/auth-guard.service.ts index b6d3678d..057996e0 100644 --- a/frontend/src/app/_services/auth-guard.service.ts +++ b/frontend/src/app/_services/auth-guard.service.ts @@ -15,7 +15,7 @@ export class AuthGuardService implements CanActivate { if (this.auth.isAuthenticated()) { return true; } - this.router.navigate(['login']); + this.router.navigate(['']); return false; } } diff --git a/frontend/src/app/_services/models.service.spec.ts b/frontend/src/app/_services/models.service.spec.ts new file mode 100644 index 00000000..b5b25752 --- /dev/null +++ b/frontend/src/app/_services/models.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { ModelsService } from './models.service'; + +describe('ModelsService', () => { + let service: ModelsService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(ModelsService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/frontend/src/app/_services/models.service.ts b/frontend/src/app/_services/models.service.ts new file mode 100644 index 00000000..f85ca44e --- /dev/null +++ b/frontend/src/app/_services/models.service.ts @@ -0,0 +1,22 @@ +import { HttpClient } from '@angular/common/http'; +import { Injectable } from '@angular/core'; +import Model from '../_data/Model'; +import { AuthService } from './auth.service'; +import { API_SETTINGS } from 'src/config'; +import Dataset from '../_data/Dataset'; + + +@Injectable({ + providedIn: 'root' +}) +export class ModelsService { + + constructor(private http: HttpClient, private authService: AuthService) { } + + addModel(model: Model) { + return this.http.post(`${API_SETTINGS.apiURL}/model/sendModel`, model, { headers: this.authService.authHeader(), responseType: 'text' }); + } + addDataset(dataset: Dataset) { + return this.http.post(`${API_SETTINGS.apiURL}/model/uploadDataset`, dataset, { headers: this.authService.authHeader(), responseType: 'text' }); + } +} diff --git a/frontend/src/app/app.component.html b/frontend/src/app/app.component.html index 7f2d4225..35e5adb1 100644 --- a/frontend/src/app/app.component.html +++ b/frontend/src/app/app.component.html @@ -1,4 +1,4 @@ <app-navbar></app-navbar> -<div class="mat-app-background container h-100"> +<div class="container h-100"> <router-outlet></router-outlet> </div>
\ No newline at end of file diff --git a/frontend/src/assets/images/add_model_background.jpg b/frontend/src/assets/images/add_model_background.jpg Binary files differnew file mode 100644 index 00000000..d86f0566 --- /dev/null +++ b/frontend/src/assets/images/add_model_background.jpg diff --git a/frontend/src/assets/images/logo_crop.png b/frontend/src/assets/images/logo_crop.png Binary files differdeleted file mode 100644 index 1775a465..00000000 --- a/frontend/src/assets/images/logo_crop.png +++ /dev/null diff --git a/frontend/src/assets/images/logo_dark_crop.png b/frontend/src/assets/images/logo_dark_crop.png Binary files differdeleted file mode 100644 index d66f13e2..00000000 --- a/frontend/src/assets/images/logo_dark_crop.png +++ /dev/null diff --git a/frontend/src/styles.css b/frontend/src/styles.css index b671a2a7..d37ab6f1 100644 --- a/frontend/src/styles.css +++ b/frontend/src/styles.css @@ -1,5 +1,3 @@ -/* 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; } -*/ +body { + background-image: url('/assets/images/add_model_background.jpg'); +}
\ No newline at end of file |