Skip to content

Commit

Permalink
For tickets #590, #648, #664, #665, #668, #686 (#701)
Browse files Browse the repository at this point in the history
  • Loading branch information
mhmdkrmabd authored Jan 11, 2025
1 parent d014c84 commit 195ba7d
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 31 deletions.
93 changes: 68 additions & 25 deletions renderer/js/events/clusters.js
Original file line number Diff line number Diff line change
Expand Up @@ -1997,7 +1997,8 @@
if (['udt', 'counter-tables-parent', 'tables-parent', 'table'].every((type) => !nodeType.includes(type)))
throw 0

contextMenu = []
if (nodeType != 'table')
contextMenu = []

targetName = keyspaceName
} catch (e) {}
Expand Down Expand Up @@ -9918,10 +9919,34 @@
$('div.modal#rightClickActionsMetadata').find('div.empty-standard-table-clustering-keys').find('span[mulang]').hide()
$('div.modal#rightClickActionsMetadata').find('div.empty-standard-table-clustering-keys').find('span:not(.no-keys)').show()

$('div.modal#rightClickActionsMetadata').find('div.empty-standard-table-columns').find('span[mulang]').hide()
$('div.modal#rightClickActionsMetadata').find('div.empty-standard-table-columns').find('span:not(.no-columns)').show()

$('div.modal#rightClickActionsMetadata').find('div.empty-standard-table-udt-columns').find('span[mulang]').hide()
$('div.modal#rightClickActionsMetadata').find('div.empty-standard-table-udt-columns').find('span.add-column').show()

$(`a#addStandardTableUDTColumns`).removeClass('hide-action-button')

// For UDT columns
try {
let keyspaceUDTs = JSON.parse(data.udts)

if (keyspaceUDTs.length > 0)
throw 0

$(`a#addStandardTableUDTColumns`).addClass('hide-action-button')

$('div.modal#rightClickActionsMetadata').find('div.empty-standard-table-udt-columns').find('span[mulang]').hide()

$('div.modal#rightClickActionsMetadata').find('div.empty-standard-table-udt-columns').find('span.no-udts').show()
} catch (e) {}

$('#rightClickActionsMetadata div.input-group-text.standard-table-name-keyspace div.keyspace-name').text(`${data.keyspaceName}`)

$(`a[action]#addStandardTablePartitionKey`).removeClass('disabled')

$(`a[action]#addStandardTablePartitionKey`).add($(`a[action]#addStandardTableClusteringKey`)).show()

$('div.modal#rightClickActionsMetadata div[action]').hide()

$('div.modal#rightClickActionsMetadata div[action="standard-tables"]').show()
Expand Down Expand Up @@ -9975,6 +10000,8 @@

$(`a[action]#addCounterTablePartitionKey`).removeClass('disabled')

$(`a[action]#addCounterTablePartitionKey`).add($(`a[action]#addCounterTableClusteringKey`)).show()

$('div.modal#rightClickActionsMetadata div[action]').hide()

$('div.modal#rightClickActionsMetadata div[action="counter-tables"]').show()
Expand Down Expand Up @@ -10071,7 +10098,7 @@

$(`a[action]#addCounterTablePartitionKey`).trigger('click', JSON.stringify(partitionKeys))

$(`a[action]#addCounterTablePartitionKey`).add($(`a[action]#addCounterTableClusteringKey`)).addClass('disabled')
$(`a[action]#addCounterTablePartitionKey`).add($(`a[action]#addCounterTableClusteringKey`)).hide()

$(`a[action]#addCounterTableClusteringKey`).trigger('click', JSON.stringify(clusteringKeys))

Expand All @@ -10096,6 +10123,8 @@
},
tableOptions = []

let keyspaceUDTs

try {
tableObj = JSON.parse(data.tables).find((table) => table.name == tableName)
} catch (e) {}
Expand All @@ -10121,7 +10150,7 @@
} catch (e) {}

try {
let keyspaceUDTs = JSON.parse(data.udts),
keyspaceUDTs = JSON.parse(data.udts),
filteredColumns = tableObj.columns.filter((column) => tableObj.primary_key.find((key) => key.name == column.name) == undefined)

for (let column of filteredColumns) {
Expand Down Expand Up @@ -10173,7 +10202,7 @@

$(`a[action]#addStandardTablePartitionKey`).trigger('click', JSON.stringify(partitionKeys))

$(`a[action]#addStandardTablePartitionKey`).add($(`a[action]#addStandardTableClusteringKey`)).addClass('disabled')
$(`a[action]#addStandardTablePartitionKey`).add($(`a[action]#addStandardTableClusteringKey`)).hide()

$(`a[action]#addStandardTableClusteringKey`).trigger('click', JSON.stringify(clusteringKeys))

Expand All @@ -10183,6 +10212,17 @@

$(`a[action]#addStandardTableUDTColumns`).trigger('click', JSON.stringify(columns.udt))

try {
if (keyspaceUDTs.length > 0)
throw 0

$(`a#addStandardTableUDTColumns`).addClass('hide-action-button')

$('div.modal#rightClickActionsMetadata').find('div.empty-standard-table-udt-columns').find('span[mulang]').hide()

$('div.modal#rightClickActionsMetadata').find('div.empty-standard-table-udt-columns').find('span.no-udts').show()
} catch (e) {}

rightClickActionsMetadataModal.show()

$('#rightClickActionsMetadata').find('div.standard-table-options-sub-container a').click()
Expand Down Expand Up @@ -10257,7 +10297,9 @@
keyspaceName = $('input#keyspaceName').val(),
durableWrites = $('input#keyspaceDurableWrites').prop('checked'),
replication = {},
isAlterState = $('div.modal#rightClickActionsMetadata').attr('data-state')
isRFAcceptable = false

isAlterState = $('div.modal#rightClickActionsMetadata').attr('data-state')

isAlterState = isAlterState != null && isAlterState == 'alter'

Expand Down Expand Up @@ -10297,8 +10339,22 @@
if (rf <= 0)
continue

isRFAcceptable = true

replication[dataCenter.attr('data-datacenter')] = rf
}

if (isAlterState)
isRFAcceptable = true

dialogElement.find('div.row.invalid-text-container').toggleClass('show', !isRFAcceptable)

let invalidState = !isAlterState && (!isRFAcceptable || ($('input#keyspaceName').hasClass('is-invalid') || `${$('input#keyspaceName').val()}`.length <= 0))

dialogElement.find('button.switch-editor').add($('#executeActionStatement')).attr('disabled', invalidState ? '' : null)

if (invalidState)
return
} catch (e) {}

let durableWritesSetValue = $('input#keyspaceDurableWrites').attr('set-value'),
Expand Down Expand Up @@ -10490,6 +10546,10 @@
return

dialogElement.find('button.switch-editor').add($('#executeActionStatement')).attr('disabled', isInvalid ? '' : null)

try {
updateActionStatusForKeyspaces()
} catch (e) {}
})
})

Expand Down Expand Up @@ -12879,29 +12939,15 @@

$(this).find('div.field-sort-type').parent().hide()

let notCondition = ['int', 'text', 'varchar'].some((type) => fieldType == type) ? `:not(.clusteringKeyType)` : ''

switch (fieldType) {
case 'int':
$(this).find(`a.dropdown-item:not([value="${fieldType}"]):not([value="varint"])`).remove()
break;
case 'text':
$(this).find(`a.dropdown-item:not([value="${fieldType}"]):not([value="varchar"])`).remove()
break;
case 'varchar':
$(this).find(`a.dropdown-item:not([value="${fieldType}"]):not([value="text"])`).remove()
break;
}

$(this).find('span.group-text').remove()

$(this).find(`a:not([value]), input${notCondition}`).removeClass('is-invalid').addClass('disabled').attr('disabled', 'disabled').css('background-color', '')
$(this).find(`a:not([value]), input`).removeClass('is-invalid').addClass('disabled').attr('disabled', 'disabled').css('background-color', '')

$(this).find(`a[action="delete-counter-table-clustering-key"]`).parent().hide()

$(this).find('div[col="clusteringKeyName"], div[col="clusteringKeyType"]').removeClass('col-md-5').addClass('col-md-6')

$(this).find(`input${notCondition}`).parent().children('ion-icon[name="arrow-down"]').hide()
$(this).find(`input`).parent().children('ion-icon[name="arrow-down"]').hide()
})

setTimeout(() => {
Expand Down Expand Up @@ -12969,10 +13015,7 @@
if (!mainDropDown)
throw 0

let newColMD = isTypeCollection ? (isCollectionMap ? 3 : 4) : 5

if (isAltered)
newColMD += 1
let newColMD = isTypeCollection ? (isCollectionMap ? 4 : 5) : 6

row.find(`div[col="clusteringKeyName"]`).removeClass(function(index, className) {
return (className.match(/(^|\s)col-md-\S+/g) || []).join(' ')
Expand Down
10 changes: 10 additions & 0 deletions renderer/js/events/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -882,12 +882,22 @@

// Once the associated select element is being focused then show the dropdown element and vice versa
input.on('focus', () => {
let isInputDisabled = input.hasClass('disabled') || input.attr('disabled') != undefined

if (isInputDisabled)
return selectDropdown.hide()

try {
input.parent().find('div.invalid-feedback').addClass('transparent-color')
} catch (e) {}

selectDropdown.show()
}).on('focusout', () => setTimeout(() => {
let isInputDisabled = input.hasClass('disabled') || input.attr('disabled') != undefined

if (isInputDisabled)
return selectDropdown.hide()

try {
input.parent().find('div.invalid-feedback').removeClass('transparent-color')
} catch (e) {}
Expand Down
2 changes: 1 addition & 1 deletion renderer/js/funcs.js
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,7 @@ let buildTreeview = (metadata, ignoreTitles = false) => {
let attributes = ['virtual', 'durable_writes', 'is_static', 'is_reversed']

if (parentType == 'partitionKeys')
attributes = `${attributes}`.slice(0, -2)
attributes = attributes.slice(0, -2)

// Loop through them all
attributes.forEach((attribute) => {
Expand Down
25 changes: 25 additions & 0 deletions renderer/styles/collections/globs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -997,3 +997,28 @@ div.btn.field-sort-type.badge {
opacity: 0.65;
}
}

.invalid-text-container {
color: #dc4c64;
height: 0;
transform: scaleY(0);

.invalid-text {
font-size: 80% !important;
width: auto;
margin-top: 3px;
display: inline-block;
transform-origin: top;
}

&.show {
transition: transform 0.15s ease-in-out;
height: auto;
transform: scaleY(1);
}
}

.hide-action-button {
opacity: 0;
pointer-events: none;
}
4 changes: 2 additions & 2 deletions renderer/styles/master.css

Large diffs are not rendered by default.

12 changes: 9 additions & 3 deletions renderer/views/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1828,6 +1828,11 @@ <h5 class="modal-title">
</span>
</div>
</div>
<div class="row invalid-text-container">
<div class="col-md-12">
<span class="invalid-text" mulang="at least one data center should have a replication factor greater than 0" capitalize-first></span>.
</div>
</div>
<div class="data-centers"></div>
</div>
<div class="form-check margin-bottom" style="margin-top: 20px;">
Expand Down Expand Up @@ -1951,7 +1956,7 @@ <h5 class="modal-title">
<div class="standard-table-columns-fields">
<div class="empty-standard-table-columns">
<span mulang="add column by clicking the + button" capitalize-first></span>
<span mulang="this table has no columns" style="display:none;" capitalize-first></span>
<span mulang="this table has no columns" class="no-columns" style="display:none;" capitalize-first></span>
</div>
</div>
<div class="fields-badge-action">
Expand All @@ -1966,8 +1971,9 @@ <h5 class="modal-title">
</div>
<div class="standard-table-udt-columns-fields">
<div class="empty-standard-table-udt-columns">
<span mulang="add column by clicking the + button" capitalize-first></span>
<span mulang="this table has no UDT columns" style="display:none;" capitalize-first></span>
<span mulang="add column by clicking the + button" class="add-column" capitalize-first></span>
<span mulang="this table has no UDT columns" class="no-columns" style="display:none;" capitalize-first></span>
<span mulang="this keyspace has no UDTs" class="no-udts" style="display:none;" capitalize-first></span>
</div>
</div>
<div class="show-standard-table-options-container">
Expand Down

0 comments on commit 195ba7d

Please sign in to comment.