Skip to content

Commit

Permalink
v0.2.2.3-alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
FlamesONE committed Jun 26, 2024
1 parent 6f4c2dc commit f45fd36
Show file tree
Hide file tree
Showing 35 changed files with 338 additions and 246 deletions.
7 changes: 0 additions & 7 deletions app/Core/Admin/Http/Controllers/Api/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Flute\Core\Admin\Http\Controllers\Api;

use Flute\Core\Admin\Http\Middlewares\HasPermissionMiddleware;
use Flute\Core\DiscordLink\DiscordLinkRoles;
use Flute\Core\Http\Middlewares\CSRFMiddleware;
use Flute\Core\Support\AbstractController;
use Flute\Core\Support\FluteRequest;
Expand Down Expand Up @@ -37,10 +36,6 @@ public function edit(FluteRequest $request, string $id): Response
return $this->error($result['message'], $result['code']);
}

$user = user()->get((int) $id, true);

app()->get(DiscordLinkRoles::class)->linkRoles($user, $user->getRoles()->toArray());

return $this->success();
}

Expand All @@ -52,8 +47,6 @@ public function delete(FluteRequest $request, string $id): Response
return $this->error($result['message'], $result['code']);
}

app()->get(DiscordLinkRoles::class)->clearRoles(user()->get((int) $id, true), );

return $this->success();
}

Expand Down
2 changes: 1 addition & 1 deletion app/Core/Admin/Http/Controllers/Views/ApiView.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function list(FluteRequest $request)
{
$apikeys = rep(ApiKey::class)->findAll();

$table = table();
$table = table()->setSelectable(true);

$table->setPhrases([
'key' => __('admin.api.key'),
Expand Down
2 changes: 1 addition & 1 deletion app/Core/Admin/Http/Controllers/Views/CurrenciesView.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function __construct()

public function list(): Response
{
$table = table();
$table = table()->setSelectable(true);

$table->setPhrases([
'code' => __('admin.currency.currency'),
Expand Down
2 changes: 1 addition & 1 deletion app/Core/Admin/Http/Controllers/Views/DatabasesView.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function __construct()

public function list(): Response
{
$table = table();
$table = table()->setSelectable(true);

$result = rep(DatabaseConnection::class)->select()->load('server');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function add(FluteRequest $request)

public function list(FluteRequest $request)
{
$table = table();
$table = table()->setSelectable(true);
$socials = rep(FooterSocial::class)->findAll();

$table->addColumns([
Expand Down Expand Up @@ -74,7 +74,8 @@ function(data, type, full, meta) {
deleteDiv.setAttribute("data-translate", "admin.footer.social_delete");
deleteDiv.setAttribute("data-translate-attribute", "data-tooltip");
deleteDiv.setAttribute("data-tooltip-conf", "left");
deleteDiv.setAttribute("data-deletesocial", data[0]);
deleteDiv.setAttribute("data-deleteaction", data[0]);
deleteDiv.setAttribute("data-deletepath", "footer/socials");
let deleteIcon = make("i");
deleteIcon.classList.add("ph-bold", "ph-trash");
deleteDiv.appendChild(deleteIcon);
Expand Down
3 changes: 2 additions & 1 deletion app/Core/Admin/Http/Controllers/Views/ModulesView.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ function(data, type, full, meta) {
deleteDiv.setAttribute("data-translate", "admin.modules_list.delete_module");
deleteDiv.setAttribute("data-translate-attribute", "data-tooltip");
deleteDiv.setAttribute("data-tooltip-conf", "left");
deleteDiv.setAttribute("data-deletemodule", data[0]);
deleteDiv.setAttribute("data-deleteaction", data[0]);
deleteDiv.setAttribute("data-deletepath", "modules");
let deleteIcon = make("i");
deleteIcon.classList.add("ph-bold", "ph-trash");
deleteDiv.appendChild(deleteIcon);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function __construct()

public function list(FluteRequest $request)
{
$table = table();
$table = table()->setSelectable(true);

$table->setPhrases([
'event' => __('admin.notifications.event'),
Expand Down
2 changes: 1 addition & 1 deletion app/Core/Admin/Http/Controllers/Views/PagesView.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function list(FluteRequest $request)
{
$pages = rep(Page::class)->select()->orderBy('id', 'desc')->fetchAll();

$table = table();
$table = table()->setSelectable(true);

$table->setPhrases([
'route' => __('admin.pages.route_label')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function __construct()

public function list(): Response
{
$table = table();
$table = table()->setSelectable(true);
$promos = rep(PromoCode::class)->select()->load('usages')->fetchAll();

foreach ($promos as $promo) {
Expand Down Expand Up @@ -63,7 +63,8 @@ function(data, type, full, meta) {
deleteDiv.setAttribute("data-translate", "admin.payments.promo.delete");
deleteDiv.setAttribute("data-translate-attribute", "data-tooltip");
deleteDiv.setAttribute("data-tooltip-conf", "left");
deleteDiv.setAttribute("data-deletepromo", data[0]);
deleteDiv.setAttribute("data-deleteaction", data[0]);
deleteDiv.setAttribute("data-deletepath", "payments/promo");
let deleteIcon = make("i");
deleteIcon.classList.add("ph-bold", "ph-trash");
deleteDiv.appendChild(deleteIcon);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function payments()

public function list(): Response
{
$table = table();
$table = table()->setSelectable(true);
$payments = rep(PaymentGateway::class)->findAll();

$table->addColumns([
Expand Down Expand Up @@ -101,7 +101,8 @@ function(data, type, full, meta) {
deleteDiv.classList.add("action-button", "delete");
deleteDiv.setAttribute("data-translate", "admin.payments.delete");
deleteDiv.setAttribute("data-translate-attribute", "data-tooltip");
deleteDiv.setAttribute("data-deletepayment", data[0]);
deleteDiv.setAttribute("data-deleteaction", data[0]);
deleteDiv.setAttribute("data-deletepath", "payments");
let deleteIcon = make("i");
deleteIcon.classList.add("ph-bold", "ph-trash");
deleteDiv.appendChild(deleteIcon);
Expand Down
2 changes: 1 addition & 1 deletion app/Core/Admin/Http/Controllers/Views/RedirectsView.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function __construct()

public function list(): Response
{
$table = table();
$table = table()->setSelectable(true);
$table->setPhrases([
'fromUrl' => __('admin.redirects.from'),
'toUrl' => __('admin.redirects.to'),
Expand Down
5 changes: 3 additions & 2 deletions app/Core/Admin/Http/Controllers/Views/ServersView.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function __construct()

public function list(): Response
{
$table = table();
$table = table()->setSelectable(true);
$servers = rep(Server::class)->findAll();

$table->addColumns([
Expand Down Expand Up @@ -58,7 +58,8 @@ function(data, type, full, meta) {
deleteDiv.classList.add("action-button", "delete");
deleteDiv.setAttribute("data-translate", "admin.servers.delete");
deleteDiv.setAttribute("data-translate-attribute", "data-tooltip");
deleteDiv.setAttribute("data-deleteserver", data[0]);
deleteDiv.setAttribute("data-deleteaction", data[0]);
deleteDiv.setAttribute("data-deletepath", "servers");
let deleteIcon = make("i");
deleteIcon.classList.add("ph-bold", "ph-trash");
deleteDiv.appendChild(deleteIcon);
Expand Down
5 changes: 3 additions & 2 deletions app/Core/Admin/Http/Controllers/Views/SocialsView.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct()

public function list(): Response
{
$table = table();
$table = table()->setSelectable(true);
$socials = rep(SocialNetwork::class)->findAll();

$table->addColumns([
Expand Down Expand Up @@ -68,7 +68,8 @@ function(data, type, full, meta) {
deleteDiv.classList.add("action-button", "delete");
deleteDiv.setAttribute("data-translate", "admin.socials.delete");
deleteDiv.setAttribute("data-translate-attribute", "data-tooltip");
deleteDiv.setAttribute("data-deletesocial", data[0]);
deleteDiv.setAttribute("data-deleteaction", data[0]);
deleteDiv.setAttribute("data-deletepath", "socials");
let deleteIcon = make("i");
deleteIcon.classList.add("ph-bold", "ph-trash");
deleteDiv.appendChild(deleteIcon);
Expand Down
3 changes: 2 additions & 1 deletion app/Core/Admin/Http/Controllers/Views/ThemesView.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ function(data, type, full, meta) {
deleteDiv.classList.add("action-button", "delete");
deleteDiv.setAttribute("data-translate", "admin.themes_list.delete_theme");
deleteDiv.setAttribute("data-translate-attribute", "data-tooltip");
deleteDiv.setAttribute("data-deletetheme", data[0]);
deleteDiv.setAttribute("data-deleteaction", data[0]);
deleteDiv.setAttribute("data-deletepath", "themes");
deleteDiv.setAttribute("data-tooltip-conf", "left");
let deleteIcon = make("i");
deleteIcon.classList.add("ph-bold", "ph-trash");
Expand Down
2 changes: 1 addition & 1 deletion app/Core/Admin/Http/Controllers/Views/UsersView.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __construct()

public function list(): Response
{
$table = table();
$table = table()->setSelectable(true);
$users = rep(User::class)->select()->load('roles')->fetchAll();

foreach ($users as $key => $user) {
Expand Down
136 changes: 136 additions & 0 deletions app/Core/Admin/Http/Views/assets/js/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,142 @@ $(function () {
$iconMenu.slideUp();
});

let isMouseDown = false;
let isCtrlKey = false;
let isShiftKey = false;
let lastSelectedIndex = null;
let $table, $rows;

$(document)
.on(
'mousedown',
'table.selectable.dataTable > tbody > tr',
function (e) {
isMouseDown = true;
isCtrlKey = e.ctrlKey || e.metaKey;
isShiftKey = e.shiftKey;
$table = $(this).closest('table');
$rows = $table.find('tbody > tr');

const $row = $(this);
const currentIndex = $rows.index($row);

if (isCtrlKey) {
$row.toggleClass('selected');
} else if (isShiftKey && lastSelectedIndex !== null) {
const start = Math.min(lastSelectedIndex, currentIndex);
const end = Math.max(lastSelectedIndex, currentIndex);
$rows.slice(start, end + 1).addClass('selected');
} else {
if ($row.hasClass('selected')) {
$row.removeClass('selected');
} else {
$rows.removeClass('selected');
$row.addClass('selected');
}
}

lastSelectedIndex = currentIndex;
updateSelectionInfo();

return false; // prevent text selection
},
)
.on(
'mousemove',
'table.selectable.dataTable > tbody > tr',
function (e) {
if (isMouseDown && !isCtrlKey && !isShiftKey) {
const $row = $(this);
const currentIndex = $rows.index($row);
const start = Math.min(lastSelectedIndex, currentIndex);
const end = Math.max(lastSelectedIndex, currentIndex);
$rows.slice(start, end + 1).addClass('selected');
}
},
);

$(document).on('mouseup', function (e) {
isMouseDown = false;
});

// Сброс выделения при клике вне таблицы
$(document).on('click', function (e) {
if (!$(e.target).closest('table.selectable.dataTable').length) {
$('table.selectable.dataTable > tbody > tr').removeClass(
'selected',
);
updateSelectionInfo();
}
});

// Сброс выделения при нажатии клавиши Esc
$(document).on('keydown', function (e) {
if (e.key === 'Escape') {
$('table.selectable.dataTable > tbody > tr').removeClass(
'selected',
);
updateSelectionInfo();
}
});

// Обновление div с информацией о выделении
function updateSelectionInfo() {
if ($('table.selectable.dataTable > tbody > tr.selected').length > 0) {
$('#selection-info').addClass('opened');
$('#count-rows > span').text(
$('table.selectable.dataTable > tbody > tr.selected').length,
);
} else {
$('#selection-info').removeClass('opened');
}
}

// Получение HTML содержимого всех выделенных ячеек
$('#delete-rows').on('click', async function () {
const selectedCells = $(
'table.selectable.dataTable > tbody > tr.selected',
);
const ids = [];

let path = null,
count = 0;

selectedCells.each(function () {
let find = $(this).find('.action-button.delete');

if (find.length) {
ids.push(find.attr('data-deleteaction'));

if (!path) {
path = find.attr('data-deletepath');
}
}
});

const callback = (res) => {
count++;

if (count === ids.length) {
refreshCurrentPage();
}
};

if (path && ids) {
if (await asyncConfirm(translate('admin.confirm_delete'))) {
for (let id of ids) {
sendRequest(
{},
'admin/api/' + path + '/' + id,
'DELETE',
callback,
false,
);
}
}
}
});

fetchIcons();
});

Expand Down
18 changes: 1 addition & 17 deletions app/Core/Admin/Http/Views/assets/js/pages/footer/social/list.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
$(function () {
$(document).on(
'click',
'.social-action-buttons .action-button.delete',
async function () {
let socialId = $(this).data('deletesocial');
if (
await asyncConfirm(
translate('admin.footer.social_confirm_delete'),
)
)
sendRequest(
{},
'admin/api/footer/socials/' + socialId,
'DELETE',
);
},
);
//
});
15 changes: 0 additions & 15 deletions app/Core/Admin/Http/Views/assets/js/pages/modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,21 +350,6 @@ $(function () {
});
});

// Handle delete module action
$(document).on(
'click',
'.module-action-buttons .action-button.delete',
async function () {
let moduleId = $(this).data('deletemodule');
if (
await asyncConfirm(
translate('admin.modules_list.confirm_delete'),
)
)
sendRequest({}, u('admin/api/modules/' + moduleId), 'DELETE');
},
);

// Handle install module action
$(document).on(
'click',
Expand Down
Loading

0 comments on commit f45fd36

Please sign in to comment.