예제 #1
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"))
         ])
     ]
예제 #2
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")
            ])
        ]
예제 #3
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")
            ])
        ]
예제 #4
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
예제 #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([], "Server Code")]
        if data["commits_history"] is None:
            if data["server_fetch_error"]:
                r.append(
                    a.notice(
                        "Failed to update repository",
                        "Please check repository settings: {0}".format(
                            data["server_fetch_error"]), "danger"))
            else:
                r.append(
                    a.notice("Repository is in progress",
                             "Please wait until repository is updated"))
        else:
            methods = {
                "switch_to_latest_commit":
                a.method("Update To The Last Commit", "primary", order=1),
                "pull_updates":
                a.method("Pull Updates", "default", order=2),
            }

            if data["current_commit"]:
                methods["detach_version"] = a.method(
                    "Disable Server Code",
                    "danger",
                    order=3,
                    danger=
                    "Are you sure you would like to disable the Server Code from launching? After this action, "
                    "services would not be able to call functions on the Server Code."
                )
            else:
                r.append(ServerCodeController.no_commit_notice())

            r.extend([
                a.form("Actions", fields={}, methods=methods, data=data),
                a.content(
                    title="Recent Commits History",
                    headers=[{
                        "id": "actions",
                        "title": "Actions"
                    }, {
                        "id": "message",
                        "title": "Commit Message"
                    }, {
                        "id": "hash",
                        "title": "Commit Hash"
                    }, {
                        "id": "date",
                        "title": "Commit Date"
                    }, {
                        "id": "author",
                        "title": "Commit Author"
                    }],
                    items=[{
                        "hash": [a.status(commit.hexsha[:7], "default")],
                        "message":
                        commit.message[:48],
                        "date":
                        str(commit.committed_datetime),
                        "author":
                        str(commit.author.name) + " (" + commit.author.email +
                        ")",
                        "actions": [
                            a.status("Current Commit", "success", "check")
                            if data["current_commit"] == commit.hexsha else
                            a.button("server",
                                     "Use This",
                                     "primary",
                                     _method="switch_commit_context",
                                     commit=str(commit.hexsha))
                        ]
                    } for commit in data["commits_history"]],
                    style="primary")
            ])

        r.extend([
            ServerCodeController.about_notice(),
            a.links("Navigate", [
                a.link("index", "Go back", icon="chevron-left"),
                a.link("server_settings", "Server Code Settings", icon="cogs")
            ])
        ])

        return r
예제 #9
0
    def render(self, data):
        r = [
            a.breadcrumbs([
                a.link("apps", "Applications"),
                a.link("app",
                       data["app_name"],
                       app_id=self.context.get("app_id")),
            ], self.context.get("app_version"))
        ]
        if data["commits_history"] is None:
            r.append(
                a.notice("Repository is in progress",
                         "Please wait until repository is updated"))
        else:
            methods = {
                "switch_to_latest_commit":
                a.method("Update To The Last Commit", "primary", order=1),
                "pull_updates":
                a.method("Pull Updates", "default", order=2),
            }

            if data["current_commit"]:
                methods["detach_version"] = a.method(
                    "Disable This Version",
                    "danger",
                    order=3,
                    danger=
                    "Are you sure you would like to disable this version from launching? After this action, "
                    "users would not be able to open sessions on this version."
                )
            else:
                r.append(
                    ApplicationVersionController.no_commit_notice(
                        self.context.get("app_version")))

            r.extend([
                a.form("Actions", fields={}, methods=methods, data=data),
                a.content(
                    title="Recent Commits History",
                    headers=[{
                        "id": "actions",
                        "title": "Actions"
                    }, {
                        "id": "message",
                        "title": "Commit Message"
                    }, {
                        "id": "hash",
                        "title": "Commit Hash"
                    }, {
                        "id": "date",
                        "title": "Commit Date"
                    }, {
                        "id": "author",
                        "title": "Commit Author"
                    }],
                    items=[{
                        "hash": [a.status(commit.hexsha[:7], "default")],
                        "message":
                        commit.message[:48],
                        "date":
                        str(commit.committed_datetime),
                        "author":
                        str(commit.author.name) + " (" + commit.author.email +
                        ")",
                        "actions": [
                            a.status("Current Commit", "success", "check")
                            if data["current_commit"] == commit.hexsha else
                            a.button(
                                "app_version",
                                "Use This",
                                "primary",
                                _method="switch_commit_context",
                                commit=str(commit.hexsha),
                                app_id=self.context.get("app_id"),
                                app_version=self.context.get("app_version"))
                        ]
                    } for commit in data["commits_history"]],
                    style="primary")
            ])

        r.extend([
            a.links("Navigate", [
                a.link("app",
                       "Go back",
                       icon="chevron-left",
                       app_id=self.context.get("app_id"))
            ])
        ])

        return r