Skip to content

Commit

Permalink
Init users manage
Browse files Browse the repository at this point in the history
  • Loading branch information
orvice committed Jul 10, 2017
1 parent 00b47ba commit d2977da
Show file tree
Hide file tree
Showing 7 changed files with 137 additions and 3 deletions.
27 changes: 27 additions & 0 deletions app/Controllers/Api/Admin/UserController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php


namespace App\Controllers\Api\Admin;


use App\Controllers\BaseController;
use Slim\Http\Request;
use Slim\Http\Response;
use App\Models\User;

class UserController extends BaseController
{
public function index(Request $req, Response $res, $args)
{
$pageNum = 1;
if (isset($req->getQueryParams()['page'])) {
$pageNum = $req->getQueryParams()['page'];
}
$traffic = User::paginate(15, [
'*',
], 'page', $pageNum);
$traffic->setPath('/api/admin/users');
//return $this->echoJsonWithData($res,$traffic);
return $this->echoJson($res, $traffic);
}
}
2 changes: 1 addition & 1 deletion public/assets/js/admin.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/assets/js/app.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/assets/js/home.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@
$this->put('/admin/config', 'App\Controllers\Api\Admin\ConfigController:update')->add(new Admin());
$this->get('/admin/nodes', 'App\Controllers\Api\Admin\NodeController:index')->add(new Admin());
$this->post('/admin/nodes', 'App\Controllers\Api\Admin\NodeController:store')->add(new Admin());
$this->get('/admin/users', 'App\Controllers\Api\Admin\UserController:index')->add(new Admin());
$this->get('/admin/users/{id}', 'App\Controllers\Api\Admin\UserController:show')->add(new Admin());
$this->put('/admin/users/{id}', 'App\Controllers\Api\Admin\UserController:update')->add(new Admin());
$this->get('/admin/invites', 'App\Controllers\Api\Admin\InviteController:index')->add(new Admin());
$this->post('/admin/invites', 'App\Controllers\Api\Admin\InviteController:store')->add(new Admin());
$this->delete('/admin/invites/{id}', 'App\Controllers\Api\Admin\InviteController:delete')->add(new Admin());
Expand Down
6 changes: 6 additions & 0 deletions src/components/AdminLeftbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
{{$t("ss.node")}}</a></router-link>
</li>

<li class="uk-nav">
<router-link tag="li" :to="{ name: 'users' }" exact><a href="#"><span class="uk-margin-small-right"
uk-icon="icon: users"></span>
{{$t("admin-nav.users")}}</a></router-link>
</li>

<li class="uk-nav">
<router-link tag="li" :to="{ name: 'invites' }" exact><a href="#"><span class="uk-margin-small-right"
uk-icon="icon: nut"></span>
Expand Down
98 changes: 98 additions & 0 deletions src/pages/Admin/User.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<template>

<div class="content-padder content-background">
<div class="uk-section-small uk-section-default header">
<div class="uk-container uk-container-large">
<h3><span class="ion-speedometer"></span> {{$t("admin-nav.users")}} </h3>
</div>
</div>
<div class="uk-section-small">
<div class="uk-container uk-container-large">
<div uk-grid class="uk-child-width-1-1@s uk-child-width-1-1@m uk-child-width-1-4@xl">
<div class="uk-card uk-card-default uk-card-body">


<table class="uk-table uk-table-striped">
<thead>
<tr>
<th>#</th>
<th>{{$t("auth.email")}}</th>
<th>{{$t("auth.username")}}</th>
<th>{{$t("ss.port")}}</th>
<th>{{$t("admin.action")}}</th>
</tr>
</thead>
<tbody>
<tr v-for="user in data.data">
<td>#{{user.id}}</td>
<td>{{user.email}}</td>
<td>{{user.user_name}}</td>
<td>{{user.port}}</td>
<td> <div class="uk-margin">
<button class="uk-button uk-button-danger" @click="deleteNode(user.id)">
{{$t("admin.delete")}}
</button>
</div></td>
</tr>
</tbody>
</table>


<pagination :data="data" v-on:pagination-change-page="Results"></pagination>
</div>
</div>
</div>
</div>
</div>


</template>

<script>
import admin from '../../http/admin'
import pagination from 'laravel-vue-pagination-uikit'
import {bytesToSize,notify} from '../../tools/util'
export default {
name: 'User',
components: {
pagination,
},
data () {
return {
data: {},
}
},
methods: {
Results(page) {
if (typeof page === 'undefined') {
page = 1;
}
admin.get(`users?page=` + page)
.then(response => {
this.data = response.data;
this.logs = response.data.data;
})
.catch(e => {
})
},
timeFormat(ut){
return new Date(ut * 1e3).toISOString();
},
deleteNode(id){
admin.delete(`users/` + id)
.then(response => {
notify(this.$t('base.success'),'primary');
this.Results();
})
.catch(e => {
notify(this.$t('base.something-wrong'),'danger');
})
},
bytesToSize,
},
mounted: function () {
this.Results();
},
}
</script>

0 comments on commit d2977da

Please sign in to comment.