Skip to content

Commit

Permalink
Add group create form API + move all pages to template
Browse files Browse the repository at this point in the history
  • Loading branch information
lcharette committed Oct 26, 2024
1 parent 0e3dd95 commit 9c300e7
Show file tree
Hide file tree
Showing 107 changed files with 326 additions and 6,055 deletions.
47 changes: 47 additions & 0 deletions app/assets/composable/GroupCreateForm.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import axios from 'axios'
import { Severity, type AlertInterface } from '@userfrosting/sprinkle-core/types'

// Interfaces
interface GroupCreateForm {
slug: string
name: string
description: string
icon: string
}

// Variables
function getDefaultForm(): GroupCreateForm {
return {
slug: '',
name: '',
description: '',
icon: 'users'
}
}

// TODO : Add validation
// 'schema://requests/group/create.yaml'

// Actions
async function sendForm(form: GroupCreateForm) {
return axios
.post('/api/groups', form)
.then((response) => {
return response.data.message
})
.catch((err) => {
const error: AlertInterface = {
...{
description: 'An error as occurred',
style: Severity.Danger,
closeBtn: true
},
...err.response.data
}

throw error
})
}

export type { GroupCreateForm }
export { getDefaultForm, sendForm }
4 changes: 1 addition & 3 deletions app/assets/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import type { App } from 'vue'

/* Install plugins */
export default {
install: (app: App, options: {}) => {}
install: () => {}
}
46 changes: 1 addition & 45 deletions app/assets/views/ActivitiesView.vue
Original file line number Diff line number Diff line change
@@ -1,47 +1,3 @@
<script setup>
import moment from 'moment'
</script>

<template>
<UFHeaderPage title="Activities" caption="A listing of user activities." />

<UFCardBox>
<UFSprunjeTable
dataUrl="/api/activities"
searchColumn="user"
:defaultSorts="{ occurred_at: 'desc' }">
<template #header>
<UFSprunjeHeader sort="occurred_at">Activity Time</UFSprunjeHeader>
<UFSprunjeHeader sort="user">User</UFSprunjeHeader>
<UFSprunjeHeader sort="description">Description</UFSprunjeHeader>
</template>

<template #body="{ item }">
<UFSprunjeColumn>
<div>{{ moment(item.occurred_at).format('dddd') }}</div>
<div>{{ moment(item.occurred_at).format('MMM Do, YYYY h:mm a') }}</div>
</UFSprunjeColumn>
<UFSprunjeColumn>
<strong>
<RouterLink
:to="{
name: 'admin.user',
params: { user_name: item.user.user_name }
}">
{{ item.user.full_name }} ({{ item.user.user_name }})
</RouterLink>
</strong>
<div class="uk-text-meta">{{ item.user.email }}</div>
</UFSprunjeColumn>
<UFSprunjeColumn>
<div>
{{ item.ip_address }}
</div>
<div>
<i>{{ item.description }}</i>
</div>
</UFSprunjeColumn>
</template>
</UFSprunjeTable>
</UFCardBox>
<UFAdminActivitiesPag />
</template>
46 changes: 0 additions & 46 deletions app/assets/views/Dashboard/DashboardActivities.vue

This file was deleted.

32 changes: 0 additions & 32 deletions app/assets/views/Dashboard/DashboardRecentUsers.vue

This file was deleted.

12 changes: 0 additions & 12 deletions app/assets/views/Dashboard/DashboardStats.vue

This file was deleted.

58 changes: 0 additions & 58 deletions app/assets/views/Dashboard/DashboardSystemInfo.vue

This file was deleted.

36 changes: 1 addition & 35 deletions app/assets/views/DashboardView.vue
Original file line number Diff line number Diff line change
@@ -1,37 +1,3 @@
<script lang="ts" setup>
import { useDashboardApi } from '../composable/dashboard'
import DashboardStats from './Dashboard/DashboardStats.vue'
import DashboardRecentUsers from './Dashboard/DashboardRecentUsers.vue'
import DashboardSystemInfo from './Dashboard/DashboardSystemInfo.vue'
import DashboardActivities from './Dashboard/DashboardActivities.vue'
const dashboard = useDashboardApi()
dashboard.load()
</script>

<template>
<UFHeaderPage title="Dashboard" />
<div class="uk-child-width-expand" uk-grid>
<DashboardStats
:users="dashboard.data.counter.users"
:roles="dashboard.data.counter.roles"
:groups="dashboard.data.counter.groups" />
</div>
<div class="uk-child-width-1-2" uk-grid>
<div>
<div class="uk-child-width-1-1" uk-grid>
<div>
<DashboardRecentUsers :users="dashboard.data.users" />
</div>
<div>
<DashboardSystemInfo
:info="dashboard.data.info"
:sprinkles="dashboard.data.sprinkles" />
</div>
</div>
</div>
<div>
<DashboardActivities />
</div>
</div>
<UFAdminDashboardPage />
</template>
38 changes: 0 additions & 38 deletions app/assets/views/Group/GroupInfo.vue

This file was deleted.

47 changes: 0 additions & 47 deletions app/assets/views/Group/GroupUsers.vue

This file was deleted.

Loading

0 comments on commit 9c300e7

Please sign in to comment.