Skip to content

Commit 3b81e00

Browse files
committed
feat: openwebui+ollama and zim management
1 parent 39d75c9 commit 3b81e00

31 files changed

+1115
-223
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,6 @@ server/temp
3838

3939
# Frontend assets compiled code
4040
admin/public/assets
41+
42+
# Admin specific development files
43+
admin/storage

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Project N.O.M.A.D. can be installed on any Debian-based operating system (we rec
77
*Note: sudo/root privileges are required to run the install script*
88

99
```bash
10-
curl -fsSL https://raw.githubusercontent.com/CrosstalkSolutions/project-nomad/main/install/install/sh -o install_nomad.sh
10+
curl -fsSL https://raw.githubusercontent.com/Crosstalk-Solutions/project-nomad/refs/heads/master/install/install_nomad.sh -o install_nomad.sh
1111

1212
sudo bash ./install_nomad.sh
1313
```

admin/app/controllers/home_controller.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ export default class HomeController {
1414
}
1515

1616
async home({ inertia }: HttpContext) {
17-
const services = await this.systemService.getServices();
17+
const services = await this.systemService.getServices({ installedOnly: true });
18+
console.log(services)
1819
return inertia.render('home', {
1920
system: {
2021
services

admin/app/controllers/settings_controller.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,19 @@ export default class SettingsController {
1818
}
1919

2020
async apps({ inertia }: HttpContext) {
21-
const services = await this.systemService.getServices();
21+
const services = await this.systemService.getServices({ installedOnly: false });
2222
return inertia.render('settings/apps', {
2323
system: {
2424
services
2525
}
2626
});
2727
}
28+
29+
async zim({ inertia }: HttpContext) {
30+
return inertia.render('settings/zim/index')
31+
}
32+
33+
async zimRemote({ inertia }: HttpContext) {
34+
return inertia.render('settings/zim/remote-explorer');
35+
}
2836
}

admin/app/controllers/system_controller.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ export default class SystemController {
1111
private dockerService: DockerService
1212
) { }
1313

14-
async getServices({ response }: HttpContext) {
15-
const services = await this.systemService.getServices();
16-
response.send(services);
14+
async getServices({ }: HttpContext) {
15+
return await this.systemService.getServices({ installedOnly: true });
1716
}
1817

1918
async installService({ request, response }: HttpContext) {
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { ZimService } from '#services/zim_service';
2+
import { inject } from '@adonisjs/core';
3+
import type { HttpContext } from '@adonisjs/core/http'
4+
5+
@inject()
6+
export default class ZimController {
7+
constructor(
8+
private zimService: ZimService
9+
) { }
10+
11+
async list({ }: HttpContext) {
12+
return await this.zimService.list();
13+
}
14+
15+
async listRemote({ request }: HttpContext) {
16+
const { start = 0, count = 12 } = request.qs();
17+
return await this.zimService.listRemote({ start, count });
18+
}
19+
20+
async downloadRemote({ request, response }: HttpContext) {
21+
const { url } = request.body()
22+
await this.zimService.downloadRemote(url);
23+
24+
response.status(200).send({
25+
message: 'Download started successfully'
26+
});
27+
}
28+
29+
async delete({ request, response }: HttpContext) {
30+
const { key } = request.params();
31+
32+
try {
33+
await this.zimService.delete(key);
34+
} catch (error) {
35+
if (error.message === 'not_found') {
36+
return response.status(404).send({
37+
message: `ZIM file with key ${key} not found`
38+
});
39+
}
40+
throw error; // Re-throw any other errors and let the global error handler catch
41+
}
42+
43+
response.status(200).send({
44+
message: 'ZIM file deleted successfully'
45+
});
46+
}
47+
}

admin/app/models/service.ts

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import { BaseModel, column, SnakeCaseNamingStrategy } from '@adonisjs/lucid/orm'
1+
import { BaseModel, belongsTo, column, hasMany, SnakeCaseNamingStrategy } from '@adonisjs/lucid/orm'
2+
import type { BelongsTo, HasMany } from '@adonisjs/lucid/types/relations'
23
import { DateTime } from 'luxon'
34

45
export default class Service extends BaseModel {
56
static namingStrategy = new SnakeCaseNamingStrategy()
67

7-
@column({ isPrimary: true })
8+
@column({ isPrimary: true })
89
declare id: number
910

1011
@column()
@@ -14,16 +15,31 @@ export default class Service extends BaseModel {
1415
declare container_image: string
1516

1617
@column()
17-
declare container_command: string
18+
declare container_command: string | null
1819

1920
@column()
2021
declare container_config: string | null
2122

22-
@column()
23+
@column({
24+
serialize(value) {
25+
return Boolean(value)
26+
},
27+
})
2328
declare installed: boolean
2429

2530
@column()
26-
declare ui_location: string
31+
declare depends_on: string | null
32+
33+
// For services that are dependencies for other services - not intended to be installed directly by users
34+
@column({
35+
serialize(value) {
36+
return Boolean(value)
37+
},
38+
})
39+
declare is_dependency_service: boolean
40+
41+
@column()
42+
declare ui_location: string | null
2743

2844
@column()
2945
declare metadata: string | null
@@ -33,4 +49,15 @@ export default class Service extends BaseModel {
3349

3450
@column.dateTime({ autoCreate: true, autoUpdate: true })
3551
declare updated_at: DateTime | null
52+
53+
// Define a self-referential relationship for dependencies
54+
@belongsTo(() => Service, {
55+
foreignKey: 'depends_on',
56+
})
57+
declare dependency: BelongsTo<typeof Service>
58+
59+
@hasMany(() => Service, {
60+
foreignKey: 'depends_on',
61+
})
62+
declare dependencies: HasMany<typeof Service>
3663
}

0 commit comments

Comments
 (0)