-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: generate apps routes with back-end
- Loading branch information
1 parent
a413a0b
commit 03871fa
Showing
6 changed files
with
102 additions
and
34 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
src/main/java/fr/recia/collabsoft/service/db/AssociatedAppService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright (C) 2023 GIP-RECIA, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package fr.recia.collabsoft.service.db; | ||
|
||
import fr.recia.collabsoft.db.entity.AssociatedApp; | ||
import fr.recia.collabsoft.db.repository.AssociatedAppRepository; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.apache.commons.collections4.IteratorUtils; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.List; | ||
|
||
@Slf4j | ||
@Service | ||
public class AssociatedAppService { | ||
|
||
@Autowired | ||
private AssociatedAppRepository<AssociatedApp> associatedAppRepository; | ||
|
||
public List<AssociatedApp> getApps() { | ||
final List<AssociatedApp> apps = IteratorUtils.toList( | ||
associatedAppRepository.findAll().iterator() | ||
); | ||
|
||
if (apps.isEmpty()) log.debug("No apps"); | ||
|
||
return apps; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import type { AssociatedApp } from '@/types/associatedAppType.ts'; | ||
import { capitalize } from 'vue'; | ||
import { type RouteRecordRaw, type Router } from 'vue-router'; | ||
|
||
const initAppsRoutes = async (apps: Array<AssociatedApp>): Promise<void> => { | ||
const router: Router = (await import('@/router/index.ts')).default; | ||
|
||
apps.forEach((app) => { | ||
const solo: RouteRecordRaw = { | ||
path: `${app.slug}/:fileId(\\d+)`, | ||
name: app.slug, | ||
component: () => import(`@/views/app/${app.slug}/${capitalize(app.slug)}View.vue`), | ||
}; | ||
router.addRoute('app', solo); | ||
|
||
const multi: RouteRecordRaw = { | ||
path: `${app.slug}/:roomId([A-Z]{6})`, | ||
name: `collaborative-${app.slug}`, | ||
component: () => import(`@/views/app/${app.slug}/Collaborative${capitalize(app.slug)}View.vue`), | ||
}; | ||
router.addRoute('app', multi); | ||
}); | ||
}; | ||
|
||
export { initAppsRoutes }; |