<commit_before>﻿
$(function () {
    var svc = new authz.Service("admin/Applications");

    function Application(keys, data) {
        var isNew = !data;
        data = data || {
            id:0,
            name: "",
            description: "",
            logoUrl: "",
            namespace: "",
            audience: "",
            tokenLifetime: 0,
            allowRefreshToken: false,
            requireConsent: false,
            rememberConsentDecision: false,
            signingKeyId: null
        };
        ko.mapping.fromJS(data, null, this);
        this.signingKeys = ko.mapping.fromJS(keys);

        var vm = this;

        authz.util.addRequired(this, "name", "Name");
        authz.util.addRequired(this, "namespace", "Namespace");
        authz.util.addRequired(this, "audience", "Audience");
        authz.util.addRequired(this, "signingKeyId", "Signing Key");
        authz.util.addAnyErrors(this);

        vm.menusEnabled = ko.computed(function () {
            return !isNew;
        });

        vm.editDescription = ko.computed(function () {
            return isNew ? "New" : "Manage";
        });

        vm.save = function () {
            if (isNew) {
                svc.post(ko.mapping.toJS(vm)).then(function (data, status, xhr) {
                    window.location = window.location + '#' + data.id;
                });
            }
            else {
                svc.put(ko.mapping.toJS(vm), vm.id());
            }
        };
    }

    var keysSvc = new authz.Service("admin/Keys");
    var kd = keysSvc.get();
    var ad = null;

    if (window.location.hash) {
        var id = window.location.hash.substring(1);
        ad = svc.get(id);
    }

    $.when(kd, ad).then(function (keyData, appData) {
        var vm = new Application(keyData[0], appData && appData[0]);
        ko.applyBindings(vm);
    });
});<commit_msg>when creating new application, show scopes button on save<commit_after>﻿
$(function () {
    var svc = new authz.Service("admin/Applications");

    function Application(keys, data) {
        var vm = this;
        vm.isNew = ko.observable(!data);
        data = data || {
            id:0,
            name: "",
            description: "",
            logoUrl: "",
            namespace: "",
            audience: "",
            tokenLifetime: 0,
            allowRefreshToken: false,
            requireConsent: false,
            rememberConsentDecision: false,
            signingKeyId: null
        };
        ko.mapping.fromJS(data, null, this);
        this.signingKeys = ko.mapping.fromJS(keys);

        authz.util.addRequired(this, "name", "Name");
        authz.util.addRequired(this, "namespace", "Namespace");
        authz.util.addRequired(this, "audience", "Audience");
        authz.util.addRequired(this, "signingKeyId", "Signing Key");
        authz.util.addAnyErrors(this);

        vm.menusEnabled = ko.computed(function () {
            return !vm.isNew();
        });

        vm.editDescription = ko.computed(function () {
            return vm.isNew() ? "New" : "Manage";
        });

        vm.save = function () {
            if (vm.isNew()) {
                svc.post(ko.mapping.toJS(vm)).then(function (data, status, xhr) {
                    window.location = window.location + '#' + data.id;
                    vm.isNew(false);
                    vm.id(data.id);
                });
            }
            else {
                svc.put(ko.mapping.toJS(vm), vm.id());
            }
        };
    }

    var keysSvc = new authz.Service("admin/Keys");
    var kd = keysSvc.get();
    var ad = null;

    if (window.location.hash) {
        var id = window.location.hash.substring(1);
        ad = svc.get(id);
    }

    $.when(kd, ad).then(function (keyData, appData) {
        var vm = new Application(keyData[0], appData && appData[0]);
        ko.applyBindings(vm);
    });
});
{'fraction_non_alphanumeric': 0.14615977395324942, 'fraction_numerical': 0.0025687130747495505, 'mean_word_length': 1.709812108559499, 'pattern_counts': {'":': 0, '<': 3, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5210557', 'n_tokens_mistral': 1183, 'n_tokens_neox': 1155, 'n_words': 217}