mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 12:20:22 +00:00
Finish API documentation and token auth (references #5)
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
$(function ()
|
||||
{
|
||||
const swaggerUi = SwaggerUIBundle({
|
||||
url: U('/api/get-open-api-specification'),
|
||||
dom_id: '#swagger-ui',
|
||||
deepLinking: true,
|
||||
presets: [
|
||||
SwaggerUIBundle.presets.apis,
|
||||
SwaggerUIStandalonePreset
|
||||
],
|
||||
plugins: [
|
||||
SwaggerUIBundle.plugins.DownloadUrl
|
||||
],
|
||||
layout: 'StandaloneLayout'
|
||||
});
|
||||
|
||||
window.ui = swaggerUi;
|
||||
});
|
@@ -1,7 +1,10 @@
|
||||
$(document).on('click', '.battery-delete-button', function(e)
|
||||
{
|
||||
var objectName = $(e.currentTarget).attr('data-battery-name');
|
||||
var objectId = $(e.currentTarget).attr('data-battery-id');
|
||||
|
||||
bootbox.confirm({
|
||||
message: L('Are you sure to delete battery "#1"?', $(e.currentTarget).attr('data-battery-name')),
|
||||
message: L('Are you sure to delete battery "#1"?', objectName),
|
||||
buttons: {
|
||||
confirm: {
|
||||
label: L('Yes'),
|
||||
@@ -16,7 +19,7 @@
|
||||
{
|
||||
if (result === true)
|
||||
{
|
||||
Grocy.Api.Get('delete-object/batteries/' + $(e.currentTarget).attr('data-battery-id'),
|
||||
Grocy.Api.Get('delete-object/batteries/' + objectId,
|
||||
function(result)
|
||||
{
|
||||
window.location.href = U('/batteries');
|
||||
|
@@ -1,6 +1,6 @@
|
||||
Grocy.Components.HabitCard = { };
|
||||
|
||||
Grocy.Components.HabitCard.Refresh = function (habitId)
|
||||
Grocy.Components.HabitCard.Refresh = function(habitId)
|
||||
{
|
||||
Grocy.Api.Get('habits/get-habit-details/' + habitId,
|
||||
function(habitDetails)
|
||||
|
@@ -60,7 +60,7 @@ $('#product_id').on('change', function(e)
|
||||
$('#product_id_text_input').addClass('has-error');
|
||||
$('#product_id_text_input').parent('.input-group').addClass('has-error');
|
||||
$('#product_id_text_input').closest('.form-group').addClass('has-error');
|
||||
$('#product-error').text('This product is not in stock.');
|
||||
$('#product-error').text(L('This product is not in stock'));
|
||||
$('#product-error').show();
|
||||
$('#product_id_text_input').focus();
|
||||
}
|
||||
|
@@ -41,7 +41,7 @@ $('.input-group-habit-period-type').on('change', function(e)
|
||||
|
||||
if (periodType === 'dynamic-regular')
|
||||
{
|
||||
$('#habit-period-type-info').text('This means it is estimated that a new "execution" of this habit is tracked ' + periodDays.toString() + ' days after the last was tracked.');
|
||||
$('#habit-period-type-info').text(L('This means it is estimated that a new execution of this habit is tracked #1 days after the last was tracked', periodDays.toString()));
|
||||
$('#habit-period-type-info').show();
|
||||
}
|
||||
else
|
||||
|
@@ -1,7 +1,10 @@
|
||||
$(document).on('click', '.habit-delete-button', function(e)
|
||||
{
|
||||
var objectName = $(e.currentTarget).attr('data-habit-name');
|
||||
var objectId = $(e.currentTarget).attr('data-habit-id');
|
||||
|
||||
bootbox.confirm({
|
||||
message: L('Are you sure to delete habit "#1"?', $(e.currentTarget).attr('data-habit-name')),
|
||||
message: L('Are you sure to delete habit "#1"?', objectName),
|
||||
buttons: {
|
||||
confirm: {
|
||||
label: L('Yes'),
|
||||
@@ -16,7 +19,7 @@
|
||||
{
|
||||
if (result === true)
|
||||
{
|
||||
Grocy.Api.Get('delete-object/habits/' + $(e.currentTarget).attr('data-habit-id'),
|
||||
Grocy.Api.Get('delete-object/habits/' + objectId,
|
||||
function(result)
|
||||
{
|
||||
window.location.href = U('/habits');
|
||||
|
@@ -291,14 +291,14 @@ $('#new_amount').on('change', function(e)
|
||||
if (newAmount > productStockAmount)
|
||||
{
|
||||
var amountToAdd = newAmount - productDetails.stock_amount;
|
||||
$('#inventory-change-info').text('This means ' + amountToAdd.toString() + ' ' + productDetails.quantity_unit_stock.name + ' will be added to stock');
|
||||
$('#inventory-change-info').text(L('This means #1 will be added to stock', amountToAdd.toString() + ' ' + productDetails.quantity_unit_stock.name));
|
||||
$('#inventory-change-info').show();
|
||||
$('#best_before_date').attr('required', 'required');
|
||||
}
|
||||
else if (newAmount < productStockAmount)
|
||||
{
|
||||
var amountToRemove = productStockAmount - newAmount;
|
||||
$('#inventory-change-info').text('This means ' + amountToRemove.toString() + ' ' + productDetails.quantity_unit_stock.name + ' will be removed from stock');
|
||||
$('#inventory-change-info').text(L('This means #1 will be removed from stock', amountToRemove.toString() + ' ' + productDetails.quantity_unit_stock.name));
|
||||
$('#inventory-change-info').show();
|
||||
$('#best_before_date').removeAttr('required');
|
||||
}
|
||||
|
@@ -1,7 +1,10 @@
|
||||
$(document).on('click', '.location-delete-button', function(e)
|
||||
{
|
||||
var objectName = $(e.currentTarget).attr('data-location-name');
|
||||
var objectId = $(e.currentTarget).attr('data-location-id');
|
||||
|
||||
bootbox.confirm({
|
||||
message: L('Are you sure to delete location "#1"?', $(e.currentTarget).attr('data-location-name')),
|
||||
message: L('Are you sure to delete location "#1"?', objectName),
|
||||
buttons: {
|
||||
confirm: {
|
||||
label: L('Yes'),
|
||||
@@ -16,7 +19,7 @@
|
||||
{
|
||||
if (result === true)
|
||||
{
|
||||
Grocy.Api.Get('delete-object/locations/' + $(e.currentTarget).attr('data-location-id'),
|
||||
Grocy.Api.Get('delete-object/locations/' + objectId,
|
||||
function(result)
|
||||
{
|
||||
window.location.href = U('/locations');
|
||||
|
50
public/viewjs/manageapikeys.js
Normal file
50
public/viewjs/manageapikeys.js
Normal file
@@ -0,0 +1,50 @@
|
||||
$(document).on('click', '.apikey-delete-button', function(e)
|
||||
{
|
||||
var objectName = $(e.currentTarget).attr('data-apikey-apikey');
|
||||
var objectId = $(e.currentTarget).attr('data-apikey-id');
|
||||
|
||||
bootbox.confirm({
|
||||
message: L('Are you sure to delete API key "#1"?', objectName),
|
||||
buttons: {
|
||||
confirm: {
|
||||
label: L('Yes'),
|
||||
className: 'btn-success'
|
||||
},
|
||||
cancel: {
|
||||
label: L('No'),
|
||||
className: 'btn-danger'
|
||||
}
|
||||
},
|
||||
callback: function(result)
|
||||
{
|
||||
if (result === true)
|
||||
{
|
||||
Grocy.Api.Get('delete-object/api_keys/' + objectId,
|
||||
function(result)
|
||||
{
|
||||
window.location.href = U('/manageapikeys');
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#apikeys-table').DataTable({
|
||||
'pageLength': 50,
|
||||
'order': [[4, 'desc']],
|
||||
'columnDefs': [
|
||||
{ 'orderable': false, 'targets': 0 }
|
||||
],
|
||||
'language': JSON.parse(L('datatables_localization'))
|
||||
});
|
||||
|
||||
var createdApiKeyId = GetUriParam('CreatedApiKeyId');
|
||||
if (createdApiKeyId !== undefined)
|
||||
{
|
||||
$('#apiKeyRow_' + createdApiKeyId).effect('highlight', { }, 3000);
|
||||
}
|
26
public/viewjs/openapiui.js
Normal file
26
public/viewjs/openapiui.js
Normal file
@@ -0,0 +1,26 @@
|
||||
function HideTopbarPlugin()
|
||||
{
|
||||
return {
|
||||
components: {
|
||||
Topbar: function () { return null }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const swaggerUi = SwaggerUIBundle({
|
||||
url: Grocy.OpenApi.SpecUrl,
|
||||
dom_id: '#swagger-ui',
|
||||
deepLinking: true,
|
||||
presets: [
|
||||
SwaggerUIBundle.presets.apis,
|
||||
SwaggerUIStandalonePreset
|
||||
],
|
||||
plugins: [
|
||||
SwaggerUIBundle.plugins.DownloadUrl,
|
||||
HideTopbarPlugin
|
||||
],
|
||||
layout: 'StandaloneLayout',
|
||||
docExpansion: "list"
|
||||
});
|
||||
|
||||
window.ui = swaggerUi;
|
@@ -1,7 +1,10 @@
|
||||
$(document).on('click', '.product-delete-button', function(e)
|
||||
{
|
||||
var objectName = $(e.currentTarget).attr('data-product-name');
|
||||
var objectId = $(e.currentTarget).attr('data-product-id');
|
||||
|
||||
bootbox.confirm({
|
||||
message: L('Are you sure to delete product "#1"?', $(e.currentTarget).attr('data-product-name')),
|
||||
message: L('Are you sure to delete product "#1"?', objectName),
|
||||
buttons: {
|
||||
confirm: {
|
||||
label: L('Yes'),
|
||||
@@ -16,7 +19,7 @@
|
||||
{
|
||||
if (result === true)
|
||||
{
|
||||
Grocy.Api.Get('delete-object/products/' + $(e.currentTarget).attr('data-product-id'),
|
||||
Grocy.Api.Get('delete-object/products/' + objectId,
|
||||
function(result)
|
||||
{
|
||||
window.location.href = U('/products');
|
||||
|
@@ -1,7 +1,10 @@
|
||||
$(document).on('click', '.quantityunit-delete-button', function(e)
|
||||
{
|
||||
var objectName = $(e.currentTarget).attr('data-quantityunit-name');
|
||||
var objectId = $(e.currentTarget).attr('data-quantityunit-id');
|
||||
|
||||
bootbox.confirm({
|
||||
message: L('Are you sure to delete quantity unit "#1"?', $(e.currentTarget).attr('data-quantityunit-name')),
|
||||
message: L('Are you sure to delete quantity unit "#1"?', objectName),
|
||||
buttons: {
|
||||
confirm: {
|
||||
label: 'Yes',
|
||||
@@ -16,7 +19,7 @@
|
||||
{
|
||||
if (result === true)
|
||||
{
|
||||
Grocy.Api.Get('delete-object/quantity_units/' + $(e.currentTarget).attr('data-quantityunit-id'),
|
||||
Grocy.Api.Get('delete-object/quantity_units/' + objectId,
|
||||
function(result)
|
||||
{
|
||||
window.location.href = U('/quantityunits');
|
||||
|
Reference in New Issue
Block a user