Skip to content

Commit

Permalink
rdbms added
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashish S. Maharjan committed Jan 8, 2024
1 parent c263ec4 commit 4b935d2
Show file tree
Hide file tree
Showing 24 changed files with 661 additions and 2 deletions.
Binary file modified django_project/db.sqlite3
Binary file not shown.
Empty file.
6 changes: 6 additions & 0 deletions django_project/rdbms/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class RdbmsConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'rdbms'
24 changes: 24 additions & 0 deletions django_project/rdbms/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 5.0.1 on 2024-01-08 16:06

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='RdbmsManager',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=200)),
('username', models.TextField()),
('password', models.TextField()),
('datestamp', models.DateTimeField(auto_now_add=True)),
],
),
]
20 changes: 20 additions & 0 deletions django_project/rdbms/migrations/0002_rdbmsmanager_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 5.0.1 on 2024-01-08 17:03

import django.utils.timezone
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('rdbms', '0001_initial'),
]

operations = [
migrations.AddField(
model_name='rdbmsmanager',
name='type',
field=models.TextField(default=django.utils.timezone.now),
preserve_default=False,
),
]
20 changes: 20 additions & 0 deletions django_project/rdbms/migrations/0003_rdbmsmanager_host.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 5.0.1 on 2024-01-08 17:55

import django.utils.timezone
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('rdbms', '0002_rdbmsmanager_type'),
]

operations = [
migrations.AddField(
model_name='rdbmsmanager',
name='host',
field=models.TextField(default=django.utils.timezone.now),
preserve_default=False,
),
]
Empty file.
17 changes: 17 additions & 0 deletions django_project/rdbms/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from django.db import models
from django.urls import reverse


class RdbmsManager(models.Model):
name = models.CharField(max_length=200)
host = models.TextField()
username = models.TextField()
password = models.TextField()
type = models.TextField()
datestamp = models.DateTimeField(auto_now_add=True)

def __str__(self):
return self.name

def get_absolute_url(self):
return reverse('rdbms-manager-list')
103 changes: 103 additions & 0 deletions django_project/rdbms/templates/mysql/databases.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
{% extends 'base.html' %}

{% load static %}

{% block title %}
Primary Vault
{% endblock %}


{% block content %}
<div class="row mt-4 sm-mt-3">
<div class="col-lg-12">
{% if result %}
<div class="card">
<div class="card-body table-responsive">
<table class="table">
<thead>
<tr>
<th></th>
<th>Name</th>
<th>Engine</th>
<th>Version</th>
<th>Row format</th>
<th>Avg row length</th>
<th>Data length</th>
<th>Max data length</th>
<th>Index length</th>
<th>Free data</th>
<th>Auto increment</th>
<th>Created time</th>
<th>Updated time</th>
<th>Checked time</th>
<th>Collation</th>
<th>Checksum</th>
<th>Create options</th>
<th>Table comment</th>
</tr>
{% for i in result.result %}
<tr>
<td></td>
<td>
{{i.table_name}}
</td>
<td>
{{i.engine}}
</td>
<td>
{{i.version}}
</td>
<td>
{{ i.row_format }}
</td>
<td>
{{ i.avg_row_length }}
</td>
<td>
{{ i.data_length }}
</td>
<td>
{{ i.max_data_length }}
</td>
<td>
{{ i.index_length }}
</td>
<td>
{{ i.data_free }}
</td>
<td>
{{ i.auto_increment }}
</td>
<td>
{{ i.create_time }}
</td>
<td>
{{ i.update_time }}
</td>
<td>
{{ i.check_time }}
</td>
<td>
{{ i.table_collation }}
</td>
<td>
{{ i.checksum }}
</td>
<td>
{{ i.create_options }}
</td>
<td>
{{ i.table_comment }}
</td>
</tr>
{% endfor %}
</thead>
</table>
</div>
</div>
{% else %}
<div class="alert alert-warning">No records found!</div>
{% endif %}
</div>
</div>
{% endblock content %}
48 changes: 48 additions & 0 deletions django_project/rdbms/templates/rdbms/add.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{% extends 'base.html' %}

{% block title %}
Add new RDBMS
{% endblock %}

{% block content %}
<div class="row">
<div class="col-md-6">
<form method="post">
{% csrf_token %}
<div class="card">
<div class="card-body">
<div class="mb-3">
<label for="id_name" class="form-label">Title</label>
<input type="text" class="form-control" id="id_name" name="name" maxlength="200" required="" autocomplete="off" placeholder="Your RDBMS name">
</div>
<div class="mb-3">
<label for="id_hostname" class="form-label">Hostname</label>
<input type="text" class="form-control" id="id_hostname" name="host" required=""
autocomplete="off" placeholder="127.0.0.1:3306">
</div>
<div class="mb-3">
<label for="id_username" class="form-label">Username</label>
<input type="text" class="form-control" id="id_username" name="username" required=""
autocomplete="off" placeholder="Root username">
</div>
<div class="mb-3">
<label for="id_password" class="form-label">Password</label>
<input type="text" class="form-control" id="id_password" name="password" required=""
autocomplete="off" placeholder="Root password">
</div>
<div class="mb-3">
<label for="id_type" class="form-label">Type</label>
<input type="text" class="form-control" id="id_type" name="type" required="" autocomplete="off" value="MySQL">
</div>
</div>
<div class="card-footer">
<div class="d-flex" style="justify-content: space-between; align-items: center;">
<button type="submit" class="btn btn-primary">Save</button>
<a href="{% url 'rdbms-manager-list' %}">Go back</button>
</div>
</div>
</div>
</form>
</div>
</div>
{% endblock content %}
40 changes: 40 additions & 0 deletions django_project/rdbms/templates/rdbms/delete.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{% extends 'base.html' %}

{% block content %}
<div class="row">
<div class="col-md-6">
<form method="post">
{% csrf_token %}
<div class="card">
<div class="card-body">
<p class="text-danger">You are about to delete</p>
<table class="table">
<tr>
<td>Title</td>
<td>{{ object.name }} </td>
</tr>
<tr>
<td>Username</td>
<td>{{ object.username }} </td>
</tr>
<tr>
<td>Password</td>
<td>{{ object.password }} </td>
</tr>
<tr>
<td>Type</td>
<td>{{ object.type }} </td>
</tr>
</table>
</div>
<div class="card-footer">
<div class="d-flex" style="justify-content: space-between; align-items: center;">
<button type="submit" class="btn btn-danger">Yes, I'm sure</button>
<a href="{% url 'vault-manager-list' %}">No, take me back</button>
</div>
</div>
</div>
</form>
</div>
</div>
{% endblock content %}
74 changes: 74 additions & 0 deletions django_project/rdbms/templates/rdbms/detail.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{% extends 'base.html' %}

{% block content %}
<div class="row mb-4">
<div class="col d-flex justify-content-end">
<a href="{% url 'rdbms-manager-list' %}" class="btn btn-primary btn-sm">
< Go back to the list</a>
</div>
</div>
<div class="row">
<div class="col-lg-7">
<div class="card">
<div class="card-header">
<h6 class="my-2">Schemas found</h6>
</div>
<div class="card-body">

<ul class="list-group">
{% for schema in schemas.result %}
<form method="POST" action="{% url 'rdbms-mysql-database-list' %}">
{% csrf_token %}
<input type="text" value="{{ schema.name }}" name="db" class="d-none">
<input type="text" value="{{ object.username }}" name="username" class="d-none">
<input type="text" value="{{ object.password }}" name="password" class="d-none">
<input type="text" value="{{ object.host }}" name="host" class="d-none">
<button class="list-group-item list-group-item-action" type="submit"
class="btn btn-primary me-2">
{{ schema.name }}
</button>
</form>
{% endfor %}
</ul>

</div>
</div>
</div>
<div class="col-md-5">
<div class="card">
<div class="card-header">
<h6 class="my-2">Connection string</h6>
</div>
<div class="card-body">
<table class="table">
<tr>
<th>Id</th>
<td>{{ object.id }}</td>
</tr>
<tr>
<th>Title</th>
<td>{{ object.name }}</td>
</tr>
<tr>
<th>Username</th>
<td>{{ object.username }}</td>
</tr>
<tr>
<th>Password</th>
<td>{{ object.password }}</td>
</tr>
<tr>
<th>Type</th>
<td>{{ object.type }}</td>
</tr>
<tr>
<th>Created date</th>
<td>{{ object.datestamp }}</td>
</tr>
</table>
</div>
</div>
</div>
</div>

{% endblock content %}
Loading

0 comments on commit 4b935d2

Please sign in to comment.