Initial cobalt setup and form/listing implementation
This commit is contained in:
23
src/app/services/Cobalt.service.ts
Normal file
23
src/app/services/Cobalt.service.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import {Config, Inject, Injectable, Routing} from '@extollo/lib'
|
||||
|
||||
@Injectable()
|
||||
export class Cobalt {
|
||||
@Inject()
|
||||
protected readonly config!: Config
|
||||
|
||||
@Inject()
|
||||
protected readonly routing!: Routing
|
||||
|
||||
public getSession(): {[key: string]: any} {
|
||||
return {
|
||||
app: {
|
||||
name: this.config.get('app.name'),
|
||||
url: this.routing.getAppUrl().toRemote,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public getState(): {[key: string]: any} {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
28
src/app/services/CobaltUnit.ts
Normal file
28
src/app/services/CobaltUnit.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import {Inject, Maybe, Request, Singleton, Unit, ViewEngine} from '@extollo/lib'
|
||||
import {Cobalt} from './Cobalt.service'
|
||||
|
||||
@Singleton()
|
||||
export class CobaltUnit extends Unit {
|
||||
@Inject()
|
||||
protected readonly viewEngine!: ViewEngine
|
||||
|
||||
up(): Promise<void> | void {
|
||||
this.viewEngine.registerGlobalFactory('cobaltSession', (req: Maybe<Request>) => {
|
||||
if ( !req ) {
|
||||
return
|
||||
}
|
||||
|
||||
const cobalt = req.make<Cobalt>(Cobalt)
|
||||
return cobalt.getSession()
|
||||
})
|
||||
|
||||
this.viewEngine.registerGlobalFactory('cobaltState', (req: Maybe<Request>) => {
|
||||
if ( !req ) {
|
||||
return
|
||||
}
|
||||
|
||||
const cobalt = req.make<Cobalt>(Cobalt)
|
||||
return cobalt.getState()
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user