Skip to content

Commit

Permalink
Toggles
Browse files Browse the repository at this point in the history
  • Loading branch information
msimmer committed Dec 6, 2019
1 parent c740c31 commit fdcd1fa
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 15 deletions.
31 changes: 31 additions & 0 deletions public/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,5 +276,36 @@
link.parentNode.removeChild(link);
});
});

$(document).on(
"change",
"[name='torrents[]'], [name='clients[]'], [name='torrents'], [name='clients']",
function() {
const checkedTorrents = $("[name='torrents[]']:checked").length;
const checkedClients = $("[name='clients[]']:checked").length;
if (checkedTorrents && checkedClients) {
$(".actions__torrents--activate").removeAttr("disabled");
$(".actions__torrents--deactivate").removeAttr("disabled");
} else {
$(".actions__torrents--activate").attr("disabled", true);
$(".actions__torrents--deactivate").attr("disabled", true);
}
}
);

$(document).on(
"change",
"[name='clients[]'], [name='clients']",
function() {
const checkedClients = $("[name='clients[]']:checked").length;
if (checkedClients) {
$(".actions__clients--activate").removeAttr("disabled");
$(".actions__clients--deactivate").removeAttr("disabled");
} else {
$(".actions__clients--activate").attr("disabled", true);
$(".actions__clients--deactivate").attr("disabled", true);
}
}
);
});
})(jQuery);
5 changes: 5 additions & 0 deletions public/stylesheets/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -307,3 +307,8 @@ input[name="torrent"] {
text-overflow: ellipsis;
overflow: hidden;
}

.float--right {
display: block;
float: right;
}
31 changes: 16 additions & 15 deletions views/index.pug
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ block content
button.flash__close ×

.actions
button.actions__clients--activate Activate Selected Clients
button.actions__clients--deactivate Deactivate Selected Clients
label(for='torrent') Upload File
input(type='file' name='torrent')
button.actions__torrents--activate Add Selected Torrents to Selected Clients
button.actions__torrents--deactivate Remove Selected Torrents from Selected Clients
label(for='torrent') Upload Torrent
input(type='file' name='torrent' accept='application/x-bittorrent')
button.actions__clients--activate(disabled) Activate Selected Clients
button.actions__clients--deactivate(disabled) Deactivate Selected Clients
button.actions__torrents--activate(disabled) Add Selected Torrents to Selected Clients
button.actions__torrents--deactivate(disabled) Remove Selected Torrents from Selected Clients

.table.table__main
.tr
.td.col-50
.td.col-40
.table.table__torrents
.thead
.tr
Expand All @@ -39,14 +39,14 @@ block content
.td.col-100= torrent.hash
.td.col-100
a(href="#" data-download=torrent.name) Download
.td.col-50
.td.col-60
.table.table__clients
.thead
.tr
.th.col-30 Client Name
.th.col-30 RPC Port
//- .th.col-30 Transmission Port
.th.col-30 Active
.th.col-20 RPC Port
.th.col-20 Trans. Port
.th.col-20.text--center Active
.th.col-10.text--center
input(type='checkbox'
name='clients')
Expand All @@ -55,9 +55,9 @@ block content
each client in clients
.tr(data-client-active=client.active data-clients=client.id)
.td.col-30= client.name
.td.col-30= client.rpc_port
//- .th.col-30= client.transmission_port
.th.col-30
.td.col-20= client.rpc_port
.td.col-20= client.transmission_port
.th.col-20.text--center
- var modifier = client.active ? 'active' : 'inactive'
span(class='indicator indicator--' + modifier
data-indicator-active=client.active)
Expand All @@ -67,7 +67,8 @@ block content
value=client.id)
.td.col-100
details(open=true).client__details
summary Torrents
summary
strong Torrents
.client__torrents
each torrent in client.torrents
.client__torrent
Expand Down

0 comments on commit fdcd1fa

Please sign in to comment.