health
This commit is contained in:
parent
045342f813
commit
799da899ae
9 changed files with 6944 additions and 6847 deletions
20
README.md
20
README.md
|
@ -1,4 +1,6 @@
|
|||
# vscode-appwrite
|
||||
# Appwrite for Visual Studio Code
|
||||
|
||||
Use the Appwrite extension to quickly monitor, manage, and interact with your Appwrite instance directly from VS Code.
|
||||
|
||||
## What is Appwrite?
|
||||
|
||||
|
@ -10,17 +12,20 @@ From [appwrite.io](https://appwrite.io)
|
|||
|
||||
## Features
|
||||
|
||||
|
||||
|
||||
Describe specific features of your extension including screenshots of your extension in action. Image paths are relative to this README file.
|
||||
|
||||
For example if there is an image subfolder under your extension project workspace:
|
||||
|
||||
\!\[feature X\]\(images/feature-x.png\)
|
||||
### Check the health of all the Appwrite services.
|
||||
![Health feature](./media/features/health/scr1.png)
|
||||
|
||||
> Tip: Many popular extensions utilize animations. This is an excellent way to show off your extension! We recommend short, focused animations that are easy to follow.
|
||||
|
||||
## Requirements
|
||||
|
||||
If you have any requirements or dependencies, add a section describing those and how to install and configure them.
|
||||
This extension does not provide features for setting up or installing Appwrite. Only managing and interacting with Appwrite once it's running.
|
||||
|
||||
## Extension Settings
|
||||
|
||||
|
@ -43,15 +48,8 @@ Users appreciate release notes as you update your extension.
|
|||
|
||||
### 1.0.0
|
||||
|
||||
Initial release of ...
|
||||
Initial release of the Appwrite extension for VS Code
|
||||
|
||||
### 1.0.1
|
||||
|
||||
Fixed issue #.
|
||||
|
||||
### 1.1.0
|
||||
|
||||
Added features X, Y, and Z.
|
||||
|
||||
-----------------------------------------------------------------------------------------------------------
|
||||
## Following extension guidelines
|
||||
|
|
BIN
media/features/health/scr1.png
Normal file
BIN
media/features/health/scr1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 62 KiB |
13663
package-lock.json
generated
13663
package-lock.json
generated
File diff suppressed because it is too large
Load diff
42
package.json
42
package.json
|
@ -6,6 +6,9 @@
|
|||
"engines": {
|
||||
"vscode": "^1.55.0"
|
||||
},
|
||||
"repository": {
|
||||
"url": "https://github.com/streamlux/vscode-appwrite"
|
||||
},
|
||||
"categories": [
|
||||
"Other"
|
||||
],
|
||||
|
@ -78,7 +81,12 @@
|
|||
"icon": "$(refresh)"
|
||||
},
|
||||
{
|
||||
"command": "vscode-appwrite.OpenDocumentation",
|
||||
"command": "vscode-appwrite.OpenUsersDocumentation",
|
||||
"title": "Open documentation",
|
||||
"icon": "$(book)"
|
||||
},
|
||||
{
|
||||
"command": "vscode-appwrite.OpenDatabaseDocumentation",
|
||||
"title": "Open documentation",
|
||||
"icon": "$(book)"
|
||||
},
|
||||
|
@ -136,6 +144,16 @@
|
|||
"command": "vscode-appwrite.editPermission",
|
||||
"title": "Edit permission",
|
||||
"icon": "$(edit)"
|
||||
},
|
||||
{
|
||||
"command": "vscode-appwrite.refreshHealth",
|
||||
"title": "Refresh health",
|
||||
"icon": "$(refresh)"
|
||||
},
|
||||
{
|
||||
"command": "vscode-appwrite.openHealthDocumentation",
|
||||
"title": "Open health documentation",
|
||||
"icon": "$(book)"
|
||||
}
|
||||
],
|
||||
"views": {
|
||||
|
@ -171,10 +189,15 @@
|
|||
"menus": {
|
||||
"view/title": [
|
||||
{
|
||||
"command": "vscode-appwrite.OpenDocumentation",
|
||||
"command": "vscode-appwrite.OpenUsersDocumentation",
|
||||
"when": "view == Users",
|
||||
"group": "navigation"
|
||||
},
|
||||
{
|
||||
"command": "vscode-appwrite.OpenDatabaseDocumentation",
|
||||
"when": "view == Database",
|
||||
"group": "navigation"
|
||||
},
|
||||
{
|
||||
"command": "vscode-appwrite.refreshUsersList",
|
||||
"when": "view == Users",
|
||||
|
@ -194,6 +217,16 @@
|
|||
"command": "vscode-appwrite.createCollection",
|
||||
"when": "view == Database",
|
||||
"group": "navigation"
|
||||
},
|
||||
{
|
||||
"command": "vscode-appwrite.refreshHealth",
|
||||
"when": "view == Health",
|
||||
"group": "navigation"
|
||||
},
|
||||
{
|
||||
"command": "vscode-appwrite.openHealthDocumentation",
|
||||
"when": "view == Health",
|
||||
"group": "navigation"
|
||||
}
|
||||
],
|
||||
"view/item/context": [
|
||||
|
@ -292,7 +325,7 @@
|
|||
{
|
||||
"id": "Appwrite",
|
||||
"title": "Appwrite",
|
||||
"icon": "resources/vscode-appwrite.svg"
|
||||
"icon": "./resources/vscode-appwrite.svg"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -302,7 +335,7 @@
|
|||
"appwrite.projects": {
|
||||
"type": "array",
|
||||
"default": [],
|
||||
"description": "List of Appwrite projects"
|
||||
"markdownDescription": "List of Appwrite project configurations. You can use the Connect command to set this up, or see [docs](https://github.com/streamlux/vscode-appwrite/) for more information."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -336,6 +369,7 @@
|
|||
"webpack-cli": "^4.4.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"dayjs": "^1.10.4",
|
||||
"fs-extra": "^9.1.0",
|
||||
"node-appwrite": "^2.1.0"
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { MarkdownString } from 'vscode';
|
||||
import { AppwriteHealth, Client, HealthClient, SDK } from "../appwrite";
|
||||
const sdk: SDK = require("node-appwrite");
|
||||
|
||||
|
@ -28,3 +29,20 @@ export class Health {
|
|||
};
|
||||
}
|
||||
}
|
||||
|
||||
export const healthTooltips: Record<keyof AppwriteHealth, string | MarkdownString | undefined> = {
|
||||
HTTP: "Check the Appwrite HTTP server is up and responsive.",
|
||||
DB: "Check the Appwrite in-memory cache server is up and connection is successful.",
|
||||
Cache: "Check the Appwrite in-memory cache server is up and connection is successful.",
|
||||
Time:
|
||||
new MarkdownString("Check the Appwrite server time is synced with Google remote NTP server. We use this technology to smoothly handle leap seconds with no disruptive events. The [Network Time Protocol (NTP)](https://en.wikipedia.org/wiki/Network_Time_Protocol) is used by hundreds of millions of computers and devices to synchronize their clocks over the Internet. If your computer sets its own clock, it likely uses NTP."),
|
||||
QueueWebhooks: "The number of webhooks that are waiting to be processed in the Appwrite internal queue server.",
|
||||
QueueTasks: "The number of tasks that are waiting to be processed in the Appwrite internal queue server.",
|
||||
QueueLogs: "The number of logs that are waiting to be processed in the Appwrite internal queue server.",
|
||||
QueueUsage: "The number of usage stats that are waiting to be processed in the Appwrite internal queue server.",
|
||||
QueueCertificates:
|
||||
new MarkdownString("The number of certificates that are waiting to be issued against [Letsencrypt](https://letsencrypt.org/) in the Appwrite internal queue server."),
|
||||
QueueFunctions: "The number of functions waiting to be executed.",
|
||||
StorageLocal: "Check the Appwrite local storage device is up and connection is successful.",
|
||||
AntiVirus: "Check the Appwrite Anti Virus server is up and connection is successful.",
|
||||
};
|
||||
|
|
|
@ -1,7 +1,14 @@
|
|||
import { openUrl } from '../utils/openUrl';
|
||||
|
||||
const appwriteDocsUrl = 'https://appwrite.io/docs';
|
||||
const documentationLinks = {
|
||||
home: 'https://appwrite.io/docs',
|
||||
users: 'https://appwrite.io/docs/server/users',
|
||||
database: 'https://appwrite.io/docs/client/database',
|
||||
health: 'https://appwrite.io/docs/server/health'
|
||||
};
|
||||
|
||||
export async function openDocumentation(): Promise<void> {
|
||||
await openUrl(appwriteDocsUrl);
|
||||
type DocsPage = keyof typeof documentationLinks;
|
||||
|
||||
export async function openDocumentation(page?: DocsPage): Promise<void> {
|
||||
await openUrl(documentationLinks[page || 'home']);
|
||||
}
|
||||
|
|
|
@ -52,7 +52,8 @@ export function registerCommands(context: ExtensionContext): void {
|
|||
registerCommand("CreateUser", createUser);
|
||||
registerCommand("refreshUsersList", refreshUsersList);
|
||||
registerCommand("DeleteUser", deleteUser);
|
||||
registerCommand("OpenDocumentation", openDocumentation);
|
||||
registerCommand("OpenUsersDocumentation", () => openDocumentation('users'));
|
||||
registerCommand("OpenDatabaseDocumentation", () => openDocumentation('database'));
|
||||
registerCommand("GetUserLogs", getUserLogs);
|
||||
registerCommand("viewDocumentAsJson", viewDocumentAsJson);
|
||||
registerCommand("AddProject", addProject);
|
||||
|
@ -66,4 +67,6 @@ export function registerCommands(context: ExtensionContext): void {
|
|||
registerCommand("createCollection", createCollection, 'database');
|
||||
registerCommand("createPermission", createPermission, 'database');
|
||||
registerCommand("deletePermission", deletePermission, 'database');
|
||||
registerCommand("refreshHealth", () => {}, 'health');
|
||||
registerCommand("openHealthDocumentation", () => openDocumentation('health'));
|
||||
}
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
import * as vscode from "vscode";
|
||||
import { MarkdownString } from 'vscode';
|
||||
|
||||
export class HealthTreeItem extends vscode.TreeItem {
|
||||
constructor(public readonly label: string, status: boolean) {
|
||||
constructor(public readonly label: string, status: any, tooltip?: string | MarkdownString | undefined) {
|
||||
super(label);
|
||||
console.log(status);
|
||||
this.label = label;
|
||||
this.iconPath = new vscode.ThemeIcon(status ? "check" : "error", new vscode.ThemeColor(status ? "#00ff00" : "list.errorForeground"));
|
||||
this.contextValue = `health.${label}`;
|
||||
this.description = "" + Object.values(status)[0];
|
||||
this.tooltip = tooltip;
|
||||
}
|
||||
|
||||
contextValue = "health";
|
||||
|
|
|
@ -1,12 +1,24 @@
|
|||
import * as vscode from "vscode";
|
||||
import { healthClient } from "../../client";
|
||||
import { ext } from "../../extensionVariables";
|
||||
import { HealthTreeItem } from "./HealthTreeItem";
|
||||
import * as dayjs from "dayjs";
|
||||
import * as relativeTime from "dayjs/plugin/relativeTime";
|
||||
import * as localizedFormat from "dayjs/plugin/localizedFormat";
|
||||
import { healthTooltips } from "../../appwrite/Health";
|
||||
import { AppwriteHealth } from "../../appwrite";
|
||||
// dayjs.extend(relativeTime);
|
||||
dayjs.extend(localizedFormat);
|
||||
|
||||
type PartialRecord<K extends string | number | symbol, T> = { [P in K]?: T };
|
||||
|
||||
export class HealthTreeItemProvider implements vscode.TreeDataProvider<vscode.TreeItem> {
|
||||
private _onDidChangeTreeData: vscode.EventEmitter<HealthTreeItem | undefined | void> = new vscode.EventEmitter<
|
||||
HealthTreeItem | undefined | void
|
||||
>();
|
||||
|
||||
private lastChecked: Date = new Date();
|
||||
|
||||
readonly onDidChangeTreeData: vscode.Event<HealthTreeItem | undefined | void> = this._onDidChangeTreeData.event;
|
||||
|
||||
constructor() {}
|
||||
|
@ -23,9 +35,17 @@ export class HealthTreeItemProvider implements vscode.TreeDataProvider<vscode.Tr
|
|||
// get children for root
|
||||
if (element === undefined) {
|
||||
const health = await healthClient.checkup();
|
||||
return Object.entries(health).map(([service, status]) => {
|
||||
return new HealthTreeItem(service, status);
|
||||
ext.outputChannel?.append(JSON.stringify(health, null, 4));
|
||||
const healthItems = Object.entries(health).map(([service, status]) => {
|
||||
return new HealthTreeItem(service, status, healthTooltips[service as keyof AppwriteHealth]);
|
||||
});
|
||||
this.lastChecked = new Date();
|
||||
return [
|
||||
{
|
||||
label: `Updated at ${dayjs(this.lastChecked).format("LTS")}`,
|
||||
},
|
||||
...healthItems,
|
||||
];
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue