Skip to content

Commit

Permalink
some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
coolsamson7 committed Nov 1, 2024
1 parent ac02afe commit 1380f67
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ export class ApplicationTreeComponent implements OnInit, OnChanges {
const version = treeConfig.instance!.version

let node : Node
if ( treeConfig.microfrontend) {
// add microfrontend

// new microfrontend?

if ( treeConfig.microfrontend) {
node = {
type: "microfrontend",
data: treeConfig.microfrontend,
Expand All @@ -81,22 +82,24 @@ export class ApplicationTreeComponent implements OnInit, OnChanges {
}
else node = this.dataSource.data.find(node => node.data.name == mfe)!

if (treeConfig.version) {
// add version
// new version?

if (treeConfig.version) {
node!.children?.push(node = {
type: "microfrontend-version",
data: treeConfig.version,
parent: node,
children: []
})
}
else node = node.children!.find(node => node.data.version == version)!

if (treeConfig.instance) {
// add instance
// instance?

if (treeConfig.instance) {
node!.children?.push(node = {
type: "microfrontend-instance",
parent: node,
data: treeConfig.instance
})
}
Expand All @@ -122,14 +125,34 @@ export class ApplicationTreeComponent implements OnInit, OnChanges {
return node
}

deletedApplication(node: Node) {
this.dataSource.data.splice(this.dataSource.data.indexOf(node), 1)
this.refreshData()
indexOf(node: Node) {
if ( node.parent)
return node.parent!.children!.indexOf(node)
else
return this.dataSource.data.indexOf(node)
}

deletedApplicationVersion(node: Node) {
node.parent?.children?.splice(node.parent?.children.indexOf(node), 1)
// return the node which should be selected

deletedNode(node: Node) : Node | undefined {
let nextNode : Node | undefined = undefined
const index = this.indexOf(node)

if ( node.parent) {
const children = node.parent!.children!

children.splice(index, 1)
nextNode = children.length > 0 ? children[Math.max(children.length - 1, index)] : node.parent
}
else {
const children = this.dataSource.data
children.splice(index, 1)
nextNode = children.length > 0 ? children[Math.max(children.length - 1, index)] : undefined
}

this.refreshData()

return nextNode
}

addApplication(application: Application) : Node{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export class ApplicationFeatureComponent extends WithCommandToolbar(WithCommands
}
}

selectNode(node: Node) {
selectNode(node: Node | undefined) {
if ( this.dirty) {
this.confirmationDialog()
.title("Dirty")
Expand All @@ -195,23 +195,25 @@ export class ApplicationFeatureComponent extends WithCommandToolbar(WithCommands
this.selectedMicrofrontendVersion = undefined
this.selectedMicrofrontendInstance = undefined

if ( node.type == "microfrontend")
this.selectedMicrofrontend = node.data
if ( node ) {
if ( node.type == "microfrontend")
this.selectedMicrofrontend = node.data

else if ( node.type == "microfrontend-version") {
this.microfrontend = node.parent?.data
this.selectedMicrofrontendVersion = node.data
}
else if ( node.type == "microfrontend-version") {
this.microfrontend = node.parent?.data
this.selectedMicrofrontendVersion = node.data
}

else if ( node.type == "application")
this.selectedApplication = node.data
else if ( node.type == "application")
this.selectedApplication = node.data

else if ( node.type == "application-version") {
this.application = node.parent?.data
this.selectedVersion = node.data
else if ( node.type == "application-version") {
this.application = node.parent?.data
this.selectedVersion = node.data
}
}

this.updateCommandState()
this.updateCommandState()
}

// private
Expand Down Expand Up @@ -256,24 +258,28 @@ export class ApplicationFeatureComponent extends WithCommandToolbar(WithCommands
}

deleteApplication(node: Node) {
this.portalAdministrationService.deleteApplication(node.data.name).subscribe()
this.portalAdministrationService.deleteApplication(node.data.name).subscribe(_ => {
this.selectNode( this.tree.deletedNode(node)!)
})
}

deleteMicrofrontend(node: Node) {
// TODO
this.portalAdministrationService.deleteMicrofrontend(node.data.name).subscribe(_ => {
this.selectNode( this.tree.deletedNode(node)!)
})
}

deleteMicrofrontendVersion(node: Node) {
// TODO
this.portalAdministrationService.deleteMicrofrontendVersion(node.parent!.data.name, node.data.version).subscribe(_ => {
this.selectNode(this.tree.deletedNode(node)!)
})
}

deleteApplicationVersion(node: Node) {
const application : Application = node.parent?.data

this.portalAdministrationService.deleteApplicationVersion(application.name, node.data.version).subscribe(_ => {
this.tree.deletedApplicationVersion(node)

this.selectNode(node.parent!)
this.selectNode(this.tree.deletedNode(node)!)
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class PortalAdministrationService extends AbstractHTTPService {
}

deleteApplication(application: String) :Observable<any> {
return this.delete<any>(`delete-application/${application}`)
return this.get<any>(`delete-application/${application}`)
}

readApplications() : Observable<Application[]>{
Expand All @@ -110,7 +110,7 @@ export class PortalAdministrationService extends AbstractHTTPService {
}

deleteApplicationVersion( application: String, version: string) : Observable<any> {
return this.delete<any>(`delete-application-version/${application}/${version}`)
return this.get<any>(`delete-application-version/${application}/${version}`)
}

// microfrontend
Expand All @@ -123,6 +123,10 @@ export class PortalAdministrationService extends AbstractHTTPService {
return this.post<Microfrontend>(`update-microfrontend`, microfrontend)
}

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

// microfrontend versions

readMicrofrontendVersions() : Observable<MicrofrontendVersion[]> {
Expand All @@ -133,6 +137,10 @@ export class PortalAdministrationService extends AbstractHTTPService {
return this.post<MicrofrontendVersion>(`update-microfrontend-version`, version)
}

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

// microfrontend instances

updateMicrofrontendInstance(instance: MicrofrontendInstance) : Observable<MicrofrontendInstance> {
Expand All @@ -143,6 +151,10 @@ export class PortalAdministrationService extends AbstractHTTPService {
return this.post<MicrofrontendRegistryResult>(`register-microfrontend-instance`, manifest)
}

deleteMicrofrontendInstance( microfrontend: String, version : String, instance : String) : Observable<any> {
return this.get<any>(`delete-microfrontend-instance/${microfrontend}/${version}/${instance}`)
}

// TEST

computeApplicationVersionConfiguration(application: number) : Observable<any> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ interface PortalAdministrationService : Service {
@PostMapping("create-stage")
fun createStage(@RequestBody stage: String)

@DeleteMapping("delete-stage/{stage}")
@GetMapping("delete-stage/{stage}")
fun deleteStage(@PathVariable stage: String)

@GetMapping("read-stages")
Expand All @@ -75,7 +75,7 @@ interface PortalAdministrationService : Service {
@PostMapping("update-application")
fun updateApplication(@RequestBody application: Application) : Application

@DeleteMapping("delete-application/{application}")
@GetMapping("delete-application/{application}")
fun deleteApplication(@PathVariable application: String)

@GetMapping("read-applications")
Expand All @@ -91,7 +91,7 @@ interface PortalAdministrationService : Service {
@PostMapping("update-application-version")
fun updateApplicationVersion(@RequestBody application: ApplicationVersion) : ApplicationVersion

@DeleteMapping("delete-application-version/{application}/{version}")
@GetMapping("delete-application-version/{application}/{version}")
fun deleteApplicationVersion(@PathVariable application: String, @PathVariable version: String)

// microfrontend
Expand All @@ -104,6 +104,9 @@ interface PortalAdministrationService : Service {
@ResponseBody
fun updateMicrofrontend(@RequestBody version: Microfrontend) : Microfrontend

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

// microfrontend version

@GetMapping("read-microfrontend-versions")
Expand All @@ -114,6 +117,9 @@ interface PortalAdministrationService : Service {
@ResponseBody
fun updateMicrofrontendVersion(@RequestBody version: MicrofrontendVersion) : MicrofrontendVersion

@GetMapping("delete-microfrontend-version/{microfrontend}/{version}")
fun deleteMicrofrontendVersion(@PathVariable microfrontend: String, @PathVariable version: String)

// microfrontend instance

@PostMapping("update-microfrontend-instance")
Expand All @@ -123,4 +129,7 @@ interface PortalAdministrationService : Service {
@PostMapping("register-microfrontend-instance")
@ResponseBody
fun registerMicrofrontendInstance(@RequestBody manifest: Manifest) : MicrofrontendRegistryResult

@GetMapping("delete-microfrontend-instance/{microfrontend}/{version}/{instance}")
fun deleteMicrofrontendInstance(@PathVariable microfrontend: String, @PathVariable version: String, @PathVariable instance: String)
}
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,11 @@ class PortalAdministrationServiceImpl : PortalAdministrationService {
return microfrontend
}

@Transactional
override fun deleteMicrofrontend(@PathVariable microfrontend: String) {
this.microfrontendRepository.deleteById(microfrontend)
}

// microfrontend versions

@Transactional
Expand All @@ -412,8 +417,26 @@ class PortalAdministrationServiceImpl : PortalAdministrationService {
return version
}

@Transactional
override fun deleteMicrofrontendVersion(microfrontend: String, version: String) {
val microfrontend = this.microfrontendRepository.findById(microfrontend).get()
val version = microfrontend.versions.find { mfev -> mfev.version == version }!!

microfrontendVersionRepository.delete(version)
}

// microfrontend instance

@Transactional
override fun deleteMicrofrontendInstance(microfrontend: String, version: String, instance: String) {
val microfrontend = this.microfrontendRepository.findById(microfrontend).get()
val version = microfrontend.versions.find { mfev -> mfev.version == version }!!
val instance = version.instances.find { i -> i.uri == instance }

microfrontendInstanceRepository.delete(instance!!)
}


@Transactional
override fun updateMicrofrontendInstance(instance: MicrofrontendInstance) : MicrofrontendInstance {
val entity = this.microfrontendInstanceRepository.findById(instance.uri).get()
Expand Down

0 comments on commit 1380f67

Please sign in to comment.