Skip to content

Commit 6facc96

Browse files
authored
Publisher Command Center: Allow publishers to publish (#135)
1 parent b01f32c commit 6facc96

File tree

4 files changed

+12
-23
lines changed

4 files changed

+12
-23
lines changed

extensions/publisher-command-center/app.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,9 @@ def get_visitor_client(token: str | None) -> connect.Client:
4747
async def contents(posit_connect_user_session_token: str = Header(None)):
4848
visitor = get_visitor_client(posit_connect_user_session_token)
4949

50-
response = client.get("metrics/procs")
51-
processes = response.json()
52-
5350
contents = visitor.me.content.find()
5451
for content in contents:
55-
content["processes"] = [
56-
process for process in processes if content["guid"] == process["app_guid"]
57-
]
52+
content["active_jobs"] = [job for job in content.jobs if job["status"] == 0]
5853

5954
return contents
6055

@@ -74,12 +69,10 @@ async def get_content_processes(
7469
visitor = get_visitor_client(posit_connect_user_session_token)
7570

7671
# Assert the viewer has access to the content
77-
assert visitor.content.get(content_id)
78-
79-
response = client.get("metrics/procs")
80-
processes = response.json()
81-
82-
return [process for process in processes if process.get("app_guid") == content_id]
72+
content = visitor.content.get(content_id)
73+
# make a list of the iterable:
74+
active_jobs = [job for job in content.jobs if job["status"] == 0]
75+
return active_jobs
8376

8477

8578
@app.delete("/api/contents/{content_id}/processes/{process_id}")

extensions/publisher-command-center/manifest.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"checksum": "a162a98758867a701ce693948ffdfa67"
2323
},
2424
"app.py": {
25-
"checksum": "0e5df52143323d9ae49cf77c51298cde"
25+
"checksum": "92709c50369eca0216b8e121cd87c94c"
2626
},
2727
"dist/assets/fa-brands-400.808443ae.ttf": {
2828
"checksum": "15d54d142da2f2d6f2e90ed1d55121af"
@@ -51,11 +51,11 @@
5151
"dist/assets/index.0c2ac2eb.css": {
5252
"checksum": "96fb5a8d93644a29ece62d52354fbc73"
5353
},
54-
"dist/assets/index.835b2c40.js": {
55-
"checksum": "52e8175304138c1ef6d18c808dcb4b04"
54+
"dist/assets/index.3b47d0e1.js": {
55+
"checksum": "b7a54352e0a5437ef97c8d3202983dac"
5656
},
5757
"dist/index.html": {
58-
"checksum": "a3cf0e03275e2436d932280af100438c"
58+
"checksum": "a64aa56406944bd2184562c18bfc3b4e"
5959
}
6060
},
6161
"extension": {
@@ -68,6 +68,6 @@
6868
"API Publishing",
6969
"OAuth Integrations"
7070
],
71-
"version": "0.0.2"
71+
"version": "0.0.3"
7272
}
7373
}

extensions/publisher-command-center/src/components/ContentsComponent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ const ContentsComponent = {
7272
"td",
7373
m(Languages, content)
7474
),
75-
m("td", content?.processes.length),
75+
m("td", content?.active_jobs?.length),
7676
m("td", format(content["last_deployed_time"], "MMM do, yyyy")),
7777
m("td", format(content["created_time"], "MMM do, yyyy")),
7878
m(

extensions/publisher-command-center/src/components/Processes.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,6 @@ export default {
103103
m("th", { scope: "col" }, ""),
104104
m("th", { scope: "col" }, "Id"),
105105
m("th", { scope: "col" }, "Started"),
106-
m("th", { scope: "col" }, "CPUs"),
107-
m("th", { scope: "col" }, "Memory"),
108106
m("th", { scope: "col" }, "Hostname"),
109107
]),
110108
),
@@ -116,16 +114,14 @@ export default {
116114
"td.text-center.py-2",
117115
m(StopButton, {
118116
content_id: vnode.attrs.id,
119-
process_id: process?.job_key,
117+
process_id: process?.key,
120118
}),
121119
),
122120
m("td", process?.pid),
123121
m(
124122
"td",
125123
formatDistanceToNow(process?.start_time, { addSuffix: true }),
126124
),
127-
m("td", Number(process?.cpu_current).toFixed(2)),
128-
m("td", filesize(process?.ram)),
129125
m("td", process?.hostname),
130126
]);
131127
}),

0 commit comments

Comments
 (0)