Skip to content

More perf improvements #134

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Dec 22, 2022
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
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@

### Added
- ability to open a template in the Dashboard
- ability to sort by workspace name, or by template name or by workspace status
- a new token is requested when the one persisted is expired

### Changed
- renamed the plugin from `Coder Gateway` to `Gateway`
- workspaces and agents are now resolved and displayed progressively

### Fixed
- icon rendering on macOS
- icon rendering on `macOS`
- `darwin` agents are now recognized as `macOS`
- unsupported OS warning is displayed only for running workspaces

## 2.1.3 - 2022-12-09

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ data class WorkspaceAgentModel(
val name: String,
val templateID: UUID,
val templateName: String,
val templateIcon: Icon,
val templateIconPath: String,
var templateIcon: Icon?,
val status: WorkspaceVersionStatus,
val agentStatus: WorkspaceAgentStatus,
val lastBuildTransition: WorkspaceTransition,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,19 @@ package com.coder.gateway.models
import com.coder.gateway.sdk.v2.models.ProvisionerJobStatus
import com.coder.gateway.sdk.v2.models.Workspace
import com.coder.gateway.sdk.v2.models.WorkspaceTransition
import com.intellij.ui.JBColor

enum class WorkspaceAgentStatus(val label: String) {
QUEUED("◍ Queued"), STARTING("⦿ Starting"), STOPPING("◍ Stopping"), DELETING("⦸ Deleting"),
RUNNING("⦿ Running"), STOPPED("◍ Stopped"), DELETED("⦸ Deleted"),
CANCELING("◍ Canceling action"), CANCELED("◍ Canceled action"), FAILED("ⓧ Failed");

fun statusColor() = when (this) {
RUNNING -> JBColor.GREEN
FAILED -> JBColor.RED
else -> if (JBColor.isBright()) JBColor.LIGHT_GRAY else JBColor.DARK_GRAY
}

companion object {
fun from(workspace: Workspace) = when (workspace.latestBuild.job.status) {
ProvisionerJobStatus.PENDING -> QUEUED
Expand All @@ -28,5 +35,7 @@ enum class WorkspaceAgentStatus(val label: String) {
ProvisionerJobStatus.CANCELED -> CANCELED
ProvisionerJobStatus.FAILED -> FAILED
}

fun from(str: String) = WorkspaceAgentStatus.values().first { it.label.contains(str, true) }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import javax.swing.Icon
@Service(Service.Level.APP)
class TemplateIconDownloader {
private val coderClient: CoderRestClientService = service()
private val cache = mutableMapOf<Pair<String, String>, Icon>()

fun load(path: String, templateName: String): Icon {
var url: URL? = null
Expand All @@ -23,9 +24,15 @@ class TemplateIconDownloader {
}

if (url != null) {
val cachedIcon = cache[Pair(templateName, path)]
if (cachedIcon != null) {
return cachedIcon
}
var img = ImageLoader.loadFromUrl(url)
if (img != null) {
return IconUtil.toRetinaAwareIcon(Scalr.resize(ImageUtil.toBufferedImage(img), Scalr.Method.ULTRA_QUALITY, 32))
val icon = IconUtil.toRetinaAwareIcon(Scalr.resize(ImageUtil.toBufferedImage(img), Scalr.Method.ULTRA_QUALITY, 32))
cache[Pair(templateName, path)] = icon
return icon
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/main/kotlin/com/coder/gateway/sdk/os.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.coder.gateway.sdk

import java.util.Locale

fun getOS(): OS? {
return OS.from(System.getProperty("os.name"))
}

fun getArch(): Arch? {
return Arch.from(System.getProperty("os.arch").toLowerCase())
return Arch.from(System.getProperty("os.arch").lowercase(Locale.getDefault()))
}

enum class OS {
Expand All @@ -22,7 +24,7 @@ enum class OS {
LINUX
}

os.contains("mac", true) -> {
os.contains("mac", true) || os.contains("darwin", true) -> {
MAC
}

Expand Down
Loading