-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added ActivityLog in admin/dashboard
- Loading branch information
1 parent
747923d
commit 26eff33
Showing
9 changed files
with
1,081 additions
and
228 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Admin; | ||
|
||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Collection; | ||
use App\Http\Controllers\Controller; | ||
use Spatie\Activitylog\Models\Activity; | ||
|
||
class ActivityController extends Controller | ||
{ | ||
|
||
/** | ||
* @return \Illuminate\Http\JsonResponse | ||
*/ | ||
public function activities() | ||
{ | ||
$activities = $this->getLatestActivityItems(); | ||
|
||
return response()->json($activities); | ||
} | ||
|
||
|
||
/** | ||
* Get all activity for admin dashboard. | ||
* | ||
* @return Collection | ||
*/ | ||
public function getLatestActivityItems(): Collection | ||
{ | ||
return Activity::with('causer') | ||
->latest() | ||
->limit(30) | ||
->get(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
resources/assets/js/vuejs/components/admin/dashboard/Activitylog.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<template> | ||
<div id="activity-log"> | ||
|
||
<scale-loader | ||
class="admin-scale-loader" | ||
:loading="loading" | ||
:color="color" | ||
:height="height" | ||
:width="width" | ||
:margin="margin" | ||
> | ||
</scale-loader> | ||
|
||
<div class="ibox" v-show="!loading"> | ||
|
||
<div class="ibox-title"> | ||
<h5>Activities in forum</h5> | ||
</div> <!-- /.ibox-title --> | ||
|
||
<div class="ibox-content"> | ||
|
||
<!-- ACTIVITYLOG TABLE --> | ||
<div class="table-responsive" v-show="!loading"> | ||
<div class="dataTables_wrapper form-inline dt-bootstrap"> | ||
<table class="table table-striped table-bordered table-hover dataTable dtr-inline"> | ||
<thead> | ||
<tr> | ||
<th>#</th> | ||
<th>Time</th> | ||
<th>Description</th> | ||
<th>User</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr v-for="activity in activities"> | ||
<td>{{ activity.id }}</td> | ||
<td>{{ activity.created_at | timeago }}</td> | ||
<td> | ||
<span v-if="activity.properties.type == 'user'"> | ||
{{ activity.description }} | ||
</span> | ||
<span v-else> | ||
{{ activity.description }} | ||
<a :href="activity.properties.link">"{{ activity.properties.title }}"</a> | ||
</span> | ||
</td> | ||
<td> | ||
<a :href="'/@' + activity.causer.username">{{ activity.causer.username }}</a> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
|
||
</div> <!-- /.dataTables_wrapper--> | ||
</div> <!-- /.table-responsive --> | ||
<!-- /ACTIVITYLOG TABLE --> | ||
|
||
</div> <!-- /.ibox-content --> | ||
</div> <!-- /.ibox --> | ||
|
||
</div> | ||
</template> | ||
|
||
<script> | ||
import ScaleLoader from 'vue-spinner/src/ScaleLoader.vue' | ||
export default { | ||
name: 'activity-log', | ||
data () { | ||
return { | ||
height: '60px', | ||
activities: [] | ||
} | ||
}, // data() | ||
components: { | ||
'scale-loader': ScaleLoader | ||
}, // components | ||
beforeMount () { | ||
this.loading = true | ||
}, // beforeMount() | ||
mounted () { | ||
this.loading = false | ||
this.getAllActivities() | ||
}, // mounted() | ||
methods: { | ||
getAllActivities () { | ||
axios.get('/api/admin/activities') | ||
.then((response) => { | ||
console.log(response) | ||
this.activities = response.data | ||
}) | ||
.catch((error) => { | ||
}) | ||
} // getAllActivities() | ||
} // methods | ||
} | ||
</script> | ||
|
||
<style lang="css"> | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,5 @@ | |
@section('title', '| Dashboard') | ||
|
||
@section('content') | ||
|
||
<activity-log></activity-log> | ||
@endsection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters