Commit 7f539aef by Aan Choesni Herlingga

master auto post

parent 85beb6f8
...@@ -4,17 +4,32 @@ namespace App\Http\Controllers\Webprofile\Backend; ...@@ -4,17 +4,32 @@ namespace App\Http\Controllers\Webprofile\Backend;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Repositories\Webprofile\AutopostRepository;
class AutopostController extends Controller class AutopostController extends Controller
{ {
private $repo;
public function __construct(
AutopostRepository $repo
) {
$this->repo = $repo;
}
/** /**
* Display a listing of the resource. * Display a listing of the resource.
* *
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function index() public function index(Request $request)
{ {
// if ($request->ajax()) {
$data = $this->repo->get();
return $this->repo->datatable($data);
}
return view('webprofile.backend.autopost.index')->withTitle('Auto Post');
} }
/** /**
...@@ -24,40 +39,52 @@ class AutopostController extends Controller ...@@ -24,40 +39,52 @@ class AutopostController extends Controller
*/ */
public function create() public function create()
{ {
// return view('webprofile.backend.autopost.create')->withTitle('Add Auto Post');
} }
/** /**
* Store a newly created resource in storage. * Store a newly created resource in storage.
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
*
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function store(Request $request) public function store(Request $request)
{ {
// $data = $request->except('_token');
$this->repo->store($data);
return redirect()->route('autopost.index');
} }
/** /**
* Display the specified resource. * Display the specified resource.
* *
* @param int $id * @param int $id
*
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function show($id) public function show($id)
{ {
//
} }
/** /**
* Show the form for editing the specified resource. * Show the form for editing the specified resource.
* *
* @param int $id * @param int $id
*
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function edit($id) public function edit($id)
{ {
// $data = $this->repo->findId($id);
$data = [
'data' => $data,
];
return view('webprofile.backend.autopost.edit', $data)->withTitle('Edit Auto Post');
} }
/** /**
...@@ -65,21 +92,31 @@ class AutopostController extends Controller ...@@ -65,21 +92,31 @@ class AutopostController extends Controller
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @param int $id * @param int $id
*
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function update(Request $request, $id) public function update(Request $request, $id)
{ {
// $data = $request->except(['_token']);
$autopost = $this->repo->findId($id);
$this->repo->update($data, $autopost);
return redirect()->route('autopost.index');
} }
/** /**
* Remove the specified resource from storage. * Remove the specified resource from storage.
* *
* @param int $id * @param int $id
*
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function destroy($id) public function destroy($id)
{ {
// $data = $this->repo->findId($id);
$this->repo->destroy($data);
return response()->json(['done']);
} }
} }
...@@ -4,6 +4,7 @@ namespace App\Repositories\Webprofile; ...@@ -4,6 +4,7 @@ namespace App\Repositories\Webprofile;
use App\Models\Webprofile\Autopost; use App\Models\Webprofile\Autopost;
use App\Repositories\Repository; use App\Repositories\Repository;
use DataTables;
class AutopostRepository extends Repository class AutopostRepository extends Repository
{ {
...@@ -42,16 +43,29 @@ class AutopostRepository extends Repository ...@@ -42,16 +43,29 @@ class AutopostRepository extends Repository
return $btn; return $btn;
}) })
->addColumn('status', function ($row) { ->addColumn('description', function ($row) {
if ($row->is_active == true) { if ($row->type == 'facebook') {
$str = '<div style="color: green;"><i class="fa fa-check"></i></div>'; $str = 'FACEBOOK ID => '.$row->key_1.'<br>';
} else { $str .= 'FACEBOOK SECRET => '.$row->key_2.'<br>';
$str = '<div style="color: red;"><i class="fa fa-times"></i></div>'; $str .= 'FACEBOOK GRAPH VERSION => '.$row->key_3.'<br>';
$str .= 'FACEBOOK ACCESS TOKEN => '.$row->key_4;
} elseif ($row->type == 'twitter') {
$str = 'TWITTER KEY => '.$row->key_1.'<br>';
$str .= 'TWITTER SECRET KEY => '.$row->key_2.'<br>';
$str .= 'TWITTER TOKEN => '.$row->key_3.'<br>';
$str .= 'TWITTER TOKEN SECRET => '.$row->key_4.'<br>';
$str .= 'TWITTER BEARER KEY => '.$row->key_5;
} elseif ($row->type == 'telegram') {
$str = 'API TOKEN => '.$row->key_1.'<br>';
$str .= 'BOT USERNAME => '.$row->key_2.'<br>';
$str .= 'CHANNEL USERNAME => '.$row->key_3.'<br>';
$str .= 'CHANNEL SIGNATURE => '.$row->key_4.'<br>';
$str .= 'PROXY => '.$row->key_5;
} }
return $str; return $str;
}) })
->rawColumns(['action', 'status']) ->rawColumns(['action', 'description'])
->make(true); ->make(true);
} }
} }
...@@ -9,11 +9,12 @@ $(function () { ...@@ -9,11 +9,12 @@ $(function () {
processing: true, processing: true,
serverSide: true, serverSide: true,
responsive: true, responsive: true,
autoWidth: false,
ajax: url, ajax: url,
columns: [ columns: [
{ data: 'DT_RowIndex', name: 'DT_RowIndex' }, { data: 'DT_RowIndex', name: 'DT_RowIndex' },
{ data: 'name', name: 'name' }, { data: 'name', name: 'name' },
{ data: 'status', name: 'status' }, { data: 'description', name: 'description' },
{ data: 'action', name: 'action', orderable: false, searchable: false }, { data: 'action', name: 'action', orderable: false, searchable: false },
], ],
columnDefs: [ columnDefs: [
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
{!! csrf_field() !!} {!! csrf_field() !!}
<!-- page start--> <!-- page start-->
<div class="row"> <div class="row">
<div class="col-md-9"> <div class="col-md-12">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
<h3 class="panel-title"><strong>Add</strong> API</h3> <h3 class="panel-title"><strong>Add</strong> API</h3>
...@@ -31,12 +31,82 @@ ...@@ -31,12 +31,82 @@
@endif @endif
</div> </div>
</div> </div>
<div class="form-group @if ($errors->has('type')) has-error @endif">
<label class="col-md-2 control-label">Type</label>
<div class="col-md-10">
{{ Form::select('type', ['facebook' => 'Facebook', 'twitter' => 'Twitter', 'telegram' => 'Telegram'], old('type'), array('class' => 'form-control fmtype', 'id' => 'type', 'placeholder' => '- Pilih -')) }}
@if ($errors->has('type'))
<label id="login-error" class="error" for="login">{{$errors->first('type')}}</label>
@endif
</div>
</div>
<div class="form-group @if ($errors->has('key_1')) has-error @endif" style="display:none;" id="fmkey_1">
<label class="col-md-2 control-label" id="key_1">KEY 1</label>
<div class="col-md-10">
{{ Form::text('key_1', old('key_1'), array('class' => 'form-control')) }}
@if ($errors->has('key_1'))
<label id="login-error" class="error" for="login">{{$errors->first('key_1')}}</label>
@endif
</div>
</div>
<div class="form-group @if ($errors->has('key_2')) has-error @endif" style="display:none;" id="fmkey_2">
<label class="col-md-2 control-label" id="key_2">KEY 2</label>
<div class="col-md-10">
{{ Form::text('key_2', old('key_2'), array('class' => 'form-control')) }}
@if ($errors->has('key_2'))
<label id="login-error" class="error" for="login">{{$errors->first('key_2')}}</label>
@endif
</div>
</div>
<div class="form-group @if ($errors->has('key_3')) has-error @endif" style="display:none;" id="fmkey_3">
<label class="col-md-2 control-label" id="key_3">KEY 3</label>
<div class="col-md-10">
{{ Form::text('key_3', old('key_3'), array('class' => 'form-control')) }}
@if ($errors->has('key_3'))
<label id="login-error" class="error" for="login">{{$errors->first('key_3')}}</label>
@endif
</div>
</div>
<div class="form-group @if ($errors->has('key_4')) has-error @endif" style="display:none;" id="fmkey_4">
<label class="col-md-2 control-label" id="key_4">KEY 4</label>
<div class="col-md-10">
{{ Form::text('key_4', old('key_4'), array('class' => 'form-control')) }}
@if ($errors->has('key_4'))
<label id="login-error" class="error" for="login">{{$errors->first('key_4')}}</label>
@endif
</div> </div>
</div> </div>
<div class="form-group @if ($errors->has('key_5')) has-error @endif" id="fmkey_5" style="display:none;">
<label class="col-md-2 control-label" id="key_5">KEY 5</label>
<div class="col-md-10">
{{ Form::text('key_5', old('key_5'), array('class' => 'form-control')) }}
@if ($errors->has('key_5'))
<label id="login-error" class="error" for="login">{{$errors->first('key_5')}}</label>
@endif
</div>
</div>
<div class="form-group @if ($errors->has('key_6')) has-error @endif" id="fmkey_6" style="display:none;">
<label class="col-md-2 control-label" id="key_6">KEY 6</label>
<div class="col-md-10">
{{ Form::text('key_6', old('key_6'), array('class' => 'form-control')) }}
@if ($errors->has('key_6'))
<label id="login-error" class="error" for="login">{{$errors->first('key_6')}}</label>
@endif
</div> </div>
</div> </div>
</div> </div>
<div class="col-md-9"> </div>
</div>
</div>
</div>
<div class="col-md-12">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-footer"> <div class="panel-footer">
<a href="{{URL::to('webprofile/autopost')}}" class="btn btn-default pull-right">Batal</a> <a href="{{URL::to('webprofile/autopost')}}" class="btn btn-default pull-right">Batal</a>
...@@ -54,4 +124,58 @@ ...@@ -54,4 +124,58 @@
{!! Html::script('https://statik.unesa.ac.id/perpus_konten_statik/admin/js/plugins/bootstrap/bootstrap-timepicker.min.js') !!} {!! Html::script('https://statik.unesa.ac.id/perpus_konten_statik/admin/js/plugins/bootstrap/bootstrap-timepicker.min.js') !!}
{!! Html::script('https://statik.unesa.ac.id/perpus_konten_statik/admin/js/plugins/bootstrap/bootstrap-file-input.js') !!} {!! Html::script('https://statik.unesa.ac.id/perpus_konten_statik/admin/js/plugins/bootstrap/bootstrap-file-input.js') !!}
{!! Html::script('https://statik.unesa.ac.id/perpus_konten_statik/admin/js/plugins/summernote/summernote.js') !!} {!! Html::script('https://statik.unesa.ac.id/perpus_konten_statik/admin/js/plugins/summernote/summernote.js') !!}
<script>
$("body").on("change", ".fmtype", function () {
var type = $(this).val();
$("#fmkey_1").hide();
$("#fmkey_2").hide();
$("#fmkey_3").hide();
$("#fmkey_4").hide();
$("#fmkey_5").hide();
$("#fmkey_6").hide();
if (type == 'facebook') {
$("#key_1").html('APP ID');
$("#fmkey_1").show();
$("#key_2").html('FACEBOOK SECRET');
$("#fmkey_2").show();
$("#key_3").html('FACEBOOK GRAPH VERSION');
$("#fmkey_3").show();
$("#key_4").html('FACEBOOK ACCESS TOKEN');
$("#fmkey_4").show();
$("#fmkey_5").hide();
$("#fmkey_6").hide();
}
if (type == 'twitter') {
$("#key_1").html('TWITTER KEY');
$("#fmkey_1").show();
$("#key_2").html('TWITTER SECRET KEY');
$("#fmkey_2").show();
$("#key_3").html('TWITTER TOKEN');
$("#fmkey_3").show();
$("#key_4").html('TWITTER TOKEN SECRET');
$("#fmkey_4").show();
$("#key_5").html('TWITTER BEARER KEY');
$("#fmkey_5").show();
$("#fmkey_6").hide();
}
if (type == 'telegram') {
$("#key_1").html('API TOKEN');
$("#fmkey_1").show();
$("#key_2").html('BOT USERNAME');
$("#fmkey_2").show();
$("#key_3").html('CHANNEL USERNAME');
$("#fmkey_3").show();
$("#key_4").html('CHANNEL SIGNATURE');
$("#fmkey_4").show();
$("#key_5").html('PROXY');
$("#fmkey_5").show();
$("#fmkey_6").hide();
}
});
</script>
@stop @stop
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
{!! csrf_field() !!} {!! csrf_field() !!}
<!-- page start--> <!-- page start-->
<div class="row"> <div class="row">
<div class="col-md-9"> <div class="col-md-12">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
<h3 class="panel-title"><strong>Edit</strong> Autopost</h3> <h3 class="panel-title"><strong>Edit</strong> Autopost</h3>
...@@ -35,11 +35,81 @@ ...@@ -35,11 +35,81 @@
</div> </div>
</div> </div>
</div> </div>
<div class="form-group @if ($errors->has('type')) has-error @endif">
<label class="col-md-2 control-label">Type</label>
<div class="col-md-10">
{{ Form::select('type', ['facebook' => 'Facebook', 'twitter' => 'Twitter', 'telegram' => 'Telegram'], old('type'), array('class' => 'form-control fmtype', 'id' => 'type', 'placeholder' => '- Pilih -')) }}
@if ($errors->has('type'))
<label id="login-error" class="error" for="login">{{$errors->first('type')}}</label>
@endif
</div>
</div>
<div class="form-group @if ($errors->has('key_1')) has-error @endif" style="display:none;" id="fmkey_1">
<label class="col-md-2 control-label" id="key_1">KEY 1</label>
<div class="col-md-10">
{{ Form::text('key_1', old('key_1'), array('class' => 'form-control')) }}
@if ($errors->has('key_1'))
<label id="login-error" class="error" for="login">{{$errors->first('key_1')}}</label>
@endif
</div>
</div>
<div class="form-group @if ($errors->has('key_2')) has-error @endif" style="display:none;" id="fmkey_2">
<label class="col-md-2 control-label" id="key_2">KEY 2</label>
<div class="col-md-10">
{{ Form::text('key_2', old('key_2'), array('class' => 'form-control')) }}
@if ($errors->has('key_2'))
<label id="login-error" class="error" for="login">{{$errors->first('key_2')}}</label>
@endif
</div>
</div>
<div class="form-group @if ($errors->has('key_3')) has-error @endif" style="display:none;" id="fmkey_3">
<label class="col-md-2 control-label" id="key_3">KEY 3</label>
<div class="col-md-10">
{{ Form::text('key_3', old('key_3'), array('class' => 'form-control')) }}
@if ($errors->has('key_3'))
<label id="login-error" class="error" for="login">{{$errors->first('key_3')}}</label>
@endif
</div>
</div>
<div class="form-group @if ($errors->has('key_4')) has-error @endif" style="display:none;" id="fmkey_4">
<label class="col-md-2 control-label" id="key_4">KEY 4</label>
<div class="col-md-10">
{{ Form::text('key_4', old('key_4'), array('class' => 'form-control')) }}
@if ($errors->has('key_4'))
<label id="login-error" class="error" for="login">{{$errors->first('key_4')}}</label>
@endif
</div>
</div>
<div class="form-group @if ($errors->has('key_5')) has-error @endif" id="fmkey_5" style="display:none;">
<label class="col-md-2 control-label" id="key_5">KEY 5</label>
<div class="col-md-10">
{{ Form::text('key_5', old('key_5'), array('class' => 'form-control')) }}
@if ($errors->has('key_5'))
<label id="login-error" class="error" for="login">{{$errors->first('key_5')}}</label>
@endif
</div> </div>
</div> </div>
<div class="form-group @if ($errors->has('key_6')) has-error @endif" id="fmkey_6" style="display:none;">
<label class="col-md-2 control-label" id="key_6">KEY 6</label>
<div class="col-md-10">
{{ Form::text('key_6', old('key_6'), array('class' => 'form-control')) }}
@if ($errors->has('key_6'))
<label id="login-error" class="error" for="login">{{$errors->first('key_6')}}</label>
@endif
</div> </div>
</div> </div>
<div class="col-md-9"> </div>
</div>
</div>
</div>
<div class="col-md-12">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-footer"> <div class="panel-footer">
<a href="{{URL::to('webprofile/category')}}" class="btn btn-default pull-right">Batal</a> <a href="{{URL::to('webprofile/category')}}" class="btn btn-default pull-right">Batal</a>
...@@ -57,4 +127,58 @@ ...@@ -57,4 +127,58 @@
{!! Html::script('https://statik.unesa.ac.id/perpus_konten_statik/admin/js/plugins/bootstrap/bootstrap-timepicker.min.js') !!} {!! Html::script('https://statik.unesa.ac.id/perpus_konten_statik/admin/js/plugins/bootstrap/bootstrap-timepicker.min.js') !!}
{!! Html::script('https://statik.unesa.ac.id/perpus_konten_statik/admin/js/plugins/bootstrap/bootstrap-file-input.js') !!} {!! Html::script('https://statik.unesa.ac.id/perpus_konten_statik/admin/js/plugins/bootstrap/bootstrap-file-input.js') !!}
{!! Html::script('https://statik.unesa.ac.id/perpus_konten_statik/admin/js/plugins/summernote/summernote.js') !!} {!! Html::script('https://statik.unesa.ac.id/perpus_konten_statik/admin/js/plugins/summernote/summernote.js') !!}
<script>
$("body").on("change", ".fmtype", function () {
var type = $(this).val();
$("#fmkey_1").hide();
$("#fmkey_2").hide();
$("#fmkey_3").hide();
$("#fmkey_4").hide();
$("#fmkey_5").hide();
$("#fmkey_6").hide();
if (type == 'facebook') {
$("#key_1").html('APP ID');
$("#fmkey_1").show();
$("#key_2").html('FACEBOOK SECRET');
$("#fmkey_2").show();
$("#key_3").html('FACEBOOK GRAPH VERSION');
$("#fmkey_3").show();
$("#key_4").html('FACEBOOK ACCESS TOKEN');
$("#fmkey_4").show();
$("#fmkey_5").hide();
$("#fmkey_6").hide();
}
if (type == 'twitter') {
$("#key_1").html('TWITTER KEY');
$("#fmkey_1").show();
$("#key_2").html('TWITTER SECRET KEY');
$("#fmkey_2").show();
$("#key_3").html('TWITTER TOKEN');
$("#fmkey_3").show();
$("#key_4").html('TWITTER TOKEN SECRET');
$("#fmkey_4").show();
$("#key_5").html('TWITTER BEARER KEY');
$("#fmkey_5").show();
$("#fmkey_6").hide();
}
if (type == 'telegram') {
$("#key_1").html('API TOKEN');
$("#fmkey_1").show();
$("#key_2").html('BOT USERNAME');
$("#fmkey_2").show();
$("#key_3").html('CHANNEL USERNAME');
$("#fmkey_3").show();
$("#key_4").html('CHANNEL SIGNATURE');
$("#fmkey_4").show();
$("#key_5").html('PROXY');
$("#fmkey_5").show();
$("#fmkey_6").hide();
}
});
</script>
@stop @stop
...@@ -3,6 +3,12 @@ ...@@ -3,6 +3,12 @@
@section('assets') @section('assets')
<link rel="stylesheet" href="{!! asset('backend/js/datatables.net-bs/css/dataTables.bootstrap.min.css') !!}"> <link rel="stylesheet" href="{!! asset('backend/js/datatables.net-bs/css/dataTables.bootstrap.min.css') !!}">
<meta name="csrf-token" content="{{ csrf_token() }}"> <meta name="csrf-token" content="{{ csrf_token() }}">
<style>
table.dataTable tbody td {
word-break: break-word;
vertical-align: middle;
}
</style>
@endsection @endsection
@section('title') @section('title')
...@@ -11,7 +17,7 @@ ...@@ -11,7 +17,7 @@
@section('breadcrumbs') @section('breadcrumbs')
<li><a href="{{ url('dashboard') }}">@lang('label.dashboard')</a></li> <li><a href="{{ url('dashboard') }}">@lang('label.dashboard')</a></li>
<li class="active">@lang('feature.category')</li> <li class="active">Auto Post</li>
@stop @stop
@section('content') @section('content')
...@@ -22,7 +28,7 @@ ...@@ -22,7 +28,7 @@
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
<h3 class="panel-title">{!! $title !!}</h3> <h3 class="panel-title">{!! $title !!}</h3>
<a class="btn btn-info" href="{{URL::to('webprofile/category/create')}}" style="margin: 0cm 0px 0cm 10px;">@lang('label.create')</a> <a class="btn btn-info" href="{{URL::to('webprofile/autopost/create')}}" style="margin: 0cm 0px 0cm 10px;">@lang('label.create')</a>
<ul class="panel-controls"> <ul class="panel-controls">
<li><a href="#" class="panel-collapse"><span class="fa fa-angle-down"></span></a></li> <li><a href="#" class="panel-collapse"><span class="fa fa-angle-down"></span></a></li>
</ul> </ul>
...@@ -33,8 +39,8 @@ ...@@ -33,8 +39,8 @@
<thead> <thead>
<tr> <tr>
<th width="7%">@lang('label.number')</th> <th width="7%">@lang('label.number')</th>
<th width="63%">@lang('label.name')</th> <th width="10%">@lang('label.name')</th>
<th width="10%">@lang('label.status')</th> <th width="63%">Description</th>
<th align="center" width="15%">@lang('label.action')</th> <th align="center" width="15%">@lang('label.action')</th>
</tr> </tr>
</thead> </thead>
...@@ -61,7 +67,7 @@ ...@@ -61,7 +67,7 @@
<script src="{{ url('backend/assets/plugins/jquery-datatable/buttons/buttons.print.min.js') }}"></script> <script src="{{ url('backend/assets/plugins/jquery-datatable/buttons/buttons.print.min.js') }}"></script>
<script> <script>
var url = "{{ route('category.index') }}"; var url = "{{ route('autopost.index') }}";
</script> </script>
{{ Html::script('js/master/category.js') }} {{ Html::script('js/master/autopost.js') }}
@stop @stop
...@@ -47,3 +47,6 @@ ...@@ -47,3 +47,6 @@
<li> <li>
<a href="{{ url('webprofile/settings') }}"><span class="fa fa-gears"></span><span class="xn-text">@lang('feature.setting')</span></a> <a href="{{ url('webprofile/settings') }}"><span class="fa fa-gears"></span><span class="xn-text">@lang('feature.setting')</span></a>
</li> </li>
<li>
<a href="{{ url('webprofile/autopost') }}"><span class="fa fa-refresh"></span><span class="xn-text">Auto Post</span></a>
</li>
...@@ -24,6 +24,7 @@ Route::group(['middleware' => 'auth'], function () { ...@@ -24,6 +24,7 @@ Route::group(['middleware' => 'auth'], function () {
Route::resource('categoriesfile', 'CategoriesFileController'); Route::resource('categoriesfile', 'CategoriesFileController');
Route::resource('file', 'FileController'); Route::resource('file', 'FileController');
Route::resource('layouts', 'LayoutController'); Route::resource('layouts', 'LayoutController');
Route::resource('autopost', 'AutopostController');
Route::resource('menu', 'MenuController'); Route::resource('menu', 'MenuController');
Route::post('storepage', 'MenuController@storepage')->name('menu.storepage'); Route::post('storepage', 'MenuController@storepage')->name('menu.storepage');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment