<commit_before><dom-module id="opencga-login">
    <template>
        <style is="custom-style" include="jso-styles"></style>
        <style>
            .basic-margin {
                width: 300px;
                margin-left: 20px;
                margin-right: auto;
            }
            .fields {
                margin-top: 10px;
            }
        </style>

        <div class="basic-margin">
            <div class="input-group fields">
                <span class="input-group-addon" id="username">
                    <i class="fa fa-user fa-lg"></i>
                </span>
                <input type="text" id="opencgaUser" class="form-control" placeholder="Username" aria-describedby="username"
                       on-keyup="checkEnterKey">
            </div>

            <div class="input-group fields">
                <span class="input-group-addon" id="password">
                    <i class="fa fa-key"></i>
                </span>
                <input id="opencgaPassword" type="password" class="form-control" placeholder="Password" aria-describedby="password"
                       on-keyup="checkEnterKey">
            </div>


            <div id="incorrect" hidden="true" style="color: #AF1616;">
                {{errorMessage}}
            </div>

            <div class="fields">
                <button type="button" on-click="login" class="btn btn-primary" style="text-align: center;">{{loginText}}</button>
            </div>
        </div>

    </template>
    <script>
        Polymer({
            is: 'opencga-login',
            properties: {
                opencgaClient: {
                    type: Object
                },
                loginText: {
                    type: String,
                    value: "Login"
                }
            },

            login: function() {
                let user = this.$.opencgaUser.value;
                let pass = this.$.opencgaPassword.value;

                var _this = this;
                this.opencgaClient.users().login(user, pass)
                        .then(function(response) {
                            _this.$.opencgaUser.value = "";
                            _this.$.opencgaPassword.value = "";
                            _this.$.incorrect.hidden = true;
                            _this.fire('login', {
                                userId: user,
                                sessionId: response.response[0].result[0].sessionId
                            });
                        })
                        .catch(function(response) {
                            this.errorMessage = response.error;
                            this.$.incorrect.hidden = false;
                        }.bind(this));
            },

            checkEnterKey: function(e) {
                if (e.keyCode == 13) { // Enter was clicked
                    this.login();
                }
            }
        });
    </script>
</dom-module>
<commit_msg>opencga: make login component to accept default user and password values<commit_after><dom-module id="opencga-login">
    <template>
        <style is="custom-style" include="jso-styles"></style>
        <style>
            .basic-margin {
                width: 300px;
                margin-left: 20px;
                margin-right: auto;
            }
            .fields {
                margin-top: 10px;
            }
        </style>

        <div class="basic-margin">
            <div class="input-group fields">
                <span class="input-group-addon" id="username">
                    <i class="fa fa-user fa-lg"></i>
                </span>
                <input type="text" id="opencgaUser" value="{{user}}" class="form-control" placeholder="Username" aria-describedby="username" on-keyup="checkEnterKey">
            </div>

            <div class="input-group fields">
                <span class="input-group-addon" id="password">
                    <i class="fa fa-key"></i>
                </span>
                <input id="opencgaPassword" value="{{password}}" type="password" class="form-control" placeholder="Password" aria-describedby="password" on-keyup="checkEnterKey">
            </div>


            <div id="incorrect" hidden="true" style="color: #AF1616;">
                {{errorMessage}}
            </div>

            <div class="fields">
                <button type="button" on-click="login" class="btn btn-primary" style="text-align: center;">{{loginText}}</button>
            </div>
        </div>

    </template>
    <script>
        Polymer({
            is: 'opencga-login',
            properties: {
                opencgaClient: {
                    type: Object
                },
                loginText: {
                    type: String,
                    value: "Login"
                },
                user: {
                    type: String,
                    value: ""
                },
                password: {
                    type: String,
                    value: ""
                }
            },

            login: function() {
                let user = this.$.opencgaUser.value;
                let pass = this.$.opencgaPassword.value;

                var _this = this;
                this.opencgaClient.users().login(user, pass)
                        .then(function(response) {
                            _this.$.opencgaUser.value = "";
                            _this.$.opencgaPassword.value = "";
                            _this.$.incorrect.hidden = true;
                            _this.fire('login', {
                                userId: user,
                                sessionId: response.response[0].result[0].sessionId
                            });
                        })
                        .catch(function(response) {
                            this.errorMessage = response.error;
                            this.$.incorrect.hidden = false;
                        }.bind(this));
            },

            checkEnterKey: function(e) {
                if (e.keyCode == 13) { // Enter was clicked
                    this.login();
                }
            }
        });
    </script>
</dom-module>

{'fraction_non_alphanumeric': 0.12594498954479652, 'fraction_numerical': 0.004825478526620556, 'mean_word_length': 1.0886798790728922, 'pattern_counts': {'":': 0, '<': 67, '<?xml version=': 0, '>': 67, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5314066', 'n_tokens_mistral': 1636, 'n_tokens_neox': 1507, 'n_words': 278}