@extends('layouts.app')
@section('content')
<section class="page-header row">
    <h2> {{ $pageTitle }} </h2>
    <ol class="breadcrumb">
      <li><a href="#"><i class="fa fa-home"></i> Home</a></li>
      <li  class="active"> {{ $pageTitle }} </li>
    </ol>
  </section>
<div class="page-content row">
  <div class="page-content-wrapper no-margin">

  <div class="row">
    <div class="col-md-12">
      <ul class="sbox">
        @foreach ($rowData as $cswitch)
          {{-- @dump($cswitch) --}}
      <li><strong style="font-weight:700;"> {{$cswitch['name']}} </strong>   <a onclick="ClearCache('{{$cswitch['cache_key']}}')" class="btn btn-sm btn-outline-primary">  CLEAR</a> ||  <span id="cacheStatus-{{$cswitch['cache_key']}}"class="label label-success"> @if( in_array($cswitch['cache_key'],$feKeys) )   Cached @else Not Cached @endif  </span>  </li>
        @endforeach
      </ul>
      </div>
  </div>

  </div>
</div>
  
  <script>
    function ClearCache(cacheKey)
    {
       
      $.ajax({
				type: 'GET',
				url: "{{url('manage/cacheswitch/clearCache?key=')}}"+cacheKey,
			}).then(function (data) {
        if(data)
        {
          $.toast({
								heading: 'Cleared',
								text: 'Cache cleared for '+cacheKey,
								position: 'top-right',
								icon: 'success',
								hideAfter: 3000,
								stack: 6
							});

            $('#cacheStatus-'+cacheKey).text('Not Cached');
        }
        else
       $.toast({
								heading: 'Not Cleared',
                text: 'Unable Cache cleared for '+cacheKey,
								position: 'top-right',
								icon: 'warning',
								hideAfter: 3000,
								stack: 6
							});
			});
       
    }
    </script>

@stop
