Skip to content

Commit

Permalink
Fix issue #42
Browse files Browse the repository at this point in the history
- Add notification about Azure publish succeeded/failed
  • Loading branch information
sdubov committed Sep 26, 2018
1 parent 4c90776 commit 4101e1a
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ package com.microsoft.intellij.runner.webapp.webappconfig

import com.intellij.execution.process.ProcessOutputTypes
import com.intellij.ide.util.PropertiesComponent
import com.intellij.notification.Notification
import com.intellij.notification.NotificationGroup
import com.intellij.notification.NotificationType
import com.intellij.notification.Notifications
import com.intellij.openapi.project.Project
import com.intellij.openapi.wm.ToolWindowId
import com.microsoft.azure.management.appservice.OperatingSystem
import com.microsoft.azure.management.appservice.WebApp
import com.microsoft.azure.management.sql.SqlDatabase
Expand Down Expand Up @@ -35,6 +40,8 @@ class RiderWebAppRunState(project: Project,
companion object {
private const val TARGET_NAME = "WebApp"
private const val URL_WEB_APP_WWWROOT = "/home/site/wwwroot"
private const val TOOL_NOTIFICATION_PUBLISH_SUCCEEDED = "Azure Publish completed"
private const val TOOL_NOTIFICATION_PUBLISH_FAILED = "Azure Publish failed"
}

/**
Expand Down Expand Up @@ -115,6 +122,8 @@ class RiderWebAppRunState(project: Project,
refreshDatabaseAfterPublish(sqlDatabase, myModel.databaseModel)
}

showPublishNotification(TOOL_NOTIFICATION_PUBLISH_SUCCEEDED, NotificationType.INFORMATION)

val isOpenBrowser = PropertiesComponent.getInstance().getBoolean(
AzureRiderSettings.PROPERTY_WEB_APP_OPEN_IN_BROWSER_NAME,
AzureRiderSettings.openInBrowserDefaultValue)
Expand All @@ -132,6 +141,8 @@ class RiderWebAppRunState(project: Project,
if (isDatabaseCreated)
AzureDatabaseMvpModel.refreshSqlServerToSqlDatabaseMap()

showPublishNotification(TOOL_NOTIFICATION_PUBLISH_FAILED, NotificationType.ERROR)

processHandler.println(errMsg, ProcessOutputTypes.STDERR)
processHandler.notifyComplete()
}
Expand All @@ -149,4 +160,10 @@ class RiderWebAppRunState(project: Project,
model.resetOnPublish(sqlDatabase)
AzureDatabaseMvpModel.refreshSqlServerToSqlDatabaseMap()
}

private fun showPublishNotification(text: String, type: NotificationType) {
val displayId = NotificationGroup.toolWindowGroup("Azure Web App Publish Message", ToolWindowId.RUN).displayId
val notification = Notification(displayId, "", text, type)
Notifications.Bus.notify(notification, project)
}
}

0 comments on commit 4101e1a

Please sign in to comment.