Skip to content

Commit

Permalink
Update UI Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
vc-urvin committed Jun 29, 2023
1 parent 1f78b8b commit 15e8cff
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
9 changes: 5 additions & 4 deletions src/Controllers/DisplayController.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public function getAudit(): JsonResponse
} else {
$value[$columnName] = $constraint;
}
$value["size"] = $value['size']." MB";
return $value;
}, $this->tablesRule());

Expand Down Expand Up @@ -123,26 +124,26 @@ public function getTableConstraint(string $tableName): JsonResponse
switch ($constraint) {
case Constant::CONSTRAINT_PRIMARY_KEY:
if (in_array($table->COLUMN_NAME, $noConstraintFields['integer'])) {
$primaryKey = '<img src=' . asset("auditor/icon/add.svg") . ' alt="key" class="m-auto add-constraint-' . $table->COLUMN_NAME . '-' . Constant::CONSTRAINT_PRIMARY_KEY . '" style="height:30px;cursor: pointer;" onclick="add(`' . $table->COLUMN_NAME . '`, `' . Constant::CONSTRAINT_PRIMARY_KEY . '`)"/>';
$primaryKey = '<img src=' . asset("auditor/icon/add.svg") . ' alt="key" class="m-auto add-constraint-' . $table->COLUMN_NAME . '-' . Constant::CONSTRAINT_PRIMARY_KEY . '" style="height:20px;cursor: pointer;" onclick="add(`' . $table->COLUMN_NAME . '`, `' . Constant::CONSTRAINT_PRIMARY_KEY . '`)"/>';
}
break;
case Constant::CONSTRAINT_INDEX_KEY:
if (in_array($table->COLUMN_NAME, $noConstraintFields['mix'])) {
$indexKey = '<img src=' . asset("auditor/icon/add.svg") . ' alt="key" class="m-auto add-constraint-' . $table->COLUMN_NAME . '-' . Constant::CONSTRAINT_INDEX_KEY . '" style="height:30px;cursor: pointer;" onclick="add(`' . $table->COLUMN_NAME . '`, `' . Constant::CONSTRAINT_INDEX_KEY . '`)"/>';
$indexKey = '<img src=' . asset("auditor/icon/add.svg") . ' alt="key" class="m-auto add-constraint-' . $table->COLUMN_NAME . '-' . Constant::CONSTRAINT_INDEX_KEY . '" style="height:20px;cursor: pointer;" onclick="add(`' . $table->COLUMN_NAME . '`, `' . Constant::CONSTRAINT_INDEX_KEY . '`)"/>';
}
break;
case Constant::CONSTRAINT_UNIQUE_KEY:
if (in_array($table->COLUMN_NAME, $noConstraintFields['mix'])) {
$fields = $this->getUniqueFields($tableName, $noConstraintFields['mix']);
if (in_array($table->COLUMN_NAME, $fields)) {
$uniqueKey = '<img src=' . asset("auditor/icon/add.svg") . ' alt="key" class="m-auto add-constraint-' . $table->COLUMN_NAME . '-' . Constant::CONSTRAINT_UNIQUE_KEY . '" style="height:30px;cursor: pointer;" onclick="add(`' . $table->COLUMN_NAME . '`, `' . Constant::CONSTRAINT_UNIQUE_KEY . '`)"/>';
$uniqueKey = '<img src=' . asset("auditor/icon/add.svg") . ' alt="key" class="m-auto add-constraint-' . $table->COLUMN_NAME . '-' . Constant::CONSTRAINT_UNIQUE_KEY . '" style="height:20px;cursor: pointer;" onclick="add(`' . $table->COLUMN_NAME . '`, `' . Constant::CONSTRAINT_UNIQUE_KEY . '`)"/>';
}
}
break;
case Constant::CONSTRAINT_FOREIGN_KEY:
if(in_array($table->COLUMN_NAME, $noConstraintFields['integer'])) {
if(!$this->tableHasValue($tableName)) {
$foreignKey = '<img src=' . asset("auditor/icon/add.svg") . ' alt="key" class="m-auto add-constraint-'.$table->COLUMN_NAME.'-'.Constant::CONSTRAINT_FOREIGN_KEY.'" style="height:30px;cursor: pointer;" onclick="add(`'.$table->COLUMN_NAME.'`, `'.Constant::CONSTRAINT_FOREIGN_KEY.'`,`'.$tableName.'`)"/>';
$foreignKey = '<img src=' . asset("auditor/icon/add.svg") . ' alt="key" class="m-auto add-constraint-'.$table->COLUMN_NAME.'-'.Constant::CONSTRAINT_FOREIGN_KEY.'" style="height:20px;cursor: pointer;" onclick="add(`'.$table->COLUMN_NAME.'`, `'.Constant::CONSTRAINT_FOREIGN_KEY.'`,`'.$tableName.'`)"/>';
}
}
break;
Expand Down
25 changes: 19 additions & 6 deletions src/views/auditor/pages/audit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@
.constraint-value {
display: none;
}
.table-value{
display: none;
}
</style>
@endpush

Expand Down Expand Up @@ -133,7 +136,7 @@ class="uppercase d-flex items-center me-3 text-[13px] pb-2 relative custom-actio
<div class="tabs__tab" id="tab_constraint" data-tab-info>

<div class="dropdown mb-3">
<label>Select Table</label>
<label style="margin-right:5px">Select Table </label>
<select
class="btn dropdown-toggle bg-light-black border-0 rounded-2xl text-white w-64 text-start relative text-sm hover:bg-light-black focus:bg-light-black active:bg-light-black mr-1"
name="table" id="tbl-dropdown">
Expand Down Expand Up @@ -419,12 +422,10 @@ function add(columnName, constraint, tableName) {
$('.constraint-value').replaceWith("<p class='constraint-value'>" + constraint + "</p>");
getForeignTables();
} else {
console.log($(".main-dialog")[0]);
if ( $(".main-dialog")[0] ) {
$('#confDialog h2').replaceWith("<h2>ADD " + constraint.toUpperCase() + " KEY</h2>");
$('.main-dialog').replaceWith('<p>Do you want to add ' + constraint.toLowerCase() +' in <span style="color:red;">' + columnName + '</span> field?</p>');
$('.confirm-dialog-btn').replaceWith('<button onclick="confirmDialog()" class="btn btn-success confirm-dialog-btn">Yes</button>');
} else {
$('#confDialog h2').replaceWith("<h2>ADD " + constraint.toUpperCase() + " KEY</h2>");
$('#confDialog p').replaceWith('<p>Do you want to add ' + constraint.toLowerCase() +' in <span style="color:red;">' + columnName + '</span> field?</p>');
Expand Down Expand Up @@ -453,20 +454,32 @@ function addConstraint() {
success: function(response) {
if (response) {
var key = "";
var constraints = ['INDEX', 'PRIMARY', 'UNIQUE', 'FOREIGN'];
if(constraint.toLowerCase() === "primary") {
key = '<img src="auditor/icon/green-key.svg" alt="key" class="m-auto" />';
} else {
key = '<img src="auditor/icon/gray-key.svg" alt="key" class="m-auto" />';
}
constraintList = jQuery.grep(constraints, function(value) {
return value != constraint;
});
$.each(constraintList, function(key, value) {
if($(".add-constraint-" + columnName + "-" + value)[0]) {
console.log(value);
$(".add-constraint-" + columnName + "-" + value).replaceWith('-');
}
});
$(".add-constraint-" + columnName + "-" + constraint).replaceWith(key);
$(".toast-container").css("display", "block");
$(".toastCustom").replaceWith("<p class='toastCustom'>" + constraint.toLowerCase() + " key added successfully</p>");
setTimeout(function() {
$(".toast-container").css("display", "none");;
}, 1000);
}, 2000);
}
},
error: function(xhr, status, error) {
Expand All @@ -486,7 +499,7 @@ function getForeignTables()
},
success: function(response) {
if (response) {
$('#confDialog h2').replaceWith("<h2>Add Foreign Key</h2>");
$('#confDialog h2').replaceWith("<h2>ADD FOREIGN KEY</h2>");
var html = "<div class='row main-dialog' style='margin-top: 30px;margin-bottom: 20px;'>";
Expand Down Expand Up @@ -571,7 +584,7 @@ function addforeignKey()
setTimeout(function() {
$(".toast-container").css("display", "none");;
}, 1000);
}, 2000);
}
},
error: function(xhr, status, error) {
Expand Down

0 comments on commit 15e8cff

Please sign in to comment.