Skip to content

Commit 70a2d41

Browse files
committed
Alert message added for file upload
1 parent ed3476c commit 70a2d41

File tree

6 files changed

+41
-6
lines changed

6 files changed

+41
-6
lines changed

app/Http/Controllers/KchatController.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,10 @@ function attachments(Request $request){
192192
$tmp = DB::table('settings')->where(['key' => 'uploadpath'])->get();
193193

194194
if(!count($tmp)){
195-
return false;
195+
if($request->role == 'admin'){
196+
return json_encode(['error' => 'File upload path is not set']);
197+
}
198+
return json_encode(['error' => 'File upload Failed']);
196199
}
197200

198201
$uploadpath = $tmp[0]->value;

public/js/kchat.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,3 +338,15 @@ function setSelectedCount(){
338338
}
339339

340340
setSelectedCount();
341+
342+
gfunc = null;
343+
344+
$('#alert-ok').on('click', function() {
345+
gfunc();
346+
});
347+
348+
function kchat_alert(body,func){
349+
$("#alertbody").html(body);
350+
$("#alertmodel").click();
351+
gfunc = func;
352+
}

public/js/kchat.msg.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -427,16 +427,17 @@ $(document).ready (function(){
427427
Data.append('files[]', files[i]);
428428
}
429429

430-
//console.log(Data);
431-
432430
$.ajax({
433431
type: "POST",
434432
url: '/messages/attachments',
435433
data: Data,
436434
processData: false,
437435
contentType: false,
438436
success: function(result){
439-
console.log(result);
437+
result = $.parseJSON(result);
438+
if(result.error != undefined){
439+
kchat_alert(result.error,(function(){}));
440+
}
440441
},
441442
error: function(result){
442443

resources/views/admin/master.blade.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,25 @@
6262
</div>
6363
</div>
6464
</div>
65+
<!-- Alert Modal -->
66+
<input type="hidden" id="alertmodel" data-toggle="modal" data-target="#alert-model" />
67+
<div class="modal fade" id="alert-model" tabindex="-1" role="dialog" aria-labelledby="alertModel" aria-hidden="true">
68+
<div class="modal-dialog modal-dialog-centered" role="document">
69+
<div class="modal-content">
70+
<div class="modal-header">
71+
<h5 class="modal-title" >Alert</h5>
72+
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
73+
<span aria-hidden="true">&times;</span>
74+
</button>
75+
</div>
76+
<p class="p-3" id="alertbody"></p>
77+
<div class="modal-footer">
78+
<button type="button" id="alert-ok" class="btn btn-secondary" data-dismiss="modal">Ok</button>
79+
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
80+
</div>
81+
</div>
82+
</div>
83+
</div>
6584
@yield('script')
6685
<script src="/js/kchat.js"></script>
6786
@yield('javascript')

resources/views/admin/members.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,5 +212,5 @@
212212
@endsection
213213

214214
@section('script')
215-
215+
<!-- No Script -->
216216
@endsection

resources/views/common/msg.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
</div>
4747
</div>
4848
<div class="chat-history" id="Msgs" style="min-height: 50%;" >
49-
<image id="loading" src="/assets/loading.gif"></image>
49+
<image id="loading" src="/assets/loading.gif"/>
5050
<ul class="pl-3 pr-3" id="Messages"></ul>
5151
<button type="button" id="gotobottom" class="btn btn-outline-secondary"><i class="fa fa-chevron-down"></i></button>
5252
</div>

0 commit comments

Comments
 (0)