Skip to content

Commit

Permalink
Added try block for images without RepoTags
Browse files Browse the repository at this point in the history
Issue #85
  • Loading branch information
lllllllillllllillll committed Jun 17, 2024
1 parent 8746155 commit da9692b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
8 changes: 5 additions & 3 deletions controllers/images.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,11 @@ export const Images = async function(req, res) {
size = size.toFixed(2);

let status = '';
if (container_images.includes(images[i].RepoTags[0])) {
status = 'In use';
}
try {
if (container_images.includes(images[i].RepoTags[0])) {
status = 'In use';
}
} catch {}

let details = `
<tr>
Expand Down
10 changes: 7 additions & 3 deletions controllers/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const Settings = (req, res) => {
}


export const settingsAction = (req, res) => {
export const settingsAction = async (req, res) => {
let action = req.params.action;
let name = req.header('hx-trigger-name');
let value = req.header('hx-trigger');
Expand All @@ -21,9 +21,13 @@ export const settingsAction = (req, res) => {
console.log(`value: ${value}`);

if ((action == 'links') && (req.body.links == 'on')) {
console.log('links on');
let exists = await ServerSettings.findOne({ where: {key: 'links'}});
if (!exists) { const newSetting = await ServerSettings.create({ key: 'links', value: 'on'}); }
const setting = await ServerSettings.update({value: 'on'}, {where: {key: 'links'}});
} else if ((action == 'links') && (!req.body.links)) {
console.log('links off');
let exists = await ServerSettings.findOne({ where: {key: 'links'}});
if (!exists) { const newSetting = await ServerSettings.create({ key: 'links', value: 'off'}); }
const setting = await ServerSettings.update({value: 'off'}, {where: {key: 'links'}});
}


Expand Down
4 changes: 2 additions & 2 deletions database/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ export const Notification = sequelize.define('Notification', {
},
});

export const ServerSettings = sequelize.define('Settings', {
export const ServerSettings = sequelize.define('ServerSettings', {
id: {
type: DataTypes.INTEGER,
autoIncrement: true,
Expand All @@ -242,7 +242,7 @@ export const ServerSettings = sequelize.define('Settings', {
}
});

export const UserSettings = sequelize.define('Settings', {
export const UserSettings = sequelize.define('UserSettings', {
id: {
type: DataTypes.INTEGER,
autoIncrement: true,
Expand Down

0 comments on commit da9692b

Please sign in to comment.