Esempio n. 1
0
        private ModuleJsRouteLibrary GetJsRouteLibrary(IStandardAngularModuleRegistration registration)
        {
            var routeLibrary   = GetRouteLibrary(registration);
            var jsRouteLibrary = new ModuleJsRouteLibrary(routeLibrary);

            return(jsRouteLibrary);
        }
Esempio n. 2
0
        private static string GetConstant <TValue>(ModuleJsRouteLibrary routeLibrary, string name, TValue value)
        {
            if (value != null)
            {
                var valueJson = JsonConvert.SerializeObject(value);
                return(".constant('" + routeLibrary.AngularModuleIdentifier + "." + name + "', " + valueJson + ")");
            }

            return(string.Empty);
        }
Esempio n. 3
0
        /// <summary>
        /// Adds scripts/templates for the core angular framework and the
        /// specified module and then bootstraps it.
        /// </summary>
        /// <param name="routeLibrary">Js routing library for the module to bootstrap,</param>
        public static IHtmlString Bootstrap(ModuleJsRouteLibrary routeLibrary, ICurrentUserViewHelper currentUserHelper, object options = null)
        {
            var script = string.Concat(
                RenderScript(SharedRouteLibrary.Js.Main),
                RenderScript(SharedRouteLibrary.Js.Templates),
                RenderScript(routeLibrary.Main),
                RenderScript(routeLibrary.Templates),
                RenderBootstrapper(routeLibrary, currentUserHelper, options)
                );

            return(new HtmlString(script));
        }
        public void RegisterRoutes(RouteCollection routes)
        {
            var controllerNamespace = new string[] { typeof(CustomEntityModuleController).Namespace };

            foreach (var definition in _customEntityModuleDefinition)
            {
                var routePrefix    = SlugFormatter.ToSlug(definition.NamePlural);
                var routeLibrary   = new ModuleRouteLibrary(routePrefix);
                var jsRouteLibrary = new ModuleJsRouteLibrary(routeLibrary);

                routes.MapRoute(
                    "Custom Entity Admin Module - " + definition.NamePlural,
                    RouteConstants.AdminAreaPrefix + "/" + routePrefix,
                    new { controller = "CustomEntityModule", action = "Index", definition = definition, Area = RouteConstants.AdminAreaName },
                    controllerNamespace
                    );
            }
        }
        public void RegisterRoutes(RouteCollection routes)
        {
            var controllerNamespace = new string[] { typeof(UsersRouteRegistration).Namespace };

            foreach (var userArea in _userAreaRepository.GetAll())
            {
                var routePrefix    = SlugFormatter.ToSlug(userArea.Name);
                var routeLibrary   = new ModuleRouteLibrary(routePrefix);
                var jsRouteLibrary = new ModuleJsRouteLibrary(routeLibrary);

                routes.MapRoute(
                    "Users Cofoundry Admin Module - " + userArea.Name,
                    RouteConstants.AdminAreaPrefix + "/" + routePrefix + "-users",
                    new { controller = "UsersModule", action = "Index", userArea = userArea, Area = RouteConstants.AdminAreaName },
                    controllerNamespace
                    );
            }
        }
Esempio n. 6
0
        public void RegisterRoutes(RouteCollection routes)
        {
            var controllerNamespace = new string[] { typeof(StandardModuleController).Namespace };

            foreach (var registration in _standardAdminModuleRegistrations)
            {
                ModuleRouteLibrary routeLibrary = GetRouteLibrary(registration);

                var jsRouteLibrary = new ModuleJsRouteLibrary(routeLibrary);

                routes.MapRoute(
                    "Cofoundry Admin Module - " + registration.RoutePrefix,
                    RouteConstants.AdminAreaPrefix + "/" + registration.RoutePrefix,
                    new { controller = "StandardModule", action = "Index", routeLibrary = routeLibrary, Area = RouteConstants.AdminAreaName },
                    controllerNamespace
                    );
            }
        }
Esempio n. 7
0
        private static string RenderBootstrapper(ModuleJsRouteLibrary routeLibrary, ICurrentUserViewHelper currentUserHelper, object options)
        {
            var args = string.Empty;

            if (Debugger.IsAttached)
            {
                // use strict DI when in debug mode to throw up errors
                args = ", { strictDi: true }";
            }

            // Might need to add more info at some point, but right now we just need roles.
            var currentUserInfo = new {
                PermissionCodes = currentUserHelper.Role.Permissions.Select(p => p.GetUniqueCode())
            };

            return(@"<script>angular.element(document).ready(function() {
                        angular.module('" + SharedRouteLibrary.Js.AngularModuleName + @"')
                               .constant('csrfToken', '" + GetCsrfToken() + @"')"
                   + GetConstant(routeLibrary, "options", options)             // not sure why the current module is loaded into the shared module - seems like a mistake?
                   + GetConstant(SharedRouteLibrary.Js, "currentUser", currentUserInfo) + @";
                        angular.bootstrap(document, ['" + routeLibrary.AngularModuleName + "']" + args + @");
                    });</script>");
        }
Esempio n. 8
0
        /// <summary>
        /// Adds a bundle  to the collection containing angular html template files.
        /// </summary>
        /// <param name="jsRoutes">The ModuleJsRouteLibrary for this module</param>
        /// <param name="directories">A collection of directory names (no slashes) to scan for files and addto the bundle.</param>
        /// <returns>BundleCollection instance for chaining</returns>
        public static BundleCollection AddAngularTemplateBundle(this BundleCollection bundles, ModuleJsRouteLibrary jsRoutes, params string[] directories)
        {
            var bundle = new AngularTemplateBundle(jsRoutes.AngularModuleName, jsRoutes.Templates);

            foreach (var directory in directories)
            {
                var path = jsRoutes.JsFolderFile(directory + "/");
                if (HostingEnvironment.VirtualPathProvider.DirectoryExists(path))
                {
                    bundle.IncludeDirectory(path, "*.html", true);
                }
            }

            bundles.Add(bundle);

            return(bundles);
        }
Esempio n. 9
0
        /// <summary>
        /// Adds the main bundle of angular scripts for this module to the bundle collection
        /// </summary>
        /// <param name="jsRoutes">The ModuleJsRouteLibrary for this module</param>
        /// <param name="directories">A collection of directory names (no slashes) to scan for files and addto the bundle.</param>
        /// <param name="files">A collection of file names to add to the bundle as single resources. This is done before adding directory bundles.</param>
        /// <returns>BundleCollection instance for chaining</returns>
        public static BundleCollection AddMainAngularScriptBundle(this BundleCollection bundles, ModuleJsRouteLibrary jsRoutes, string[] files, string[] directories)
        {
            var bundle = new ScriptBundle(jsRoutes.Main);

            if (files != null)
            {
                foreach (var file in files)
                {
                    bundle.Include(jsRoutes.JsFolderFile(file));
                }
            }

            if (directories != null)
            {
                foreach (var directory in directories)
                {
                    var path = jsRoutes.JsFolderFile(directory + "/");
                    if (HostingEnvironment.VirtualPathProvider.DirectoryExists(path))
                    {
                        bundle.IncludeDirectory(path, "*.js", true);
                    }
                }
            }

            bundles.Add(bundle);

            return(bundles);
        }
Esempio n. 10
0
 /// <summary>
 /// Adds the main bundle of angular scripts for this module to the bundle collection
 /// </summary>
 /// <param name="jsRoutes">The ModuleJsRouteLibrary for this module</param>
 /// <param name="directories">A collection of directory names (no slashes) to scan for files and add to the bundle.</param>
 /// <returns>BundleCollection instance for chaining</returns>
 public static BundleCollection AddMainAngularScriptBundle(this BundleCollection bundles, ModuleJsRouteLibrary jsRoutes, params string[] directories)
 {
     return(bundles.AddMainAngularScriptBundle(jsRoutes, null, directories));
 }
Esempio n. 11
0
 private static string GetOptions(ModuleJsRouteLibrary routeLibrary, object options)
 {
     return(GetConstant(routeLibrary, "options", options));
 }
        public ActionResult Index(ModuleRouteLibrary routeLibrary)
        {
            var jsRouteLibrary = new ModuleJsRouteLibrary(routeLibrary);

            return(View("~/Framework/StandardAngularModules/Routes/index.cshtml", jsRouteLibrary));
        }