Skip to content
Permalink
Browse files

Added the ability to set the API key description #287

  • Loading branch information...
magicbug committed Jul 9, 2019
1 parent b782593 commit a62764e69d3bf7129180cdf85853951a68008b6c
@@ -57,6 +57,44 @@ function help()
$this->load->view('interface_assets/footer');
}
function edit($key) {
$this->load->model('user_model');
if(!$this->user_model->authorize(99)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
$this->load->model('api_model');
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
$this->form_validation->set_rules('api_desc', 'API Description', 'required');
$this->form_validation->set_rules('api_key', 'API Key is required do not change this field', 'required');
$data['api_info'] = $this->api_model->key_description($key);
if ($this->form_validation->run() == FALSE)
{
$data['page_title'] = "Edit API Description";
$this->load->view('interface_assets/header', $data);
$this->load->view('api/description');
$this->load->view('interface_assets/footer');
}
else
{
// Success!
$this->api_model->update_key_description($this->input->post('api_key'), $this->input->post('api_desc'));
$this->session->set_flashdata('notice', 'API Key <b>'.$this->input->post('api_key')."</b> description has been updated.");
redirect('api/help');
}
}
function generate($rights) {
$this->load->model('user_model');
if(!$this->user_model->authorize(99)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
@@ -19,6 +19,25 @@ function keys() {
return $this->db->get('api');
}
function key_description($key) {
$this->db->where('key', $key);
$query = $this->db->get('api');
return $query->result_array()[0];
}
function update_key_description($key, $description) {
$data = array(
'description' => $description,
);
$this->db->where('key', $key);
$this->db->update('api', $data);
}
function delete_key($key) {
$this->db->where('key', $key);
$this->db->delete('api');
@@ -0,0 +1,40 @@
<div class="container api">

<br>
<?php if($this->session->flashdata('notice')) { ?>
<div class="alert alert-success" role="alert">
<?php echo $this->session->flashdata('notice'); ?>
</div>
<?php } ?>

<div class="card">
<div class="card-header">
<?php echo $page_title; ?>
</div>
<div class="card-body">
<h5 class="card-title">Editing Description for API Key: <?php echo $api_info['key']; ?></h5>

<?php if(validation_errors()) { ?>
<div class="alert alert-warning" role="alert">
<?php echo validation_errors(); ?>
</div>
<?php } ?>


<form method="post" action="<?php echo site_url('api/edit'); ?>/<?php echo $api_info['key']; ?>" name="APIDescription">
<div class="form-group">
<label for="APIDescription">API Description</label>
<input type="text" class="form-control" name="api_desc" id="APIDescription" aria-describedby="APIDescriptionHelp" value="<?php echo $api_info['description']; ?>">
<small id="APIDescriptionHelp" class="form-text text-muted">Simple name to describle what you use this API for.</small>
</div>

<input type="hidden" name="api_key" value="<?php echo $api_info['key']; ?>">

<button type="submit" class="btn btn-primary">Submit</button>
</form>

</div>
</div>

</div>

@@ -21,6 +21,7 @@
<thead>
<tr>
<th scope="col">API Key</th>
<th scope="col">Description</th>
<th scope="col">Rights</th>
<th scope="col">Status</th>
</tr>
@@ -29,6 +30,7 @@
<?php foreach ($api_keys->result() as $row) { ?>
<tr>
<td><?php echo $row->key; ?></td>
<td><?php echo $row->description; ?></td>
<td>
<?php
@@ -44,6 +46,9 @@

</td>
<td><span class="badge badge-pill badge-light"><?php echo ucfirst($row->status); ?></span>

<a href="<?php echo site_url('api/edit'); ?>/<?php echo $row->key; ?>" class="btn btn-outline-primary btn-sm">Edit</a>

<a href="<?php echo site_url('api/auth/'.$row->key); ?>" target="_blank" class="btn btn-primary btn-sm">Test</a>

<a href="<?php echo site_url('api/delete/'.$row->key); ?>" class="btn btn-danger btn-sm" onclick="return confirm('Are you sure you want delete API Key <?php echo $row->key; ?>?');">Delete</a>
@@ -46,6 +46,10 @@
margin-bottom: 0rem;
}

.api .alert p {
margin-bottom: 0rem;
}


.qso_panel {
padding-top: 25px;

0 comments on commit a62764e

Please sign in to comment.
You can’t perform that action at this time.