<commit_before>import { Component } from '@angular/core';
import { faEye, faEyeSlash } from '@fortawesome/pro-regular-svg-icons';
import { faChevronDown, faChevronUp, faUserPlus } from '@fortawesome/pro-solid-svg-icons';

import { CharacterService } from '../../models/character/character.service';
import { UserService } from '../../models/user/user.service';

@Component({
    selector: 'app-scopes',
    styleUrls: ['./scopes.component.scss'],
    templateUrl: './scopes.component.html',
})
export class ScopesComponent {

    public static readonly scopeCodes = {
        JOBS: 'esi-industry.read_character_jobs.v1',
        LOCATION: 'esi-location.read_location.v1',
        ORDERS: 'esi-markets.read_character_orders.v1',
        SHIP_TYPE: 'esi-location.read_ship_type.v1',
        SKILLQUEUE: 'esi-skills.read_skillqueue.v1',
        SKILLS: 'esi-skills.read_skills.v1',
        WALLET: 'esi-wallet.read_character_wallet.v1',
    };

    // Icons
    public addCharacterIcon = faUserPlus;
    public viewEnabledIcon = faEye;
    public viewDisabledIcon = faEyeSlash;
    public caretDown = faChevronDown;
    public caretUp = faChevronUp;

    public scopes = [
        {
            code: ScopesComponent.scopeCodes.SKILLS,
            enabled: false,
            eveDescription: 'Allows reading of a character\'s currently known skills.',
            infoVisible: false,
            name: 'Read skills',
            usageDescription: 'EVIE uses this scope heavily on the Skills page.',
            usagePages: ['skills'],
        },
        {
            code: ScopesComponent.scopeCodes.SKILLQUEUE,
            enabled: false,
            eveDescription: 'Allows reading of a character\'s currently training skill queue.',
            infoVisible: false,
            name: 'Read skillqueue',
            usageDescription: 'EVIE uses this scope on the Dashboard and Skills pages.',
            usagePages: ['skills'],
        },
        {
            code: ScopesComponent.scopeCodes.WALLET,
            enabled: false,
            eveDescription: 'Allows reading of a character\'s wallet, journal and transaction history.',
            infoVisible: false,
            name: 'Read wallet balance',
            usageDescription: 'EVIE uses this scope on the Dashboard and Wallet pages.',
            usagePages: ['wallet'],
        },
        {
            code: ScopesComponent.scopeCodes.ORDERS,
            enabled: false,
            eveDescription: 'Allows reading a character\'s market orders.',
            infoVisible: false,
            name: 'Read market orders',
            usageDescription: 'EVIE uses this scope on the Wallet page.',
            usagePages: ['wallet'],
        },
        // {
        //     code: ScopesComponent.scopeCodes.JOBS,
        //     enabled: false,
        //     eveDescription: 'Allows reading a character\'s industry jobs.',
        //     infoVisible: false,
        //     name: 'Read industry jobs',
        //     usageDescription: 'EVIE uses this scope on the Industry page.',
        //     usagePages: ['industry'],
        // },
        {
            code: ScopesComponent.scopeCodes.SHIP_TYPE,
            enabled: false,
            eveDescription: 'Allows reading of a character\'s active ship class.',
            infoVisible: false,
            name: 'Read current ship type',
            usageDescription: 'EVIE uses this scope on the Dashboard page.',
            usagePages: [],
        },
        // {
        //     code: ScopesComponent.scopeCodes.LOCATION,
        //     enabled: false,
        //     eveDescription: 'Allows reading of a character\'s active ship location.',
        //     infoVisible: false,
        //     name: 'Read current location',
        //     usageDescription: 'EVIE uses this scope on the Skills page.',
        //     usagePages: [],
        // },
    ];

    constructor(private userService: UserService) {
        if (CharacterService.selectedCharacter) {
            for (const scope of this.scopes) {
                if (CharacterService.selectedCharacter.scopes.includes(scope.code)) {
                    scope.enabled = true;
                }
            }
        }
    }

    public get allComponentsEnabled(): boolean {
        return this.scopes.every((scope) => scope.enabled);
    }

    public set allComponentsEnabled(value) {
        this.scopes.forEach((scope) => scope.enabled = value);
    }

    public authCharacter() {
        const enabledScopes = this.scopes.filter((scope) => scope.enabled);
        const scopeCodes = enabledScopes.map((scope) => scope.code);
        this.userService.authCharacter(scopeCodes);
    }
}<commit_msg>Show currently active scopes when switching characters on scopes page<commit_after>import { Component, OnInit } from '@angular/core';
import { faEye, faEyeSlash } from '@fortawesome/pro-regular-svg-icons';
import { faChevronDown, faChevronUp, faUserPlus } from '@fortawesome/pro-solid-svg-icons';

import { CharacterService } from '../../models/character/character.service';
import { UserService } from '../../models/user/user.service';
import { DataPageComponent } from '../data-page/data-page.component';

@Component({
    selector: 'app-scopes',
    styleUrls: ['./scopes.component.scss'],
    templateUrl: './scopes.component.html',
})
export class ScopesComponent extends DataPageComponent implements OnInit {

    public static readonly scopeCodes = {
        JOBS: 'esi-industry.read_character_jobs.v1',
        LOCATION: 'esi-location.read_location.v1',
        ORDERS: 'esi-markets.read_character_orders.v1',
        SHIP_TYPE: 'esi-location.read_ship_type.v1',
        SKILLQUEUE: 'esi-skills.read_skillqueue.v1',
        SKILLS: 'esi-skills.read_skills.v1',
        WALLET: 'esi-wallet.read_character_wallet.v1',
    };

    // Icons
    public addCharacterIcon = faUserPlus;
    public viewEnabledIcon = faEye;
    public viewDisabledIcon = faEyeSlash;
    public caretDown = faChevronDown;
    public caretUp = faChevronUp;

    public scopes = [
        {
            code: ScopesComponent.scopeCodes.SKILLS,
            enabled: false,
            eveDescription: 'Allows reading of a character\'s currently known skills.',
            infoVisible: false,
            name: 'Read skills',
            usageDescription: 'EVIE uses this scope heavily on the Skills page, the skills page does not work without this scope.',
            usagePages: ['skills'],
        },
        {
            code: ScopesComponent.scopeCodes.SKILLQUEUE,
            enabled: false,
            eveDescription: 'Allows reading of a character\'s currently training skill queue.',
            infoVisible: false,
            name: 'Read skillqueue',
            usageDescription: 'EVIE uses this scope on the Dashboard and Skills pages.',
            usagePages: ['skills'],
        },
        {
            code: ScopesComponent.scopeCodes.WALLET,
            enabled: false,
            eveDescription: 'Allows reading of a character\'s wallet, journal and transaction history.',
            infoVisible: false,
            name: 'Read wallet balance',
            usageDescription: 'EVIE uses this scope on the Dashboard and Wallet pages.',
            usagePages: ['wallet'],
        },
        {
            code: ScopesComponent.scopeCodes.ORDERS,
            enabled: false,
            eveDescription: 'Allows reading a character\'s market orders.',
            infoVisible: false,
            name: 'Read market orders',
            usageDescription: 'EVIE uses this scope on the Wallet page.',
            usagePages: ['wallet'],
        },
        // {
        //     code: ScopesComponent.scopeCodes.JOBS,
        //     enabled: false,
        //     eveDescription: 'Allows reading a character\'s industry jobs.',
        //     infoVisible: false,
        //     name: 'Read industry jobs',
        //     usageDescription: 'EVIE uses this scope on the Industry page.',
        //     usagePages: ['industry'],
        // },
        {
            code: ScopesComponent.scopeCodes.SHIP_TYPE,
            enabled: false,
            eveDescription: 'Allows reading of a character\'s active ship class.',
            infoVisible: false,
            name: 'Read current ship type',
            usageDescription: 'EVIE uses this scope on the Dashboard page.',
            usagePages: [],
        },
        // {
        //     code: ScopesComponent.scopeCodes.LOCATION,
        //     enabled: false,
        //     eveDescription: 'Allows reading of a character\'s active ship location.',
        //     infoVisible: false,
        //     name: 'Read current location',
        //     usageDescription: 'EVIE uses this scope on the Skills page.',
        //     usagePages: [],
        // },
    ];

    constructor(private userService: UserService) {
        super();
    }

    public ngOnInit() {
        super.ngOnInit();
        if (CharacterService.selectedCharacter) {
            for (const scope of this.scopes) {
                scope.enabled = CharacterService.selectedCharacter.scopes.includes(scope.code);
            }
        }
    }

    public get allComponentsEnabled(): boolean {
        return this.scopes.every((scope) => scope.enabled);
    }

    public set allComponentsEnabled(value) {
        this.scopes.forEach((scope) => scope.enabled = value);
    }

    public authCharacter() {
        const enabledScopes = this.scopes.filter((scope) => scope.enabled);
        const scopeCodes = enabledScopes.map((scope) => scope.code);
        this.userService.authCharacter(scopeCodes);
    }
}
{'fraction_non_alphanumeric': 0.10903589315525876, 'fraction_numerical': 0.0014607679465776294, 'mean_word_length': 2.1049562682215743, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '1362188', 'n_tokens_mistral': 2571, 'n_tokens_neox': 2542, 'n_words': 665}