This commit is contained in:
Ravi Gulhane 2022-05-20 13:41:35 +05:30
parent e6883b2318
commit ac8c288290
8 changed files with 136 additions and 17 deletions

View File

@ -103,6 +103,23 @@ class FormController extends Controller
}
}
public function ajaxsubmit(Request $request) {
$post = $request->except('_token');
$formdata = $request->session()->get('formdata');
if(isset($formdata) && !empty($formdata) && $formdata->user_id != '') {
$post = $this->processformdata($formdata->form_id, $post);
$finfo = LambdaRequest::postrequest('form', 'formentity/submitform', ['formdata' => $post, 'entity_id' => $post['form_id'], 'user_id' => $formdata->user_id, 'partition' => $formdata->partition ]);
//Log::debug(print_r($finfo, true));
if($finfo->status == 'success') {
return response()->json(['status' => 'success']);
} else {
return response()->json(['status' => 'failure']);
}
} else {
return response()->json(['status' => 'failure']);
}
}
protected function processformdata($form, $post) {
switch($form) {
case '1650365556-f06dde85-6138-4dae-9c23-5067e318c522':

View File

@ -7,6 +7,7 @@
"require": {
"php": "^7.3|^8.0",
"arrilot/laravel-widgets": "^3.13",
"baopham/dynamodb": "^6.1",
"fideloper/proxy": "^4.4",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1",

59
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "8769036ccc97e257ed44ee87f7e98df6",
"content-hash": "af3e22a28807021ab01a150a444be582",
"packages": [
{
"name": "arrilot/laravel-widgets",
@ -269,6 +269,63 @@
},
"time": "2022-01-14T19:29:33+00:00"
},
{
"name": "baopham/dynamodb",
"version": "6.1.3",
"source": {
"type": "git",
"url": "https://github.com/baopham/laravel-dynamodb.git",
"reference": "963811691313124e7562a02aefdcc31fdbd75e78"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/baopham/laravel-dynamodb/zipball/963811691313124e7562a02aefdcc31fdbd75e78",
"reference": "963811691313124e7562a02aefdcc31fdbd75e78",
"shasum": ""
},
"require": {
"aws/aws-sdk-php": "^3.0.0",
"illuminate/database": "5.1.* || 5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.* || ^6.0 || ^7.0 || ^8.0 || ^9.0",
"illuminate/support": "5.1.* || 5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.* || ^6.0 || ^7.0 || ^8.0 || ^9.0"
},
"require-dev": {
"orchestra/testbench": "~3.0 || ~5.0"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"BaoPham\\DynamoDb\\DynamoDbServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"BaoPham\\DynamoDb\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Bao Pham",
"email": "gbaopham@gmail.com"
}
],
"description": "Eloquent syntax for DynamoDB",
"keywords": [
"aws",
"dynamodb",
"laravel"
],
"support": {
"issues": "https://github.com/baopham/laravel-dynamodb/issues",
"source": "https://github.com/baopham/laravel-dynamodb/tree/6.1.3"
},
"time": "2022-02-10T16:53:52+00:00"
},
{
"name": "brick/math",
"version": "0.9.2",

View File

@ -178,6 +178,7 @@ return [
App\Providers\RouteServiceProvider::class,
Maatwebsite\Excel\ExcelServiceProvider::class,
BaoPham\DynamoDb\DynamoDbServiceProvider::class,
],

View File

@ -3,9 +3,10 @@
<head>
@include('layouts.shared/title-meta', ['title' => "Form"])
@include('layouts.shared/head-css', ["mode" => $mode ?? '', "demo" => $demo ?? ''])
<link href="{{asset('assets/libs/sweetalert2/sweetalert2.min.css')}}" rel="stylesheet" type="text/css" />
</head>
<div class="loader text-white">
<i class="mdi mdi-loading mdi-spin mdi-48px" aria-hidden="true"></i><br />Loading
<div id="pageloader">
<img src="http://cdnjs.cloudflare.com/ajax/libs/semantic-ui/0.16.1/images/loader-large.gif" alt="processing..." />
</div>
<body class="loading">
<div class="account-pages">
@ -33,6 +34,7 @@
</div>
@endif
<form method="POST" action="/form/submit" id="report-form">
<input type="hidden" name="form_id" value="{{$form_id}}">
@csrf
@if($id)
<input type="hidden" name="id" value="{{$id}}">
@ -88,22 +90,54 @@
</div>
<!-- end page -->
<style type="text/css">
.loader{
position: absolute;
height: 100vh;
width: 100vw;
z-index: 999;
background-color: rgba(0,0,0,0.5);
padding-top: calc(50vh - 24px);
padding-left: calc(50vw - 24px);
}
#pageloader {
background: rgba( 255, 255, 255, 0.8 );
display: none;
height: 100%;
position: fixed;
width: 100%;
z-index: 9999;
}
#pageloader img {
left: 50%;
margin-left: -32px;
margin-top: -32px;
position: absolute;
top: 50%;
}
</style>
@include('layouts.shared/footer-script')
<script src="{{asset('assets/libs/sweetalert2/sweetalert2.min.js')}}"></script>
<script type="text/javascript">
jQuery(document).ready(function($){
$('.loader').hide()
$('#report-form').submit(function(){
$('.loader').show()
$('#report-form').on('submit', function(event){
event.preventDefault();
$("#pageloader").fadeIn();
$.ajax({
type: "POST",
url: '/form/ajaxsubmit',
data: new FormData($('#report-form')[0]),
processData: false,
contentType: false,
success: function( data ) {
$("#pageloader").fadeOut();
if(data.status == 'success') {
Swal.fire({
title: 'Great!',
text: 'Your data is successfully submitted!',
icon: 'success'
})
$('#report-form').trigger("reset");
} else {
Swal.fire({
icon: 'error',
title: 'Data not submitted',
text: 'Something went wrong, please try again after some time!'
})
}
},
});
});
});
</script>

View File

@ -77,6 +77,11 @@
<a href="/hierarchys">Hierarchy</a>
</li>
@endif
@if(in_array('all_data_access', $permissions))
<li>
<a href="/positions">Positions</a>
</li>
@endif
@if(in_array('team_get_all', $permissions))
<li>
<a href="/teams">Teams</a>
@ -97,6 +102,7 @@
<a href="/domain/edit">Domain</a>
</li>
@endif
</ul>
</div>
</li>

View File

@ -80,13 +80,13 @@
@switch(true)
@case($graph->chart == 'leaderboard')
<div id="cardCollpase4" class="collapse pt-3 show">
@if($graph->agg_type == 'individual')
<div class="btn-group mb-2">
<button type="button" class="btn btn-info leaderboard-prev" {{$graph->current_level==$graph->level?'disabled':''}}><i class="mdi mdi-play mdi-rotate-180 mdi-18px"></i></button>
<button type="button" class="btn btn-info">Level {{$graph->current_level}}</button>
<button type="button" class="btn btn-info leaderboard-next" {{$graph->current_level==1?'disabled':''}}><i class="mdi mdi-play mdi-18px"></i></button>
</div>
@endif
<div class="table-responsive">
<table class="table table-centered table-nowrap table-borderless mb-0">
<thead class="table-light">

View File

@ -36,6 +36,7 @@ use App\Http\Controllers\WidgetController;
use App\Http\Controllers\FormdataController;
use App\Http\Controllers\FormsubmissionController;
use App\Http\Controllers\FormexportController;
use App\Http\Controllers\PositionController;
/*
|--------------------------------------------------------------------------
| Web Routes
@ -96,6 +97,7 @@ $modules = ['user' => UserController::class,
'formdata' => FormdataController::class,
'formsubmission' => FormsubmissionController::class,
'formexport' => FormexportController::class,
'position' => PositionController::class,
];
foreach ($modules as $mod => $class) {
Route::get('/'.$mod.'s', [$class, 'list'])->name($mod.'-list');
@ -113,6 +115,7 @@ Route::get('/form/{finfo}', [FormController::class, 'handle']);
Route::post('/form/getformfielddata', [FormController::class, 'getformfielddata']);
Route::post('/form/submit', [FormController::class, 'submit']);
Route::post('/form/ajaxsubmit', [FormController::class, 'ajaxsubmit']);
// require __DIR__ . '/auth.php';