<template>
    <cs-centered-alert
        v-if="! controller.isBooted"
        :height="controller.height"
        :width="controller.width"
        message="Se încarcă..."
    >
        <v-progress-circular
            indeterminate
            color="orange darken-1"
        >
        </v-progress-circular>
    </cs-centered-alert>

    <user-dashboard-page v-else
        :app="app"
        :controller="controller"
    />
</template>

<script>
    export default {
        props: {
            app: {require: true},
        },

        computed: {
            controller() {
                return this.app.classes.Userdashboard;
            }
        },

        methods: {

            LoadResources() {
                this.app.AddClassesByContext(require.context('./../../Classes', true, /\.class.js$/i));
                this.app.AddDataProvidersByContext(require.context('./../../DataSessions', true, /\.dataprovider.js$/i));
                this.app.AddDatatablesByContext(require.context('./../../Datatables', true, /\.datatable.js$/i));
                this.app.AddFormProvidersByContext(require.context('./../../FormProviders', true, /\.formprovider.js$/i));                
                this.app.AddFormsByContext(require.context('./../../Forms', true, /\.form.js$/i));
                this.app.AddFilterFormsByContext(require.context('./../../Filterforms', true, /\.filterform.js$/i));
                this.app.AddMenusByContext(require.context('./../../Toolbars', true, /\.toolbar.js$/i));
                this.app.AddMenusByContext(require.context('./../../Menus', true, /\.menu.js$/i));
                this.app.AddMenusByContext(require.context('./../../Breadcrumbs', true, /\.breadcrumbs.js$/i));
                this.app.AddRequestsByContext(require.context('./../../Requests', true, /\.request.js$/i));
                this.app.AddEditableControlsByContext(require.context('./../../Editablecontrols', true, /\.editable.js$/i));
            },

            LoadData() {
                this.app.dataSession.Users.GetById(this.controller.user_id);
                this.app.dataSession.Roles.GetByType('b2b');
                if(this.controller.customer_id)
                {
                    this.app.dataSession.Customers.GetById(this.controller.customer_id);
                }           
            }
        },

        created() {
            this.LoadResources();
            this.LoadData();
        },

        components: {
            CsCenteredAlert: require('@CsVueComp/sheets/CsCenteredAlert').default,
        },

        name: 'Index',
    }
</script>