Skip to content
This repository was archived by the owner on Nov 13, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,33 @@ Please open issues on the [PowerShell Universal issue repository](https://github

### APIs

![](https://github.com/ironmansoftware/universal-code/raw/master/images/apis.png)
![PowerShell Universal APIs](https://github.com/ironmansoftware/universal-code/raw/master/images/apis.png)

- View APIs
- Automatically insert `Invoke-RestMethod` to call APIs
- Edit APIs

### Dashboards
### Apps

![](https://github.com/ironmansoftware/universal-code/raw/master/images/dashboards.png)
![PowerShell Universal Apps](https://github.com/ironmansoftware/universal-code/raw/master/images/dashboards.png)

- View dashboards
- Open Dashboard scripts
- Restart Dashboards
- View Dashboard log
- Debug Dashboard Process
- View Apps
- Open App scripts
- Restart Apps
- View App log
- Debug App Process

### Scripts
### Scripts

![](https://github.com/ironmansoftware/universal-code/raw/master/images/scripts.png)
![PowerShell Universal Scripts](https://github.com/ironmansoftware/universal-code/raw/master/images/scripts.png)

- View scripts
- Edit scripts
- Run scripts and receive notifications on job status

### Configuration
### Configuration

![](https://github.com/ironmansoftware/universal-code/raw/master/images/config.png)
![PowerShell Universal Configuration](https://github.com/ironmansoftware/universal-code/raw/master/images/config.png)

- Edit configuration scripts

Expand All @@ -58,7 +58,7 @@ Next, click your user name in the top right corner and select Tokens. Create a n

Within Visual Studio Code, open the command palette (Ctrl+Shift+P) and type "Preferences: Open Settings (UI)". Search for PowerShell Universal and fill in the following values:

- App Token - The contents of the token you created in PowerShell Universal.
- App Token - The contents of the token you created in PowerShell Universal. Use the Administrator role to provide full access.
- URL - The URL to your PowerShell Universal server (e.g. http://localhost:5000)

Once connected, click the PowerShell Universal icon in the Activity Bar on the left side of the window. You can now start using the extension.
Expand All @@ -69,7 +69,7 @@ For more information, visit the [PowerShell Universal documentation](https://doc

This extension contributes the following settings:

* `powershellUniversal.appToken`: An app token for communicating with the Universal REST API. An app token will be granted the first time the extension starts up.
* `powershellUniversal.appToken`: An app token for communicating with the Universal REST API. An app token will be granted the first time the extension starts up.
* `powershellUniversal.url`: The URL to your PowerShell Universal server.
* `powershellUniversal.localEditing`: Whether to edit local configuration files or using the REST API
* `powershellUniversal.connections`: An array of connections.
Expand Down
13 changes: 8 additions & 5 deletions src/commands/dashboards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,11 @@ export const registerDashboardCommands = (context: vscode.ExtensionContext) => {
vscode.window.showErrorMessage(`Page ${info.name} not found.`);
return;
} else {
page.content = file.getText();
Container.universal.saveDashboardPage(page.modelId, dashboard.id, page);
const codePath = path.join(tmpdir(), '.universal.code.dashboardPage');
const fileName = file.fileName.toLocaleLowerCase().replace(codePath.toLocaleLowerCase(), "").substring(1);
const filePath = path.join("dashboards", info.dashboardName, "pages", info.name + ".ps1");
await Container.universal.saveFileContent(filePath, file.getText());
await Container.universal.deployApp(dashboard.id);
}
}
else if (file.fileName.includes('.universal.code.dashboardModule')) {
Expand Down Expand Up @@ -245,20 +248,20 @@ export const openFileRemote = async (dashboard: DashboardTreeItem) => {
}

export const openPageFile = async (page: DashboardPageTreeItem) => {
const os = require('os');
const codePath = path.join(tmpdir(), '.universal.code.dashboardPage');
//Use the id in the path so that we can save the dashboard
const codePathId = path.join(codePath, page.page.modelId.toString());
const filePath = path.join(codePathId, page.page.name + ".ps1");

const dashboardFile = await Container.universal.getDashboardPage(page.page.dashboardId, page.page.modelId);
const dashboard = await Container.universal.getDashboard(page.page.dashboardId);
var dirName = path.dirname(filePath);
if (!fs.existsSync(dirName)) {
fs.mkdirSync(dirName, { recursive: true });
}

fs.writeFileSync(filePath, dashboardFile.content);
const content = await Container.universal.getFileContent(path.join("dashboards", dashboard.name, "pages", page.page.name + ".ps1"));

fs.writeFileSync(filePath, content.content);

files.push({
id: page.page.modelId,
Expand Down
8 changes: 8 additions & 0 deletions src/universal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,14 @@ export class Universal {
})
}

deployApp(id: number): Promise<Dashboard> {
return new Promise((resolve, reject) => {
this.request(`/api/v1/dashboard/${id}/status/deploy`, 'PUT')?.then(x => resolve(x.data)).catch(x => {
reject(x.message);
});
});
}

getDashboard(id: number): Promise<Dashboard> {
return new Promise((resolve, reject) => {
this.request(`/api/v1/dashboard/${id}`, 'GET')?.then(x => resolve(x.data)).catch(x => {
Expand Down
Loading