<admin-page-header [title]="'Domain Transfer'"></admin-page-header>

<div class="row justify-content-center">
    <div class="col-xl-10">
        <div class="card custom-card mb-7">
            <div class="card-header border-0 block">
                <div class="card-title">
                    {{'Download Complete Files' | translate}}
                </div>
            </div>
            <div class="card-body pt-0">
                <span class="badge bg-danger steps-badge">{{'Step' | translate}}: 1
                </span>
                <p>{{'Transfer all website files, including images, scripts, and other assets, via FTP.' | translate}}</p>
                @if (sendingResponse['exportFile']) {
                    <button [disabled]="sendingResponse['exportFile']" class="btn btn-primary ">{{'Please Wait it will take some time.' | translate}}</button>
                }
                @else {
                    <button [disabled]="sendingResponse['exportFile']" class="btn btn-primary " (click)="exportFile('exportFile', pleaswait)">{{'Download FTP Files' | translate}}</button>
                }
            </div>
        </div>
        <div class="card custom-card mb-7">
            <div class="card-header border-0">
                <div class="card-title">
                    {{'Download Database' | translate}}
                </div>
            </div>
            <div class="card-body pt-0">
                <span class="badge bg-danger steps-badge">{{'Step' | translate}}: 2
                </span>
                <p>{{'Transfer the website\'s database containing crucial information such as content, user data, and settings.' | translate}}</p>
                <button [disabled]="sendingResponse['database']" class="btn btn-primary " (click)="database('database', pleaswait)">{{'Export' | translate}}</button>
            </div>
        </div>
        <div class="card custom-card">
            <div class="card-header border-0">
                <div class="card-title">
                    {{'Migration Token' | translate}}
                </div>
            </div>
            <div class="card-body pt-1">
                <span class="badge bg-danger steps-badge">{{'Step' | translate}}: 3
                </span>
                <p>
                    {{'The Migration Token is a unique identifier generated for seamless transfer of your application from one domain to another. This token ensures a smooth transition by securely authorizing the migration process, allowing you to effortlessly transfer your website, including files and databases, to your desired destination. Additionally, upon activation of the new domain, the Migration Token automatically cancels the license associated with the previous domain, ensuring that access to the application is restricted exclusively to the newly activated domain.' | translate}}
                </p>
                <div class="bg-warning-transparent p-2 text-warning mb-3 rounded  text-dark">
                    <span class="font-weight-semibold">{{'Note' | translate}}:</span> {{'Once the new domain is activated, the previous domain\'s license is automatically revoked, preventing access to the application from the old domain.' | translate}}
                </div>
                <div class="p-2 border rounded">
                    {{'Note' | translate}}:{{'To Receive a mail should need to complete "SMTP" Setup' | translate}}. 
                </div>
            </div>
            <div class="card-footer">
                    @if (token) {
                        <div class="d-flex align-items-center">
                            <div class="alert bg-warning-transparent text-dark p-2 mb-0 token-alert w-75" role="alert">
                                {{token}}
                            </div>
                            <button ngbTooltip="Show" class="btn btn-sm btn-primary btn-br-begin-0" disabled><i class="feather feather-eye "></i></button>
                        </div>        
                    }
        
                    @if (!token) {
                        @if((settingToken == 0) && (userId == 1)){
                        <button ngbTooltip="Generate"  [disabled]="sendingResponse['generate']" class="btn btn-lg btn-primary float-end"
                            (click)="tokenGenerate('generate')">{{'Generate Token' |
                            translate}}@if (sendingResponse['generate']) {
                            <i class="fa fa-spinner fa-spin mx-1"></i>
                            }</button>
                        }
                        @else {
                            <div class="d-flex align-items-center">
                                <div class="alert bg-warning-transparent text-dark p-2 mb-0 token-alert w-75" role="alert">
                                    ************
                                </div>
                                <button ngbTooltip="Show" class="btn btn-sm btn-primary btn-br-begin-0" (click)="requesttoken('requesttoken')"><i class="feather feather-eye "></i></button>
                            </div>
                        }
                    }
            </div>
        </div>
    </div>
</div>


<ng-template #pleaswait let-modal>
    <div class="modal-body">
        
            {{'Please Wait it will take some time' | translate}}...
            <span class="spinner-border" role="status">
                <span class="visually-hidden">Loading...</span>
              </span>
              
    </div>
  </ng-template>