コード例 #1
0
    def render(self, data):

        return [
            a.breadcrumbs([], "Create New"),
            a.form(
                "Create New Blog",
                fields={
                    "name":
                    a.field("Blog Name",
                            "text",
                            "primary",
                            "non-empty",
                            order=1),
                    "schema":
                    a.field(
                        "Blog Schema",
                        "json",
                        "primary",
                        order=2,
                        description=
                        "A JSON Scheme every blog entry will be matched on. "
                        "See docs below for more information."),
                    "enabled":
                    a.field("Enabled", "switch", "primary", order=3)
                },
                methods={"create": a.method("Create", "primary")},
                data=data),
            a.links("Navigate", [
                a.link("index", "Go back", icon="chevron-left"),
                a.link(
                    "https://spacetelescope.github.io/understanding-json-schema/index.html",
                    "See docs",
                    icon="book")
            ])
        ]
コード例 #2
0
 def render(self, data):
     new_entry = self.context.get("clone", None) is None
     return [
         a.breadcrumbs([
             a.link("blog",
                    data["blog_name"],
                    blog_id=self.context.get("blog_id"))
         ], "New Blog Entry" if new_entry else "Clone Blog Entry"),
         a.form("Blog Entry",
                fields={
                    "data":
                    a.field("Entry",
                            "dorn",
                            "primary",
                            schema=data["blog_schema"],
                            order=1),
                    "enabled":
                    a.field("Enabled", "switch", "primary", order=2)
                },
                methods={
                    "create":
                    a.method("Create" if new_entry else "Clone", "primary")
                },
                data=data),
         a.links("Navigate", [
             a.link("blog",
                    "Go back",
                    icon="chevron-left",
                    blog_id=self.context.get("blog_id")),
             a.link("blog_settings",
                    "Edit Blog Settings",
                    icon="cogs",
                    blog_id=self.context.get("blog_id"))
         ])
     ]
コード例 #3
0
    def render(self, data):
        r = [
            a.breadcrumbs([
                a.link("server", "Server Code"),
            ], "Server Code Settings"),
            ServerCodeController.about_notice()
        ]

        if not data["repository_url"]:
            r.append(ServerCodeSettingsController.no_settings_notice())

        r.extend([
            a.form(
                "Server Code Settings",
                fields={
                    "repository_url":
                    a.field("Git source code repository url (ssh only)",
                            "text",
                            "primary",
                            description="""
                        You need to use SSH remote url in order to deploy source code to this service. See 
                        <a href="https://help.github.com/articles/which-remote-url-should-i-use/#cloning-with-ssh-urls"
                        target="_blank">this</a>.
                    """,
                            order=1),
                    "repository_branch":
                    a.field("Git branch to use on the source code repository",
                            "text",
                            "primary",
                            order=2),
                    "ssh_private_key":
                    a.field("Private SSH key",
                            "text",
                            "primary",
                            multiline=6,
                            description="""
                                Please generate SSH key pair, paste private key (for example, 
                                <span class="label label-default">id_rsa</span>) here, and add public key (for example, 
                                <span class="label label-default">id_rsa.pub</span>) into user's SSH keys with 
                                read access to the repository above.
                                For example, on GitHub, it can be done <a href="https://github.com/settings/keys" 
                                target="_blank">here</a>.
                            """,
                            order=3)
                },
                methods={
                    "update_settings": a.method("Update Settings", "primary")
                },
                data=data),
            a.links("Navigate", [
                a.link("server", "Go back", icon="chevron-left"),
            ])
        ])

        return r
コード例 #4
0
    def render(self, data):

        return [
            a.breadcrumbs([
                a.link(
                    "blog", data["name"], blog_id=self.context.get("blog_id"))
            ], "Settings"),
            a.form(
                "Blog Settings",
                fields={
                    "name":
                    a.field("Blog Name",
                            "text",
                            "primary",
                            "non-empty",
                            order=1),
                    "schema":
                    a.field(
                        "Blog Schema",
                        "json",
                        "primary",
                        order=2,
                        description=
                        "A JSON Scheme every blog entry will be matched on. "
                        "See docs below for more information."),
                    "enabled":
                    a.field("Enabled", "switch", "primary", order=3)
                },
                methods={"update": a.method("Update", "primary")},
                data=data),
            a.form("Danger",
                   fields={},
                   methods={
                       "delete": a.method("Delete This Blog Forever", "danger")
                   },
                   data=data,
                   icon="warning"),
            a.links("Navigate", [
                a.link("index", "Go back", icon="chevron-left"),
                a.link(
                    "https://spacetelescope.github.io/understanding-json-schema/index.html",
                    "See docs",
                    icon="book")
            ])
        ]
コード例 #5
0
 def render(self, data):
     return [
         a.breadcrumbs([
             a.link("blog",
                    data["blog_name"],
                    blog_id=self.context.get("blog_id"))
         ], "Blog Entry #{0}".format(self.context.get("entry_id"))),
         a.form("Blog Entry",
                fields={
                    "data":
                    a.field("Entry",
                            "dorn",
                            "primary",
                            schema=data["blog_schema"],
                            order=1),
                    "enabled":
                    a.field("Enabled", "switch", "primary", order=2)
                },
                methods={
                    "update": a.method("Update", "primary"),
                    "delete": a.method("Delete", "danger")
                },
                data=data),
         a.links("Navigate", [
             a.link("blog",
                    "Go back",
                    icon="chevron-left",
                    blog_id=self.context.get("blog_id")),
             a.link("new_blog_entry",
                    "Clone This Entry",
                    icon="clone",
                    blog_id=self.context.get("blog_id"),
                    clone=self.context.get("entry_id")),
             a.link("blog_settings",
                    "Edit Blog Settings",
                    icon="cogs",
                    blog_id=self.context.get("blog_id"))
         ])
     ]
コード例 #6
0
    def render(self, data):

        r = [
            a.breadcrumbs([
                a.link("index", "File Hosting"),
            ], "Settings"),
            a.form("Deployment method", fields={
                "deployment_method": a.field(
                    "Deployment method", "select", "primary", "non-empty", values=data["deployment_methods"]
                )
            }, methods={
                "update_deployment_method": a.method("Switch deployment method", "primary")
            }, data=data)
        ]

        deployment_method = data["deployment_method"]
        deployment_data = data["deployment_data"]

        if deployment_method:
            m = DeploymentMethods.get(deployment_method)
            if m.has_admin():
                r.append(a.form("Update deployment", fields=m.render(a), methods={
                    "update_deployment": a.method("Update", "primary")
                }, data=deployment_data))
        else:
            r.append(a.notice(
                "Please select deployment method",
                """
                    Players cannot upload files until the deployment is configured
                """))

        r.extend([
            a.links("Navigate", [
                a.link("index", "Back", icon="chevron-left"),
            ])
        ])

        return r
コード例 #7
0
    def render(self, data):

        reports = [{
            "see": [
                a.link("report",
                       str(r.report_id),
                       icon="flag",
                       report_id=r.report_id)
            ],
            "account_id": [
                a.link("app_version",
                       str(r.account_id),
                       icon="filter",
                       app_name=self.context.get("app_name"),
                       app_version=self.context.get("app_version"),
                       account_id=r.account_id)
            ],
            "message":
            r.message,
            "category": [
                a.link("app_version",
                       str(r.category),
                       icon="filter",
                       app_name=self.context.get("app_name"),
                       app_version=self.context.get("app_version"),
                       category=r.category)
            ],
            "info": [a.json_view(r.info)],
            "time":
            str(r.time)
        } for r in data["reports"]]

        methods = {
            "filter":
            a.method("Filter reports", "primary", order=1),
            "export_reports":
            a.method("Export reports to CSV",
                     "default",
                     icon="download",
                     order=3),
        }

        if self.context.get("account_id") or self.context.get("info"):
            methods["clear_filters"] = a.method("Clear filters",
                                                "default",
                                                order=2)

        r = [
            a.breadcrumbs([
                a.link("index", "Reports"),
                a.link("apps", "Applications"),
                a.link("app",
                       data["app_title"],
                       app_name=self.context.get("app_name")),
            ], self.context.get("app_version")),
            a.content("Reports: {0} total".format(data["total_count"]),
                      [{
                          "id": "see",
                          "title": "See"
                      }, {
                          "id": "message",
                          "title": "Report Message"
                      }, {
                          "id": "category",
                          "title": "Report Category"
                      }, {
                          "id": "account_id",
                          "title": "Reporter"
                      }, {
                          "id": "info",
                          "title": "Report info"
                      }, {
                          "id": "time",
                          "title": "Report Time"
                      }],
                      reports,
                      "default",
                      empty="No reports to display")
        ]

        if data["pages_count"]:
            r.append(a.pages(data["pages_count"]))

        r.extend([
            a.form("Filters",
                   fields={
                       "account_id":
                       a.field("Reporter Account", "text", "primary", order=1),
                       "report_message":
                       a.field("Report Message", "text", "primary", order=2),
                       "category":
                       a.field("Report Category", "text", "primary", order=3),
                       "info":
                       a.field("Report Info",
                               "json",
                               "primary",
                               order=4,
                               height=120),
                   },
                   methods=methods,
                   data=data,
                   icon="filter"),
            a.links("Navigate", [
                a.link("app",
                       "Go back",
                       icon="chevron-left",
                       app_name=self.context.get("app_name"))
            ])
        ])

        return r
コード例 #8
0
    def render(self, data):
        r = [
            a.breadcrumbs([
                a.link("index", "Reports"),
                a.link("apps", "Applications"),
                a.link("app", data["app_title"], app_name=data["app_name"]),
                a.link("app_version",
                       data["app_version"],
                       app_name=data["app_name"],
                       app_version=data["app_version"]),
            ], "Report {0}".format(self.context.get("report_id")))
        ]

        report_format = data["format"]

        if report_format == ReportFormat.JSON:
            r.append(
                a.form("Contents",
                       fields={
                           "payload":
                           a.field("Report Contents",
                                   "json",
                                   "primary",
                                   height=400,
                                   parse=True)
                       },
                       methods={},
                       data=data))

        elif report_format == ReportFormat.TEXT:
            r.append(
                a.form("Contents",
                       fields={
                           "payload":
                           a.field("Report Contents",
                                   "text",
                                   "primary",
                                   multiline=20)
                       },
                       methods={},
                       data=data))

        r.extend([
            a.links("Download", [
                a.link("report",
                       "Download the Report",
                       icon="download",
                       report_id=self.context.get("report_id"),
                       download=True)
            ]),
            a.form("Report Information",
                   fields={
                       "account_id":
                       a.field("Reporter Account", "text", "primary", order=1),
                       "category":
                       a.field("Report Category", "status", "default",
                               order=2),
                       "message":
                       a.field("Report Message",
                               "text",
                               "primary",
                               multiline=3,
                               order=3),
                       "info":
                       a.field("Report Info",
                               "json",
                               "primary",
                               height=140,
                               order=4),
                       "time":
                       a.field("Report Time", "text", "primary", order=5),
                       "format_title":
                       a.field("Report Format", "text", "primary", order=6)
                   },
                   methods={},
                   data=data),
            a.links("Navigate", [
                a.link("app_version",
                       "Go back",
                       icon="chevron-left",
                       app_name=data["app_name"])
            ])
        ])

        return r