<commit_before><%@ page import="dk.danthrane.twbs.NavStyle; dk.sdu.tekvideo.NodeStatus; dk.danthrane.twbs.ButtonSize; dk.danthrane.twbs.ButtonStyle; dk.sdu.tekvideo.FaIcon" contentType="text/html;charset=UTF-8" %>
<html>
<head>
    <title>Mine kurser</title>
    <meta name="layout" content="main_fluid"/>
    <sdu:requireAjaxAssets/>
</head>

<body>

<twbs:pageHeader><h3>Mine kurser</h3></twbs:pageHeader>

<twbs:row>
    <twbs:column>
        <ol class="breadcrumb">
            <li class="active">Mine Kurser</li>
        </ol>
    </twbs:column>
</twbs:row>

<sdu:card>
    <g:if test="${activeCourses.isEmpty()}">
        <p>Du har ingen aktive kurser!</p>
    </g:if>
    <g:else>
        <g:each in="${activeCourses}" var="course">
            <div data-subject-id="${course.id}" class="hide"></div>
            <twbs:row>
                <twbs:column cols="8">
                    <div class="node-header">
                        <g:link action="manage" id="${course.id}">${course.fullName} (${course.name})</g:link>
                        <ul class="list-inline course-list">
                            <!-- I definitely didn't implement the bullets like this because I'm too lazy ;-) -->
                            <li>&raquo; <sdu:semesterString course="${course}"/></li>
                            <li>&raquo; ${course.subjects.size()} emne(r)</li>
                        </ul>
                    </div>
                </twbs:column>
                <twbs:column cols="4" class="align-right">
                    <twbs:buttonGroup>
                        <twbs:dropdownToggle style="${ButtonStyle.WARNING}">
                            <fa:icon icon="${FaIcon.ARROW_CIRCLE_RIGHT}"/> Flyt til

                            <twbs:dropdownMenu>
                                <twbs:dropdownItem disabled="${status == NodeStatus.VISIBLE}"
                                                   action="courseStatus" id="${course.id}"
                                                   params="${[status: NodeStatus.VISIBLE]}">
                                    <fa:icon icon="${FaIcon.EYE}"/> Synlige
                                </twbs:dropdownItem>
                                <twbs:dropdownItem disabled="${status == NodeStatus.INVISIBLE}"
                                                   action="courseStatus" id="${course.id}"
                                                   params="${[status: NodeStatus.INVISIBLE]}">
                                    <fa:icon icon="${FaIcon.EYE_SLASH}"/> Usynlige
                                </twbs:dropdownItem>
                                <twbs:dropdownItem disabled="${status == NodeStatus.TRASH}"
                                                   action="courseStatus" id="${course.id}"
                                                   params="${[status: NodeStatus.TRASH]}">
                                    <fa:icon icon="${FaIcon.TRASH}"/> Papirkurv
                                </twbs:dropdownItem>
                            </twbs:dropdownMenu>
                        </twbs:dropdownToggle>
                    </twbs:buttonGroup>
                    <twbs:buttonGroup>
                        <twbs:dropdownToggle style="${ButtonStyle.SUCCESS}">
                            <fa:icon icon="${FaIcon.PLUS_CIRCLE}"/> Tilføj

                            <twbs:dropdownMenu>
                                <twbs:dropdownItem action="createSubject" id="${course.id}">
                                    <fa:icon icon="${FaIcon.USERS}"/> Emne
                                </twbs:dropdownItem>
                                <twbs:dropdownItem action="createVideo" id="${course.id}">
                                    <fa:icon icon="${FaIcon.PLAY}"/> Video
                                </twbs:dropdownItem>
                            </twbs:dropdownMenu>
                        </twbs:dropdownToggle>
                    </twbs:buttonGroup>
                </twbs:column>
            </twbs:row>
            <twbs:row>
                <twbs:column>
                    <markdown:renderHtml text="${sdu.abbreviate([:], { course.description })}"/>
                </twbs:column>
            </twbs:row>
            <hr>
        </g:each>

        <twbs:modal id="course-delete-modal">
            <twbs:modalHeader>Er du sikker?</twbs:modalHeader>
            Dette vil slette dette fag!
            <twbs:modalFooter>
                <twbs:button data-dismiss="modal">Annulér</twbs:button>
                <sdu:ajaxSubmitButton style="${ButtonStyle.DANGER}" id="subject-delete-button">
                    <fa:icon icon="${FaIcon.TRASH}"/>
                    Slet fag
                </sdu:ajaxSubmitButton>
            </twbs:modalFooter>
        </twbs:modal>
    </g:else>
</sdu:card>

<g:content key="sidebar-left">
    <div id="tree-container"></div>
</g:content>

<g:content key="sidebar-right">
    <twbs:pageHeader>
        <h4>Filter</h4>
    </twbs:pageHeader>
    <twbs:nav style="${NavStyle.PILL}" stacked="true">
        <twbs:navItem active="${status == NodeStatus.VISIBLE}" params="${[status: NodeStatus.VISIBLE]}">
            <fa:icon icon="${FaIcon.EYE}"/> Synlige
        </twbs:navItem>
        <twbs:navItem active="${status == NodeStatus.INVISIBLE}" params="${[status: NodeStatus.INVISIBLE]}">
            <fa:icon icon="${FaIcon.EYE_SLASH}"/> Usynlige
        </twbs:navItem>
        <twbs:navItem active="${status == NodeStatus.TRASH}" params="${[status: NodeStatus.TRASH]}">
            <fa:icon icon="${FaIcon.TRASH}"/> Papirkurv
        </twbs:navItem>
    </twbs:nav>

    <twbs:pageHeader>
        <h4>Handlinger</h4>
    </twbs:pageHeader>

    <twbs:linkButton action="createCourse" style="${ButtonStyle.LINK}" block="true">
        <fa:icon icon="${FaIcon.PLUS_CIRCLE}"/>
        Opret nyt kursus
    </twbs:linkButton>
    <twbs:linkButton action="importCourse" style="${ButtonStyle.LINK}" block="true">
        <fa:icon icon="${FaIcon.UPLOAD}"/>
        Importer kursus
    </twbs:linkButton>
</g:content>

<script>
    $(function () {
        var courseToDelete = null;

        $("#course-delete-modal").on("show.bs.modal", function (e) {
            courseToDelete = $(e.relatedTarget).data("id");
        });

        AjaxUtil.registerJSONForm(
                "#subject-delete-button",
                "${createLink(action: "deleteCourse")}",
                function () {
                    return {course: courseToDelete};
                },
                {
                    success: function () {
                        $("#course-delete-modal").modal("hide");
                        $($("[data-id=" + courseToDelete + "]").closest(".course")[0]).fadeOut(function () {
                            $(this).remove();
                        });
                    }
                }
        );

        $('#tree-container').jstree({
            "core": {
                "check_callback": true,
                "themes": {
                    "name": "proton",
                    "responsive": true
                },
                "data": {
                    "url": function (node) {
                        if (node.id === "#") {
                            return "jstCourses";
                        } else {
                            switch (node.type) {
                                case "course":
                                    return "jstSubjects/" + node.id;
                                case "subject":
                                    return "jstVideos/" + node.id;
                                default:
                                    console.log("Unknown node ");
                                    console.log(node);
                                    return null;
                            }
                        }
                    },
                    "dataType": "json",
                    "contentType": "application/json"
                }
            },
            "types": {
                "#": {
                    "valid_children": ["course"]
                },
                "course": {
                    "icon": "fa fa-graduation-cap",
                    "valid_children": ["subject"]
                },
                "subject": {
                    "icon": "fa fa-users",
                    "valid_children": ["video"]
                },
                "video": {
                    "icon": "fa fa-play",
                    "valid_children": []
                }
            },
            "plugins": ["contextmenu", "dnd", "search", "state", "types", "wholerow"]
        }).bind("move_node.jstree", function (e, data) {
            console.log("move event!");
            console.log(e);
            console.log(data);
        });
    });
</script>

<asset:javascript src="./lib/jstree.js"/>
<asset:stylesheet src="./vendor/proton/style.min.css"/>

</body>
</html><commit_msg>Updated the context-menu  to show relevant items<commit_after><%@ page import="dk.danthrane.twbs.NavStyle; dk.sdu.tekvideo.NodeStatus; dk.danthrane.twbs.ButtonSize; dk.danthrane.twbs.ButtonStyle; dk.sdu.tekvideo.FaIcon" contentType="text/html;charset=UTF-8" %>
<html>
<head>
    <title>Mine kurser</title>
    <meta name="layout" content="main_fluid"/>
    <sdu:requireAjaxAssets/>
</head>

<body>

<twbs:pageHeader><h3>Mine kurser</h3></twbs:pageHeader>

<twbs:row>
    <twbs:column>
        <ol class="breadcrumb">
            <li class="active">Mine Kurser</li>
        </ol>
    </twbs:column>
</twbs:row>

<sdu:card>
    <g:if test="${activeCourses.isEmpty()}">
        <p>Du har ingen aktive kurser!</p>
    </g:if>
    <g:else>
        <g:each in="${activeCourses}" var="course">
            <div data-subject-id="${course.id}" class="hide"></div>
            <twbs:row>
                <twbs:column cols="8">
                    <div class="node-header">
                        <g:link action="manage" id="${course.id}">${course.fullName} (${course.name})</g:link>
                        <ul class="list-inline course-list">
                            <!-- I definitely didn't implement the bullets like this because I'm too lazy ;-) -->
                            <li>&raquo; <sdu:semesterString course="${course}"/></li>
                            <li>&raquo; ${course.subjects.size()} emne(r)</li>
                        </ul>
                    </div>
                </twbs:column>
                <twbs:column cols="4" class="align-right">
                    <twbs:buttonGroup>
                        <twbs:dropdownToggle style="${ButtonStyle.WARNING}">
                            <fa:icon icon="${FaIcon.ARROW_CIRCLE_RIGHT}"/> Flyt til

                            <twbs:dropdownMenu>
                                <twbs:dropdownItem disabled="${status == NodeStatus.VISIBLE}"
                                                   action="courseStatus" id="${course.id}"
                                                   params="${[status: NodeStatus.VISIBLE]}">
                                    <fa:icon icon="${FaIcon.EYE}"/> Synlige
                                </twbs:dropdownItem>
                                <twbs:dropdownItem disabled="${status == NodeStatus.INVISIBLE}"
                                                   action="courseStatus" id="${course.id}"
                                                   params="${[status: NodeStatus.INVISIBLE]}">
                                    <fa:icon icon="${FaIcon.EYE_SLASH}"/> Usynlige
                                </twbs:dropdownItem>
                                <twbs:dropdownItem disabled="${status == NodeStatus.TRASH}"
                                                   action="courseStatus" id="${course.id}"
                                                   params="${[status: NodeStatus.TRASH]}">
                                    <fa:icon icon="${FaIcon.TRASH}"/> Papirkurv
                                </twbs:dropdownItem>
                            </twbs:dropdownMenu>
                        </twbs:dropdownToggle>
                    </twbs:buttonGroup>
                    <twbs:buttonGroup>
                        <twbs:dropdownToggle style="${ButtonStyle.SUCCESS}">
                            <fa:icon icon="${FaIcon.PLUS_CIRCLE}"/> Tilføj

                            <twbs:dropdownMenu>
                                <twbs:dropdownItem action="createSubject" id="${course.id}">
                                    <fa:icon icon="${FaIcon.USERS}"/> Emne
                                </twbs:dropdownItem>
                                <twbs:dropdownItem action="createVideo" id="${course.id}">
                                    <fa:icon icon="${FaIcon.PLAY}"/> Video
                                </twbs:dropdownItem>
                            </twbs:dropdownMenu>
                        </twbs:dropdownToggle>
                    </twbs:buttonGroup>
                </twbs:column>
            </twbs:row>
            <twbs:row>
                <twbs:column>
                    <markdown:renderHtml text="${sdu.abbreviate([:], { course.description })}"/>
                </twbs:column>
            </twbs:row>
            <hr>
        </g:each>

        <twbs:modal id="course-delete-modal">
            <twbs:modalHeader>Er du sikker?</twbs:modalHeader>
            Dette vil slette dette fag!
            <twbs:modalFooter>
                <twbs:button data-dismiss="modal">Annulér</twbs:button>
                <sdu:ajaxSubmitButton style="${ButtonStyle.DANGER}" id="subject-delete-button">
                    <fa:icon icon="${FaIcon.TRASH}"/>
                    Slet fag
                </sdu:ajaxSubmitButton>
            </twbs:modalFooter>
        </twbs:modal>
    </g:else>
</sdu:card>

<g:content key="sidebar-left">
    <div id="tree-container"></div>
</g:content>

<g:content key="sidebar-right">
    <twbs:pageHeader>
        <h4>Filter</h4>
    </twbs:pageHeader>
    <twbs:nav style="${NavStyle.PILL}" stacked="true">
        <twbs:navItem active="${status == NodeStatus.VISIBLE}" params="${[status: NodeStatus.VISIBLE]}">
            <fa:icon icon="${FaIcon.EYE}"/> Synlige
        </twbs:navItem>
        <twbs:navItem active="${status == NodeStatus.INVISIBLE}" params="${[status: NodeStatus.INVISIBLE]}">
            <fa:icon icon="${FaIcon.EYE_SLASH}"/> Usynlige
        </twbs:navItem>
        <twbs:navItem active="${status == NodeStatus.TRASH}" params="${[status: NodeStatus.TRASH]}">
            <fa:icon icon="${FaIcon.TRASH}"/> Papirkurv
        </twbs:navItem>
    </twbs:nav>

    <twbs:pageHeader>
        <h4>Handlinger</h4>
    </twbs:pageHeader>

    <twbs:linkButton action="createCourse" style="${ButtonStyle.LINK}" block="true">
        <fa:icon icon="${FaIcon.PLUS_CIRCLE}"/>
        Opret nyt kursus
    </twbs:linkButton>
    <twbs:linkButton action="importCourse" style="${ButtonStyle.LINK}" block="true">
        <fa:icon icon="${FaIcon.UPLOAD}"/>
        Importer kursus
    </twbs:linkButton>
</g:content>

<script>
    $(function () {
        var courseToDelete = null;

        $("#course-delete-modal").on("show.bs.modal", function (e) {
            courseToDelete = $(e.relatedTarget).data("id");
        });

        AjaxUtil.registerJSONForm(
                "#subject-delete-button",
                "${createLink(action: "deleteCourse")}",
                function () {
                    return {course: courseToDelete};
                },
                {
                    success: function () {
                        $("#course-delete-modal").modal("hide");
                        $($("[data-id=" + courseToDelete + "]").closest(".course")[0]).fadeOut(function () {
                            $(this).remove();
                        });
                    }
                }
        );

        $('#tree-container').jstree({
            "core": {
                "check_callback": true,
                "themes": {
                    "name": "proton",
                    "responsive": true
                },
                "data": {
                    "url": function (node) {
                        if (node.id === "#") {
                            return "jstCourses";
                        } else {
                            switch (node.type) {
                                case "course":
                                    return "jstSubjects/" + node.id;
                                case "subject":
                                    return "jstVideos/" + node.id;
                                default:
                                    console.log("Unknown node ");
                                    console.log(node);
                                    return null;
                            }
                        }
                    },
                    "dataType": "json",
                    "contentType": "application/json"
                }
            },
            "types": {
                "#": {
                    "valid_children": ["course"]
                },
                "course": {
                    "icon": "fa fa-graduation-cap",
                    "valid_children": ["subject"]
                },
                "subject": {
                    "icon": "fa fa-users",
                    "valid_children": ["video"]
                },
                "video": {
                    "icon": "fa fa-play",
                    "valid_children": []
                }
            },
            "plugins": ["contextmenu", "dnd", "search", "state", "types", "wholerow"],
            "contextmenu": {
                "items": function (node) {
                    var options = {};
                    if (node.type !== "video") {
                        options.create = {
                            "label": "Tilføj element",
                            "action": function (obj) {
                                console.log("create");
                            }
                        };
                    }
                    options.edit = {
                        "label": "Rediger",
                        "action": function (obj) {
                            console.log("edit");
                        }
                    };
                    options.move_to_visible = {
                        "label": "Flyt til: Synlige",
                        "separator_before": true,
                        "_disabled": true,
                        "action": function (obj) {
                            console.log("vis");
                        }
                    };
                    options.move_to_invisible = {
                        "label": "Flyt til: Usynlige",
                        "action": function (obj) {
                            console.log("invis");
                        }
                    };
                    options.move_to_trash = {
                        "label": "Flyt til: Papirkurv",
                        "action": function (obj) {
                            console.log("trash");
                        }
                    };
                    return options;
                }
            }
        }).bind("move_node.jstree", function (e, data) {
            console.log("move event!");
            console.log(e);
            console.log(data);
        });
    });
</script>

<asset:javascript src="./lib/jstree.js"/>
<asset:stylesheet src="./vendor/proton/style.min.css"/>

</body>
</html>
{'fraction_non_alphanumeric': 0.1448977494604871, 'fraction_numerical': 0.001027643613194944, 'mean_word_length': 1.1925199954939731, 'pattern_counts': {'":': 62, '<': 271, '<?xml version=': 0, '>': 271, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 44, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3822112', 'n_tokens_mistral': 5292, 'n_tokens_neox': 4994, 'n_words': 776}