Skip to content

Commit

Permalink
Add deletion for admins
Browse files Browse the repository at this point in the history
  • Loading branch information
soasada committed Jan 12, 2021
1 parent 2fe747f commit 8642722
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 31 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 1.0.45 (12-01-2021)

### Frontend

* Add deletion for admins.

## 1.0.44 (11-01-2021)

### Frontend
Expand Down
1 change: 0 additions & 1 deletion kemenu-admin-backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<artifactId>kemenu-admin-backend</artifactId>

<properties>
<kotlin.version>1.4.21</kotlin.version>
<logstash-logback-encoder.version>6.6</logstash-logback-encoder.version>
<java-jwt.version>3.12.0</java-jwt.version>
<moneta.version>1.4.2</moneta.version>
Expand Down
37 changes: 26 additions & 11 deletions kemenu-admin-frontend/src/admin/AdminManagement.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import BorderBottomTitle from '@/layout/BorderBottomTitle.vue';
import ResponsiveTable from '@/responsive_table/ResponsiveTable.vue';
import HttpClient from '@/http/HttpClient';
import AdminResponse from '@/admin/AdminResponse';
import AdminService from '@/admin/AdminService';
export default defineComponent({
name: 'AdminManagement',
Expand All @@ -34,26 +35,40 @@ export default defineComponent({
const loading = ref(true);
const router = useRouter();
HttpClient.get('/v1/admins', store.getters.getAccessToken).then((response: Response) => {
response.json().then((adminResponse: AdminResponse[]) => {
admins.value = adminResponse;
loading.value = false;
}).catch((error) => {
console.log(error);
loading.value = false;
});
});
AdminService.findAll(store.getters.getAccessToken)
.then(response => {
admins.value = response;
loading.value = false;
})
.catch(error => {
console.log(error);
loading.value = false;
});
const onEdit = (admin: AdminResponse) => {
router.push('/admin/user/' + admin.id);
};
const onDelete = (admin: AdminResponse) => {
console.log('Deleting: ' + admin.email);
HttpClient.delete('/v1/admins', admin.id, store.getters.getAccessToken)
.then(() => {
AdminService.findAll(store.getters.getAccessToken)
.then(response => {
admins.value = response;
loading.value = false;
})
.catch(error => {
console.log(error);
loading.value = false;
});
})
.catch(error => {
console.log(error);
});
};
const createAdmin = () => {
router.push('/create/admin');
router.push({name: 'CreateAdminUser'});
}
return {store, admins, loading, onEdit, onDelete, createAdmin};
Expand Down
15 changes: 15 additions & 0 deletions kemenu-admin-frontend/src/admin/AdminService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import AdminResponse from '@/admin/AdminResponse';
import HttpClient from '@/http/HttpClient';

export default class AdminService {
private static ENDPOINT = '/v1/admins';

private constructor() {
// Utility class, does not make sense to have an instance
}

static async findAll(token: string): Promise<AdminResponse[]> {
const response = await HttpClient.get(AdminService.ENDPOINT, token);
return await response.json();
}
}
24 changes: 24 additions & 0 deletions kemenu-admin-frontend/src/admin/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import {RouteRecordRaw} from 'vue-router';

const adminRoutes: Array<RouteRecordRaw> = [
{
path: '/admin/management',
name: 'AdminManagement',
component: () => import(/* webpackChunkName: "adminManagement" */ './AdminManagement.vue'),
meta: {requiresAuth: true}
},
{
path: '/admin/create',
name: 'CreateAdminUser',
component: () => import(/* webpackChunkName: "createAdminUser" */ './CreateAdminUser.vue'),
meta: {requiresAuth: true}
},
{
path: '/admin/user/:id',
name: 'EditAdminUser',
component: () => import(/* webpackChunkName: "editAdminUser" */ './EditAdminUser.vue'),
meta: {requiresAuth: true}
}
];

export default adminRoutes;
22 changes: 3 additions & 19 deletions kemenu-admin-frontend/src/router/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {createRouter, createWebHashHistory, RouteRecordRaw} from 'vue-router';
import blog from '@/blog';
import customers from '@/customers';
import admin from '@/admin';

const routes: Array<RouteRecordRaw> = [
{
Expand All @@ -13,30 +14,13 @@ const routes: Array<RouteRecordRaw> = [
name: 'Dashboard',
component: () => import(/* webpackChunkName: "dashboard" */ '../dashboard/Dashboard.vue'),
meta: {requiresAuth: true}
},
{
path: '/admin/management',
name: 'AdminManagement',
component: () => import(/* webpackChunkName: "adminManagement" */ '../admin/AdminManagement.vue'),
meta: {requiresAuth: true}
},
{
path: '/create/admin',
name: 'CreateAdminUser',
component: () => import(/* webpackChunkName: "createAdminUser" */ '../admin/CreateAdminUser.vue'),
meta: {requiresAuth: true}
},
{
path: '/admin/user/:id',
name: 'EditAdminUser',
component: () => import(/* webpackChunkName: "editAdminUser" */ '../admin/EditAdminUser.vue'),
meta: {requiresAuth: true}
}
];

const finalRoutes = routes
.concat(blog)
.concat(customers);
.concat(customers)
.concat(admin);

const router = createRouter({
history: createWebHashHistory(),
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

<properties>
<java.version>15</java.version>
<kotlin.version>1.4.21</kotlin.version>
<maven-release-plugin.version>3.0.0-M1</maven-release-plugin.version>
</properties>

Expand Down

0 comments on commit 8642722

Please sign in to comment.