diff --git a/dashboard/public/js/index.js b/dashboard/public/js/index.js index ddaf5f47a..3642525dd 100644 --- a/dashboard/public/js/index.js +++ b/dashboard/public/js/index.js @@ -109,8 +109,8 @@ app.config(['$routeProvider', function ($routeProvider) { controller: 'SystemController', templateUrl: 'views/system.html?' + window.VITE_CACHE_ID }).when('/services', { - controller: 'ServicesController', - templateUrl: 'views/services.html?' + window.VITE_CACHE_ID + // controller: 'ServicesController', + // templateUrl: 'views/services.html?' + window.VITE_CACHE_ID }).when('/volumes', { // controller: 'VolumesController', // templateUrl: 'views/volumes.html?' + window.VITE_CACHE_ID diff --git a/dashboard/src/components/Index.vue b/dashboard/src/components/Index.vue index de39cd634..2a962a12f 100644 --- a/dashboard/src/components/Index.vue +++ b/dashboard/src/components/Index.vue @@ -5,6 +5,7 @@ import { Notification } from 'pankow'; import AppsView from './AppsView.vue'; import AppstoreView from './AppstoreView.vue'; import ProfileView from './ProfileView.vue'; +import ServicesView from '../views/ServicesView.vue'; import SupportView from './SupportView.vue'; import UserDirectoryView from './UserDirectoryView.vue'; import VolumesView from './VolumesView.vue'; @@ -18,6 +19,7 @@ const VIEWS = { APPSTORE: 'appstore', PROFILE: 'profile', SUPPORT: 'support', + SERVICES: 'services', USER_DIRECTORY: 'user-directory', VOLUMES: 'volumes', }; @@ -30,6 +32,7 @@ export default { Notification, ProfileView, SupportView, + ServicesView, UserDirectoryView, VolumesView, }, @@ -62,6 +65,8 @@ export default { that.view = VIEWS.APPSTORE; } else if (view === VIEWS.PROFILE) { that.view = VIEWS.PROFILE; + } else if (view === VIEWS.SERVICES) { + that.view = VIEWS.SERVICES; } else if (view === VIEWS.SUPPORT) { that.view = VIEWS.SUPPORT; } else if (view === VIEWS.USER_DIRECTORY) { @@ -91,6 +96,7 @@ export default { + diff --git a/dashboard/src/models/AppsModel.js b/dashboard/src/models/AppsModel.js index 8965a191e..ee1742326 100644 --- a/dashboard/src/models/AppsModel.js +++ b/dashboard/src/models/AppsModel.js @@ -152,7 +152,7 @@ function create(origin, accessToken, id) { return result.body.apps; }, - async get() { + async get(id) { let error, result; try { result = await fetcher.get(`${origin}/api/v1/apps/${id}`, { access_token: accessToken }); @@ -160,13 +160,8 @@ function create(origin, accessToken, id) { error = e; } - if (error || result.status !== 200) { - console.error(`Invalid app ${id}`, error || result.status); - this.fatalError = `Invalid app ${id}`; - return; - } - - return result.body; + if (error || result.status !== 200) return [error || result]; + return [null, result.body]; }, async restart() { let error, result; diff --git a/dashboard/src/models/ServicesModel.js b/dashboard/src/models/ServicesModel.js new file mode 100644 index 000000000..96c290a93 --- /dev/null +++ b/dashboard/src/models/ServicesModel.js @@ -0,0 +1,44 @@ + +import { fetcher } from 'pankow'; + +function create(origin, accessToken) { + return { + async list() { + let error, result; + try { + result = await fetcher.get(`${origin}/api/v1/services`, { access_token: accessToken }); + } catch (e) { + error = e; + } + + if (error || result.status !== 200) return [error || result]; + return [null, result.body.services]; + }, + async get(id) { + let error, result; + try { + result = await fetcher.get(`${origin}/api/v1/services/${id}`, { access_token: accessToken }); + } catch (e) { + error = e; + } + + if (error || result.status !== 200) return [error || result]; + return [null, result.body.service]; + }, + async restart(id) { + let error, result; + try { + result = await fetcher.post(`${origin}/api/v1/services/${id}/restart`, {}, { access_token: accessToken }); + } catch (e) { + error = e; + } + + if (error || result.status !== 202) return [error || result]; + return [null]; + }, + }; +} + +export default { + create, +}; diff --git a/dashboard/src/views/ServicesView.vue b/dashboard/src/views/ServicesView.vue new file mode 100644 index 000000000..667bb2265 --- /dev/null +++ b/dashboard/src/views/ServicesView.vue @@ -0,0 +1,143 @@ + + +