Beispiel #1
0
        public async Task <HttpResponseMessage> Get()
        {
            var umbracoVersion   = UmbracoVersion.Current;
            var footprintVersion = InstalledPackage.GetAllInstalledPackages()
                                   .Select(x => x.Data)
                                   .Concat(CreatedPackage.GetAllCreatedPackages().Select(x => x.Data))
                                   .Where(x => x.Name == "Novicell Footprint")
                                   .Select(x => x.Version)
                                   .FirstOrDefault();

            if (footprintVersion == null)
            {
                LogHelper.Warn <DashboardController>("Footprint version is null.");
            }

            //Use this to return your own custom dashboard content
            //using (var http = new HttpClient())
            //{
            //    return await http.GetAsync($"http://novicell.io/Umbraco/Api/Documentation/Get?umbracoVersion={umbracoVersion}&packageVersion={footprintVersion}&cache={Random.Next()}");
            //}

            /*
             * Example structure:
             * {"umbracoVersion":"7.2.4","packageVersion":"1.4.2","content":"<div ng-controller=\"ncFootprint.Backoffice.OverviewDashboard.Controller\" class=\"ncbt-section-dashboard\">\r\n    <div class=\"span12\">\r\n        <h1>Novicell Footprint 1.4.2.1</h1>\r\n        <p>\r\n            Stay tuned on <a href=\"http://novicell.io/footprint\" target=\"_blank\" title=\"Novicell Footprint\">http://novicell.io/footprint</a> and Our for more information and documentation.\r\n        </p>\r\n\r\n        <p>\r\n        \t<b>The library provides the following methods:</b> <br /><br />\r\n        \t<code>\r\n        \tfootprint.currentVisitor.addToSegment(segmentAlias, onSuccess, onError); <br />\r\n\t\t\tfootprint.currentVisitor.isInSegment(segmentAlias, onSuccess, onError); <br />\r\n\t\t\tfootprint.currentVisitor.setId(visitorId, onSuccess, onError); <br />\r\n\t\t\tfootprint.currentVisitor.setProperties({ key1: value1, key2: value2 }, onSuccess, onError); <br />\r\n\t\t\t</code>\r\n        </p>\r\n        <br />\r\n        <p>\r\n        \t<b>Example</b><br /><br />\r\n        \t<code>\r\n        \tdocument.getElementById(\"newsletter-subscribe-form\").addEventListener(\"submit\", function (e) { <br/>\r\n\t\t\t    console.info(\"\\\"submit\\\" event listener hit.\", arguments);<br/>\r\n\t\t\t    <br/>\r\n\t\t\t    e.preventDefault();<br/>\r\n\t\t\t    <br/>\r\n\t\t\t    // TODO: Subscribe to newsletter via AJAX or somesuch.<br/>\r\n\t\t\t    <br/>\r\n\t\t\t    footprint.currentVisitor.addToSegment(\"newsletter\", function (response, xhr) {<br/>\r\n\t\t\t        console.info(\"\\\"addToSegment\\\" onSuccess.\", arguments);<br/>\r\n\t\t\t    }, function (xhr, statusText) {<br/>\r\n\t\t\t        console.info(\"\\\"addToSegment\\\" onError.\", arguments);<br/>\r\n\t\t\t    });<br/>\r\n\t\t\t});<br/>\r\n\t\t\t</code>\r\n        </p>\r\n\r\n<iframe width=\"420\" height=\"315\" src=\"https://www.youtube.com/embed/NXN0QQRWx5g?rel=0\" frameborder=\"0\" allowfullscreen></iframe>\r\n    </div>\r\n</div>"}
             *
             */
            return(null);
        }
        protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
        {
            var baseUrl = Constants.Applications.Developer + "/packages/";

            var nodes = new TreeNodeCollection();

            var createdPackages = CreatedPackage.GetAllCreatedPackages();

            if (id == "created")
            {
                nodes.AddRange(
                    createdPackages
                    .OrderBy(entity => entity.Data.Name)
                    .Select(dt =>
                {
                    var node = CreateTreeNode(dt.Data.Id.ToString(), id, queryStrings, dt.Data.Name, "icon-inbox", false,
                                              string.Format("/{0}/framed/{1}",
                                                            queryStrings.GetValue <string>("application"),
                                                            Uri.EscapeDataString("developer/Packages/EditPackage.aspx?id=" + dt.Data.Id)));
                    return(node);
                }));
            }
            else
            {
                //must be root
                var node = CreateTreeNode(
                    "created",
                    id,
                    queryStrings,
                    Services.TextService.Localize("treeHeaders/createdPackages"),
                    "icon-folder",
                    createdPackages.Count > 0,
                    string.Empty);



                //TODO: This isn't the best way to ensure a noop process for clicking a node but it works for now.
                node.AdditionalData["jsClickCallback"] = "javascript:void(0);";

                nodes.Add(node);
            }



            return(nodes);
        }
        public async Task <HttpResponseMessage> Get()
        {
            var umbracoVersion   = UmbracoVersion.Current;
            var footprintVersion = InstalledPackage.GetAllInstalledPackages()
                                   .Select(x => x.Data)
                                   .Concat(CreatedPackage.GetAllCreatedPackages().Select(x => x.Data))
                                   .Where(x => x.Name == "Novicell Footprint")
                                   .Select(x => x.Version)
                                   .FirstOrDefault();

            if (footprintVersion == null)
            {
                LogHelper.Warn <DashboardController>("Footprint version is null.");
            }

            using (var http = new HttpClient())
            {
                return(await http.GetAsync($"http://novicell.io/Umbraco/Api/Documentation/Get?umbracoVersion={umbracoVersion}&packageVersion={footprintVersion}&cache={Random.Next()}"));
            }
        }
        public override void Render(ref XmlTree tree)
        {
            _packageType = HttpContext.Current.Request.QueryString["packageType"];

            switch (_packageType)
            {
            case "installed":
                Version v;
                // Display the unique packages, ordered by the latest version number. [LK 2013-06-10]
                var uniquePackages = InstalledPackage.GetAllInstalledPackages()
                                     .OrderByDescending(x => Version.TryParse(x.Data.Version, out v) ? v : new Version())
                                     .GroupBy(x => x.Data.Name)
                                     .Select(x => x.First())
                                     .OrderBy(x => x.Data.Name);
                foreach (var p in uniquePackages)
                {
                    var xNode = XmlTreeNode.Create(this);
                    xNode.NodeID   = string.Concat(PACKAGE_TREE_PREFIX, p.Data.Id);
                    xNode.Text     = p.Data.Name;
                    xNode.Action   = string.Format("javascript:openInstalledPackage('{0}');", p.Data.Id);
                    xNode.Icon     = "icon-box";
                    xNode.OpenIcon = "icon-box";
                    xNode.NodeType = "createdPackageInstance";
                    tree.Add(xNode);
                }
                break;

            case "created":
                foreach (CreatedPackage p in CreatedPackage.GetAllCreatedPackages())
                {
                    XmlTreeNode xNode = XmlTreeNode.Create(this);
                    xNode.NodeID   = PACKAGE_TREE_PREFIX + p.Data.Id.ToString();
                    xNode.Text     = p.Data.Name;
                    xNode.Action   = "javascript:openCreatedPackage('" + p.Data.Id.ToString() + "');";
                    xNode.Icon     = "icon-box";
                    xNode.OpenIcon = "icon-box";
                    xNode.NodeType = "createdPackageInstance";
                    xNode.Menu.Add(umbraco.BusinessLogic.Actions.ActionDelete.Instance);
                    tree.Add(xNode);
                }
                break;

            case "repositories":
                List <cms.businesslogic.packager.repositories.Repository> repos = cms.businesslogic.packager.repositories.Repository.getAll();

                foreach (cms.businesslogic.packager.repositories.Repository repo in repos)
                {
                    XmlTreeNode xNode = XmlTreeNode.Create(this);
                    xNode.Text     = repo.Name;
                    xNode.Action   = "javascript:openPackageCategory('BrowseRepository.aspx?repoGuid=" + repo.Guid + "');";
                    xNode.Icon     = "icon-server-alt";
                    xNode.OpenIcon = "icon-server-alt";
                    xNode.NodeType = "packagesRepo" + repo.Guid;
                    xNode.Menu.Add(umbraco.BusinessLogic.Actions.ActionRefresh.Instance);
                    xNode.Source = "tree.aspx?app=" + this._app + "&id=" + this._id + "&treeType=packagerPackages&packageType=repository&repoGuid=" + repo.Guid + "&rnd=" + Guid.NewGuid();
                    tree.Add(xNode);
                }

                break;

            case "repository":

                _repoGuid = HttpContext.Current.Request.QueryString["repoGuid"];
                Umbraco.Web.org.umbraco.our.Repository r = new Umbraco.Web.org.umbraco.our.Repository();

                foreach (var cat in r.Categories(_repoGuid))
                {
                    XmlTreeNode xNode = XmlTreeNode.Create(this);
                    xNode.NodeID   = cat.Id.ToInvariantString();
                    xNode.Text     = cat.Text;
                    xNode.Action   = "javascript:openPackageCategory('BrowseRepository.aspx?category=" + cat.Id + "&repoGuid=" + _repoGuid + "');";
                    xNode.Icon     = "icon-folder";
                    xNode.OpenIcon = "icon-folder";
                    xNode.NodeType = "packagesCategory" + cat.Id;
                    tree.Add(xNode);
                }

                break;
            }
        }