-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
98 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,81 @@ | ||
{% extends 'base.html' %} | ||
{% block title %}Targets{% endblock %} | ||
{% block content %} | ||
{% extends 'base.html' %} | ||
{% block title %}Targets{% endblock %} | ||
|
||
{% block content %} | ||
<div> | ||
<div class="d-flex"> | ||
<div class="ml-0 mr-auto my-auto"> | ||
<h1 class="text-success">Targets</h1> | ||
</div> | ||
<div class="ml-auto mr-0 my-auto"> | ||
<div class="dropdown"></div> | ||
<button class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown">Create</button> | ||
<div class="dropdown-menu"> | ||
{% for target in available_targets %} | ||
<a class="dropdown-item" href="{% url 'target_create' target.model.html_name %}">{{target.model.html_name}}</a> | ||
{% endfor %} | ||
</div> | ||
<button class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown">Create</button> | ||
<div class="dropdown-menu"> | ||
{% for target in available_targets %} | ||
<a class="dropdown-item" | ||
href="{% url 'target_create' target.model.html_name %}">{{target.model.html_name}}</a> | ||
{% endfor %} | ||
</div> | ||
</div> | ||
</div> | ||
<hr> | ||
|
||
{% for target in user_targets %} | ||
|
||
<div class="card my-4"> | ||
<div class="d-flex card-header"> | ||
<img width=48 class="rounded float-end my-auto ml-0 mr-3" src="{{target.logo_url}}"> | ||
<h5 class="my-auto ml-0 mr-auto">{{ target.name }}</h5> | ||
</div> | ||
<!-- <h5 class="card-header"><img width=48 class="rounded float-end" src="{{target.logo_url}}">{{ target.name }}</h5> --> | ||
<div class="card-body"> | ||
<p class="card-text"> | ||
|
||
{% if target.html_name == 'Mantium' %} | ||
Application ID: {{ target.app_id }} | ||
{% elif target.html_name == 'Redis' %} | ||
Host: {{ target.host }}<br/> | ||
Port: {{ target.port }}<br/> | ||
Database Name: {{ target.database_name }}<br/> | ||
Username: {{ target.username }} | ||
{% endif %} | ||
{% if target.html_name == 'Pinecone' %} | ||
API Key: {{ target.decrypted_api_key }}<br/> | ||
Environment: {{ target.environment }}<br/> | ||
Index Name: {{ target.index_name }}<br/> | ||
Project Name: {{ target.project_name }} | ||
{% endif %} | ||
</p> | ||
<div class="d-flex"> | ||
<a href="{% url 'target_delete' target.id %}" class="btn btn-danger ml-auto mr-0">Delete</a> | ||
<a href="#" class="btn btn-primary ml-2 mr-0 disabled">Edit</a> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
{% endfor %} | ||
</div> | ||
{% endblock %} | ||
</div> | ||
<hr> | ||
|
||
{% for target in user_targets %} | ||
|
||
<div class="card my-4"> | ||
<div class="d-flex card-header"> | ||
<img width=48 class="rounded float-end my-auto ml-0 mr-3" src="{{target.logo_url}}"> | ||
<h5 class="my-auto ml-0 mr-auto">{{ target.name }}</h5> | ||
</div> | ||
<!-- <h5 class="card-header"><img width=48 class="rounded float-end" src="{{target.logo_url}}">{{ target.name }}</h5> --> | ||
<div class="card-body"> | ||
<p class="card-text"> | ||
|
||
{% if target.html_name == 'Mantium' %} | ||
Application ID: {{ target.app_id }} | ||
{% elif target.html_name == 'Redis' %} | ||
Host: {{ target.host }}<br /> | ||
Port: {{ target.port }}<br /> | ||
Database Name: {{ target.database_name }}<br /> | ||
Username: {{ target.username }} | ||
{% endif %} | ||
{% if target.html_name == 'Pinecone' %} | ||
API Key: {{ target.decrypted_api_key }}<br /> | ||
Environment: {{ target.environment }}<br /> | ||
Index Name: {{ target.index_name }}<br /> | ||
Project Name: {{ target.project_name }} | ||
{% endif %} | ||
</p> | ||
<div class="d-flex"> | ||
<a href="{% url 'target_delete' target.id %}" class="btn btn-danger ml-auto mr-0">Delete</a> | ||
<a href="#" class="btn btn-primary ml-2 mr-0 disabled">Edit</a> | ||
{% if target.html_name == 'Redis' %} | ||
<button data-target-id="{{ target.id }}" class="btn btn-info ml-2 mr-0 ping-btn">Ping</button> | ||
{% endif %} | ||
</div> | ||
</div> | ||
</div> | ||
|
||
{% endfor %} | ||
</div> | ||
|
||
<script> | ||
document.addEventListener('DOMContentLoaded', function () { | ||
const pingButtons = document.querySelectorAll('.ping-btn'); | ||
pingButtons.forEach(btn => { | ||
btn.addEventListener('click', async function () { | ||
const targetId = btn.getAttribute('data-target-id'); | ||
const response = await fetch(`/target/ping/${targetId}/`, { headers: { 'X-Requested-With': 'XMLHttpRequest' } }); | ||
const result = await response.json(); | ||
if (result.success) { | ||
alert('Ping successful'); | ||
} else { | ||
alert('Ping failed: ' + (result.error || 'Unknown error')); | ||
} | ||
}); | ||
}); | ||
}); | ||
</script> | ||
|
||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters