Example #1
0
    def render(self, data):

        tbl_rows = [{
            "edit": [
                a.link("blog_entry",
                       entry.data["title"]["en"] if entry.data.get(
                           "title", {}).get("en", None) is not None else
                       entry.entry_id,
                       icon="rss",
                       blog_id=self.context.get("blog_id"),
                       entry_id=entry.entry_id)
            ],
            "enabled": [
                a.status("Yes" if entry.enabled else "No",
                         "success" if entry.enabled else "danger")
            ],
            "created":
            str(entry.create_date),
            "updated":
            str(entry.update_date)
        } for entry in data["entries"]]

        return [
            a.breadcrumbs([], data["blog_name"]),
            a.content("Entries", [{
                "id": "edit",
                "title": "Edit"
            }, {
                "id": "enabled",
                "title": "Enabled"
            }, {
                "id": "created",
                "title": "Created"
            }, {
                "id": "updated",
                "title": "Updated"
            }],
                      tbl_rows,
                      "default",
                      empty="No blog entries"),
            a.pages(data["pages"]),
            a.links("Navigate", [
                a.link("index", "Go back", icon="chevron-left"),
                a.link("new_blog_entry",
                       "New Blog Entry",
                       icon="plus",
                       blog_id=self.context.get("blog_id")),
                a.link("blog_settings",
                       "Settings",
                       icon="cogs",
                       blog_id=self.context.get("blog_id"))
            ])
        ]
Example #2
0
    def render(self, data):
        tbl_rows = [{
            "edit":
            [a.link("blog", blog.name, icon="rss", blog_id=blog.blog_id)],
            "enabled": [
                a.status("Yes" if blog.enabled else "No",
                         "success" if blog.enabled else "danger")
            ],
        } for blog in data["blogs"]]

        return [
            a.content("Blogs", [{
                "id": "edit",
                "title": "Blog"
            }, {
                "id": "enabled",
                "title": "Enabled"
            }],
                      tbl_rows,
                      "default",
                      empty="No blogs"),
            a.links("Actions", [a.link("new_blog", "New Blog", icon="plus")])
        ]
Example #3
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
Example #4
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
Example #5
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