-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a659a5e
Showing
29 changed files
with
1,115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/.idea | ||
/vendor | ||
/node_modules | ||
package-lock.json | ||
composer.phar | ||
composer.lock | ||
phpunit.xml | ||
.phpunit.result.cache | ||
.DS_Store | ||
Thumbs.db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"name": "coreproc/nova-artisan-cards", | ||
"description": "A Laravel Nova card.", | ||
"keywords": [ | ||
"laravel", | ||
"nova" | ||
], | ||
"license": "MIT", | ||
"require": { | ||
"php": "^7.3|^8.0", | ||
"spatie/laravel-backup": "^8.8" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Coreproc\\NovaArtisanCards\\": "src/" | ||
} | ||
}, | ||
"extra": { | ||
"laravel": { | ||
"providers": [ | ||
"Coreproc\\NovaArtisanCards\\CardServiceProvider" | ||
] | ||
} | ||
}, | ||
"config": { | ||
"sort-packages": true | ||
}, | ||
"minimum-stability": "dev", | ||
"prefer-stable": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"/js/card.js": "/js/card.js", | ||
"/css/card.css": "/css/card.css" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const mix = require('laravel-mix') | ||
const webpack = require('webpack') | ||
const path = require('path') | ||
|
||
class NovaExtension { | ||
name() { | ||
return 'nova-extension' | ||
} | ||
|
||
register(name) { | ||
this.name = name | ||
} | ||
|
||
webpackConfig(webpackConfig) { | ||
webpackConfig.externals = { | ||
vue: 'Vue', | ||
} | ||
|
||
webpackConfig.resolve.alias = { | ||
...(webpackConfig.resolve.alias || {}), | ||
'laravel-nova': path.join( | ||
__dirname, | ||
'../../vendor/laravel/nova/resources/js/mixins/packages.js' | ||
), | ||
} | ||
|
||
webpackConfig.output = { | ||
uniqueName: this.name, | ||
} | ||
} | ||
} | ||
|
||
mix.extend('nova', new NovaExtension()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"private": true, | ||
"scripts": { | ||
"dev": "npm run development", | ||
"development": "mix", | ||
"watch": "mix watch", | ||
"watch-poll": "mix watch -- --watch-options-poll=1000", | ||
"hot": "mix watch --hot", | ||
"prod": "npm run production", | ||
"production": "mix --production", | ||
"nova:install": "npm --prefix='../../vendor/laravel/nova' ci" | ||
}, | ||
"dependencies": { | ||
"laravel-nova-ui": "0.4.10" | ||
}, | ||
"devDependencies": { | ||
"@vue/compiler-sfc": "^3.2.22", | ||
"laravel-mix": "^6.0.41", | ||
"luxon": "^1.28.1", | ||
"postcss": "^8.3.11", | ||
"vue-loader": "^16.8.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* Nova Card CSS */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import MigrateFreshCard from "./components/MigrateFresh/MigrateFreshCard.vue"; | ||
import MaintenanceModeCard from "./components/MaintenanceMode/MaintenanceModeCard.vue"; | ||
import MaintenanceModeWarningCard from "./components/MaintenanceMode/MaintenanceModeWarningCard.vue"; | ||
import DatabaseBackupCard from "./components/DatabaseBackup/DatabaseBackupCard.vue"; | ||
|
||
Nova.booting((app, store) => { | ||
app.component('nova-artisan-migrate-fresh-card', MigrateFreshCard) | ||
app.component('nova-artisan-maintenance-mode-card', MaintenanceModeCard) | ||
app.component('nova-artisan-maintenance-mode-warning-card', MaintenanceModeWarningCard) | ||
app.component('nova-artisan-database-backup-card', DatabaseBackupCard) | ||
}) |
101 changes: 101 additions & 0 deletions
101
resources/js/components/DatabaseBackup/DatabaseBackupCard.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
<template> | ||
<Card class="flex flex-col justify-center min-h-8"> | ||
<div class="px-4 py-4 flex justify-between items-center"> | ||
<div class="flex-grow pr-2"> | ||
<h3 class="text-lg font-bold">Database Backup</h3> | ||
<p> | ||
This will create a database backup in the following disks: | ||
<span class="font-bold">{{ card.backup_disks }}</span> | ||
</p> | ||
<br/> | ||
<p class="text-xs" v-if="card.last_database_backup_at">Last database backup was generated at <span | ||
class="font-bold">{{ lastDatabaseBackupAt }}</span></p> | ||
</div> | ||
<div class="shrink-0 ml-4"> | ||
<Button | ||
@click="showModal = true" | ||
ref="confirmButton" | ||
state="default" | ||
> | ||
Backup Database | ||
</Button> | ||
</div> | ||
</div> | ||
<ConfirmActionModal | ||
:show="showModal" | ||
title="Create Database Backup" | ||
:message="'Are you sure you want to create a backup of the database? These will saved in the following disks: '+card.backup_disks" | ||
@confirm="handleConfirm" | ||
confirmButtonState="default" | ||
confirmButtonText="Backup Database" | ||
@close="handleClose" | ||
/> | ||
</Card> | ||
</template> | ||
|
||
<script> | ||
import ConfirmActionModal from "../Modals/ConfirmActionModal.vue"; | ||
import {Button} from "laravel-nova-ui"; | ||
import {DateTime} from "luxon"; | ||
export default { | ||
components: {Button, ConfirmActionModal}, | ||
props: [ | ||
'card', | ||
// The following props are only available on resource detail cards... | ||
// 'resource', | ||
// 'resourceId', | ||
// 'resourceName', | ||
], | ||
data() { | ||
return { | ||
loading: false, | ||
showModal: false, | ||
}; | ||
}, | ||
methods: { | ||
async handleConfirm() { | ||
this.loading = true; | ||
try { | ||
await Nova.request() | ||
.post('/nova-vendor/nova-artisan-cards/artisan/database-backup', { | ||
// Add any data you need to send with the request here | ||
}); | ||
} catch (error) { | ||
console.error('Error creating a database backup:', error); | ||
alert('Error creating a database backup. Please try again later.') | ||
// Handle error here | ||
} finally { | ||
this.showModal = false; | ||
this.loading = false; | ||
} | ||
}, | ||
handleClose() { | ||
this.showModal = false; | ||
this.loading = false; | ||
}, | ||
convertDateTime(dateTime) { | ||
return DateTime.fromISO(dateTime) | ||
.setZone(this.timezone) | ||
.toLocaleString({ | ||
year: 'numeric', | ||
month: '2-digit', | ||
day: '2-digit', | ||
hour: '2-digit', | ||
minute: '2-digit', | ||
timeZoneName: 'short', | ||
}) | ||
}, | ||
}, | ||
computed: { | ||
lastDatabaseBackupAt() { | ||
// if this.card.maintenance_mode_since doesn't have a value, return | ||
if (!this.card.last_database_backup_at) { | ||
return null; | ||
} | ||
return this.convertDateTime(this.card.last_database_backup_at) | ||
}, | ||
}, | ||
}; | ||
</script> |
33 changes: 33 additions & 0 deletions
33
resources/js/components/MaintenanceMode/Badges/MaintenanceModeBadge.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<template> | ||
<div class="inline-block"> | ||
<Badge | ||
class="whitespace-nowrap inline-flex items-center min-h-6 px-2 rounded-full uppercase text-xs font-bold whitespace-nowrap inline-flex items-center" | ||
:class="{ | ||
'bg-red-100 text-red-600 dark:bg-red-400 dark:text-red-900': isDownForMaintenance, | ||
'bg-green-100 text-green-600 dark:bg-green-400 dark:text-green-900': !isDownForMaintenance, | ||
}" | ||
> | ||
<span class="mr-1 -ml-1"> | ||
<Icon | ||
v-if="isDownForMaintenance" | ||
:solid="true" | ||
type="exclamation-circle" | ||
/> | ||
<Icon | ||
v-if="!isDownForMaintenance" | ||
:solid="true" | ||
type="check-circle" | ||
/> | ||
</span> | ||
{{ (isDownForMaintenance) ? 'Down' : 'Up' }} | ||
</Badge> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
props: { | ||
isDownForMaintenance: Boolean, | ||
} | ||
} | ||
</script> |
Oops, something went wrong.