mirror of
https://github.com/smartyellow/status.git
synced 2025-01-18 13:37:59 +00:00
Route prefix
This commit is contained in:
parent
be51bba14d
commit
7691085e8f
@ -45,7 +45,7 @@ function openOutage(title, id) {
|
||||
}
|
||||
|
||||
onMount(async () => {
|
||||
outages = (await api.get('/outages')).filter(o => o.services?.includes(service));
|
||||
outages = (await api.get('/status/outages')).filter(o => o.services?.includes(service));
|
||||
});
|
||||
|
||||
</script>
|
||||
|
@ -88,7 +88,7 @@
|
||||
|
||||
onMount(() => {
|
||||
proportionalGrid();
|
||||
const ws = new WebSocket('ws://__SERVER__/statusdashboard/socket');
|
||||
const ws = new WebSocket('ws://__SERVER__/status/dashboard/socket');
|
||||
|
||||
ws.onmessage = async evt => {
|
||||
const data = JSON.parse(evt.data || '""');
|
||||
|
@ -21,7 +21,7 @@ let webservices = [];
|
||||
async function refresh() {
|
||||
console.log('refresh');
|
||||
try {
|
||||
webservices = await api.get('/webservices');
|
||||
webservices = await api.get('/status/webservices');
|
||||
}
|
||||
catch (err) {
|
||||
console.error(err);
|
||||
|
@ -76,19 +76,19 @@ onMount(async function () {
|
||||
// get item, form and log for specified id
|
||||
try {
|
||||
// get settings, to read previewUrl
|
||||
settings = await api.get('/outages/settings');
|
||||
({ item, form, log } = isNew ? await api.post('/outages', {}, { init: true }) : await api.get('/outages/' + id));
|
||||
settings = await api.get('/status/outages/settings');
|
||||
({ item, form, log } = isNew ? await api.post('/status/outages', {}, { init: true }) : await api.get('/status/outages/' + id));
|
||||
// if existing item, set tabtitle to title of item
|
||||
if (!isNew) {
|
||||
dispatch('tabchanged', { title: item.name });
|
||||
}
|
||||
api.subscribe(pluginName + '/reload', async msg => {
|
||||
if (msg.id == item.id) {
|
||||
({ item, form, log } = await api.get('/outages' + id));
|
||||
({ item, form, log } = await api.get('/status/outages' + id));
|
||||
}
|
||||
});
|
||||
api.subscribe(entity + '/reload', async () => {
|
||||
({ form, log } = await api.get('/outages/' + id));
|
||||
({ form, log } = await api.get('/status/outages/' + id));
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
@ -99,8 +99,8 @@ onMount(async function () {
|
||||
}
|
||||
}
|
||||
else {
|
||||
filters = await api.get('/outages/filters');
|
||||
gridOptions.columns = await api.get('/outages/formats');
|
||||
filters = await api.get('/status/outages/filters');
|
||||
gridOptions.columns = await api.get('/status/outages/formats');
|
||||
// subscribe to 'reload' message
|
||||
api.subscribe(pluginName + '/reload', async () => {
|
||||
multifilter.submit();
|
||||
@ -131,8 +131,8 @@ async function saveChanges() {
|
||||
// save changes for outage in form
|
||||
savebar.start();
|
||||
const result = isNew ?
|
||||
await api.post('/outages', item) :
|
||||
await api.put('/outages/' + item.id, item);
|
||||
await api.post('/status/outages', item) :
|
||||
await api.put('/status/outages/' + item.id, item);
|
||||
savebar.stop(result);
|
||||
if (!result.errors) {
|
||||
log = result.log;
|
||||
@ -148,7 +148,7 @@ async function submitFilters({ detail }) {
|
||||
if (grid) {
|
||||
grid.reset();
|
||||
}
|
||||
items = await api.post('/outages/search', detail);
|
||||
items = await api.post('/status/outages/search', detail);
|
||||
}
|
||||
|
||||
async function deleteItem() {
|
||||
@ -158,7 +158,7 @@ async function deleteItem() {
|
||||
msg: translate('Are you sure you want to delete this item?', language),
|
||||
});
|
||||
dispatch('close');
|
||||
await api.delete('/outages/' + item.id);
|
||||
await api.delete('/status/outages/' + item.id);
|
||||
}
|
||||
catch (e) {
|
||||
console.log(e);
|
||||
|
@ -76,19 +76,19 @@ onMount(async function () {
|
||||
// get item, form and log for specified id
|
||||
try {
|
||||
// get settings, to read previewUrl
|
||||
settings = await api.get('/webservices/settings');
|
||||
({ item, form, log } = isNew ? await api.post('/webservices', {}, { init: true }) : await api.get('/webservices/' + id));
|
||||
settings = await api.get('/status/webservices/settings');
|
||||
({ item, form, log } = isNew ? await api.post('/status/webservices', {}, { init: true }) : await api.get('/status/webservices/' + id));
|
||||
// if existing item, set tabtitle to title of item
|
||||
if (!isNew) {
|
||||
dispatch('tabchanged', { title: item.name });
|
||||
}
|
||||
api.subscribe(pluginName + '/reload', async msg => {
|
||||
if (msg.id == item.id) {
|
||||
({ item, form, log } = await api.get('/webservices' + id));
|
||||
({ item, form, log } = await api.get('/status/webservices' + id));
|
||||
}
|
||||
});
|
||||
api.subscribe(entity + '/reload', async () => {
|
||||
({ form, log } = await api.get('/webservices/' + id));
|
||||
({ form, log } = await api.get('/status/webservices/' + id));
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
@ -99,8 +99,8 @@ onMount(async function () {
|
||||
}
|
||||
}
|
||||
else {
|
||||
filters = await api.get('/webservices/filters');
|
||||
gridOptions.columns = await api.get('/webservices/formats');
|
||||
filters = await api.get('/status/webservices/filters');
|
||||
gridOptions.columns = await api.get('/status/webservices/formats');
|
||||
// subscribe to 'reload' message
|
||||
api.subscribe(pluginName + '/reload', async () => {
|
||||
multifilter.submit();
|
||||
@ -131,8 +131,8 @@ async function saveChanges() {
|
||||
// save changes for web service in form
|
||||
savebar.start();
|
||||
const result = isNew ?
|
||||
await api.post('/webservices', item) :
|
||||
await api.put('/webservices/' + item.id, item);
|
||||
await api.post('/status/webservices', item) :
|
||||
await api.put('/status/webservices/' + item.id, item);
|
||||
savebar.stop(result);
|
||||
if (!result.errors) {
|
||||
log = result.log;
|
||||
@ -148,7 +148,7 @@ async function submitFilters({ detail }) {
|
||||
if (grid) {
|
||||
grid.reset();
|
||||
}
|
||||
items = await api.post('/webservices/search', detail);
|
||||
items = await api.post('/status/webservices/search', detail);
|
||||
}
|
||||
|
||||
async function deleteItem() {
|
||||
@ -158,7 +158,7 @@ async function deleteItem() {
|
||||
msg: translate('Are you sure you want to delete this item?', language),
|
||||
});
|
||||
dispatch('close');
|
||||
await api.delete('/webservices/' + item.id);
|
||||
await api.delete('/status/webservices/' + item.id);
|
||||
}
|
||||
catch (e) {
|
||||
console.log(e);
|
||||
|
@ -18,7 +18,7 @@ const icons = {
|
||||
let promise;
|
||||
|
||||
async function refresh() {
|
||||
promise = await api.get('/webservices');
|
||||
promise = await api.get('/status/webservices');
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
|
36
index.js
36
index.js
@ -239,7 +239,7 @@ module.exports = {
|
||||
routes: ({ server, settings }) => [
|
||||
|
||||
// Get all services
|
||||
{ route: '/webservices',
|
||||
{ route: '/status/webservices',
|
||||
method: 'get',
|
||||
requires: 'smartyellow/status/seeServices',
|
||||
handler: async (req, res, user) => {
|
||||
@ -270,7 +270,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
// Get details for specific service
|
||||
{ route: '/webservices/:id',
|
||||
{ route: '/status/webservices/:id',
|
||||
method: 'get',
|
||||
requires: 'smartyellow/status/seeServices',
|
||||
handler: async (req, res, user) => {
|
||||
@ -287,7 +287,7 @@ module.exports = {
|
||||
},
|
||||
},
|
||||
|
||||
{ route: '/webservices/search',
|
||||
{ route: '/status/webservices/search',
|
||||
method: 'post',
|
||||
requires: 'smartyellow/status/seeServices',
|
||||
handler: async (req, res, user) => {
|
||||
@ -302,7 +302,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
// Get filters for services
|
||||
{ route: '/webservices/filters',
|
||||
{ route: '/status/webservices/filters',
|
||||
method: 'get',
|
||||
requires: 'smartyellow/status/seeServices',
|
||||
handler: async (req, res, user) => {
|
||||
@ -314,7 +314,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
// Get formats for services
|
||||
{ route: '/webservices/formats',
|
||||
{ route: '/status/webservices/formats',
|
||||
method: 'get',
|
||||
requires: 'smartyellow/status/seeServices',
|
||||
handler: async (req, res, user) => {
|
||||
@ -327,7 +327,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
// Create new service
|
||||
{ route: '/webservices',
|
||||
{ route: '/status/webservices',
|
||||
method: 'post',
|
||||
requires: 'smartyellow/status/createServices',
|
||||
handler: async (req, res, user) => {
|
||||
@ -353,7 +353,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
// Update existing service
|
||||
{ route: '/webservices/:id',
|
||||
{ route: '/status/webservices/:id',
|
||||
method: 'put',
|
||||
requires: 'smartyellow/status/editServices',
|
||||
handler: async (req, res, user) => {
|
||||
@ -380,7 +380,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
// Delete specific service
|
||||
{ route: '/webservices/:id',
|
||||
{ route: '/status/webservices/:id',
|
||||
method: 'delete',
|
||||
requires: 'smartyellow/status/deleteServices',
|
||||
handler: async (req, res, user) => {
|
||||
@ -396,7 +396,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
// Get all outages
|
||||
{ route: '/outages',
|
||||
{ route: '/status/outages',
|
||||
method: 'get',
|
||||
requires: 'smartyellow/status/seeOutages',
|
||||
handler: async (req, res, user) => {
|
||||
@ -407,7 +407,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
// Get details for specific outage
|
||||
{ route: '/outages/:id',
|
||||
{ route: '/status/outages/:id',
|
||||
method: 'get',
|
||||
requires: 'smartyellow/status/seeOutages',
|
||||
handler: async (req, res, user) => {
|
||||
@ -424,7 +424,7 @@ module.exports = {
|
||||
},
|
||||
},
|
||||
|
||||
{ route: '/outages/search',
|
||||
{ route: '/status/outages/search',
|
||||
method: 'post',
|
||||
requires: 'smartyellow/status/seeOutages',
|
||||
handler: async (req, res, user) => {
|
||||
@ -439,7 +439,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
// Get filters for outages
|
||||
{ route: '/outages/filters',
|
||||
{ route: '/status/outages/filters',
|
||||
method: 'get',
|
||||
requires: 'smartyellow/status/seeOutages',
|
||||
handler: async (req, res, user) => {
|
||||
@ -451,7 +451,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
// Get formats for outages
|
||||
{ route: '/outages/formats',
|
||||
{ route: '/status/outages/formats',
|
||||
method: 'get',
|
||||
requires: 'smartyellow/status/seeOutages',
|
||||
handler: async (req, res, user) => {
|
||||
@ -464,7 +464,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
// Create new service
|
||||
{ route: '/outages',
|
||||
{ route: '/status/outages',
|
||||
method: 'post',
|
||||
requires: 'smartyellow/status/createOutages',
|
||||
handler: async (req, res, user) => {
|
||||
@ -490,7 +490,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
// Update existing service
|
||||
{ route: '/outages/:id',
|
||||
{ route: '/status/outages/:id',
|
||||
method: 'put',
|
||||
requires: 'smartyellow/status/editOutages',
|
||||
handler: async (req, res, user) => {
|
||||
@ -517,7 +517,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
// Delete specific service
|
||||
{ route: '/outages/:id',
|
||||
{ route: '/status/outages/:id',
|
||||
method: 'delete',
|
||||
requires: 'smartyellow/status/deleteOutages',
|
||||
handler: async (req, res, user) => {
|
||||
@ -532,7 +532,7 @@ module.exports = {
|
||||
},
|
||||
},
|
||||
|
||||
{ route: '/statusdashboard',
|
||||
{ route: '/status/dashboard',
|
||||
method: 'get',
|
||||
handler: async (req, res) => {
|
||||
try {
|
||||
@ -569,7 +569,7 @@ module.exports = {
|
||||
},
|
||||
},
|
||||
|
||||
{ route: '/statusdashboard/sound',
|
||||
{ route: '/status/dashboard/sound',
|
||||
method: 'get',
|
||||
handler: (req, res) => {
|
||||
res.headers['content-type'] = 'audio/x-wav';
|
||||
|
@ -17,7 +17,7 @@ const mapService = (s, beat) => ({
|
||||
|
||||
async function createDashboardSocket(server) {
|
||||
uws = server.ws({
|
||||
route: '/statusdashboard/socket',
|
||||
route: '/status/dashboard/socket',
|
||||
onOpen: async ws => {
|
||||
async function sendStatuses() {
|
||||
const services = await server.storage
|
||||
|
Loading…
Reference in New Issue
Block a user