<%@ page language="VB" masterpagefile="~/Template/Master.master" autoeventwireup="false" inherits="PCC_DC_ListADUser, MachSol.MachPanel.Web" %>

<asp:Content ID="Content1" ContentPlaceHolderID="CPH_Content" Runat="Server">

    <script type="module">

        import { createApp } from 'vue'
        import TabContainer from '/Components/Common/TabContainer.js?v=3.4'
        import ADUsersList from '/Components/DC/ADUsersList.js?v=3.4'
        import GroupActions from '/Components/Network/GroupActions.js?v=3.4'
        import { getLabelText } from '/Components/Common/utils.js?v=3.4'

        createApp({
            data() {
                return {
                    readOnly: <%= Helper.ReadOnlyRole.ToString().ToLower() %>,
                    isSubReseller: <%= Helper.IsSubReseller.ToString().Tolower() %>,
                    isProviderLogin: <%= Helper.IsLoggedInAsProvider.ToString().Tolower() %>,
                    isLoggedInAsCustomer: <%= Helper.IsLoggedInAsCustomer.ToString().ToLower() %>,
                    isLoggedInAsReseller: <%= Helper.IsLoggedInAsReseller.ToString().ToLower() %>,
                    showOperations: <%= ShowOperations.ToString().ToLower() %>,
                    showDeleteOption: <%= ShowDeleteOption.ToString().ToLower() %>,
                    showLogonName: <%= ShowLogonName.ToString().ToLower() %>,
                    exchManage: <%= ExchManage.ToString().ToLower() %>,
                    lyncManage: <%= LyncManage.ToString().ToLower() %>,
                    o365Manage: <%= O365Manage.ToString().ToLower() %>,
                    spManage: <%= SPManage.ToString().ToLower() %>,
                    shManage: <%= SHManage.ToString().ToLower() %>,
                    crmManage: <%= CRMManage.ToString().ToLower() %>,
                    adManage: <%= ADManage.ToString().ToLower() %>,
                    rdsManage: <%= RDSManage.ToString().ToLower() %>,
                    wfManage: <%= WFManage.ToString().ToLower() %>,
                    sendEmailOptionChecked: <%= Convert.ToBoolean(Session("SendEmailOptionChecked")).ToString().ToLower() %>,
                    dcId: <%= DCId %>,
                    hostedOrgId: <%= HostedOrgId %>,
                    packageTypeId: <%= PackageTypeId %>,
                    serviceHostingId: <%= ServiceHostingId %>,
                    showADUserEdit: <%= ShowADUserEdit.ToString().ToLower() %>,
                    showADUserRemove: <%= ShowADUserRemove.ToString().ToLower() %>,
                    allowAddUser: <%= AllowAddUser.ToString().ToLower() %>,
                    allowGroupAction: <%= AllowGroupAction.ToString().ToLower() %>,
                    allowToExportUser: <%= AllowToExportUser.ToString().ToLower() %>,
                    allowToExportLockedUser: <%= AllowToExportLockedUser.ToString().ToLower() %>,
                    packageTypeIdGA: '3',
                    runGroupJob: <%= Helper.CustomerAccessTemplates.RunGroupJob.ToString().ToLower() %>,
                    customerId: '<%= IIF(Helper.IsLoggedInAsCustomer, Session("CustomerId"), 0) %>',
                    isEgyptBenyaTechPlatform: <%= MachSol.MachPanel.DBCore.SystemSettings.IsEgyptBenyaTechPlatform.ToString().ToLower() %>,
                    companyId: '<%= Session("CompanyId") %>',
                    orgIdFilterForManagement: '<%= OrgIdGA %>',
                    adUserResultMessage: "<%= ADUserResultMessage %>",
                    statusReport: "<%= StatusReport %>",
                    sortPreferenceGA: <%= Newtonsoft.Json.JsonConvert.SerializeObject(InitialSortPreferenceGA) %>,
                    currentTab: 0,
                    tabPanels: []
                }
            },

            methods: {
                getLabelText,
                activeTabChanged: function (newTabIndex) {
                    this.currentTab = vueActiveTabChanged(newTabIndex, this.currentTab, this.tabPanels);
                },
            },
            components: {
                TabContainer,
                ADUsersList,
                GroupActions
            },
            created: function () {
                let vm = this;

                this.tabPanels = [{ text: this.getLabelText('SM0104'), enabled: true },
                    { text: this.getLabelText('strGroupActionsLog'), enabled: vm.allowGroupAction }];

                let urlParams = new URLSearchParams(window.location.search);

                if (urlParams.has('M')) {
                    if (urlParams.get('M') == 1 && this.adUserResultMessage != '') {
                        displaySuccessMsg(this.adUserResultMessage);

                        this.adUserResultMessage = '';
                    }
                    if (urlParams.get('M') == 'ud')
                        displayErrorMsg(Error(this.getLabelText('ADUserIsDisabled')));
                }
                if (this.statusReport != '') {
                    displayErrorMsg(Error(this.statusReport));

                    this.statusReport = '';
                }
                if (urlParams.has('TI')) {
                    this.activeTabChanged(urlParams.get('TI'));
                }
            },
            template: `
<TabContainer :id="'listadusers'" :tabPanels="tabPanels" :activeTabIndex="currentTab" @onActiveTabChanged="activeTabChanged"></TabContainer>

<ADUsersList v-if="currentTab == 0" :readOnly="readOnly" :isSubReseller="isSubReseller" :isProviderLogin="isProviderLogin":isLoggedInAsCustomer="isLoggedInAsCustomer"
    :isLoggedInAsReseller="isLoggedInAsReseller" :sendEmailOptionChecked="sendEmailOptionChecked" :isEgyptBenyaTechPlatform="isEgyptBenyaTechPlatform"
    :showLogonName="showLogonName" :exchManage="exchManage" :lyncManage="lyncManage" :o365Manage="o365Manage" :spManage="spManage" :shManage="shManage" :crmManage="crmManage"
    :adManage="adManage" :rdsManage="rdsManage" :wfManage="wfManage" :dcId="dcId" :hostedOrgId="hostedOrgId" :packageTypeId="packageTypeId"
    :serviceHostingId="serviceHostingId" :showADUserEdit="showADUserEdit" :showADUserRemove="showADUserRemove" :allowAddUser="allowAddUser"
    :allowGroupAction="allowGroupAction" :allowToExportUser="allowToExportUser" :allowToExportLockedUser="allowToExportLockedUser" />

<GroupActions v-if="currentTab == 1" :sortPreference="sortPreferenceGA" :readOnly="readOnly" :isSubReseller="isSubReseller"
    :isLoggedInAsCustomer="isLoggedInAsCustomer" :isLoggedInAsReseller="isLoggedInAsReseller" :customerId="customerId" :packageTypeId="packageTypeIdGA"
    :companyId="companyId" :runGroupJob="runGroupJob" :orgIdFilterForManagement="orgIdFilterForManagement" />
                
                       
`
        }).mount('#app')

    </script>

    <div id="app">
    </div>

</asp:Content>
