Skip to content

Commit

Permalink
Merge branch 'bap-brehme-wulff' into 'main'
Browse files Browse the repository at this point in the history
Bachelorproject Brehme & Wulff - Snapshots & Annotations & API management

See merge request ExplorViz/code/frontend!200
  • Loading branch information
Malte-Hansen committed Nov 18, 2024
2 parents 244c3bc + bea7017 commit 82dac81
Show file tree
Hide file tree
Showing 112 changed files with 4,852 additions and 373 deletions.
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ FRONTEND_URL=http://localhost:4200
COLLABORATION_SERV_URL=http://localhost:4444
SPAN_SERV_URL=http://localhost:8083
USER_SERV_URL=http://localhost:8084
USER_SERV_API_URL=http://localhost:8080
SHARE_SNAPSHOT_URL=http://localhost:4200/
GITLAB_API=http://localhost:5000
CODE_SERV_URL=http://localhost:8085
METRICS_SERV_URL=http://localhost:8086
VSCODE_SERV_URL=http://localhost:3000
Expand Down
40 changes: 22 additions & 18 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ module.exports = {
sourceType: 'module',
project: './tsconfig.json',
},
plugins: ['@typescript-eslint', 'import', 'prettier'],
plugins: [
// 'ember',
'prettier',
'@typescript-eslint',
'import',
],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
Expand All @@ -24,47 +29,46 @@ module.exports = {
auth0: false,
},
rules: {
'prettier/prettier': 'error',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/ban-ts-comment': [
'error',
{ 'ts-ignore': 'allow-with-description' },
],
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/type-annotation-spacing': ['error'],
'linebreak-style': 'off',
'class-methods-use-this': 'off',
'import/no-unresolved': 'off',
'@typescript-eslint/no-this-alias': [
'error',
{
allowDestructuring: true,
allowedNames: ['self'],
},
],
'@typescript-eslint/type-annotation-spacing': ['error'],
'class-methods-use-this': 'off',
'require-yield': 'off',
'no-plusplus': 'off',
'import/no-cycle': 'off',
'prefer-rest-params': 'off',
'ember/no-mixins': 'off',
'ember/require-computed-property-dependencies': 'off',
'func-names': ['error', 'always', { generators: 'never' }],
'import/no-cycle': 'off',
'import/no-unresolved': 'off',
'linebreak-style': 'off',
'no-console': ['error', { allow: ['warn', 'error'] }],
'no-param-reassign': ['error', { props: false }],
'no-plusplus': 'off',
'prefer-rest-params': 'off',
'prettier/prettier': 'error',
'require-yield': 'off',
'func-names': ['error', 'always', { generators: 'never' }],
},
overrides: [
// node files
{
files: [
'config/**/*.js',
'ember-cli-build.js',
'lib/*/index.js',
'testem.js',
'config/**/*.js',
'lib/*/index.js',
],
parserOptions: {
ecmaVersion: 2015,
sourceType: 'script',
ecmaVersion: 2015,
},
env: {
browser: false,
Expand Down
44 changes: 44 additions & 0 deletions app/components/additional-snapshot-info.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<div id='colorPresets' class='dropdown'>
<a
class='button-svg-with-hover'
type='button'
tabindex='0'
href='#'
{{on 'focusout' this.hidePopover}}
{{on 'click' this.onClick}}
>
{{svg-jar 'info-16' class='octicon align-middle'}}
<BsTooltip @placement='bottom' @triggerEvents='hover'>
Show additional info
</BsTooltip>
<BsPopover id={{this.id}} @title={{@token.name}}>
<table class='table table-striped' style='width: 100%'>
<tbody>
<tr>
<td>Owner</td>
<td style='word-break: break-all'>
{{if (eq @token.owner this.auth.user.sub) 'You' @token.owner}}
</td>
<td></td>
</tr>
<tr>
<td>ID</td>
<td>{{@token.landscapeToken.value}}</td>
<td>
<CopyButton
class='button-svg-with-hover'
@text={{@token.landscapeToken.value}}
@onSuccess={{this.onTokenIdCopied}}
>
{{svg-jar 'copy-16' class='octicon align-middle'}}
<BsTooltip @placement='bottom' @triggerEvents='hover'>
Copy id to clipboard
</BsTooltip>
</CopyButton>
</td>
</tr>
</tbody>
</table>
</BsPopover>
</a>
</div>
55 changes: 55 additions & 0 deletions app/components/additional-snapshot-info.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import Component from '@glimmer/component';
import ToastHandlerService from 'explorviz-frontend/services/toast-handler';
import Auth from 'explorviz-frontend/services/auth';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';
import { TinySnapshot } from 'explorviz-frontend/services/snapshot-token';

export default class AdditionalSnapshotInfoComponent extends Component<TinySnapshot> {
@service('auth')
auth!: Auth;

@service('toast-handler')
toastHandlerService!: ToastHandlerService;

focusedClicks = 0;

@action
// eslint-disable-next-line class-methods-use-this
onTokenIdCopied() {
this.toastHandlerService.showSuccessToastMessage(
'Token id copied to clipboard'
);
}

@action
hidePopover(event: Event) {
if (this.isMouseOnPopover()) {
return;
}

// Clicks enable us to differentiate between opened and closed popovers
if (this.focusedClicks % 2 === 1) {
event.target?.dispatchEvent(new Event('click'));
}
this.focusedClicks = 0;
}

isMouseOnPopover() {
const hoveredElements = document.querySelectorAll(':hover');

for (const element of hoveredElements) {
if (element.matches('.popover')) {
return true;
}
}
return false;
}

@action
onClick(event: Event) {
this.focusedClicks += 1;
// Prevent click on table row which would trigger to open the visualization
event.stopPropagation();
}
}
133 changes: 133 additions & 0 deletions app/components/api-token-selection.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
<div class='pb-5 px-5 w-100'>
<h5 class='text-left mb-3'>API-Tokens</h5>
<div class='flex-row justify-content-center overflow-scroll'>
<table class='table table-striped'>
<thead>
<tr>
<th scope='col' {{on 'click' (fn this.sortBy 'name')}}>Name</th>
<th scope='col'>API Token</th>
<th
scope='col'
{{on 'click' (fn this.sortBy 'createdAt')}}
>Created</th>
<th scope='col' {{on 'click' (fn this.sortBy 'expires')}}>Expires</th>
<th scope='col'></th>
</tr>
</thead>
<tbody>
{{#each
(sort-by
(concat this.sortProperty ':' this.sortOrder) 'createdAt' @apiTokens
)
as |apiToken|
}}
<tr class='snapshot-selection-row'>
<th style='width: 40%' scope='row'>{{apiToken.name}} </th>
<th style='width: 25%' scope='row'>{{apiToken.token}} </th>
<th scope='row'>{{this.formatDate apiToken.createdAt true}}</th>
<th scope='row'>{{this.formatDate apiToken.expires}}</th>
<th scope='row'>
<ul class='token-selection-icons'>
<li>
<div id='colorPresets' class='dropdown'>
<a
class='button-svg-with-hover'
type='button'
tabindex='0'
href='#'
{{on 'click' (fn this.deleteApiToken apiToken)}}
>
{{svg-jar 'trash-16' class='octicon align-middle'}}
<BsTooltip @placement='bottom' @triggerEvents='hover'>
Delete Snapshot
</BsTooltip>
</a>
</div>
</li>
</ul>
</th>
</tr>
{{else}}
There are no saved API-Tokens.
{{/each}}
<tr>
<td colspan='5' class='p-1'>
<div class='d-flex flex-row justify-content-center'>
<BsButton
@type='primary'
class='align-self-center pt-2 px-3'
{{on 'click' this.openMenu}}
>
{{svg-jar 'plus-16' class='octicon'}}
</BsButton>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div>
<BsModal @open={{this.createToken}} @onHidden={{this.closeMenu}} as |modal|>
<modal.header>
<h4 class='modal-title'>Create API Token</h4>
</modal.header>
<modal.body>

<label class='mt-2' for='token'>Name:</label>
<div class='d-flex justify-content-between'>
<input
id='name'
class='form-control mr-2'
oninput={{this.updateName}}
value={{this.name}}
/>
</div>
<label for='token'>API Token:</label>
<div class='d-flex justify-content-between'>
<input
id='token'
class='form-control mr-2'
oninput={{this.updateToken}}
value={{this.token}}
/>
</div>
<label for='token'>Host URL:</label>
<div class='d-flex justify-content-between'>
<input
id='url'
class='form-control mr-2'
placeholder='e.g.: https://git.<hostname>.<de/com...>'
oninput={{this.updateHostUrl}}
value={{this.hostUrl}}
/>
</div>
<label class='mt-2' for='token'>Expires <i>- Optional:</i> </label>
<div class='d-flex justify-content-between'>
<input
id='date'
class='form-control mr-2'
type='date'
min={{this.today}}
oninput={{this.updateExpDate}}
{{!-- value={{this.expDate}} --}}
/>
</div>
</modal.body>
<modal.footer>
<BsButton
@outline={{true}}
@type='danger'
@onClick={{this.reset}}
>Cancel</BsButton>
<BsButton
title='Save'
@type='secondary'
@outline={{true}}
@onClick={{(fn this.createApiToken @refreshRoute)}}
disabled={{this.saveBtnDisabled}}
>Save</BsButton>
</modal.footer>

</BsModal>
</div>
Loading

0 comments on commit 82dac81

Please sign in to comment.