Skip to content

Commit

Permalink
fixed css
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonEntholzer committed Oct 17, 2024
1 parent 94f39c3 commit af8f80b
Show file tree
Hide file tree
Showing 7 changed files with 213 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ public CreateContainerResponse configureContainer(String containerName, String i
// container from exiting until it finishes.
// It waits until the script that is running the tests (see below execCreateCmdResponse) is completed, and until the result files are extracted which is indicated
// by the creation of a file "stop_container.txt" in the container's root directory.
.withCmd("sh", "-c", "while [ ! -f " + LOCALCI_WORKING_DIRECTORY + "/stop_container.txt ]; do sleep 0.5; done")
// .withCmd("tail", "-f", "/dev/null") // Activate for debugging purposes instead of the above command to get a running container that you can peek into using
// .withCmd("sh", "-c", "while [ ! -f " + LOCALCI_WORKING_DIRECTORY + "/stop_container.txt ]; do sleep 0.5; done")
.withCmd("tail", "-f", "/dev/null") // Activate for debugging purposes instead of the above command to get a running container that you can peek into using
// "docker exec -it <container-id> /bin/bash".
.exec();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ public List<UserSshPublicKey> getAllSshKeysForUser(User user) {
}

public void deleteUserSshPublicKey(Long userId, Long keyId) {
var key = userPublicSshKeyRepository.findById(userId);
if (key.isPresent() && key.get().getUserId().equals(userId)) {
userPublicSshKeyRepository.deleteById(userId);
var keys = userPublicSshKeyRepository.findAllByUserId(userId);
if (!keys.isEmpty() && keys.stream().map(UserSshPublicKey::getId).toList().contains(keyId)) {
userPublicSshKeyRepository.deleteById(keyId);
}
else {
throw new AccessForbiddenException("SSH key", keyId);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd">
<changeSet id="20241013150001" author="entholzer">
<!--
Change Set for creating a new table for storing public SSH keys of users
-->
<insert tableName="user_public_ssh_key">
<column name="user_id" valueComputed="(SELECT id FROM jhi_user WHERE ssh_key IS NOT NULL)"/>
<column name="public_key" valueComputed="(SELECT ssh_key FROM jhi_user WHERE ssh_key IS NOT NULL)"/>
<column name="key_hash" valueComputed="(SELECT ssh_key_hash FROM jhi_user WHERE ssh_key_hash IS NOT NULL)"/>
<column name="creation_date" valueDate="CURRENT_TIMESTAMP"/>
</insert>


<createTable tableName="user_public_ssh_key">
<column autoIncrement="true" name="id" type="bigint">
<constraints nullable="false" primaryKey="true"/>
</column>
<column name="user_id" type="bigint">
<constraints nullable="false"/>
</column>
<column name="label" type="VARCHAR(50)">
<constraints nullable="false"/>
</column>
<column name="public_key" type="varchar(1000)">
<constraints nullable="false"/>
</column>
<column name="key_hash" type="VARCHAR(100)">
<constraints nullable="false"/>
</column>
<column name="creation_date" type="TIMESTAMP">
<constraints nullable="false"/>
</column>
<column name="last_used_date" type="TIMESTAMP">
<constraints nullable="true"/>
</column>
<column name="expiry_date" type="TIMESTAMP">
<constraints nullable="true"/>
</column>
</createTable>
<createIndex indexName="idx_user_public_ssh_key_user_id" tableName="user_public_ssh_key">
<column name="user_id"/>
</createIndex>
<createIndex indexName="idx_user_public_ssh_key_ssh_public_key_hash" tableName="user_public_ssh_key">
<column name="key_hash"/>
</createIndex>
</changeSet>
</databaseChangeLog>


<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd">
<changeSet id="20241013150000" author="entholzer">

<!-- Step 1: Create the new SSHPublicKey table -->
<changeSet id="1" author="yourname">
<createTable tableName="SSHPublicKey">
<column name="id" type="BIGINT" autoIncrement="true">
<constraints primaryKey="true" nullable="false"/>
</column>
<column name="user_id" type="BIGINT">
<constraints nullable="false"/>
</column>
<column name="ssh_key" type="VARCHAR(1000)">
<constraints nullable="false"/>
</column>
<column name="ssh_key_hash" type="VARCHAR(255)">
<constraints nullable="false"/>
</column>
<column name="created_at" type="TIMESTAMP" defaultValueDate="CURRENT_TIMESTAMP">
<constraints nullable="false"/>
</column>
<column name="last_used_at" type="TIMESTAMP"/>
<column name="expiry_date" type="TIMESTAMP"/>
</createTable>

<!-- Add a foreign key constraint to link SSHPublicKey to User table -->
<addForeignKeyConstraint
baseTableName="SSHPublicKey"
baseColumnNames="user_id"
referencedTableName="User"
referencedColumnNames="id"
constraintName="fk_sshpublickey_user"/>
</changeSet>

<!-- Step 2: Migrate existing SSH keys and hashes from User table to SSHPublicKey table -->
<changeSet id="2" author="yourname">
<insert tableName="SSHPublicKey">
<column name="user_id" valueComputed="(SELECT id FROM User WHERE ssh_key IS NOT NULL)"/>
<column name="ssh_key" valueComputed="(SELECT ssh_key FROM User WHERE ssh_key IS NOT NULL)"/>
<column name="ssh_key_hash" valueComputed="(SELECT ssh_key_hash FROM User WHERE ssh_key_hash IS NOT NULL)"/>
<column name="created_at" valueDate="CURRENT_TIMESTAMP"/>
</insert>
</changeSet>

<!-- Step 3: Optionally drop the old ssh_key and ssh_key_hash columns from User table -->
<changeSet id="3" author="yourname" runOnChange="true">
<dropColumn tableName="User" columnName="ssh_key"/>
<dropColumn tableName="User" columnName="ssh_key_hash"/>
</changeSet>

</databaseChangeLog>
1 change: 1 addition & 0 deletions src/main/resources/config/liquibase/master.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<include file="classpath:config/liquibase/changelog/20240924125742_changelog.xml" relativeToChangelogFile="false"/>
<include file="classpath:config/liquibase/changelog/20240816150000_changelog.xml" relativeToChangelogFile="false"/>
<include file="classpath:config/liquibase/changelog/20241013150000_changelog.xml" relativeToChangelogFile="false"/>
<include file="classpath:config/liquibase/changelog/20241013150001_changelog.xml" relativeToChangelogFile="false"/>

<!-- NOTE: please use the format "YYYYMMDDhhmmss_changelog.xml", i.e. year month day hour minutes seconds and not something else! -->
<!-- we should also stay in a chronological order! -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,30 +61,99 @@ <h4 jhiTranslate="artemisApp.userSettings.sshSettingsPage.keysTablePageTitle"></
</td>

<td class="container">
<div class="vertical-center">
<div class="dropdown" tabindex="1">
<i class="db2" tabindex="1"></i>
<a class="dropbtn">
<fa-icon [icon]="faEllipsis"></fa-icon>
<ul
ngbDropdown
container="body"
placement="bottom auto"
style="opacity: 1"
class="navbar-nav justify-content-end flex-grow-1 text-decoration-none pointer"
>
<li ngbDropdownToggle class="nav-item">
<div class="nav-link px-3">
<fa-icon style="opacity: 1" [fixedWidth]="true" [icon]="faEllipsis" class="ms-2 me-3" />
</div>
</li>
<div ngbDropdownMenu>
<a ngbDropdownItem class="d-flex align-items-center py-1 px-2" style="text-decoration: none" [routerLink]="['view', key.id]">
<div
jhiTranslate="artemisApp.userSettings.sshSettingsPage.viewExistingSshKey"
class="h6 fw-normal mb-0 course-title text-wrap"
></div>
</a>

<button
jhiDeleteButton
ngbDropdownItem
[renderButtonText]="false"
(delete)="deleteSshKey(key)"
deleteQuestion="artemisApp.userSettings.sshSettingsPage.deleteSshKeyQuestion"
[dialogError]="dialogError$"
class="d-flex align-items-center py-1 px-2"
>
<div jhiTranslate="artemisApp.userSettings.sshSettingsPage.deleteSshKey" class="h6 fw-normal mb-0 course-title text-wrap"></div>
</button>
</div>
</ul>

<!--
<div class="vertical-center">
<div ngbDropdown container="body" class="d-flex">
<fa-icon ngbDropdown [icon]="faEllipsis"></fa-icon>
<div ngbDropdownMenu class="dropdown-menu py-1 ms-n2">
<button ngbDropdownItem (click)="foobar()"
class="d-flex align-items-center py-1 px-2">
<div
class="h6 fw-normal mb-0 course-title text-wrap">{{ "View" }}
</div>
</button>
<a ngbDropdownItem class="d-flex align-items-center py-1 px-2" style="text-decoration: none;" [routerLink]="['view', key.id]">
<div
jhiTranslate="artemisApp.userSettings.sshSettingsPage.viewExistingSshKey"
class="h6 fw-normal mb-0 course-title text-wrap">
</div>
</a>
<div class="dropdown-content">
<a class="btn dropdown-button" [routerLink]="['view', key.id]">
<span jhiTranslate="artemisApp.userSettings.sshSettingsPage.viewExistingSshKey"></span>
</a>
<button
jhiDeleteButton
class="btn dropdown-button dropdown-delete-btn me-2 bottom-border"
[buttonSize]="ButtonSize.SMALL"
<button jhiDeleteButton
ngbDropdownItem
[renderButtonText]="false"
(delete)="deleteSshKey(key)"
deleteQuestion="artemisApp.userSettings.sshSettingsPage.deleteSshKeyQuestion"
[dialogError]="dialogError$"
>
<span class="ms-1" jhiTranslate="artemisApp.userSettings.sshSettingsPage.deleteSshKey"></span>
</button>
</div>
class="d-flex align-items-center py-1 px-2">
<div
jhiTranslate="artemisApp.userSettings.sshSettingsPage.deleteSshKey"
class="h6 fw-normal mb-0 course-title text-wrap">
</div>
</button>
</div>
</div>
<div class="dropdown" tabindex="1">
<i class="db2" tabindex="1"></i>
<a class="dropbtn">
<fa-icon [icon]="faEllipsis"></fa-icon>
</a>
<div class="dropdown-content">
<a class="btn dropdown-button" [routerLink]="['view', key.id]">
<span jhiTranslate="artemisApp.userSettings.sshSettingsPage.viewExistingSshKey"></span>
</a>
<button
jhiDeleteButton
class="btn dropdown-button dropdown-delete-btn me-2 bottom-border"
[buttonSize]="ButtonSize.SMALL"
[renderButtonText]="false"
(delete)="deleteSshKey(key)"
deleteQuestion="artemisApp.userSettings.sshSettingsPage.deleteSshKeyQuestion"
[dialogError]="dialogError$"
>
<span class="ms-1" jhiTranslate="artemisApp.userSettings.sshSettingsPage.deleteSshKey"></span>
</button>
</div>
</div>
-->
</td>
</tr>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,81 +81,19 @@ tbody tr:hover {
background-color: var(--ssh-key-settings-table-hover-background);
}

/* dd container */
.dropdown {
display: inline-block;
position: absolute;
outline: none;
margin: 0;
}

/* button */
.dropbtn {
padding: 0;
color: grey;
cursor: pointer;
transition: 0.35s ease-out;
a:link:hover {
text-decoration: none !important;
}

/* dd content */
.dropdown .dropdown-content {
.dropdown-content {
overflow-y: auto;
position: absolute;
top: -25%;
min-width: 120%;
box-shadow: 0 8px 16px var(--ssh-key-settings-shadow);
z-index: 100000; // makes sure the drop down menu is always shown at the highest view plane
visibility: hidden;
opacity: 1;
transition: 0.35s ease-out;
width: 80px;
}

/* show dd content */
.dropdown:focus .dropdown-content {
z-index: 100000;
outline: none;
transform: translateY(20px);
visibility: visible;
opacity: 1;
background-color: var(--light);
}

/* mask to close menu by clicking on the button */
.dropdown .db2 {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
opacity: 0;
cursor: pointer;
z-index: 10;
display: none;
}

.dropdown:focus .db2 {
display: inline-block;
}

.dropdown .db2:focus .dropdown-content {
outline: none;
visibility: hidden;
margin-right: 15px;
opacity: 0;
}

.dropdown-button {
color: var(--ssh-key-settings-text-color);
background-color: var(--dropdown-bg);
border-color: var(--dropdown-bg);
max-width: 80px;
width: 100%;
text-align: left;
font-size: smaller;
border: 1px solid var(--border-color);
z-index: 3000;
border-radius: 4px;
}

.dropdown-button:hover {
background-color: var(--ssh-key-settings-dropdown-buttons-hover);
border-color: var(--ssh-key-settings-dropdown-buttons-hover);
display: block;
.dropdown-toggle::after {
display: none;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnDestroy, OnInit } from '@angular/core';
import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { AccountService } from 'app/core/auth/account.service';
import { Subject, Subscription, tap } from 'rxjs';
import { ProfileService } from 'app/shared/layouts/profiles/profile.service';
Expand All @@ -8,6 +8,7 @@ import { DocumentationType } from 'app/shared/components/documentation-button/do
import { ButtonSize, ButtonType } from 'app/shared/components/button.component';
import { AlertService } from 'app/core/util/alert.service';
import { UserSshPublicKey } from 'app/entities/programming/user-ssh-public-key.model';
import { NgbDropdown } from '@ng-bootstrap/ng-bootstrap';

@Component({
selector: 'jhi-account-information',
Expand All @@ -34,6 +35,8 @@ export class SshUserSettingsComponent implements OnInit, OnDestroy {
private dialogErrorSource = new Subject<string>();
dialogError$ = this.dialogErrorSource.asObservable();

@ViewChild('itemsDrop', { static: true }) itemsDrop: NgbDropdown;

constructor(
private accountService: AccountService,
private profileService: ProfileService,
Expand Down Expand Up @@ -70,7 +73,8 @@ export class SshUserSettingsComponent implements OnInit, OnDestroy {
this.sshPublicKeys.splice(index, 1);
}
},
error: () => {
error: (error) => {
console.log(error);
this.alertService.error('artemisApp.userSettings.sshSettingsPage.deleteFailure');
},
});
Expand Down

0 comments on commit af8f80b

Please sign in to comment.