<commit_before>var notificationsApp;

// Vue.component('notification', {
//     delimiters: ['${', '}'],
//     template: '#notification',
//     props: {
//         title: { type: Object, required: true },
//         status: { type: Boolean, required: true },
//     },
//     data: function () {
//         return {}
//     },
// });

$(document).ready(function () {
    const checkDelay = 1000; // ms

    $('#notifications-dropdown').on('show.bs.dropdown', function () {
        notificationsApp.fetchTasks();
    });

    notificationsApp = new Vue({
        el: '#app-notifications',
        delimiters: ['${', '}'],
        data: {
            tasks: [],
            loading: true,
            isCheckingStatus: false,
            taskMessages: {
                "bag download": {
                    title: "Download all content as Zipped BagIt Archive",
                    status: {
                        "Pending execution": "Pending...",
                        "In progress": "Getting your files ready for download...",
                        "Aborted": "Aborted",
                        "Failed": "Download failed",
                        "Delivered": "Download delivered"
                    }
                },
                "zip download": {
                    title: "File download",
                    status: {
                        "Pending execution": "Pending...",
                        "In progress": "Getting your files ready for download...",
                        "Aborted": "Aborted",
                        "Failed": "Download failed",
                        "Delivered": "Download delivered"
                    }
                },
                "resource delete": {
                    title: "Resource delete",
                    status: {
                        "Pending execution": "Pending...",
                        "In progress": "Getting your resource ready for deletion...",
                        "Aborted": "Aborted",
                        "Failed": "Resource deletion failed",
                        "Delivered": "Resource deletion delivered"
                    }
                }
            },
            statusIcons: {
                "Aborted": "glyphicon glyphicon-ban-circle",
                "Failed": "glyphicon glyphicon-remove-sign",
                "Completed": "glyphicon glyphicon-ok-sign",
                "Pending execution": "fa fa-spinner fa-pulse fa-2x fa-fw icon-blue",
                "In progress": "fa fa-spinner fa-pulse fa-2x fa-fw icon-blue",
                "Delivered": "glyphicon glyphicon-ok-sign"
            }
        },
        computed: {
            someInProgress: function () {
                return this.tasks.find(function (task) {
                    return task.status === "In progress" || task.status === "Pending execution";
                });
            }
        },
        methods: {
            // Shows the tasks dropdown
            show: function () {
                $('#notifications-dropdown').addClass('open');
            },
            fetchTasks: function () {
                let vue = this;
                vue.loading = true;
                $.ajax({
                    type: "GET",
                    url: '/hsapi/_internal/get_tasks_by_user/',
                    success: function (ret_data) {
                        vue.loading = false;
                        tasks = ret_data['tasks']
                        for (let i = 0; i < tasks.length; i++) {
                            vue.registerTask(tasks[i]);
                        }
                    },
                    error: function (response) {
                        console.log(response);
                        vue.loading = false;
                    }
                });
            },
            dismissTask: function (task) {
                let vue = this;
                if (vue.canBeDismissed(task)) {
                    $.ajax({
                        type: "GET",
                        url: '/hsapi/_internal/dismiss_task/' + task.id,
                        success: function (task) {
                            vue.tasks = vue.tasks.filter(function(t) {
                                return t.id !== task.id;
                            });
                        },
                        error: function (response) {
                            console.log(response);
                        }
                    });
                }
            },
            canBeDismissed: function (task) {
                return task.status === 'Completed'
                    || task.status === 'Failed'
                    || task.status === 'Aborted'
                    || task.status === 'Delivered'
            },
            deliverTask: function(task) {
                let vue = this;
                if (vue.canBeDelivered(task)) {
                    $.ajax({
                        type: "GET",
                        url: '/hsapi/_internal/set_task_delivered/' + task.id,
                        success: function (task) {
                        },
                        error: function (response) {
                            console.log(response);
                        }
                    });
                }
            },
            canBeDelivered: function (task) {
                return task.status === 'Completed'
            },
            abortTask: function(task) {
                let vue = this;
                if (vue.canBeAborted(task)) {
                    $.ajax({
                        type: "GET",
                        url: '/hsapi/_internal/abort_task/' + task.id,
                        success: function (task) {
                            vue.registerTask(task);
                        },
                        error: function (response) {
                            console.log(response);
                        }
                    });
                }
            },
            canBeAborted: function (task) {
                return task.status === 'In progress'
                    || task.status === 'Pending execution'
            },
            clear: function () {
                let vue = this;
                vue.tasks = vue.tasks.filter(function(task) {
                    if (vue.canBeDismissed(task))
                        vue.dismissTask(task);
                    return !vue.canBeDismissed(task);
                });
            },
            scheduleCheck() {
                let vue = this;
                if (vue.someInProgress && !vue.isCheckingStatus) {
                    vue.isCheckingStatus = true;

                    // check in 1s
                    setTimeout(function() {
                        vue.checkStatus();
                    }, checkDelay);
                }
                else {
                    vue.isCheckingStatus = false;
                }
            },
            // Checks every 1s for every task in progress
            checkStatus: function () {
                let vue = this;

                if (vue.someInProgress) {<commit_msg>removed abort task option for resource deletion<commit_after>var notificationsApp;

// Vue.component('notification', {
//     delimiters: ['${', '}'],
//     template: '#notification',
//     props: {
//         title: { type: Object, required: true },
//         status: { type: Boolean, required: true },
//     },
//     data: function () {
//         return {}
//     },
// });

$(document).ready(function () {
    const checkDelay = 1000; // ms

    $('#notifications-dropdown').on('show.bs.dropdown', function () {
        notificationsApp.fetchTasks();
    });

    notificationsApp = new Vue({
        el: '#app-notifications',
        delimiters: ['${', '}'],
        data: {
            tasks: [],
            loading: true,
            isCheckingStatus: false,
            taskMessages: {
                "bag download": {
                    title: "Download all content as Zipped BagIt Archive",
                    status: {
                        "Pending execution": "Pending...",
                        "In progress": "Getting your files ready for download...",
                        "Aborted": "Aborted",
                        "Failed": "Download failed",
                        "Delivered": "Download delivered"
                    }
                },
                "zip download": {
                    title: "File download",
                    status: {
                        "Pending execution": "Pending...",
                        "In progress": "Getting your files ready for download...",
                        "Aborted": "Aborted",
                        "Failed": "Download failed",
                        "Delivered": "Download delivered"
                    }
                },
                "resource delete": {
                    title: "Resource delete",
                    status: {
                        "Pending execution": "Pending...",
                        "In progress": "Getting your resource ready for deletion...",
                        "Failed": "Resource deletion failed",
                        "Delivered": "Resource deletion delivered"
                    }
                }
            },
            statusIcons: {
                "Aborted": "glyphicon glyphicon-ban-circle",
                "Failed": "glyphicon glyphicon-remove-sign",
                "Completed": "glyphicon glyphicon-ok-sign",
                "Pending execution": "fa fa-spinner fa-pulse fa-2x fa-fw icon-blue",
                "In progress": "fa fa-spinner fa-pulse fa-2x fa-fw icon-blue",
                "Delivered": "glyphicon glyphicon-ok-sign"
            }
        },
        computed: {
            someInProgress: function () {
                return this.tasks.find(function (task) {
                    return task.status === "In progress" || task.status === "Pending execution";
                });
            }
        },
        methods: {
            // Shows the tasks dropdown
            show: function () {
                $('#notifications-dropdown').addClass('open');
            },
            fetchTasks: function () {
                let vue = this;
                vue.loading = true;
                $.ajax({
                    type: "GET",
                    url: '/hsapi/_internal/get_tasks_by_user/',
                    success: function (ret_data) {
                        vue.loading = false;
                        tasks = ret_data['tasks']
                        for (let i = 0; i < tasks.length; i++) {
                            vue.registerTask(tasks[i]);
                        }
                    },
                    error: function (response) {
                        console.log(response);
                        vue.loading = false;
                    }
                });
            },
            dismissTask: function (task) {
                let vue = this;
                if (vue.canBeDismissed(task)) {
                    $.ajax({
                        type: "GET",
                        url: '/hsapi/_internal/dismiss_task/' + task.id,
                        success: function (task) {
                            vue.tasks = vue.tasks.filter(function(t) {
                                return t.id !== task.id;
                            });
                        },
                        error: function (response) {
                            console.log(response);
                        }
                    });
                }
            },
            canBeDismissed: function (task) {
                return task.status === 'Completed'
                    || task.status === 'Failed'
                    || task.status === 'Aborted'
                    || task.status === 'Delivered'
            },
            deliverTask: function(task) {
                let vue = this;
                if (vue.canBeDelivered(task)) {
                    $.ajax({
                        type: "GET",
                        url: '/hsapi/_internal/set_task_delivered/' + task.id,
                        success: function (task) {
                        },
                        error: function (response) {
                            console.log(response);
                        }
                    });
                }
            },
            canBeDelivered: function (task) {
                return task.status === 'Completed'
            },
            abortTask: function(task) {
                let vue = this;
                if (vue.canBeAborted(task)) {
                    $.ajax({
                        type: "GET",
                        url: '/hsapi/_internal/abort_task/' + task.id,
                        success: function (task) {
                            vue.registerTask(task);
                        },
                        error: function (response) {
                            console.log(response);
                        }
                    });
                }
            },
            canBeAborted: function (task) {
                return task.name != 'resource delete' && (task.status === 'In progress'
                    || task.status === 'Pending execution')
            },
            clear: function () {
                let vue = this;
                vue.tasks = vue.tasks.filter(function(task) {
                    if (vue.canBeDismissed(task))
                        vue.dismissTask(task);
                    return !vue.canBeDismissed(task);
                });
            },
            scheduleCheck() {
                let vue = this;
                if (vue.someInProgress && !vue.isCheckingStatus) {
                    vue.isCheckingStatus = true;

                    // check in 1s
                    setTimeout(function() {
                        vue.checkStatus();
                    }, checkDelay);
                }
                else {
                    vue.isCheckingStatus = false;
                }
            },
            // Checks every 1s for every task in progress
            checkStatus: function () {
                let vue = this;

                if (vue.someInProgress) {
{'fraction_non_alphanumeric': 0.11343472750316856, 'fraction_numerical': 0.0012674271229404308, 'mean_word_length': 0.9247865564439626, 'pattern_counts': {'":': 47, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '814406', 'n_tokens_mistral': 3413, 'n_tokens_neox': 3111, 'n_words': 699}