<!--
@license GNU AGPL version 3 or any later version

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<template>
    <div id="side-menu">
		<div v-for="category in items">
			<h2 v-html="category.name"></h2>

			<ul>
			    <li v-for="app in category.apps">
					<a v-bind:href="app.href" v-bind:title="app.name">
						 <img class="side-menu-app-icon" v-bind:src="app.icon"></span>
						 <span class="side-menu-app-text" v-html="app.name"></span>
					</a>
				</li>
			</ul>
		</div>
    </div>
</template>

<script>
import trim from 'trim'
import axios from 'axios'

export default {
    name: 'SideMenuBig',
    data() {
        return {
            items: [],
            logo: null,
            forceLightIcon: false,
        }
    },
    methods: {
        retrieveApps() {
            this.apps = []
			let that = this

			axios
				.get(OC.generateUrl('/apps/side_menu/nav/items'))
				.then(function(response) {
					that.items = response.data.items

					jQuery('body').trigger('side-menu.apps', [])
				});
		},
    },
    mounted() {
        this.retrieveApps()

		this.forceLightIcon = document.querySelector('#side-menu-container').getAttribute('data-forcelighticon') == 1;
        this.ignoreExternalSites = document.querySelector('#side-menu-container').getAttribute('data-externalsitesintopmenu') == 1;
    }
}
</script>
