Skip to content

Commit

Permalink
Merge pull request #269 from macmedia/VersionCheck
Browse files Browse the repository at this point in the history
Update VersionCheck Component
  • Loading branch information
HDVinnie authored Apr 28, 2018
2 parents 04073b2 + 64a56cb commit 1da0c2f
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 39 deletions.
7 changes: 5 additions & 2 deletions app/Http/Controllers/Staff/VersionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ public function checkVersion()
$client = new Client();
$response = json_decode($client->get('https://api.github.com/repos/HDInnovations/UNIT3D/releases')->getBody());
$lastestVersion = $response[0]->tag_name;
return response(['updated' => version_compare($this->version, $lastestVersion, '<') ? 'true' : 'false']);
return response([
'updated' => version_compare($this->version, $lastestVersion, '<') ? 'false' : 'true',
'latestversion' => $lastestVersion
]);
}
}
}
85 changes: 48 additions & 37 deletions resources/assets/js/components/Version.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,45 +7,56 @@
</template>

<script>
import Swal from 'sweetalert2'
import Swal from "sweetalert2";
export default {
export default {
data() {
return {
loading: false
};
},
data() {
return {
loading: false,
}
},
methods: {
checkUpdate() {
this.loading = true;
axios.get('/staff_dashboard/check-update')
.then((response) => {
if (response.data.updated === false) {
this.loading = false;
Swal({
position: 'center',
type: 'warning',
title: 'There Is A Update Available!',
showConfirmButton: false,
timer: 4500
})
} else {
this.loading = false;
Swal({
position: 'center',
type: 'success',
title: 'You Are Running The Latest Version Of UNIT3D!',
showConfirmButton: false,
timer: 4500
})
}
})
.catch((error) => {
Swal('Oops...', error.response.data, 'error')
})
},
methods: {
checkUpdate() {
this.loading = true;
axios
.get("/staff_dashboard/check-update")
.then(response => {
if (response.data.updated === "false") {
this.loading = false;
Swal({
position: "center",
type: "warning",
title: "There Is A Update Available!",
showCancelButton: true,
showConfirmButton: true,
confirmButtonText:
'<i class="fa fa-github"></i> Download from Github',
html: `New version <a href="//github.com/HDInnovations/UNIT3D/releases">v${
response.data.latestversion
} </a> is available`
}).then(result => {
if (result.value) {
window.location.assign(
"//github.com/HDInnovations/UNIT3D/releases"
);
}
});
} else {
this.loading = false;
Swal({
position: "center",
type: "success",
title: "You Are Running The Latest Version Of UNIT3D!",
showCancelButton: false,
timer: 4500
});
}
})
.catch(error => {
Swal("Oops...", error.response.data, "error");
});
}
}
};
</script>

0 comments on commit 1da0c2f

Please sign in to comment.