<template>
  <!-- SUB Contents -->
  <div class="ui--content-wrapper">
    <sdl-breadcrumb></sdl-breadcrumb>
    <div class="ui--search-container clearfix">
      <div class="col-10 float-start">
        <!-- row1 -->
        <div class="row">
          <div class="col-12">
            <!-- form -->
            <div class="row">
              <label class="col-3 col-form-label text-end">Clear all cache</label>
              <div class="col-9">
                <div class="input-group">
                  <button
                      type="button"
                      class="btn btn-primary btn-sm"
                      @click="clearCacheAll">
                    Clear
                  </button>
                </div>
              </div>
            </div>
          </div>
        </div>
        <!-- //row1 -->
      </div>
    </div>
  </div>
</template>

<script>
import axios from 'axios';
import { SDLUtil } from '@/utils';

export default {
  data() {
    return { };
  },
  methods: {
    clearCacheAll() {
      SDLUtil.showLoadingBar(true);
      axios.get(`${SDLUtil.API_URL}/caches/clear-all`)
        .then(() => {
          SDLUtil.showLoadingBar(false);
        })
        .catch(err => {
          console.error(err);
          SDLUtil.showLoadingBar(false);
          SDLUtil.errorAlert(err);
        });
    },
  },
};
</script>