Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
sandervanhooft committed Jun 9, 2020
1 parent 6f5b344 commit c6e3692
Show file tree
Hide file tree
Showing 3 changed files with 243 additions and 0 deletions.
104 changes: 104 additions & 0 deletions install-stubs/app/Policies/UserPolicy.php.stub
@@ -0,0 +1,104 @@
<?php

namespace App\Policies;

use App\User;
use Illuminate\Auth\Access\HandlesAuthorization;

class stub
{
use HandlesAuthorization;

/**
* Determine whether the user can view any models.
*
* @param \App\User $user
* @return mixed
*/
public function viewAny(User $user)
{
//
}

/**
* Determine whether the user can view the model.
*
* @param \App\User $user
* @param \App\User $model
* @return mixed
*/
public function view(User $user, User $model)
{
//
}

/**
* Determine whether the user can create models.
*
* @param \App\User $user
* @return mixed
*/
public function create(User $user)
{
//
}

/**
* Determine whether the user can update the model.
*
* @param \App\User $user
* @param \App\User $model
* @return mixed
*/
public function update(User $user, User $model)
{
//
}

/**
* Determine whether the user can delete the model.
*
* @param \App\User $user
* @param \App\User $model
* @return mixed
*/
public function delete(User $user, User $model)
{
//
}

/**
* Determine whether the user can restore the model.
*
* @param \App\User $user
* @param \App\User $model
* @return mixed
*/
public function restore(User $user, User $model)
{
//
}

/**
* Determine whether the user can permanently delete the model.
*
* @param \App\User $user
* @param \App\User $model
* @return mixed
*/
public function forceDelete(User $user, User $model)
{
//
}

/**
* Determine whether the user can upload files.
*
* @param \App\User $user
* @return mixed
*/
public function uploadFiles(User $user)
{
return true;
}
}
@@ -0,0 +1,65 @@
Vue.component('spark-update-profile-photo', {
props: ['user'],

/**
* The component's data.
*/
data() {
return {
form: new SparkForm({})
};
},


methods: {
/**
* Update the user's profile photo.
*/
update(e) {
e.preventDefault();

if ( ! this.$refs.photo.files.length) {
return;
}

var self = this;

this.form.startProcessing();

// Stream the file to S3
window.Vapor.store(this.$refs.photo.files[0], {
progress: progress => {
this.uploadProgress = Math.round(progress * 100);
}
}).then(response => {
// Now we send details of the uploaded photo to the server.
// We will update the user after this action.
axios.post('/settings/photo',{
bucket: response.bucket,
key: response.key,
content_type: this.$refs.photo.files[0].type,
})
.then(
() => {
Bus.$emit('updateUser');

self.form.finishProcessing();
},
(error) => {
self.form.setErrors(error.response.data.errors);
}
);
});
},
},

computed: {
/**
* Calculate the style attribute for the photo preview.
*/
previewStyle() {
return `background-image: url(${this.user.photo_url})`;
}
}

});
74 changes: 74 additions & 0 deletions resources/js/spark-components/settings/teams/update-team-photo.js
@@ -0,0 +1,74 @@
Vue.component('spark-update-team-photo', {
props: ['user', 'team'],

/**
* The component's data.
*/
data() {
return {
form: new SparkForm({})
};
},


methods: {
/**
* Update the user's profile photo.
*/
update(e) {
e.preventDefault();

if ( ! this.$refs.photo.files.length) {
return;
}

var self = this;

this.form.startProcessing();

// Stream the file to S3
window.Vapor.store(this.$refs.photo.files[0], {
progress: progress => {
this.uploadProgress = Math.round(progress * 100);
}
}).then(response => {
// Now we send details of the uploaded photo to the server.
// We will update the user after this action.
axios.post(this.urlForUpdate,{
bucket: response.bucket,
key: response.key,
content_type: this.$refs.photo.files[0].type,
})
.then(
() => {
Bus.$emit('updateTeam');
Bus.$emit('updateTeams');

self.form.finishProcessing();
},
(error) => {
self.form.setErrors(error.response.data.errors);
}
);
});
},
},

computed: {
/**
* Get the URL for updating the team photo.
*/
urlForUpdate() {
return `/settings/${Spark.teamsPrefix}/${this.team.id}/photo`;
},


/**
* Calculate the style attribute for the photo preview.
*/
previewStyle() {
return `background-image: url(${this.team.photo_url})`;
}
}

});

0 comments on commit c6e3692

Please sign in to comment.