Skip to content
This repository has been archived by the owner on Mar 18, 2024. It is now read-only.

Commit

Permalink
Add basic 'your version, latest version' info
Browse files Browse the repository at this point in the history
  • Loading branch information
mattstauffer committed Sep 5, 2018
1 parent c5927f6 commit b21c298
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 33 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
],
"license": "MIT",
"require": {
"php": ">=7.1.0"
"php": ">=7.1.0",
"kitetail/zttp": "^0.3.0"
},
"autoload": {
"psr-4": {
Expand Down
51 changes: 42 additions & 9 deletions dist/js/card.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ module.exports = __webpack_require__(6);
/***/ (function(module, exports, __webpack_require__) {

Nova.booting(function (Vue, router) {
Vue.component('nova-releases', __webpack_require__(2));
Vue.component('nova-releases-latest', __webpack_require__(2));
});

/***/ }),
Expand Down Expand Up @@ -105,7 +105,7 @@ var Component = normalizeComponent(
__vue_scopeId__,
__vue_module_identifier__
)
Component.options.__file = "resources/js/components/Card.vue"
Component.options.__file = "resources/js/components/LatestRelease.vue"

/* hot reload */
if (false) {(function () {
Expand All @@ -114,9 +114,9 @@ if (false) {(function () {
if (!hotAPI.compatible) return
module.hot.accept()
if (!module.hot.data) {
hotAPI.createRecord("data-v-b9bc2c0a", Component.options)
hotAPI.createRecord("data-v-5601d625", Component.options)
} else {
hotAPI.reload("data-v-b9bc2c0a", Component.options)
hotAPI.reload("data-v-5601d625", Component.options)
}
module.hot.dispose(function (data) {
disposed = true
Expand Down Expand Up @@ -249,12 +249,33 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
//
//
//
//
//
//
//

/* harmony default export */ __webpack_exports__["default"] = ({
props: ['card'],

data: function data() {
return {
installed_version: null,
releases: [],
current_release_version: null
};
},

mounted: function mounted() {
//
var _this = this;

Nova.request().get('/nova-vendor/nova-releases/releases').then(function (response) {
_this.releases = response.data.releases;
_this.current_release_version = response.data.current_version;
});

Nova.request().get('/nova-vendor/nova-releases/installed-version').then(function (response) {
_this.installed_version = response.data.installed_version;
});
}
});

Expand All @@ -271,9 +292,21 @@ var render = function() {
{ staticClass: "flex flex-col items-center justify-center" },
[
_c("div", { staticClass: "px-3 py-3" }, [
_c("h1", { staticClass: "text-center text-3xl text-80 font-light" }, [
_vm._v("Nova Releases")
])
_c(
"h1",
{ staticClass: "text-center text-3xl text-80 font-light mt-4 mb-4" },
[_vm._v("Nova Releases")]
),
_vm._v(
"\n\n Latest version: " + _vm._s(_vm.current_release_version)
),
_c("br"),
_c("br"),
_vm._v(
"\n\n Installed version: " + _vm._s(_vm.installed_version)
),
_c("br"),
_c("br")
])
]
)
Expand All @@ -284,7 +317,7 @@ module.exports = { render: render, staticRenderFns: staticRenderFns }
if (false) {
module.hot.accept()
if (module.hot.data) {
require("vue-hot-reload-api") .rerender("data-v-b9bc2c0a", module.exports)
require("vue-hot-reload-api") .rerender("data-v-5601d625", module.exports)
}
}

Expand Down
2 changes: 1 addition & 1 deletion resources/js/card.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Nova.booting((Vue, router) => {
Vue.component('nova-releases', require('./components/Card'));
Vue.component('nova-releases-latest', require('./components/LatestRelease'));
})
17 changes: 0 additions & 17 deletions resources/js/components/Card.vue

This file was deleted.

36 changes: 36 additions & 0 deletions resources/js/components/LatestRelease.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<template>
<card class="flex flex-col items-center justify-center">
<div class="px-3 py-3">
<h1 class="text-center text-3xl text-80 font-light mt-4 mb-4">Nova Releases</h1>

Latest version: {{ current_release_version }}<br><br>

Installed version: {{ installed_version }}<br><br>
</div>
</card>
</template>

<script>
export default {
props: ['card'],
data: () => {
return {
installed_version: null,
releases: [],
current_release_version: null,
};
},
mounted() {
Nova.request().get('/nova-vendor/nova-releases/releases').then(response => {
this.releases = response.data.releases;
this.current_release_version = response.data.current_version;
});
Nova.request().get('/nova-vendor/nova-releases/installed-version').then(response => {
this.installed_version = response.data.installed_version;
});
},
}
</script>
18 changes: 15 additions & 3 deletions routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use Laravel\Nova\Nova;
use Zttp\Zttp;

/*
|--------------------------------------------------------------------------
Expand All @@ -14,6 +16,16 @@
|
*/

// Route::get('/endpoint', function (Request $request) {
// //
// });
Route::get('releases', function (Request $request) {
$data = Cache::remember('tightenco-nova-releases::releases', 60, function () {
// @todo: Cache it on novapackages.com so as to save load on the Nova folks <3
$response = Zttp::get('https://nova.laravel.com/api/releases');
return $response->json();
});

return response()->json($data);
});

Route::get('installed-version', function (Request $request) {
return response()->json(['installed_version' => Nova::version()]);
});
4 changes: 2 additions & 2 deletions src/NovaReleases.php → src/LatestRelease.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Laravel\Nova\Card;

class NovaReleases extends Card
class LatestRelease extends Card
{
/**
* The width of the card (1/3, 1/2, or full).
Expand All @@ -20,6 +20,6 @@ class NovaReleases extends Card
*/
public function component()
{
return 'nova-releases';
return 'nova-releases-latest';
}
}

0 comments on commit b21c298

Please sign in to comment.