Skip to content
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

Fix bugs and prepare refactoring course #100

Merged
merged 7 commits into from
Mar 13, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ inline fun <reified T : BaseConfig> buildBaseConfig(
require(config == null) {
"The ${config?.configName} config was already parsed"
}
logger.info("Building ${config?.configName} config...")
return configBuilder(configFile)
return configBuilder(configFile).also {
logger.info("Building ${it.configName} config...")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,17 @@ import java.io.File

object FileRequests {

private val client = HttpClient(CIO)
private val client = HttpClient(CIO) {
install(HttpTimeout)
}
private val logger: Logger = Logger.getInstance(FileRequests::class.java)
private const val TIMEOUT: Long = 15_000 // 15 seconds
private const val TIMEOUT: Long = 120_000 // 2 minutes

@Suppress("TooGenericExceptionCaught")
@Suppress("TooGenericExceptionCaught", "ReturnCount")
suspend fun sendFile(file: File, logFileType: String): Boolean {
if (!file.exists() || file.length() == 0L) {
return true
}
try {
val researchId = GlobalPluginStorage.currentResearchId
?: error("ResearchId is undefined")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ class MainPluginPanelFactory : ToolWindowFactory {
mainWindow = project.getService(MainWindowService::class.java).mainWindow
trackingService = project.getService(TrackingService::class.java)
mainWindow.jComponent.size = JBUI.size(toolWindow.component.width, toolWindow.component.height)
mainWindow.onError {
nextButton.text = UIBundle.message("ui.button.welcome")
setNextAction { agreementAcceptance() }
}
agreementAcceptance()
val buttonPanel = JBPanel<JBPanel<*>>(FlowLayout()).apply {
add(backButton)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import org.intellij.lang.annotations.Language
import org.jetbrains.concurrency.Promise
import org.jetbrains.research.tasktracker.ui.main.panel.models.LinkType
import org.jetbrains.research.tasktracker.ui.main.panel.models.Theme
import org.jetbrains.research.tasktracker.ui.main.panel.template.DefaultErrorPage
import org.jetbrains.research.tasktracker.ui.main.panel.template.HtmlTemplate
import org.jetbrains.research.tasktracker.ui.main.panel.template.MainPageTemplate
import org.jetbrains.research.tasktracker.ui.main.panel.template.ServerErrorPage
import javax.swing.JComponent

class MainPluginWindow(service: MainWindowService) {
Expand All @@ -28,9 +28,6 @@ class MainPluginWindow(service: MainWindowService) {

init {
windowBrowser.jbCefClient.setProperty(JBCefClient.Properties.JS_QUERY_POOL_SIZE, JS_QUERY_POOL_SIZE)
windowBrowser.setErrorPage { errorCode, errorText, failedUrl ->
DefaultErrorPage(errorCode.code.toString(), errorText, failedUrl).htmlContent
}
loadHtmlTemplate(currentTemplate)
val app = ApplicationManager.getApplication().messageBus
app.connect().subscribe(
Expand All @@ -46,6 +43,13 @@ class MainPluginWindow(service: MainWindowService) {
Disposer.register(service, windowBrowser)
}

fun onError(action: () -> Unit) {
windowBrowser.setErrorPage { errorCode, errorText, failedUrl ->
action.invoke()
ServerErrorPage().htmlContent
}
}

private fun getJsElementByIdCommand(elementId: String) = "document.getElementById('$elementId')"

fun getElementValue(elementId: String): Promise<JsExpressionResult> =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ fun Panel.agreementAcceptance() {
project,
UIBundle.message("ui.connection.lose")
)
return@runOnSuccess
}
}
GlobalPluginStorage.currentResearchId = IdRequests.getResearchId()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,2 @@
agreements:
- text: |
Multiline
example
required: false
- text: "Example <a href=\"https://github.com/JetBrains-Research/tasktracker-3\">link</a>"
- text: "Example link in JCEF <a href=\"https://github.com/JetBrains-Research/tasktracker-3\">link</a>"
openLinkInDefaultBrowser: false
- text: "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,"
- text: I agree to save my name and email in the taskTracker plugin database.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pluginName: "Kotlin Introduction"
pluginDescription: "We want to track your progress through the kotlin introduction course in order to collect data on file changes during the course completion. Please, when you are ready, press the next button."
researchId: "Kotlin Introduction"
pluginName: "Kotlin Refactoring course"
pluginDescription: "We want to track your progress through the kotlin refactoring course in order to collect data on file changes during the course completion. Please, when you are ready, press the next button."
researchId: "Kotlin Refactoring"
logs:
- logPaths:
- "edu-assistant/eduAssistant.log"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ defaultMessageTemplate: " No worries, though! You can still send us your tracke

Copy this link: <i>%s</i>
Open the folder using the link.
Once you're in the folder, please send us all its files.
Once you're in the folder, please send us all files in this folder
to the email [email protected].

We appreciate your assistance!"
Loading
Loading