Skip to content

Commit

Permalink
login redirection
Browse files Browse the repository at this point in the history
  • Loading branch information
nkarmazina committed Oct 12, 2023
1 parent 59804c2 commit 7c95f31
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 104 deletions.
68 changes: 1 addition & 67 deletions frontend/src/app/login/login.component.css
Original file line number Diff line number Diff line change
Expand Up @@ -43,26 +43,6 @@ h1{
color: var(--light-blue);
}

.repositories{
grid-area: repositories;
grid-row: 3 / 4;
grid-column: 3 / 4;
/*width: 400px;*/
text-align: center;
margin-right: auto;
margin-bottom: 5%;
margin-left: auto;
padding: 25px;
background-color:rgb(224, 224, 224);
border: 1px solid #999;
}

.darkTheme .repositories {
background: #455A64;
border: 1px solid #60767b
}


.howToStart {
grid-area: howToStart;
grid-row: 2 / 3;
Expand Down Expand Up @@ -157,33 +137,6 @@ h1{
color: black;
}

.repo_img{
margin-left: 5px;
margin-right: 5px;
max-height: 18px;
}

.repositoryList{
list-style: none;
}

a.repoLink{
color: var(--ocean-blue);
transition: 0.2s;
}

.darkTheme a.repoLink {
color: var(--light-blue);
}

a.repoLink:hover{
color: var(--marine-blue);
}

.darkTheme a.repoLink:hover {
color: white;
}

.wrongLogin{
background-color: var(--grape);
text-align: center;
Expand Down Expand Up @@ -274,7 +227,7 @@ a.repoLink:hover{
.grid{
display: grid;
grid-template-rows: auto;
grid-template-areas: "formular" "repositories";
grid-template-areas: "formular";
}
}

Expand Down Expand Up @@ -307,25 +260,6 @@ a.repoLink:hover{
padding: 40px;
}

.repositories{
grid-area: repositories;
grid-row: 3 / 4;
grid-column: 3 / 4;
width: 400px;
text-align: center;
margin-right: 100px;
margin-bottom: 80px;
margin-top: -30px;
padding: 15px;
background-color:rgb(224, 224, 224);
border: 1px solid #999;
}

}

.darkTheme .repositories {
background-color: #37474F;
border-color:#60767b;
}

/* .darkTheme button {
Expand Down
20 changes: 4 additions & 16 deletions frontend/src/app/login/login.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
</div>
</div>
<div class="formular">
<p class="wrongLogin" *ngIf="error">{{error}}</p>
<div *ngIf="error" class="alert alert-danger text-center" style="margin-bottom: 15px; width: 210px;">
<b>Login Failed: </b>{{error}}
</div>
<!-- <p class="wrongLogin" ></p> -->
<!-- Formular -->
<h1 class="LargeHeadline2 loginFont">Login</h1>
<form #form="ngForm" novalidate (ngSubmit)="login(form)">
Expand Down Expand Up @@ -68,19 +71,4 @@ <h1 class="LargeHeadline2 loginFont">Login</h1>
</span>
</div>
</div>
<!-- Repositories -->
<div class="repositories" *ngIf="repositories">
<div id="repositoriesList">
<label class="MediumSubline1H4">Select Your Project:</label>
<br>
<ul class="repositoryList">
<li *ngFor="let repository of repositories; let i = index" >
<img class="repo_img" *ngIf="this.apiService.isGithubRepo(repository)" src="../assets/GitHub-Mark-32px.png" alt="github">
<img class="repo_img" *ngIf="this.apiService.isJiraRepo(repository)" src="../assets/[email protected]" alt="jira">
<img class="repo_img" *ngIf="this.apiService.isCustomRepo(repository)" src="../assets/database-5-32.png" alt="database">
<a class="MediumBody2 repoLink" id="{{'repository_'+i}}" (click)="selectRepository(repository);" >{{repository.value}}</a>
</li>
</ul>
</div>
</div>
</div>
29 changes: 8 additions & 21 deletions frontend/src/app/login/login.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class LoginComponent implements OnInit, AfterViewInit {
* Login error
*/
error: string;
defaultErrorMessage = 'Login Failed: Wrong Username Or Password';
defaultErrorMessage = 'Wrong Username Or Password';

/**
* Boolean to see if the repository is loading
Expand Down Expand Up @@ -217,6 +217,7 @@ export class LoginComponent implements OnInit, AfterViewInit {
* Retrieves the repositories / projects of the user
*/
getRepositories() {
let repoNotSet = false;
const value = localStorage.getItem('repository');
const source = localStorage.getItem('source');
const _id = localStorage.getItem('id');
Expand All @@ -234,35 +235,21 @@ export class LoginComponent implements OnInit, AfterViewInit {
resp.forEach((elem) => {
if (elem.value == repository.value && elem.source == repository.source && elem._id == repository._id) {
this.router.navigate(['']);
}});
repoNotSet = true;
}
});
if(!repoNotSet){
this.router.navigate(['/accountManagement']);
}
this.repositories = resp;
this.isLoadingRepositories = false;
setTimeout(() => {
const repositoriesList: HTMLElement = document.getElementById('repositoriesList');
if (repositoriesList) {
repositoriesList.scrollIntoView();
}
}, 500);

}, (_) => {
this.error = this.defaultErrorMessage;
this.isLoadingRepositories = false;
});
}

/**
* Selects a repository and redirects the user to the story editor
* @param userRepository selected repository
*/
selectRepository(userRepository: RepositoryContainer) {
const ref: HTMLLinkElement = document.getElementById('githubHref') as HTMLLinkElement;
ref.href = 'https://github.com/' + userRepository.value;
localStorage.setItem('repository', userRepository.value);
localStorage.setItem('source', userRepository.source);
localStorage.setItem('id', userRepository._id);
this.router.navigate(['']);
}

/**
* Loggs in the user with Github
*/
Expand Down

0 comments on commit 7c95f31

Please sign in to comment.