Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Stefano Beretta 101 posts 246 karma points
    Oct 05, 2019 @ 12:29
    Stefano Beretta
    0

    Override or Replace "/umbraco/GetGridConfig"

    Hi!

    I'd like to change the behaviour of the method that returns the list of the Grid editors without edit the source code.

    If I'm correct is this one.

            [UmbracoAuthorize(Order = 0)]
            [HttpGet]
            public JsonNetResult GetGridConfig()
            {
                var gridConfig = UmbracoConfig.For.GridConfig(
                    Logger,
                    ApplicationContext.ApplicationCache.RuntimeCache,
                    new DirectoryInfo(Server.MapPath(SystemDirectories.AppPlugins)),
                    new DirectoryInfo(Server.MapPath(SystemDirectories.Config)),
                    HttpContext.IsDebuggingEnabled);
    
                return new JsonNetResult { Data = gridConfig.EditorsConfig.Editors, Formatting = Formatting.Indented };
            }
    

    What I want is just to filter the editors based on the user group.

    Thankyou :D

    S

  • Søren Kottal 702 posts 4497 karma points MVP 5x c-trib
    Oct 07, 2019 @ 06:54
    Søren Kottal
    100

    Hi Stefano

    You can intercept the call in angular, and replace it with your own. Check out this article (the last section) describing how its done: https://24days.in/umbraco-cms/2015/umbraco-7-back-office-tweaks/

  • Stefano Beretta 101 posts 246 karma points
    Oct 07, 2019 @ 09:01
    Stefano Beretta
    0

    Woah, thank you!

    That's almost what I need: I intercepted the call, but I also should retrieve the group/s of the current user

    angular.module('umbraco.services').config([
        '$httpProvider',
        function ($httpProvider) {
            $httpProvider.interceptors.push(function ($q, $injector) {
                return {
                    'response': function (response) {
                        var userS = $injector.get('userService');
                        if (response.config.url.indexOf("/umbraco/GetGridConfig") === 0) {
                            userS.getCurrentUser().then(function (currentUser) {
                                //check the user group and return the filtered
                                //response.data
                            });
                        }
                    }
                };
            });
        }]);
    

    if the only way is the userService then I should wait for the userS.getCurrentUser() to finish the call before return the data, but I can't find the way to do it...

    Could you give me a hint? :D

    Thank you

    S

  • Søren Kottal 702 posts 4497 karma points MVP 5x c-trib
    Oct 07, 2019 @ 09:35
    Søren Kottal
    1

    Hi Stefano

    I would probably create my own API endpoint to replace GetGridConfig in that one it should be possible to read the groups of the current user and mangle with the object.

    Then angular should intercept the request in order to change the url to eg. /umbraco/backoffice/MyGridConfig/GetGridConfig.

  • Stefano Beretta 101 posts 246 karma points
    Oct 07, 2019 @ 09:43
    Stefano Beretta
    0

    Oh... Yeah... Ehmmm... I feel very stupid right now...

    I didn't think about it, sorry :D

    Thank you again!

    H5YR!

    S

Please Sign in or register to post replies

Write your reply to:

Draft