-
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.
Merge pull request #8 from priatmoko/user-profile
User profile
- Loading branch information
Showing
15 changed files
with
577 additions
and
8 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,52 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Admin\Apps; | ||
|
||
use Illuminate\Http\Request; | ||
use App\Http\Controllers\Controller; | ||
|
||
/**loading models */ | ||
use App\Models\Apps; | ||
|
||
class FormController extends Controller | ||
{ | ||
/** | ||
* Displaying create menu | ||
*/ | ||
public function create() | ||
{ | ||
$breadcrumb = ['Application Management'=>route('apps'), 'Register New Application'=>'']; | ||
$title = 'Register New Application'; | ||
return view('Admin.Apps.create') | ||
->with('breadcrumb', $breadcrumb) | ||
->with('title', $title); | ||
} | ||
/** | ||
* Store data | ||
* @param void object laravel Request | ||
* @return string json | ||
*/ | ||
public function store(Request $r) | ||
{ | ||
//validate before saving | ||
$validation = \Validator::make($r->all(),[ | ||
'name'=>'required', | ||
'url'=>'required',]); | ||
|
||
if ($validation->fails()) | ||
return response()->json(['errors'=>$validation->errors()], 422); | ||
$apps = new Apps; | ||
$apps->name = $r->input('name'); | ||
$apps->parent = $r->input('parent'); | ||
$apps->node_name = $r->input('node_name'); | ||
$apps->url = $r->input('url'); | ||
$apps->color = $r->input('color'); | ||
$apps->icon = $r->input('icon'); | ||
$apps->desc = $r->input('desc'); | ||
$apps->sorter = $r->input('sorter'); | ||
$apps->save(); | ||
|
||
return response()->json(['status'=>'success']); | ||
} | ||
|
||
} |
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,37 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Admin\Apps; | ||
|
||
use Illuminate\Http\Request; | ||
use App\Http\Controllers\Controller; | ||
|
||
/**loading models */ | ||
use App\Models\Apps; | ||
|
||
class IndexController extends Controller | ||
{ | ||
/** | ||
* Displaying main panel of application management | ||
* @return void displaying main panel of Application management | ||
*/ | ||
public function index() | ||
{ | ||
$breadcrumb = ['Application Management'=>'']; | ||
$title = 'Application Management'; | ||
return view('Admin.Apps.index') | ||
->with('title', $title) | ||
->with('breadcrumb', $breadcrumb); | ||
} | ||
/** | ||
* Getting list of registered Application | ||
*/ | ||
public function getList(Request $r) | ||
{ | ||
$apps = Apps::where('name', 'like', '%'.$r->input('name').'%') | ||
->get(); | ||
if (is_object($apps) && count($apps)>0) | ||
return response()->json(['status'=>'success', 'd'=>$apps]); | ||
else | ||
return response()->json(['status'=>'fail']); | ||
} | ||
} |
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
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,10 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class Apps extends Model | ||
{ | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
database/migrations/2019_05_02_064742_create_apps_table.php
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,39 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Schema; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Migrations\Migration; | ||
|
||
class CreateAppsTable extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::create('apps', function (Blueprint $table) { | ||
$table->bigIncrements('id'); | ||
$table->bigInteger('parent')->nullable(); | ||
$table->integer('sorter')->nullable(); | ||
$table->string('name'); | ||
$table->string('node_name')->nullable(); | ||
$table->mediumText('desc')->nullable(); | ||
$table->string('url'); | ||
$table->string('color')->nullable(); | ||
$table->string('icon')->nullable(); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::dropIfExists('apps'); | ||
} | ||
} |
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,32 @@ | ||
/** | ||
* initialize event on creating menu management features | ||
*/ | ||
var init = function(){ | ||
$('#app-form').submit(function(e){ | ||
e.preventDefault(); | ||
saveApps(); | ||
}); | ||
} | ||
var saveApps = function(){ | ||
if ($('#app-form').postValidate()===false){ | ||
return false; | ||
} | ||
$('#app-form').postAjax({ | ||
success:function(r){ | ||
console.log(r); | ||
if (r.status=="success"){ | ||
iziToast.success({ | ||
title: 'INFO !', | ||
message: 'Operation success, data has been saved', | ||
position: 'topRight' | ||
}); | ||
}else{ | ||
iziToast.error({ | ||
title: 'INFO !', | ||
message: 'Operation failed, please check the data input', | ||
position: 'topRight' | ||
}); | ||
} | ||
} | ||
}); | ||
} |
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,60 @@ | ||
/** | ||
* Initial event | ||
*/ | ||
var init = function(){ | ||
$('#app-index').submit(function(e){ | ||
e.preventDefault(); | ||
displayIndex(); | ||
}); | ||
} | ||
/** | ||
* displaying list of registered application | ||
*/ | ||
var displayIndex = function(){ | ||
$('#app-index').postAjax({ | ||
success:function(r){ | ||
|
||
if (r.status=="success"){ | ||
injectTable(r.d); | ||
}else{ | ||
iziToast.error({ | ||
title: 'Not Found !', | ||
message: 'Please try other keywords', | ||
position: 'topRight' | ||
}); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
var injectTable = function(obj){ | ||
|
||
var tr = ""; | ||
var td = $('#table-apps thead tr th'); | ||
var tbody = $('#table-apps tbody'); | ||
$.each(obj, function(i, v) { | ||
datas = ""; | ||
$.each(v, function(id, iv) { | ||
datas += 'data-' + id + '="' + iv + '"'; | ||
}); | ||
tr += "<tr id='act_" + i + "' " + datas + " class='context-menu' title='Right Click to choose operation. 
Sequence : 
"+v.caseqn+"'>"; | ||
$.each(td, function(index, field) { | ||
tr += "<td style='" + $(this).attr('style') + "' class='" + $(this).attr('class') + "'>"; | ||
if ($(this).data('field')=='icon'){ | ||
if (v[$(this).data('field')]==null) | ||
tr += "<i class='fa fa-th'></i>"; | ||
else | ||
tr += "<i class='fa "+v[$(this).data('field')]+"'></i>"; | ||
}else{ | ||
if (v[$(this).data('field')]==null) | ||
tr += '-'; | ||
else | ||
tr += v[$(this).data('field')]; | ||
} | ||
|
||
tr += "</td>"; | ||
}); | ||
tr += "</tr>"; | ||
}); | ||
tbody.html(tr); | ||
} |
Oops, something went wrong.