Skip to content

Commit 38e76bb

Browse files
committed
UI to allow blocking a client ID
1 parent d5ad177 commit 38e76bb

3 files changed

Lines changed: 19 additions & 5 deletions

File tree

solid/js/settings-admin.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
$(document).ready(function() {
2-
32
$('#solid-private-key').change(function(el) {
4-
OCP.AppConfig.setValue('solid','privateKey',this.value);
3+
OCP.AppConfig.setValue('solid', 'privateKey', this.value);
54
});
65

76
$('#solid-encryption-key').change(function(el) {
8-
OCP.AppConfig.setValue('solid','encryptionKey',this.value);
7+
OCP.AppConfig.setValue('solid', 'encryptionKey', this.value);
8+
});
9+
10+
$('.solid-client-block').change(function(el) {
11+
let blocked = this.checked ? true : false;
12+
let keyName = 'client-' + this.getAttribute("data-client");
13+
let clientConfig = OCP.AppConfig.getValue('solid', keyName, "{}", {
14+
"success" : function(xmlData) {
15+
let clientJson = xmlData.querySelector('data > data').textContent;
16+
let clientConfig = JSON.parse(clientJson);
17+
clientConfig.blocked = blocked;
18+
OCP.AppConfig.setValue('solid', keyName, JSON.stringify(clientConfig));
19+
}
20+
});
921
});
10-
1122
});

solid/lib/BaseServerConfig.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ public function getClients() {
9090
$clientRegistration = json_decode($this->config->getAppValue('solid', $key, '{}'), true);
9191
$clients[] = [
9292
"clientId" => $matches[1],
93-
"clientName" => $clientRegistration['client_name']
93+
"clientName" => $clientRegistration['client_name'],
94+
"clientBlocked" => $clientRegistration['blocked']
9495
];
9596
}
9697
}

solid/templates/admin.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@
2222
<tr>
2323
<th>Client ID</th>
2424
<th>Client name</th>
25+
<th>Block</th>
2526
</tr>
2627
</thead>
2728
<tbody>
2829
<?php foreach ($_['clients'] as $client => $registration) { ?>
2930
<tr>
3031
<td><?php p($registration['clientId']); ?></td>
3132
<td><?php p($registration['clientName']); ?></td>
33+
<td><input type="checkbox" class="solid-client-block" data-client="<?php p($registration['clientId']); ?>"<?php if ($registration['clientBlocked']) { echo " checked";} ?> value=1></td>
3234
</tr>
3335
<?php } ?>
3436
</tbody>

0 commit comments

Comments
 (0)