Merge pull request #14024 from spencerrlongg/chore/last_vue_component

Last Vue Components
This commit is contained in:
snipe 2023-12-13 04:35:35 +00:00 committed by GitHub
commit 9edb631d52
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 450 additions and 1026 deletions

View file

@ -0,0 +1,109 @@
<?php
namespace App\Http\Livewire;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
use Laravel\Passport\Client;
use Laravel\Passport\ClientRepository;
use Laravel\Passport\TokenRepository;
use Livewire\Component;
class OauthClients extends Component
{
public $name;
public $redirect;
public $editClientId;
public $editName;
public $editRedirect;
public $authorizationError;
protected $clientRepository;
protected $tokenRepository;
public function __construct()
{
$this->clientRepository = app(ClientRepository::class);
$this->tokenRepository = app(TokenRepository::class);
parent::__construct();
}
public function render()
{
return view('livewire.oauth-clients', [
'clients' => $this->clientRepository->activeForUser(auth()->user()->id),
'authorized_tokens' => $this->tokenRepository->forUser(auth()->user()->id)->where('revoked', false),
]);
}
public function createClient(): void
{
$this->validate([
'name' => 'required|string|max:255',
'redirect' => 'required|url|max:255',
]);
$newClient = $this->clientRepository->create(
auth()->user()->id,
$this->name,
$this->redirect,
);
$this->dispatchBrowserEvent('clientCreated');
}
public function deleteClient(Client $clientId): void
{
// test for safety
// ->delete must be of type Client - thus the model binding
if ($clientId->user_id == auth()->user()->id) {
$this->clientRepository->delete($clientId);
} else {
Log::warning('User ' . auth()->user()->id . ' attempted to delete client ' . $clientId->id . ' which belongs to user ' . $clientId->user_id);
$this->authorizationError = 'You are not authorized to delete this client.';
}
}
public function deleteToken($tokenId): void
{
$token = $this->tokenRepository->find($tokenId);
if ($token->user_id == auth()->user()->id) {
$this->tokenRepository->revokeAccessToken($tokenId);
} else {
Log::warning('User ' . auth()->user()->id . ' attempted to delete token ' . $tokenId . ' which belongs to user ' . $token->user_id);
$this->authorizationError = 'You are not authorized to delete this token.';
}
}
public function editClient(Client $editClientId): void
{
$this->editName = $editClientId->name;
$this->editRedirect = $editClientId->redirect;
$this->editClientId = $editClientId->id;
$this->dispatchBrowserEvent('editClient');
}
public function updateClient(Client $editClientId): void
{
$this->validate([
'editName' => 'required|string|max:255',
'editRedirect' => 'required|url|max:255',
]);
$client = $this->clientRepository->find($editClientId->id);
if ($client->user_id == auth()->user()->id) {
$client->name = $this->editName;
$client->redirect = $this->editRedirect;
$client->save();
} else {
Log::warning('User ' . auth()->user()->id . ' attempted to edit client ' . $editClientId->id . ' which belongs to user ' . $client->user_id);
$this->authorizationError = 'You are not authorized to edit this client.';
}
$this->dispatchBrowserEvent('clientUpdated');
}
}

424
package-lock.json generated
View file

@ -37,7 +37,6 @@
"sheetjs": "^2.0.0",
"tableexport.jquery.plugin": "1.28.0",
"tether": "^1.4.0",
"vue-resource": "^1.5.2",
"webpack": "^5.89.0"
},
"devDependencies": {
@ -46,10 +45,7 @@
"jquery": "<3.6.0",
"laravel-mix": "^6.0.49",
"lodash": "^4.17.20",
"postcss": "^8.4.5",
"vue": "2.4.4",
"vue-loader": "^15.9.7",
"vue-template-compiler": "2.4.4"
"postcss": "^8.4.5"
},
"engines": {
"node": ">=0.12"
@ -1996,16 +1992,6 @@
"node": ">= 8"
}
},
"node_modules/@sindresorhus/is": {
"version": "4.6.0",
"license": "MIT",
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sindresorhus/is?sponsor=1"
}
},
"node_modules/@swc/helpers": {
"version": "0.3.17",
"license": "MIT",
@ -2013,16 +1999,6 @@
"tslib": "^2.4.0"
}
},
"node_modules/@szmarczak/http-timer": {
"version": "4.0.6",
"license": "MIT",
"dependencies": {
"defer-to-connect": "^2.0.0"
},
"engines": {
"node": ">=10"
}
},
"node_modules/@tokenizer/token": {
"version": "0.3.0",
"license": "MIT"
@ -2089,16 +2065,6 @@
"@types/node": "*"
}
},
"node_modules/@types/cacheable-request": {
"version": "6.0.3",
"license": "MIT",
"dependencies": {
"@types/http-cache-semantics": "*",
"@types/keyv": "^3.1.4",
"@types/node": "*",
"@types/responselike": "^1.0.0"
}
},
"node_modules/@types/clean-css": {
"version": "4.2.8",
"dev": true,
@ -2176,10 +2142,6 @@
"@types/node": "*"
}
},
"node_modules/@types/http-cache-semantics": {
"version": "4.0.2",
"license": "MIT"
},
"node_modules/@types/http-errors": {
"version": "2.0.2",
"dev": true,
@ -2238,13 +2200,6 @@
"version": "7.0.13",
"license": "MIT"
},
"node_modules/@types/keyv": {
"version": "3.1.4",
"license": "MIT",
"dependencies": {
"@types/node": "*"
}
},
"node_modules/@types/mime": {
"version": "1.3.3",
"dev": true,
@ -2282,13 +2237,6 @@
"dev": true,
"license": "MIT"
},
"node_modules/@types/responselike": {
"version": "1.0.1",
"license": "MIT",
"dependencies": {
"@types/node": "*"
}
},
"node_modules/@types/retry": {
"version": "0.12.0",
"dev": true,
@ -2342,59 +2290,6 @@
"@types/node": "*"
}
},
"node_modules/@vue/component-compiler-utils": {
"version": "3.3.0",
"dev": true,
"license": "MIT",
"dependencies": {
"consolidate": "^0.15.1",
"hash-sum": "^1.0.2",
"lru-cache": "^4.1.2",
"merge-source-map": "^1.1.0",
"postcss": "^7.0.36",
"postcss-selector-parser": "^6.0.2",
"source-map": "~0.6.1",
"vue-template-es2015-compiler": "^1.9.0"
},
"optionalDependencies": {
"prettier": "^1.18.2 || ^2.0.0"
}
},
"node_modules/@vue/component-compiler-utils/node_modules/lru-cache": {
"version": "4.1.5",
"dev": true,
"license": "ISC",
"dependencies": {
"pseudomap": "^1.0.2",
"yallist": "^2.1.2"
}
},
"node_modules/@vue/component-compiler-utils/node_modules/picocolors": {
"version": "0.2.1",
"dev": true,
"license": "ISC"
},
"node_modules/@vue/component-compiler-utils/node_modules/postcss": {
"version": "7.0.39",
"dev": true,
"license": "MIT",
"dependencies": {
"picocolors": "^0.2.1",
"source-map": "^0.6.1"
},
"engines": {
"node": ">=6.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/postcss/"
}
},
"node_modules/@vue/component-compiler-utils/node_modules/yallist": {
"version": "2.1.2",
"dev": true,
"license": "ISC"
},
"node_modules/@vue/reactivity": {
"version": "3.1.5",
"license": "MIT",
@ -3544,11 +3439,6 @@
"node": ">=8"
}
},
"node_modules/bluebird": {
"version": "3.7.2",
"dev": true,
"license": "MIT"
},
"node_modules/blueimp-canvas-to-blob": {
"version": "3.5.0",
"license": "MIT",
@ -4027,29 +3917,6 @@
"node": ">= 0.8"
}
},
"node_modules/cacheable-lookup": {
"version": "5.0.4",
"license": "MIT",
"engines": {
"node": ">=10.6.0"
}
},
"node_modules/cacheable-request": {
"version": "7.0.4",
"license": "MIT",
"dependencies": {
"clone-response": "^1.0.2",
"get-stream": "^5.1.0",
"http-cache-semantics": "^4.0.0",
"keyv": "^4.0.0",
"lowercase-keys": "^2.0.0",
"normalize-url": "^6.0.1",
"responselike": "^2.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/cached-path-relative": {
"version": "1.1.0",
"license": "MIT"
@ -4343,16 +4210,6 @@
"node": ">=6"
}
},
"node_modules/clone-response": {
"version": "1.0.3",
"license": "MIT",
"dependencies": {
"mimic-response": "^1.0.0"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/codepage": {
"version": "1.15.0",
"license": "Apache-2.0",
@ -4524,17 +4381,6 @@
"node_modules/console-browserify": {
"version": "1.2.0"
},
"node_modules/consolidate": {
"version": "0.15.1",
"dev": true,
"license": "MIT",
"dependencies": {
"bluebird": "^3.1.1"
},
"engines": {
"node": ">= 0.10.0"
}
},
"node_modules/constants-browserify": {
"version": "1.0.0",
"license": "MIT"
@ -4922,11 +4768,6 @@
"jquery": ">=1.7"
}
},
"node_modules/de-indent": {
"version": "1.0.2",
"dev": true,
"license": "MIT"
},
"node_modules/debug": {
"version": "2.6.9",
"dev": true,
@ -4935,29 +4776,6 @@
"ms": "2.0.0"
}
},
"node_modules/decompress-response": {
"version": "6.0.0",
"license": "MIT",
"dependencies": {
"mimic-response": "^3.1.0"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/decompress-response/node_modules/mimic-response": {
"version": "3.1.0",
"license": "MIT",
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/deep-equal": {
"version": "2.2.2",
"license": "MIT",
@ -5000,13 +4818,6 @@
"node": ">= 10"
}
},
"node_modules/defer-to-connect": {
"version": "2.0.1",
"license": "MIT",
"engines": {
"node": ">=10"
}
},
"node_modules/define-data-property": {
"version": "1.1.1",
"license": "MIT",
@ -5344,13 +5155,6 @@
"node": ">= 0.8"
}
},
"node_modules/end-of-stream": {
"version": "1.4.4",
"license": "MIT",
"dependencies": {
"once": "^1.4.0"
}
},
"node_modules/enhanced-resolve": {
"version": "5.15.0",
"license": "MIT",
@ -5961,19 +5765,6 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/get-stream": {
"version": "5.2.0",
"license": "MIT",
"dependencies": {
"pump": "^3.0.0"
},
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/glob": {
"version": "7.2.3",
"license": "ISC",
@ -6059,29 +5850,6 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/got": {
"version": "11.8.6",
"license": "MIT",
"dependencies": {
"@sindresorhus/is": "^4.0.0",
"@szmarczak/http-timer": "^4.0.5",
"@types/cacheable-request": "^6.0.1",
"@types/responselike": "^1.0.0",
"cacheable-lookup": "^5.0.3",
"cacheable-request": "^7.0.2",
"decompress-response": "^6.0.0",
"http2-wrapper": "^1.0.0-beta.5.2",
"lowercase-keys": "^2.0.0",
"p-cancelable": "^2.0.0",
"responselike": "^2.0.0"
},
"engines": {
"node": ">=10.19.0"
},
"funding": {
"url": "https://github.com/sindresorhus/got?sponsor=1"
}
},
"node_modules/graceful-fs": {
"version": "4.2.11",
"license": "ISC"
@ -6362,10 +6130,6 @@
"entities": "^2.0.0"
}
},
"node_modules/http-cache-semantics": {
"version": "4.1.1",
"license": "BSD-2-Clause"
},
"node_modules/http-deceiver": {
"version": "1.2.7",
"dev": true,
@ -6427,17 +6191,6 @@
}
}
},
"node_modules/http2-wrapper": {
"version": "1.0.3",
"license": "MIT",
"dependencies": {
"quick-lru": "^5.1.1",
"resolve-alpn": "^1.0.0"
},
"engines": {
"node": ">=10.19.0"
}
},
"node_modules/https-browserify": {
"version": "1.0.0",
"license": "MIT"
@ -7116,10 +6869,6 @@
"node": ">=4"
}
},
"node_modules/json-buffer": {
"version": "3.0.1",
"license": "MIT"
},
"node_modules/json-parse-even-better-errors": {
"version": "2.3.1",
"license": "MIT"
@ -7217,13 +6966,6 @@
"jquery": ">=1.5"
}
},
"node_modules/keyv": {
"version": "4.5.4",
"license": "MIT",
"dependencies": {
"json-buffer": "3.0.1"
}
},
"node_modules/kind-of": {
"version": "6.0.3",
"dev": true,
@ -7713,13 +7455,6 @@
"tslib": "^2.0.3"
}
},
"node_modules/lowercase-keys": {
"version": "2.0.0",
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/lru-cache": {
"version": "5.1.1",
"dev": true,
@ -7798,14 +7533,6 @@
"dev": true,
"license": "MIT"
},
"node_modules/merge-source-map": {
"version": "1.1.0",
"dev": true,
"license": "MIT",
"dependencies": {
"source-map": "^0.6.1"
}
},
"node_modules/merge-stream": {
"version": "2.0.0",
"license": "MIT"
@ -7887,13 +7614,6 @@
"node": ">=6"
}
},
"node_modules/mimic-response": {
"version": "1.0.1",
"license": "MIT",
"engines": {
"node": ">=4"
}
},
"node_modules/mini-css-extract-plugin": {
"version": "1.6.2",
"dev": true,
@ -8146,6 +7866,7 @@
},
"node_modules/normalize-url": {
"version": "6.1.0",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=10"
@ -8285,13 +8006,6 @@
"version": "0.3.0",
"license": "MIT"
},
"node_modules/p-cancelable": {
"version": "2.1.1",
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/p-limit": {
"version": "2.3.0",
"dev": true,
@ -9103,21 +8817,6 @@
"version": "4.2.0",
"license": "MIT"
},
"node_modules/prettier": {
"version": "2.8.8",
"dev": true,
"license": "MIT",
"optional": true,
"bin": {
"prettier": "bin-prettier.js"
},
"engines": {
"node": ">=10.13.0"
},
"funding": {
"url": "https://github.com/prettier/prettier?sponsor=1"
}
},
"node_modules/pretty-time": {
"version": "1.1.0",
"dev": true,
@ -9170,11 +8869,6 @@
"license": "MIT",
"optional": true
},
"node_modules/pseudomap": {
"version": "1.0.2",
"dev": true,
"license": "ISC"
},
"node_modules/public-encrypt": {
"version": "4.0.3",
"license": "MIT",
@ -9191,14 +8885,6 @@
"version": "4.12.0",
"license": "MIT"
},
"node_modules/pump": {
"version": "3.0.0",
"license": "MIT",
"dependencies": {
"end-of-stream": "^1.1.0",
"once": "^1.3.1"
}
},
"node_modules/punycode": {
"version": "1.4.1",
"license": "MIT"
@ -9240,16 +8926,6 @@
],
"license": "MIT"
},
"node_modules/quick-lru": {
"version": "5.1.1",
"license": "MIT",
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/raf": {
"version": "3.4.1",
"license": "MIT",
@ -9530,10 +9206,6 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/resolve-alpn": {
"version": "1.2.1",
"license": "MIT"
},
"node_modules/resolve-cwd": {
"version": "3.0.0",
"dev": true,
@ -9561,16 +9233,6 @@
"node": ">=4"
}
},
"node_modules/responselike": {
"version": "2.0.1",
"license": "MIT",
"dependencies": {
"lowercase-keys": "^2.0.0"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/restructure": {
"version": "2.0.1",
"license": "MIT"
@ -10757,74 +10419,6 @@
"version": "1.1.2",
"license": "MIT"
},
"node_modules/vue": {
"version": "2.4.4",
"dev": true,
"license": "MIT"
},
"node_modules/vue-hot-reload-api": {
"version": "2.3.4",
"dev": true,
"license": "MIT"
},
"node_modules/vue-loader": {
"version": "15.10.2",
"dev": true,
"license": "MIT",
"dependencies": {
"@vue/component-compiler-utils": "^3.1.0",
"hash-sum": "^1.0.2",
"loader-utils": "^1.1.0",
"vue-hot-reload-api": "^2.3.0",
"vue-style-loader": "^4.1.0"
},
"peerDependencies": {
"css-loader": "*",
"webpack": "^3.0.0 || ^4.1.0 || ^5.0.0-0"
},
"peerDependenciesMeta": {
"cache-loader": {
"optional": true
},
"prettier": {
"optional": true
},
"vue-template-compiler": {
"optional": true
}
}
},
"node_modules/vue-loader/node_modules/json5": {
"version": "1.0.2",
"dev": true,
"license": "MIT",
"dependencies": {
"minimist": "^1.2.0"
},
"bin": {
"json5": "lib/cli.js"
}
},
"node_modules/vue-loader/node_modules/loader-utils": {
"version": "1.4.2",
"dev": true,
"license": "MIT",
"dependencies": {
"big.js": "^5.2.2",
"emojis-list": "^3.0.0",
"json5": "^1.0.1"
},
"engines": {
"node": ">=4.0.0"
}
},
"node_modules/vue-resource": {
"version": "1.5.3",
"license": "MIT",
"dependencies": {
"got": ">=8.0 <12.0"
}
},
"node_modules/vue-style-loader": {
"version": "4.1.3",
"dev": true,
@ -10858,20 +10452,6 @@
"node": ">=4.0.0"
}
},
"node_modules/vue-template-compiler": {
"version": "2.4.4",
"dev": true,
"license": "MIT",
"dependencies": {
"de-indent": "^1.0.2",
"he": "^1.1.0"
}
},
"node_modules/vue-template-es2015-compiler": {
"version": "1.9.1",
"dev": true,
"license": "MIT"
},
"node_modules/watchpack": {
"version": "2.4.0",
"license": "MIT",

View file

@ -18,10 +18,7 @@
"jquery": "<3.6.0",
"laravel-mix": "^6.0.49",
"lodash": "^4.17.20",
"postcss": "^8.4.5",
"vue": "2.4.4",
"vue-loader": "^15.9.7",
"vue-template-compiler": "2.4.4"
"postcss": "^8.4.5"
},
"dependencies": {
"@fortawesome/fontawesome-free": "^6.4.2",
@ -56,7 +53,6 @@
"sheetjs": "^2.0.0",
"tableexport.jquery.plugin": "1.28.0",
"tether": "^1.4.0",
"vue-resource": "^1.5.2",
"webpack": "^5.89.0"
}
}

View file

@ -19,28 +19,6 @@ jQuery.fn.uitooltip = jQuery.fn.tooltip;
*/
require('bootstrap-less');
/**
* Vue is a modern JavaScript library for building interactive web interfaces
* using reactive data binding and reusable components. Vue's API is clean
* and simple, leaving you to focus on building your next great project.
*/
window.Vue = require('vue').default;
window.eventHub = new Vue();
require('vue-resource');
/**
* We'll register a HTTP interceptor to attach the "CSRF" header to each of
* the outgoing requests issued by this application. The CSRF middleware
* included with Laravel will automatically verify the header's value.
*/
Vue.http.interceptors.push(function (request, next) {
request.headers.set('X-CSRF-TOKEN', Laravel.csrfToken);
next();
});
// require('admin-lte');
// require('chart.js');

View file

@ -1,112 +0,0 @@
<style scoped>
.action-link {
cursor: pointer;
}
.m-b-none {
margin-bottom: 0;
}
</style>
<template>
<div>
<div v-if="tokens.length > 0">
<div class="panel panel-default">
<h2 class="panel-heading">Authorized Applications</h2>
<div class="panel-body">
<!-- Authorized Tokens -->
<table class="table table-borderless m-b-none">
<thead>
<tr>
<th>Name</th>
<th>Scopes</th>
<th><span class="sr-only">Delete</span></th>
</tr>
</thead>
<tbody>
<tr v-for="token in tokens">
<!-- Client Name -->
<td style="vertical-align: middle;">
{{ token.client.name }}
</td>
<!-- Scopes -->
<td style="vertical-align: middle;">
<span v-if="token.scopes.length > 0">
{{ token.scopes.join(', ') }}
</span>
</td>
<!-- Revoke Button -->
<td style="vertical-align: middle;">
<a class="action-link text-danger" @click="revoke(token)">
Revoke
</a>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
props: ['clientsUrl', 'tokensUrl'],
/*
* The component's data.
*/
data() {
return {
tokens: []
};
},
/**
* Prepare the component (Vue 1.x).
*/
ready() {
this.prepareComponent();
},
/**
* Prepare the component (Vue 2.x).
*/
mounted() {
this.prepareComponent();
},
methods: {
/**
* Prepare the component (Vue 2.x).
*/
prepareComponent() {
this.getTokens();
},
/**
* Get all of the authorized tokens for the user.
*/
getTokens() {
this.$http.get(this.tokensUrl)
.then(response => {
this.tokens = response.data;
});
},
/**
* Revoke the given token.
*/
revoke(token) {
this.$http.delete(this.tokensUrl +'/'+ token.id)
.then(response => {
this.getTokens();
});
}
}
}
</script>

View file

@ -1,357 +0,0 @@
<style scoped>
.action-link {
cursor: pointer;
}
.m-b-none {
margin-bottom: 0;
}
</style>
<template>
<div>
<div class="panel panel-default">
<div class="panel-heading">
<div style="display: flex; justify-content: space-between; align-items: center;">
<h2>
OAuth Clients
</h2>
<a class="action-link" @click="showCreateClientForm">
Create New Client
</a>
</div>
</div>
<div class="panel-body">
<!-- Current Clients -->
<p class="m-b-none" v-if="clients.length === 0">
You have not created any OAuth clients.
</p>
<table class="table table-borderless m-b-none" v-if="clients.length > 0">
<thead>
<tr>
<th>Client ID</th>
<th>Name</th>
<th>Secret</th>
<th><span class="sr-only">Edit</span></th>
<th><span class="sr-only">Delete</span></th>
</tr>
</thead>
<tbody>
<tr v-for="client in clients">
<!-- ID -->
<td style="vertical-align: middle;">
{{ client.id }}
</td>
<!-- Name -->
<td style="vertical-align: middle;">
{{ client.name }}
</td>
<!-- Secret -->
<td style="vertical-align: middle;">
<code>{{ client.secret }}</code>
</td>
<!-- Edit Button -->
<td style="vertical-align: middle;">
<a class="action-link" @click="edit(client)">
Edit
</a>
</td>
<!-- Delete Button -->
<td style="vertical-align: middle;">
<a class="action-link text-danger" @click="destroy(client)">
Delete
</a>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<!-- Create Client Modal -->
<div class="modal fade" id="modal-create-client" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button " class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h2 class="modal-title">
Create Client
</h2>
</div>
<div class="modal-body">
<!-- Form Errors -->
<div class="alert alert-danger" v-if="createForm.errors.length > 0">
<p><strong>Whoops!</strong> Something went wrong!</p>
<br>
<ul>
<li v-for="error in createForm.errors">
{{ error }}
</li>
</ul>
</div>
<!-- Create Client Form -->
<form class="form-horizontal" role="form">
<!-- Name -->
<div class="form-group">
<label class="col-md-3 control-label" for="create-client-name">Name</label>
<div class="col-md-7">
<input id="create-client-name" type="text" aria-label="create-client-name" class="form-control"
@keyup.enter="store" v-model="createForm.name">
<span class="help-block">
Something your users will recognize and trust.
</span>
</div>
</div>
<!-- Redirect URL -->
<div class="form-group">
<label class="col-md-3 control-label" for="redirect">Redirect URL</label>
<div class="col-md-7">
<input type="text" class="form-control" aria-label="redirect" name="redirect"
@keyup.enter="store" v-model="createForm.redirect">
<span class="help-block">
Your application's authorization callback URL.
</span>
</div>
</div>
</form>
</div>
<!-- Modal Actions -->
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" @click="store">
Create
</button>
</div>
</div>
</div>
</div>
<!-- Edit Client Modal -->
<div class="modal fade" id="modal-edit-client" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button " class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title">
Edit Client
</h4>
</div>
<div class="modal-body">
<!-- Form Errors -->
<div class="alert alert-danger" v-if="editForm.errors.length > 0">
<p><strong>Whoops!</strong> Something went wrong!</p>
<br>
<ul>
<li v-for="error in editForm.errors">
{{ error }}
</li>
</ul>
</div>
<!-- Edit Client Form -->
<form class="form-horizontal" role="form">
<!-- Name -->
<div class="form-group">
<label class="col-md-3 control-label" for="edit-client-name">Name</label>
<div class="col-md-7">
<input id="edit-client-name" type="text" aria-label="edit-client-name" class="form-control"
@keyup.enter="update" v-model="editForm.name">
<span class="help-block">
Something your users will recognize and trust.
</span>
</div>
</div>
<!-- Redirect URL -->
<div class="form-group">
<label class="col-md-3 control-label" for="redirect">Redirect URL</label>
<div class="col-md-7">
<input type="text" class="form-control" name="redirect" aria-label="redirect"
@keyup.enter="update" v-model="editForm.redirect">
<span class="help-block">
Your application's authorization callback URL.
</span>
</div>
</div>
</form>
</div>
<!-- Modal Actions -->
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" @click="update">
Save Changes
</button>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
/*
* The component's data.
*/
props: ['clientsUrl'],
data() {
return {
clients: [],
createForm: {
errors: [],
name: '',
redirect: ''
},
editForm: {
errors: [],
name: '',
redirect: ''
}
};
},
/**
* Prepare the component (Vue 1.x).
*/
ready() {
this.prepareComponent();
},
/**
* Prepare the component (Vue 2.x).
*/
mounted() {
this.prepareComponent();
},
methods: {
/**
* Prepare the component.
*/
prepareComponent() {
this.getClients();
$('#modal-create-client').on('shown.bs.modal', () => {
$('#create-client-name').focus();
});
$('#modal-edit-client').on('shown.bs.modal', () => {
$('#edit-client-name').focus();
});
},
/**
* Get all of the OAuth clients for the user.
*/
getClients() {
this.$http.get(this.clientsUrl)
.then(response => {
this.clients = response.data;
});
},
/**
* Show the form for creating new clients.
*/
showCreateClientForm() {
$('#modal-create-client').modal('show');
},
/**
* Create a new OAuth client for the user.
*/
store() {
this.persistClient(
'post', this.clientsUrl,
this.createForm, '#modal-create-client'
);
},
/**
* Edit the given client.
*/
edit(client) {
this.editForm.id = client.id;
this.editForm.name = client.name;
this.editForm.redirect = client.redirect;
$('#modal-edit-client').modal('show');
},
/**
* Update the client being edited.
*/
update() {
this.persistClient(
'put', this.clientsUrl + '/' + this.editForm.id,
this.editForm, '#modal-edit-client'
);
},
/**
* Persist the client to storage using the given form.
*/
persistClient(method, uri, form, modal) {
console.log('persisting');
form.errors = [];
console.log('method: ' + method);
this.$http[method](uri, form)
.then(response => {
this.getClients();
form.name = '';
form.redirect = '';
form.errors = [];
$(modal).modal('hide');
})
.catch(response => {
if (typeof response.data === 'object') {
form.errors = _.flatten(_.toArray(response.data));
} else {
form.errors = ['Something went wrong. Please try again.'];
}
});
},
/**
* Destroy the given client.
*/
destroy(client) {
this.$http.delete(this.clientsUrl +'/' + client.id)
.then(response => {
this.getClients();
});
}
}
}
</script>

View file

@ -1,47 +0,0 @@
<style scoped>
.select2-dropdown {
z-index:9999;
}
</style>
<template>
<select style="width:100%">
<slot></slot>
</select>
</template>
<script>
//require('select2');
export default {
/*
* The component's data.
*/
props: ['options', 'value'],
mounted() {
var vm = this;
$(this.$el)
.select2({
data: this.options
})
.on('change', function() { vm.$emit('input', this.value) } )
.val(this.value).trigger('change');
},
watch: {
value: function (value) {
$(this.$el).val(value)
},
options: function (options) {
var vm = this;
$(this.$el).select2('destroy').empty().select2({data: options})
.on('change', function() { vm.$emit('input', this.value) } )
.val(this.value).trigger('change');
},
destroyed: function() {
$(this.$el).off().select2('destroy')
}
}
}
</script>

View file

@ -4,6 +4,8 @@
// window.jQuery = jQuery
// window.$ = jQuery
require('./bootstrap');
/**
* Module containing core application logic.
* @param {jQuery} $ Insulated jQuery object

View file

@ -1,45 +0,0 @@
/**
* First we will load all of this project's JavaScript dependencies which
* include Vue and Vue Resource. This gives a great starting point for
* building robust, powerful web applications using Vue and Laravel.
*/
require('./bootstrap');
/**
* Next, we will create a fresh Vue application instance and attach it to
* the page. Then, you may begin adding components to this application
* or customize the JavaScript scaffolding to fit your unique needs.
*/
Vue.component(
'passport-clients',
require('./components/passport/Clients.vue').default
);
Vue.component(
'passport-authorized-clients',
require('./components/passport/AuthorizedClients.vue').default
);
// This component has been removed and replaced with a Livewire implementation
// Vue.component(
// 'passport-personal-access-tokens',
// require('./components/passport/PersonalAccessTokens.vue').default
// );
// This component has been removed and replaced with a Livewire implementation
// Vue.component(
// 'importer',
// require('./components/importer/importer.vue').default
// );
// This component has been removed and replaced with a Livewire implementation
// Vue.component(
// 'fieldset-default-values',
// require('./components/forms/asset-models/fieldset-default-values.vue').default
// );
// Commented out currently to avoid trying to load vue everywhere.
// const app = new Vue({
// el: '#app'
// });

View file

@ -34,9 +34,4 @@
@stop
@section('moar_scripts')
<script nonce="{{ csrf_token() }}">
new Vue({
el: "#app",
});
</script>
@endsection

View file

@ -0,0 +1,333 @@
<div>
<div class="panel panel-default">
<div class="panel-heading">
<div style="display: flex; justify-content: space-between; align-items: center;">
<h2>
OAuth Clients
</h2>
@if($authorizationError)
<div class="alert alert-danger">
<p><strong>Whoops!</strong> Something went wrong!</p>
<br>
{{ $authorizationError }}
</div>
@endif
<a class="button button-small"
wire:click="$emit('openModal')"
onclick="$('#modal-create-client').modal('show');"
>
Create New Client
</a>
</div>
</div>
<div class="panel-body">
<!-- Current Clients -->
@if($clients->count() === 0)
<p class="m-b-none">
You have not created any OAuth clients.
</p>
@endif
@if($clients->count() > 0)
<table class="table table-borderless m-b-none">
<thead>
<tr>
<th>Client ID</th>
<th>Name</th>
<th>Secret</th>
<th><span class="sr-only">Edit</span></th>
<th><span class="sr-only">Delete</span></th>
</tr>
</thead>
<tbody>
@foreach($clients as $client)
<tr>
<!-- ID -->
<td style="vertical-align: middle;">
{{ $client->id }}
</td>
<!-- Name -->
<td style="vertical-align: middle;">
{{ $client->name }}
</td>
<!-- Secret -->
<td style="vertical-align: middle;">
<code>{{ $client->secret }}</code>
</td>
<!-- Edit Button -->
<td style="vertical-align: middle;">
<a class="action-link btn"
wire:click="editClient('{{ $client->id }}')"
onclick="$('#modal-edit-client').modal('show');"
>
Edit
</a>
</td>
<!-- Delete Button -->
<td style="vertical-align: middle;" class="text-right">
<a class="action-link btn btn-danger btn-sm" wire:click="deleteClient('{{ $client->id }}')">
<i class="fas fa-trash"></i>
</a>
</td>
</tr>
@endforeach
</tbody>
</table>
@endif
</div>
<div>
@if ($authorized_tokens->count() > 0)
<div>
<div class="panel panel-default">
<h2 class="panel-heading">Authorized Applications</h2>
<div class="panel-body">
<!-- Authorized Tokens -->
<table class="table table-borderless m-b-none">
<thead>
<tr>
<th>Name</th>
<th>Scopes</th>
<th><span class="sr-only">Delete</span></th>
</tr>
</thead>
<tbody>
@foreach($authorized_tokens as $token)
<tr>
<!-- Client Name -->
<td style="vertical-align: middle;">
{{ $token->client->name }}
</td>
<!-- Scopes -->
<td style="vertical-align: middle;">
@if(!$token->scopes)
<span class="label label-default">No Scopes</span>
@endif
</td>
<!-- Revoke Button -->
<td style="vertical-align: middle;">
<a class="btn btn-sm btn-danger"
wire:click="deleteToken('{{ $token->id }}')"
>
<i class="fas fa-trash"></i>
</a>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
@endif
</div>
</div>
<!-- Create Client Modal -->
<div class="modal fade" id="modal-create-client" tabindex="-1" role="dialog" wire:ignore.self>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h2 class="modal-title">
Create Client
</h2>
</div>
<div class="modal-body">
<!-- Form Errors -->
@if($errors->has('name') || $errors->has('redirect'))
<div class="alert alert-danger">
<p><strong>Whoops!</strong> Something went wrong!</p>
<br>
<ul>
@if($errors->has('name'))
<li>{{ $errors->first('name') }}</li>
@endif
@if($errors->has('redirect'))
<li>{{ $errors->first('redirect') }}</li>
@endif
</ul>
</div>
@endif
<!-- Create Client Form -->
<form class="form-horizontal" role="form">
<!-- Name -->
<div class="form-group">
<label class="col-md-3 control-label" for="create-client-name">Name</label>
<div class="col-md-7">
<input id="create-client-name"
type="text"
aria-label="create-client-name"
class="form-control"
wire:model="name"
wire:keydown.enter="createClient"
autofocus
>
<span class="help-block">
Something your users will recognize and trust.
</span>
</div>
</div>
<!-- Redirect URL -->
<div class="form-group">
<label class="col-md-3 control-label" for="redirect">Redirect URL</label>
<div class="col-md-7">
<input type="text"
class="form-control"
aria-label="redirect"
name="redirect"
wire:model="redirect"
wire:keydown.enter="createClient"
>
<span class="help-block">
Your application's authorization callback URL.
</span>
</div>
</div>
</form>
</div>
<!-- Modal Actions -->
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button"
class="btn btn-primary"
wire:click="createClient"
>
Create
</button>
</div>
</div>
</div>
</div>
<!-- Edit Client Modal -->
<div class="modal fade" id="modal-edit-client" tabindex="-1" role="dialog" wire:ignore.self>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title">
Edit Client
</h4>
</div>
<div class="modal-body">
@if($errors->has('newName') || $errors->has('newRedirect'))
<div class="alert alert-danger">
<p><strong>Whoops!</strong> Something went wrong!</p>
<br>
<ul>
@if($errors->has('newName'))
<li>{{ $errors->first('newName') }}</li>
@endif
@if($errors->has('newRedirect'))
<li>{{ $errors->first('newRedirect') }}</li>
@endif
@if($authorizationError)
<li>{{ $authorizationError }}</li>
@endif
</ul>
</div>
@endif
<!-- Edit Client Form -->
<form class="form-horizontal">
<!-- Name -->
<div class="form-group">
<label class="col-md-3 control-label" for="edit-client-name">Name</label>
<div class="col-md-7">
<input
id="edit-client-name"
type="text"
aria-label="edit-client-name"
class="form-control"
wire:model="editName"
wire:keydown.enter="updateClient('{{ $editClientId }}')"
>
<span class="help-block">
Something your users will recognize and trust.
</span>
</div>
</div>
<!-- Redirect URL -->
<div class="form-group">
<label class="col-md-3 control-label" for="redirect">Redirect URL</label>
<div class="col-md-7">
<input
type="text"
class="form-control"
name="redirect"
aria-label="redirect"
wire:model="editRedirect"
wire:keydown.enter="updateClient('{{ $editClientId }}')"
>
<span class="help-block">
Your application's authorization callback URL.
</span>
</div>
</div>
</form>
</div>
<!-- Modal Actions -->
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button
class="btn btn-primary"
wire:click="updateClient('{{ $editClientId }}')"
>
Update Client
</button>
</div>
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
window.livewire.on('openModal', () => {
$('#modal-create-client').modal('show').on('shown.bs.modal', function() {
$(this).find('[autofocus]').focus();
});
});
});
window.addEventListener('clientCreated', function() {
$('#modal-create-client').modal('hide');
});
window.addEventListener('editClient', function() {
$('#modal-edit-client').modal('show');
});
window.addEventListener('clientUpdated', function() {
$('#modal-edit-client').modal('hide');
});
</script>
</div>

View file

@ -14,8 +14,7 @@
@section('content')
@if (!config('app.lock_passwords'))
<div id="app">
<passport-clients clients-url="{{ url('oauth/clients') }}"></passport-clients>
<passport-authorized-clients clients-url="{{ url('oauth/clients') }}" tokens-url="{{ url('oauth/tokens') }}"></passport-authorized-clients>
<livewire:oauth-clients />
</div>
@else
<p class="text-warning"><i class="fas fa-lock"></i> {{ trans('general.feature_disabled') }}</p>
@ -24,9 +23,4 @@
@stop
@section('moar_scripts')
<script nonce="{{ csrf_token() }}">
new Vue({
el: "#app",
});
</script>
@endsection

View file

@ -9,7 +9,7 @@
<title>{{ config('app.name') }} - Authorization</title>
{{-- stylesheets --}}
<link rel="stylesheet" href="{{ url(mix('css/all.css')) }}">
<link rel="stylesheet" href="{{ url(mix('css/dist/all.css')) }}">
<style>
.passport-authorize .container {
margin-top: 30px;

View file

@ -50,13 +50,11 @@ mix
mix
.js(
[
"./resources/assets/js/vue.js", // require()s vue, and require()s bootstrap.js
"./resources/assets/js/snipeit.js", //this is the actual Snipe-IT JS
"./resources/assets/js/snipeit.js", //this is the actual Snipe-IT JS - require()s bootstrap.js
"./resources/assets/js/snipeit_modals.js",
],
"./public/js/build/app.js" //because of compiling - this does not work very well :(
)
.vue();
// Convert the skins to CSS
mix.less(