Skip to content

Commit

Permalink
some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
coolsamson7 committed Nov 3, 2024
1 parent 20d278f commit c1baf05
Show file tree
Hide file tree
Showing 14 changed files with 87 additions and 345 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export class ApplicationFeatureComponent extends WithCommandToolbar(WithCommands
this.deleteApplicationVersion(request.node)

else if ( request.node.type == "microfrontend")
this.deleteMicrofrontend(request.node)
this.deleteMicrofrontend(request.node, false)

else if ( request.node.type == "microfrontend-version")
this.deleteMicrofrontendVersion(request.node)
Expand Down Expand Up @@ -263,9 +263,23 @@ export class ApplicationFeatureComponent extends WithCommandToolbar(WithCommands
})
}

deleteMicrofrontend(node: Node) {
this.portalAdministrationService.deleteMicrofrontend(node.data.name).subscribe(_ => {
this.selectNode( this.tree.deletedNode(node)!)
deleteMicrofrontend(node: Node, force: boolean) {
this.portalAdministrationService.deleteMicrofrontend(node.data.name, force).subscribe(ok => {
if (ok)
this.selectNode( this.tree.deletedNode(node)!)
else {
this.confirmationDialog()
.title("Delete Microfrontend")
.message("Microfrontend is assigned. Still delete?")
.okCancel()
.show()
.subscribe(ok => {
if ( ok )
this.portalAdministrationService.deleteMicrofrontend(node.data.name, true).subscribe(_ => {
this.selectNode( this.tree.deletedNode(node)!)
})
})
} // else
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { AbstractControl, AbstractControlDirective, AsyncValidatorFn, FormBuilde
import { AbstractFeature, Command, Feature, FeatureConfig, Manifest, MessageAdministrationService, SuggestionProvider, Translator, WithCommands, WithDialogs } from "@modulefederation/portal";
import { I18NTreeComponent } from "./widgets/i18n-tree";
import { MatFormField } from "@angular/material/form-field";

// TODO obsolete?
@Component({
selector: '[errorMessages]',
template: '{{ error }}'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { MatSnackBar } from "@angular/material/snack-bar";
import { Feature, Manifest, WithDialogs } from "@modulefederation/portal";
import { fromFetch } from "rxjs/fetch";
import { catchError, of, switchMap } from "rxjs";

// TODO obsolete?
@Component({
selector: 'microfrontends',
templateUrl: './microfrontends.component.html',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ export class PortalAdministrationService extends AbstractHTTPService {
return this.post<Microfrontend>(`update-microfrontend`, microfrontend)
}

deleteMicrofrontend( microfrontend: String) : Observable<any> {
return this.get<any>(`delete-microfrontend/${microfrontend}`)
deleteMicrofrontend( microfrontend: String, force: boolean) : Observable<boolean> {
return this.get<any>(`delete-microfrontend/${microfrontend}/${force}`)
}

// microfrontend versions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ typealias ManifestFilter = (context: FilterContext, manifest: Manifest) -> Boole
typealias FeatureFilter = (context: FilterContext, feature: Feature) -> Boolean

@Component
class DeploymentManager(@Autowired val manager: ManifestManager) {
class DeploymentManager() {
// instance data

private val manifestFilters = mutableListOf<ManifestFilter>()
Expand Down Expand Up @@ -225,8 +225,4 @@ class DeploymentManager(@Autowired val manager: ManifestManager) {

return deployment
}

fun create(session: Boolean) : Deployment {
return this.createDeployment(manager.manifests, "{\"type\":\"object\",\"value\": [] }", session)
}
}
153 changes: 0 additions & 153 deletions portal/core/src/main/java/com/serious/portal/ManifestManager.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ package com.serious.portal
* All rights reserved
*/

import com.serious.portal.model.Manifest
import com.serious.portal.model.MicrofrontendInstance
import com.serious.portal.persistence.ManifestEntityManager
import com.serious.portal.persistence.MicrofrontendEntityManager
import jakarta.annotation.PostConstruct
import org.springframework.beans.factory.annotation.Autowired
Expand All @@ -17,7 +15,7 @@ import java.net.URL


@Component
class MicrofrontendManager {
class MicrofrontendHealthCheck {
// instance data

val instances = mutableListOf<MicrofrontendInstance>()
Expand Down Expand Up @@ -52,47 +50,13 @@ class MicrofrontendManager {
} // for
}

// public

fun load(url: URL) : MicrofrontendInstance {
val manifest = manifestLoader.load(url)

manifest.enabled = true
manifest.health = "alive"
manifest.remoteEntry = url.toString()

if ( manifest.healthCheck == null)
manifest.healthCheck = manifest.remoteEntry

return register(manifest)
}

fun register(manifest: Manifest) : MicrofrontendInstance {
val microfrontendInstance = entityManager.createMicrofrontendInstance(manifest)

fun register(microfrontendInstance: MicrofrontendInstance) {
this.instances.add(microfrontendInstance)

return microfrontendInstance
}

fun remove(url: String) {
instances.removeIf { instance -> instance.uri == url}

entityManager.deleteMicrofrontendInstanceById(url)
}
/*
fun save(manifest: Manifest) {
val index = instances.indexOfFirst { man -> man.remoteEntry == manifest.remoteEntry }
if ( index >= 0) {
instances[index] = manifest
}
else {
instances.add(manifest)
}
this.entityManager.saveManifest(manifest)
} */

@Scheduled(fixedRate = 1000 * 10)
fun checkHealth() {
Expand Down Expand Up @@ -142,12 +106,4 @@ class MicrofrontendManager {
}
}
}

/*fun enableMicrofrontend(name : String, enabled: Boolean) {
val manifest = this.instances.find { instance -> instance.name == name }
manifest?.enabled = enabled
this.entityManager.updateEnabled(manifest!!.remoteEntry!!, enabled)
}*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,6 @@ import java.util.*
@RequestMapping("portal-administration/")
@RestController
interface PortalAdministrationService : Service {
@PostMapping("register-microfrontend")
@ResponseBody
fun registerMicrofrontend(@RequestBody url : Address) : RegistryResult

@PostMapping("register-manifest")
@ResponseBody
fun registerManifest(@RequestBody manifest: Manifest) : RegistryResult

@PostMapping("remove-microfrontend")
fun removeMicrofrontend(@RequestBody url : Address)

@PostMapping("save-manifest")
@ResponseBody
fun saveManifest(@RequestBody manifest : Manifest)

@GetMapping("enable-microfrontend/{name}/{enabled}")
fun enableMicrofrontend(@PathVariable name : String, @PathVariable enabled: Boolean)

@GetMapping("refresh")
fun refresh()

// TEST TODO
@RequestMapping(path = ["throwDeclared"], method = [RequestMethod.GET])
@ResponseBody
Expand Down Expand Up @@ -104,8 +83,8 @@ interface PortalAdministrationService : Service {
@ResponseBody
fun updateMicrofrontend(@RequestBody version: Microfrontend) : Microfrontend

@GetMapping("delete-microfrontend/{microfrontend}")
fun deleteMicrofrontend(@PathVariable microfrontend: String)
@GetMapping("delete-microfrontend/{microfrontend}/{force}")
fun deleteMicrofrontend(@PathVariable microfrontend: String, @PathVariable force: Boolean) : Boolean

// microfrontend version

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ import org.springframework.web.bind.annotation.RestController
@RequestMapping("portal-administration/")
@RestController
interface PortalDeploymentService : Service {
@GetMapping("deployment/{session}")
fun getDeployment(@PathVariable session: Boolean) : Deployment

@GetMapping("compute-deployment/{application}/{version}/{session}")
fun computeDeployment(@PathVariable application: String, @PathVariable version : String, @PathVariable session: Boolean) : Deployment
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@ package com.serious.service.administration.portal.impl
*/

import com.serious.portal.HelpAdministrationService
import com.serious.portal.ManifestLoader
import com.serious.portal.ManifestManager
import com.serious.portal.PortalAdministrationService
import com.serious.portal.model.Address
import com.serious.portal.model.Manifest
import com.serious.portal.model.RegistryError
import com.serious.portal.model.RegistryResult
import com.serious.portal.persistence.HelpEntityManager
import com.serious.portal.persistence.HelpRepository
import com.serious.portal.persistence.entity.HelpEntity
Expand Down
Loading

0 comments on commit c1baf05

Please sign in to comment.