Skip to content

Commit

Permalink
Merge branch 'release/0.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
w1lldone committed Apr 23, 2021
2 parents caacb3f + 77e0c6e commit adafad0
Show file tree
Hide file tree
Showing 35 changed files with 1,431 additions and 360 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/laravel.yml
Expand Up @@ -36,7 +36,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php-versions: ["7.3", 7.4"]
php-versions: ["7.3", "7.4"]
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Api/StationController.php
Expand Up @@ -17,7 +17,7 @@ public function index(Request $request)

$station = $this->stationQuery($station, $request);

$stations = $station->paginate();
$stations = $station->with('schedules')->paginate();

return $stations;
}
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/UserController.php
Expand Up @@ -36,7 +36,8 @@ public function store(Request $request)
'name' => 'required|string|min:3|max:255',
'email' => 'required|email|unique:users,email',
'password' => 'required|min:8',
'is_superadmin' => 'nullable|boolean'
'is_superadmin' => 'nullable|boolean',
'permissions' => ['array', Rule::in(User::$permissions), 'nullable']
]);

$data['password'] = Hash::make($data['password']);
Expand Down
5 changes: 5 additions & 0 deletions app/Models/Dropbox.php
Expand Up @@ -18,4 +18,9 @@ public function station()
{
return $this->belongsTo('App\Models\Station');
}

public function dropboxLogs()
{
return $this->hasMany('App\Models\DropboxLog');
}
}
29 changes: 29 additions & 0 deletions app/Models/DropboxLog.php
@@ -0,0 +1,29 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class DropboxLog extends Model
{
use HasFactory;

protected $guarded = ['id'];
static public $availableActivities = ['replacement', 'deployment', 'inspection'];

public function station()
{
return $this->belongsTo('App\Models\Dropbox');
}

public function children()
{
return $this->hasMany('App\Models\DropboxLog', 'parent_id');
}

public function parent()
{
return $this->belongsTo('App\Models\DropboxLog', 'parent_id');
}
}
5 changes: 4 additions & 1 deletion app/Models/Station.php
Expand Up @@ -15,7 +15,10 @@ class Station extends Model implements HasMedia

protected $guarded = ['id'];
protected $withCount = ['dropboxes'];
protected $with = ['schedules'];
protected $dates = ['last_operation_at'];
protected $casts = [
'last_operation_at' => 'datetime:Y-m-d\TH:i:sP',
];

public function registerMediaCollections(): void
{
Expand Down
94 changes: 94 additions & 0 deletions app/Policies/DropboxLogPolicy.php
@@ -0,0 +1,94 @@
<?php

namespace App\Policies;

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

class DropboxLogPolicy
{
use HandlesAuthorization;

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

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

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

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

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

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

/**
* Determine whether the user can permanently delete the model.
*
* @param \App\Models\User $user
* @param \App\Models\DropboxLog $dropboxLog
* @return mixed
*/
public function forceDelete(User $user, DropboxLog $dropboxLog)
{
//
}
}
3 changes: 2 additions & 1 deletion app/Providers/AppServiceProvider.php
Expand Up @@ -3,6 +3,7 @@
namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\Pagination\Paginator;

class AppServiceProvider extends ServiceProvider
{
Expand All @@ -23,6 +24,6 @@ public function register()
*/
public function boot()
{
//
Paginator::useBootstrap();
}
}
35 changes: 35 additions & 0 deletions database/factories/DropboxLogFactory.php
@@ -0,0 +1,35 @@
<?php

namespace Database\Factories;

use App\Models\Dropbox;
use App\Models\DropboxLog;
use Illuminate\Database\Eloquent\Factories\Factory;

class DropboxLogFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = DropboxLog::class;

/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'dropbox_id' => Dropbox::factory(),
'parent_id' => null,
'activity' => $this->faker->randomElement(DropboxLog::$availableActivities),
'weight' => $this->faker->numberBetween(100, 150) / 100,
'final_weight' => $this->faker->numberBetween(200, 500) / 100,
'starts_at' => $this->faker->dateTime(),
'ends_at' => $this->faker->dateTime(),
];
}
}
@@ -0,0 +1,38 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateDropboxLogsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('dropbox_logs', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('dropbox_id')->index();
$table->unsignedBigInteger('parent_id')->nullable();
$table->string('activity')->nullable();
$table->decimal('weight')->nullable();
$table->decimal('final_weight')->nullable();
$table->timestamp('starts_at')->nullable();
$table->timestamp('ends_at')->nullable();
$table->timestamps();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('dropbox_logs');
}
}
2 changes: 1 addition & 1 deletion public/css/app.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/css/tailwind.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/js/app.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions public/mix-manifest.json
@@ -1,6 +1,6 @@
{
"/js/app.js": "/js/app.js?id=8d18995014bb05fe0573",
"/js/app.js": "/js/app.js?id=89c3fb98035f1e02267c",
"/js/alpine.js": "/js/alpine.js?id=eea86eb67d792d022004",
"/css/app.css": "/css/app.css?id=c3bf9f2999a83e5ef503",
"/css/tailwind.css": "/css/tailwind.css?id=b58e2cfa033369d655d9"
"/css/app.css": "/css/app.css?id=23bf7dc849d484910f1f",
"/css/tailwind.css": "/css/tailwind.css?id=7a569a1ed13d8e85c3f1"
}
96 changes: 96 additions & 0 deletions resources/js/components/Auth/ForgotPassword.vue
@@ -0,0 +1,96 @@
<template>
<div>
<div class="card border-0 shadow my-auto" style="border-radius: 0.5em">
<div class="card-body">
<div class="text-center mb-3">
<img src="/img/logo_navbar.svg" class="w-50" alt="logo_dumask">
</div>
<p class="text-justify text-muted w-100 my-4">
Masukkan alamat email akun Dumask.id Anda.
Kami akan mengirimkan link untuk reset password.
</p>

<p v-show="isSent" class="text-justify text-success w-100 my-4">
Kami telah mengirimkan link untuk reset password melalui email Anda.
</p>

<div class="form-group">
<label for="email">Email</label>
<input type="email"
required
v-model="form.email"
class="form-control"
:class="{ 'is-invalid': hasErrors('email') }"
/>
<div class="invalid-feedback">
{{ getErrors("email") }}
</div>
</div>

<div class="form-group mt-4 text-right">
<button
class="btn btn-primary w-100"
v-show="!isLoading"
@click="doEmailPasswordReset()"
>
RESET PASSWORD
</button>
<button class="btn btn-primary w-100" disabled v-show="isLoading">
RESET PASSWORD
</button>
</div>
</div>
</div>
</div>
</template>

<script>
export default {
name: "ForgotPassword",
data() {
return {
form: {
email: null,
},
isLoading: false,
isSent: false,
errors: {},
};
},
methods: {
async doEmailPasswordReset() {
this.isLoading = true;
try {
let response = await axios.post("/forgot-password", this.form);
this.isSent = true;
} catch (error) {
console.log(error.response);
this.errors = error.response.data.errors;
}
this.isLoading = false;
},
hasErrors(key) {
if (this.errors[key]) {
return true;
}
return false;
},
getErrors(key) {
if (this.hasErrors(key)) {
return this.errors[key].join(", ");
}
return "";
},
},
};
</script>

<style lang="scss" scoped>
</style>

0 comments on commit adafad0

Please sign in to comment.