<template>

    <my-profile-page 
        v-if="isBooted"
        :app="app"

    />

    <cs-centered-alert
        v-else
        :height="app.height"
        :width="app.width"
        message="Se încarcă..."
    >
        <v-progress-circular
            indeterminate
            color="orange darken-1"
        >
        </v-progress-circular>
    </cs-centered-alert>

</template>

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

        computed: {
            isBooted() {
                return this.app.classes.Controller.isBooted;
            }
        },

        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.AddRequestsByContext(require.context('./../../Requests', true, /\.request.js$/i));
            },

            InitDatatable() {
            },

            InitForms() {
                this.app.forms.Users.SetFormProvider(this.app.formproviders.Users);
                this.app.forms.ChangePassword.SetFormProvider(this.app.formproviders.Changepassword);
            },

            InitEditableColumns() {
            },

            InitFiltering() {
            },

            LoadData() {
                this.app.dataSession.Customers.Post();
                this.app.dataSession.Customerpersons.GetUserCustomerPersons(this.app.user.id);
                this.app.dataSession.Usercustomers.GetUserCustomers(this.app.user.id);
            },
        },

        created() {
            this.LoadResources();
            this.InitDatatable();
            this.InitForms();

            this.InitEditableColumns();
            this.InitFiltering();

            this.LoadData();
            
            if(this.app.config.env == 'local')
            {
            
            }
        },

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

        name: 'Index',
    }
</script>