This is the codeAbility Sharing Platform! Learn more about the codeAbility Sharing Platform.

Skip to content
Snippets Groups Projects
Commit a6a45776 authored by Daniel Crazzolara's avatar Daniel Crazzolara
Browse files

Implemented gitlab groups selector

parent 6fadc58a
Branches
Tags
2 merge requests!62created achievementService and separated some functionality out of...,!61Feature/#51 import from artemis
<div>
<div class="modal-header">
<h4 class="modal-title" jhiTranslate="gitlab.pathSelector.title">Gitlab Path</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true" (click)="closeModal(undefined)">&times;</button>
</div>
<div class="modal-body">
<div class="justify-content-center p-1">
<jhi-alert></jhi-alert>
<jhi-alert-error></jhi-alert-error>
<div class="table-responsive p-1">
<table class="table table-striped">
<thead>
<tr>
<th></th>
<th><span jhiTranslate="gitlab.pathSelector.name">Name</span></th>
<th><span jhiTranslate="gitlab.pathSelector.description">Description</span></th>
<th><span jhiTranslate="gitlab.pathSelector.visibility">Visibility</span></th>
<th><span jhiTranslate="gitlab.pathSelector.url">URL</span></th>
</tr>
</thead>
<tbody>
<tr *ngFor="let group of groups">
<td>
<img
[height]="48"
src="{{ group.avatarUrl ? group.avatarUrl : '' }}"/>
<!--onerror="this.src='/content/images/image-placeholder.png'"
/>-->
</td>
<td>
<strong>{{group.name}}</strong>
</td>
<td>
<span>{{group.description}}</span>
</td>
<td>
<span>{{group.visibility}}</span>
</td>
<td>
<span>{{group.webUrl}}</span>
</td>
<td>
<button type="button" class="btn ml-2 btn-primary" (click)="closeModal(group)" jhiTranslate="gitlab.pathSelector.select">
Select
</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
import { Component, OnInit } from '@angular/core';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { JhiAlertService } from 'ng-jhipster';
import { GitlabGroup } from 'app/shared/model/gitlab-group.model';
import { GitlabService } from 'app/shared/gitlab/gitlab.service';
@Component({
selector: 'jhi-gitlab-path-selector',
templateUrl: './gitlab-path-selector.component.html',
styleUrls: ['./gitlab-path-selector.component.scss'],
})
export class GitlabPathSelectorComponent implements OnInit {
groups: GitlabGroup[] | undefined;
subgroups: GitlabGroup[] | undefined;
constructor(private activeModal: NgbActiveModal, private jhiAlertService: JhiAlertService, private gitlabService: GitlabService) {}
ngOnInit(): void {
this.gitlabService.getGroups().subscribe(
data => {
this.groups = data;
},
error => {
this.jhiAlertService.error(error.error);
}
);
}
/**
* Utility function used to retrieve the upper groups in the
* hierarchy
*/
getParentGroups() {
return this.groups?.filter(group => !group.parentId);
}
/**
* Utility function used to retrieve the subgroups of
* a given group
* @param group to search for subGroups
*/
getSubGroupsOfGroup(group: GitlabGroup) {
return this.groups?.filter(subGroup => subGroup.parentId === group.id);
}
closeModal(group: GitlabGroup | undefined) {
this.activeModal.close(group);
}
}
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { GitlabPathSelectorComponent } from './gitlab-path-selector/gitlab-path-selector.component';
import { GitSearchV2SharedModule } from 'app/shared/shared.module';
@NgModule({
imports: [CommonModule, GitSearchV2SharedModule],
declarations: [GitlabPathSelectorComponent],
})
export class GitlabModule {}
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { SERVER_API_URL } from 'app/app.constants';
import { GitlabGroup } from 'app/shared/model/gitlab-group.model';
import { Observable } from 'rxjs';
@Injectable({
providedIn: 'root',
})
export class GitlabService {
public resourceUrl = SERVER_API_URL + 'api/gitlab/';
constructor(private http: HttpClient) {}
/**
* Used to retrieve all groups of current user
* (As user: their groups, as admin: all groups)
*/
public getGroups(): Observable<Array<GitlabGroup>> {
return this.http.get<Array<GitlabGroup>>(`${this.resourceUrl}groups`);
}
/**
* used to retrieve subgroups of a given Gitlab group
* @param group to retrieve its subgroups
*/
public getSubGroups(group: GitlabGroup): Observable<Array<GitlabGroup>> {
return this.http.get<Array<GitlabGroup>>(`${this.resourceUrl}subgroups/${group.id}`);
}
}
export enum IVisibility {
PUBLIC = 'public',
PRIVATE = 'private',
INTERNAL = 'internal',
}
/**
* Gitlab Group model basing on org.gitlab4j.api.models.Group
*/
export interface GitlabGroup {
id: number;
name: string;
path: string;
description: string;
visibility: IVisibility;
avatarUrl: string;
webUrl: string;
fullName: string;
fullPath: string;
parentId: number;
}
{
"gitlab": {
"pathSelector": {
"title": "Gitlab Pfad",
"name": "Name",
"description": "Beschreibung",
"url": "URL",
"visibility": "Freischaltung",
"select": "Auswählen"
}
}
}
{
"gitlab": {
"pathSelector": {
"title": "Gitlab Path",
"name": "Name",
"description": "Description",
"url": "URL",
"visibility": "Visibility",
"select": "Select"
}
}
}
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