@fleetbase/solid-engine 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +651 -21
- package/README.md +89 -18
- package/addon/components/explorer-header.hbs +18 -0
- package/addon/components/explorer-header.js +25 -0
- package/addon/components/modals/backup-pod.hbs +3 -0
- package/addon/components/modals/create-pod.hbs +5 -0
- package/addon/components/modals/resync-pod.hbs +3 -0
- package/addon/components/table/cell/pod-content-actions.hbs +32 -0
- package/addon/components/table/cell/pod-content-actions.js +73 -0
- package/addon/components/table/cell/pod-content-name.hbs +8 -0
- package/addon/components/table/cell/pod-content-name.js +16 -0
- package/addon/controllers/account.js +130 -0
- package/addon/controllers/application.js +16 -13
- package/addon/controllers/home.js +23 -0
- package/addon/controllers/pods/explorer/content.js +12 -0
- package/addon/controllers/pods/explorer.js +149 -0
- package/addon/controllers/pods/index/pod.js +12 -0
- package/addon/controllers/pods/index.js +137 -0
- package/addon/routes/account.js +3 -0
- package/addon/routes/home.js +3 -0
- package/addon/routes/pods/explorer/content.js +10 -0
- package/addon/routes/pods/explorer.js +44 -0
- package/addon/routes/pods/index/pod.js +3 -0
- package/addon/routes/pods/index.js +21 -0
- package/addon/routes.js +12 -1
- package/addon/services/explorer-state.js +101 -0
- package/addon/styles/solid-engine.css +46 -0
- package/addon/templates/account.hbs +42 -0
- package/addon/templates/application.hbs +17 -12
- package/addon/templates/home.hbs +11 -0
- package/addon/templates/pods/explorer/content.hbs +19 -0
- package/addon/templates/pods/explorer.hbs +20 -0
- package/addon/templates/pods/index/pod.hbs +11 -0
- package/addon/templates/pods/index.hbs +19 -0
- package/app/components/explorer-header.js +1 -0
- package/app/components/modals/backup-pod.js +1 -0
- package/app/components/modals/create-pod.js +1 -0
- package/app/components/modals/resync-pod.js +1 -0
- package/app/components/table/cell/pod-content-actions.js +1 -0
- package/app/components/table/cell/pod-content-name.js +1 -0
- package/app/controllers/account.js +1 -0
- package/app/controllers/home.js +1 -0
- package/app/controllers/pods/explorer/content.js +1 -0
- package/app/controllers/pods/explorer.js +1 -0
- package/app/controllers/pods/index/pod.js +1 -0
- package/app/controllers/pods/index.js +1 -0
- package/app/routes/account.js +1 -0
- package/app/routes/home.js +1 -0
- package/app/routes/pods/explorer/content.js +1 -0
- package/app/routes/pods/explorer.js +1 -0
- package/app/routes/pods/index/pod.js +1 -0
- package/app/routes/pods/index.js +1 -0
- package/app/services/explorer-state.js +1 -0
- package/app/templates/account.js +1 -0
- package/app/templates/home.js +1 -0
- package/app/templates/pods/explorer/content.js +1 -0
- package/app/templates/pods/explorer.js +1 -0
- package/app/templates/pods/index/pod.js +1 -0
- package/app/templates/pods/index.js +1 -0
- package/composer.json +10 -4
- package/extension.json +2 -2
- package/package.json +5 -5
- package/server/data/pods.json +328 -0
- package/server/src/Client/OpenIDConnectClient.php +2 -2
- package/server/src/Client/SolidClient.php +1 -1
- package/server/src/Http/Controllers/SolidController.php +57 -4
- package/server/src/LegacyClient/OIDCClient.php +1 -1
- package/server/src/LegacyClient/SolidClient.php +2 -1
- package/server/src/Support/Utils.php +38 -0
- package/server/src/routes.php +1 -0
|
@@ -7,8 +7,9 @@ use Fleetbase\Http\Requests\AdminRequest;
|
|
|
7
7
|
use Fleetbase\Models\Setting;
|
|
8
8
|
use Fleetbase\Solid\Client\SolidClient;
|
|
9
9
|
use Fleetbase\Solid\Models\SolidIdentity;
|
|
10
|
-
use Fleetbase\Support\Utils;
|
|
10
|
+
use Fleetbase\Solid\Support\Utils;
|
|
11
11
|
use Illuminate\Http\Request;
|
|
12
|
+
use Illuminate\Support\Str;
|
|
12
13
|
|
|
13
14
|
class SolidController extends BaseController
|
|
14
15
|
{
|
|
@@ -90,9 +91,9 @@ class SolidController extends BaseController
|
|
|
90
91
|
'remember' => true,
|
|
91
92
|
],
|
|
92
93
|
[
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
'withoutAuth' => true,
|
|
95
|
+
'headers' => [
|
|
96
|
+
'Cookie' => '_interaction=TDQMh2DWuC8wZvkEB2n_G; _interaction.sig=3HHA_FUVo7Cw9up2keCJ7IaQJws; _session.legacy=jdxTxnTGmvWx2ECaiwYeP; _session.legacy.sig=EUGYX6DAKtBNQqZN5PGcbIJ-5ac',
|
|
96
97
|
],
|
|
97
98
|
]
|
|
98
99
|
);
|
|
@@ -114,4 +115,56 @@ class SolidController extends BaseController
|
|
|
114
115
|
// dump($createFileResponse->json());
|
|
115
116
|
}
|
|
116
117
|
}
|
|
118
|
+
|
|
119
|
+
public function getPods(Request $request)
|
|
120
|
+
{
|
|
121
|
+
// Retrieve search and sort parameters from the request
|
|
122
|
+
$query = $request->searchQuery();
|
|
123
|
+
$sort = $request->input('sort', '-created_at');
|
|
124
|
+
$id = $request->input('id');
|
|
125
|
+
$slug = $request->input('slug');
|
|
126
|
+
|
|
127
|
+
// Collection of pods data
|
|
128
|
+
$pods = json_decode(file_get_contents(base_path('vendor/fleetbase/solid-api/server/data/pods.json')));
|
|
129
|
+
|
|
130
|
+
// Get single content from pod via slug
|
|
131
|
+
if ($slug) {
|
|
132
|
+
$result = Utils::searchPods($pods, 'slug', $slug);
|
|
133
|
+
|
|
134
|
+
return response()->json($result);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// Get a single item via ID
|
|
138
|
+
if ($id && is_array($pods)) {
|
|
139
|
+
$result = Utils::searchPods($pods, 'id', $id);
|
|
140
|
+
if ($result && $query) {
|
|
141
|
+
$result->contents = array_values(
|
|
142
|
+
array_filter(
|
|
143
|
+
data_get($result, 'contents', []),
|
|
144
|
+
function ($content) use ($query) {
|
|
145
|
+
return Str::contains(strtolower(data_get($content, 'name')), strtolower($query));
|
|
146
|
+
}
|
|
147
|
+
)
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return response()->json($result);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Filtering by search query
|
|
155
|
+
if ($query) {
|
|
156
|
+
$pods = array_filter($pods, function ($pod) use ($query) {
|
|
157
|
+
return Str::contains(strtolower(data_get($pod, 'name')), strtolower($query));
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Determine sorting direction and key
|
|
162
|
+
$sortDesc = substr($sort, 0, 1) === '-';
|
|
163
|
+
$sortKey = ltrim($sort, '-');
|
|
164
|
+
|
|
165
|
+
// Sorting by specified field
|
|
166
|
+
$pods = collect($pods)->sortBy($sortKey, SORT_REGULAR, $sortDesc);
|
|
167
|
+
|
|
168
|
+
return response()->json($pods->values());
|
|
169
|
+
}
|
|
117
170
|
}
|
|
@@ -141,7 +141,7 @@ final class OIDCClient extends OpenIDConnectClient
|
|
|
141
141
|
return rtrim($url, '=');
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
public function createDPoP(string $method, string $url, bool $includeAth = true, string $accessToken = null): string
|
|
144
|
+
public function createDPoP(string $method, string $url, bool $includeAth = true, ?string $accessToken = null): string
|
|
145
145
|
{
|
|
146
146
|
if (null === $this->dpopPrivateKey) {
|
|
147
147
|
$this->dpopPrivateKey = JWKFactory::createECKey('P-256', ['use' => 'sig', 'kid' => base64_encode(random_bytes(20))]);
|
|
@@ -98,7 +98,7 @@ class SolidClient
|
|
|
98
98
|
*
|
|
99
99
|
* @return string the fully constructed URL
|
|
100
100
|
*/
|
|
101
|
-
private function createRequestUrl(string $uri = null): string
|
|
101
|
+
private function createRequestUrl(?string $uri = null): string
|
|
102
102
|
{
|
|
103
103
|
$url = $this->getServerUrl();
|
|
104
104
|
|
|
@@ -165,6 +165,7 @@ class SolidClient
|
|
|
165
165
|
$url = $this->createRequestUrl($uri);
|
|
166
166
|
}
|
|
167
167
|
$this->setAuthenticationHeaders($options, $method, $url);
|
|
168
|
+
|
|
168
169
|
return Http::withOptions($options)->{$method}($url, $data);
|
|
169
170
|
}
|
|
170
171
|
|
|
@@ -3,7 +3,45 @@
|
|
|
3
3
|
namespace Fleetbase\Solid\Support;
|
|
4
4
|
|
|
5
5
|
use Fleetbase\Support\Utils as FleetbaseUtils;
|
|
6
|
+
use Illuminate\Support\Str;
|
|
6
7
|
|
|
7
8
|
class Utils extends FleetbaseUtils
|
|
8
9
|
{
|
|
10
|
+
/**
|
|
11
|
+
* Recursively searches through a nested array of pods and their contents
|
|
12
|
+
* to find an item that matches a given key-value pair.
|
|
13
|
+
*
|
|
14
|
+
* This function handles nested structures where each folder may contain
|
|
15
|
+
* additional folders and files. It returns the first matching item based
|
|
16
|
+
* on the specified key and value.
|
|
17
|
+
*
|
|
18
|
+
* @param array $data the array representing the pods and their nested contents
|
|
19
|
+
* @param string $key The key used to search items (e.g., 'name', 'id').
|
|
20
|
+
* @param string $value the value to match against the specified key
|
|
21
|
+
* @param bool $search whether to perform a search match with string contains
|
|
22
|
+
*
|
|
23
|
+
* @return mixed|null returns the first matching item found in the structure or
|
|
24
|
+
* `null` if no item is found that matches the criteria
|
|
25
|
+
*/
|
|
26
|
+
public static function searchPods(array $data = [], string $key, string $value, bool $search = false)
|
|
27
|
+
{
|
|
28
|
+
foreach ($data as $item) {
|
|
29
|
+
if ($search === false && data_get($item, $key) && strcasecmp(data_get($item, $key), $value) === 0) {
|
|
30
|
+
return $item;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if ($search === true && data_get($item, $key) && Str::contains(strtolower(data_get($item, $key)), strtolower($value))) {
|
|
34
|
+
return $item;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (is_array(data_get($item, 'contents'))) {
|
|
38
|
+
$contentSearchResult = static::searchPods(data_get($item, 'contents', []), $key, $value);
|
|
39
|
+
if ($contentSearchResult) {
|
|
40
|
+
return $contentSearchResult;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
9
47
|
}
|
package/server/src/routes.php
CHANGED
|
@@ -28,6 +28,7 @@ Route::prefix(config('solid.api.routing.prefix', 'solid'))->namespace('Fleetbase
|
|
|
28
28
|
$router->group(
|
|
29
29
|
['prefix' => 'v1'],
|
|
30
30
|
function ($router) {
|
|
31
|
+
$router->get('pods', 'SolidController@getPods');
|
|
31
32
|
$router->get('authenticate/{identifier}', 'SolidController@authenticate');
|
|
32
33
|
$router->group(['middleware' => ['fleetbase.protected']], function ($router) {
|
|
33
34
|
$router->get('account', 'SolidController@getAccountIndex');
|