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