PYS++

Display green cards for valid TACE

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         PYS++
// @license      MIT
// @namespace    http://tampermonkey.net/
// @version      1.8
// @description  Display green cards for valid TACE
// @author       Matthieu Auger
// @match        https://app.pickyourskills.com/reporting/staffing_dashboard?view=user
// @match        https://app.pickyourskills.com/reporting/staffing_dashboard?view=user&tribe=lyon
// @match        https://app.pickyourskills.com/reporting/staffing_dashboard?view=user&tribe=kumo
// @icon         https://www.google.com/s2/favicons?domain=pickyourskills.com
// @grant        none
// @require      https://code.jquery.com/jquery-3.6.0.min.js
// @require      https://greatest.deepsurf.us/scripts/383527-wait-for-key-elements/code/Wait_for_key_elements.js?version=701631
// ==/UserScript==

(function() {
    'use strict';

    var $ = window.jQuery;
    var currentWeekNumber = getCurrentWeekNumber();
    var currentYear = new Date().getFullYear();

    var displayExceedingTacesInOrange = false;
    var displayWeekStandard = false;
    var defaultTaces = {
        Dev: 100,
        Sales: 0,
        'Growth Team': 0,
        Architecte: 90,
        'Head of Tribe': 0,
        'VP Tech': 50,
        'CA / PO': 100,
        'DP / PM / AM': 100,
        'Externe': 0
    }

    var tacesByTribe = {
        'Theodo Lyon': {
            ...defaultTaces,
            'Head of Tribe': 50,
            'CA / PO': 50,
            'DP / PM / AM': 50
        },
        'Kumo': {
            ...defaultTaces,
            Dev: 90,
            Architecte: 80
        }
    }

    var defaultWeekStandard = 9;
    var weekStandardByTribe = {
        'Theodo Lyon': 9,
        'Kumo': 3,
    }

    const urlParams = new URLSearchParams(window.location.search);
    if (urlParams.get('tribe') === 'kumo') {
        displayExceedingTacesInOrange = true;
        displayWeekStandard = true;
    }

    if (urlParams.get('tribe') === 'lyon') {
        displayWeekStandard = true;
    }



    function colorizeRowBasedOnStaffingAndTace(jNode) {
        var role = jNode.find('[label=Position]').text();
        var tribe = jNode.find('[label=Tribe]').text();

        jNode.find('div.cell.main_cell[width=85] > div > div').each(function(jNode) {
            var staffing = $(this).text();

            if (staffing.endsWith('%')) {
                var staffingNumber = parseInt(staffing.slice(0, -1));

                var taces = defaultTaces;
                if (tribe in tacesByTribe) {
                    taces = tacesByTribe[tribe];
                }

                if (staffingNumber === taces[role]) {
                    displayGreen($(this));
                } else if (staffingNumber > taces[role]) {
                    if (displayExceedingTacesInOrange) {
                        displayOrange($(this));
                    } else {
                        displayGreen($(this));
                    }
                } else {
                    displayRed($(this));
                }
            }

            if (displayWeekStandard) {
                // we want to add a border x weeks after current and works even with new years, hence the modulo
                var weekStandard = defaultWeekStandard;
                if (tribe in weekStandardByTribe) {
                    weekStandard = weekStandardByTribe[tribe];
                }
                var weekNumberInStandard = currentWeekNumber + weekStandard;

                var yearNumberInStandard = currentYear;
                if (weekNumberInStandard > 52) {
                    weekNumberInStandard = weekNumberInStandard % 52;
                    yearNumberInStandard++
                }

                var twoDigitsWeekStandard = ("0" + weekNumberInStandard).slice(-2);

                if ($(this).parent().data('cy') === 'date-' + yearNumberInStandard + '-W' + twoDigitsWeekStandard) {
                    $(this).parent().css('border-right', '3px solid orange');
                }
            }
        });

    }

    function getCurrentWeekNumber() {
        var today = new Date();
        var d = new Date(Date.UTC(today.getFullYear(), today.getMonth(), today.getDate()));
        var dayNum = d.getUTCDay() || 7;
        d.setUTCDate(d.getUTCDate() + 4 - dayNum);
        var yearStart = new Date(Date.UTC(d.getUTCFullYear(),0,1));
        return Math.ceil((((d - yearStart) / 86400000) + 1)/7)
    }

    function displayGreen(_this) {
        _this.css('color', 'rgb(112, 215, 98)');
        _this.css('background-color', 'rgba(112, 215, 98, 0.1)');
    }

    function displayOrange(_this) {
        _this.css('color', 'rgb(255, 165, 0)');
        _this.css('background-color', 'rgba(255, 165, 0, 0.1)');
    }

    function displayRed(_this) {
        _this.css('color', 'rgb(219, 40, 40)');
        _this.css('background-color', 'rgba(219, 40, 40, 0.1)');
    }

    waitForKeyElements("#individual_staffing_reporting_table_export .row", colorizeRowBasedOnStaffingAndTace);
})();