import Component  from '../component.js';
import DivComponent from '../div.js';

export default class CoEuiFileUploadProgress extends Component {
    constructor(parent) {
        let selector = 'eui-file-upload-progress';
        super(parent, selector);
        //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/eui-file-upload/progress/eui-file-upload-progress.component.html?at=master
    }
    get divCO() {
        return new DivComponent(this.currentPath);
    }
    get fileUploadProgressBarDivCO() {
        return new DivComponent(this.divCO).addPredicateClassContains('file-upload__progress-bar');
    }
    async hasProgressBar() {
        return await (await this.fileUploadProgressBarDivCO.element()).isExisting();
    }
    get progressBarContainerDivCO() {
        return new DivComponent(this.fileUploadProgressBarDivCO).addPredicateClassContains('progress-bar__container');
    }
    // <div class="progress-bar" [style.width]="progress + '%'"></div>
    get progressBarDivCO() {
        return new DivComponent(this.progressBarContainerDivCO).addPredicateClassContains('progress-bar');
    }
    async progressPercentage() {
        let result = await (await this.progressBarDivCO.element()).getAttribute('style.width');  
        result = result.replace(' + \'%\'', '');
        result = result.valueOf();
        if (result == 0) {
            return 0;
        }
        else {
            return (result * 100);
        }
    }
    get fileUploadProgressValueDivCO() {
        return new DivComponent(this.fileUploadProgressBarDivCO).byAttributeNotContains('class','progress-bar__container');
    }
}


