Example #1
0
        protected override string GetPageHtml(HttpProcessor p, Session s)
        {
            sb.Clear();
            string itemtype = p.GetParam("itemtype");
            string itemid   = p.GetParam("itemid").ToLower();

            sb.Append("<div id=\"itemtype\" itemtype=\"").Append(itemtype).Append("\" style=\"display:none;\"></div>");
            sb.Append("<div id=\"itemid\" itemid=\"").Append(itemid).Append("\" style=\"display:none;\"></div>");
            sb.Append("<div id=\"itemfields\">");
            if (itemtype == "camera")
            {
                sb.AppendLine("<div style=\"display:none;\" id=\"pageToLoadWhenFinished\" page=\"cameras\"></div>");
                bool foundCamera = false;
                lock (MJpegWrapper.cfg)
                {
                    foreach (CameraSpec cs in MJpegWrapper.cfg.cameras)
                    {
                        if (cs.id == itemid)
                        {
                            foundCamera = true;
                            CreateItemEditor(cs);
                            break;
                        }
                    }
                }
                if (!foundCamera)
                {
                    sb.Append("Could not find camera");
                }
                return(sb.ToString());
            }
            else if (itemtype == "user")
            {
                sb.AppendLine("<div style=\"display:none;\" id=\"pageToLoadWhenFinished\" page=\"users\"></div>");
                bool foundUser = false;
                lock (MJpegWrapper.cfg)
                {
                    foreach (Configuration.User u in MJpegWrapper.cfg.users)
                    {
                        if (u.name == itemid)
                        {
                            foundUser = true;
                            CreateItemEditor(u);
                            break;
                        }
                    }
                }
                if (!foundUser)
                {
                    sb.Append("Could not find user");
                }
                return(sb.ToString());
            }
            else if (itemtype == "ptzprofile")
            {
                sb.AppendLine("<div style=\"display:none;\" id=\"pageToLoadWhenFinished\" page=\"ptzprofiles\"></div>");
                bool foundProfile = false;
                lock (MJpegWrapper.cfg)
                {
                    foreach (Configuration.PTZProfile f in PTZProfile.GetPtzProfiles())
                    {
                        if (f.spec.name.ToLower() == itemid)
                        {
                            foundProfile = true;
                            CreateItemEditor(f.spec);
                            break;
                        }
                    }
                }
                if (!foundProfile)
                {
                    sb.Append("Could not find PTZ Profile");
                }
                return(sb.ToString());
            }
            else
            {
                sb.AppendLine("<div style=\"display:none;\" id=\"pageToLoadWhenFinished\" page=\"main\"></div>");
            }
            sb.Append("</div>");
            return(sb.ToString());
        }
Example #2
0
        protected override string GetPageHtml(HttpProcessor p, Session s)
        {
            ItemTable <PTZProfile> tbl = new ItemTable <PTZProfile>("PTZ Profiles", "ptzprofile", "name", PTZProfile.GetPtzProfiles(), PTZProfile.lockObj, ItemTableMode.Add, new ItemTableColumnDefinition <PTZProfile>[]
            {
                new ItemTableColumnDefinition <PTZProfile>("Name", c => { return("<a href=\"javascript:EditItem('" + HttpUtility.JavaScriptStringEncode(c.spec.name) + "')\">" + HttpUtility.HtmlEncode(c.spec.name) + "</a>"); })
            });

            return(tbl.GetSectionHtml());
        }