Additional API routes for licenses, manufacturers

This commit is contained in:
snipe 2017-01-24 18:58:07 -08:00
parent e4e4e6ae47
commit e8310c8f3c
5 changed files with 54 additions and 20 deletions

View file

@ -76,7 +76,7 @@
<th data-sortable="true" data-field="id" data-visible="false">{{ trans('general.id') }}</th>
<th data-field="companyName" data-searchable="true" data-sortable="true" data-switchable="true" data-visible="false">{{ trans('general.company') }}</th>
<th data-sortable="true" data-field="image" data-visible="false">{{ trans('admin/hardware/table.image') }}</th>
<th data-sortable="true" data-field="name" data-visible="false">{{ trans('admin/hardware/form.name') }}</th>
<th data-sortable="true" data-field="name" data-visible="false" data-formatter="assetFormatter">{{ trans('admin/hardware/form.name') }}</th>
<th data-sortable="true" data-field="asset_tag" data-formatter="assetFormatter">{{ trans('admin/hardware/table.asset_tag') }}</th>
<th data-sortable="true" data-field="serial" data-formatter="assetFormatter">{{ trans('admin/hardware/table.serial') }}</th>
<th data-sortable="true" data-field="model" data-formatter="modelFormatter">{{ trans('admin/hardware/form.model') }}</th>

View file

@ -26,17 +26,18 @@
<table
name="licenses"
id="table"
data-url="{{ route('api.licenses.list') }}"
data-url="{{ route('api.licenses.index') }}"
class="table table-striped snipe-table"
data-cookie="true"
data-click-to-select="true"
data-cookie-id-table="licenseTable">
<thead>
<tr>
<th data-checkbox="true" data-field="checkbox"></th>
<th data-sortable="true" data-field="id" data-visible="false">{{ trans('general.id') }}</th>
<th data-field="company" data-sortable="true" data-switchable="true">{{ trans('general.company') }}</th>
<th data-field="name" data-sortable="true">{{ trans('admin/licenses/table.title') }}</th>
<th data-field="manufacturer" data-sortable="true">{{ trans('general.manufacturer') }}</th>
<th data-field="companyName" data-searchable="true" data-sortable="true" data-switchable="true" data-visible="false" data-formatter="companyFormatter">{{ trans('general.company') }}</th>
<th data-sortable="true" data-field="name" data-visible="false" data-formatter="licenseFormatter">{{ trans('admin/licenses/table.title') }}</th>
<th data-field="manufacturer" data-sortable="true" data-formatter="manufacturerFormatter">{{ trans('general.manufacturer') }}</th>
<th data-field="serial" data-sortable="true" >{{ trans('admin/licenses/form.license_key') }}</th>
<th data-field="license_name" data-sortable="true" data-visible="false">{{ trans('admin/licenses/form.to_name') }}</th>
<th data-field="license_email" data-sortable="true" data-visible="false">{{ trans('admin/licenses/form.to_email') }}</th>
@ -46,8 +47,10 @@
<th data-field="purchase_cost" data-sortable="true">{{ trans('general.purchase_cost') }}</th>
<th data-field="purchase_order" data-sortable="true" data-visible="false">{{ trans('admin/licenses/form.purchase_order') }}</th>
<th data-field="expiration_date" data-sortable="true" data-visible="false">{{ trans('admin/licenses/form.expiration') }}</th>
<th data-sortable="true" data-field="created_at" data-formatter="createdAtFormatter" data-searchable="true" data-visible="false">{{ trans('general.created_at') }}</th>
<th data-field="notes" data-sortable="true" data-visible="false">{{ trans('admin/hardware/form.notes') }}</th>
<th data-field="actions">{{ trans('table.actions') }}</th>
<th data-switchable="false" data-searchable="false" data-formatter="actionsFormatter" data-sortable="false" data-field="actions" >{{ trans('table.actions') }}</th>
</tr>
</thead>
</table>
@ -62,4 +65,17 @@
@section('moar_scripts')
@include ('partials.bootstrap-table', ['exportFile' => 'licenses-export', 'search' => true])
<script>
function actionsFormatter(value, row) {
return '<nobr><a href="{{ url('/') }}/licenses/' + row.id + '/edit" class="btn btn-sm btn-warning"><i class="fa fa-pencil"></i></a> '
+ '<a data-html="false" class="btn delete-asset btn-danger btn-sm" ' +
+ 'data-toggle="modal" href="" data-content="Are you sure you wish to delete this?" '
+ 'data-title="{{ trans('general.delete') }}?" onClick="return false;">'
+ '<i class="fa fa-trash"></i></a></nobr>';
}
</script>
@stop

View file

@ -48,7 +48,7 @@
name="manufacturer_assets"
class="table table-striped bootstrap-table snipe-table"
id="assets-table"
data-url="{{ route('api.manufacturers.view', ['manufacturerId' => $manufacturer->id, 'itemtype' => 'assets']) }}"
data-url="{{ route('api.manufacturers.show', ['manufacturerId' => $manufacturer->id, 'itemtype' => 'assets']) }}"
data-cookie="true"
data-click-to-select="true"
data-cookie-id-table="maufacturerAssetsTable-{{config('version.hash_version') }}"
@ -76,7 +76,7 @@
name="manufacturer_licenses"
class="table table-striped bootstrap-table snipe-table"
id="licenses-table"
data-url="{{ route('api.manufacturers.view', ['manufacturerId' => $manufacturer->id, 'itemtype' => 'licenses']) }}"
data-url="{{ route('api.manufacturers.show', ['manufacturerId' => $manufacturer->id, 'itemtype' => 'licenses']) }}"
data-cookie="true"
data-click-to-select="true"
data-cookie-id-table="maufacturerLicensesTable-{{config('version.hash_version') }}"
@ -108,7 +108,7 @@
name="manufacturer_licenses"
class="table table-striped bootstrap-table snipe-table"
id="licenses-table"
data-url="{{ route('api.manufacturers.view', ['manufacturerId' => $manufacturer->id, 'itemtype' => 'accessories']) }}"
data-url="{{ route('api.manufacturers.show', ['manufacturerId' => $manufacturer->id, 'itemtype' => 'accessories']) }}"
data-cookie="true"
data-click-to-select="true"
data-cookie-id-table="manufacturerAccessoriesTable-{{config('version.hash_version') }}"
@ -137,7 +137,7 @@
name="manufacturer_licenses"
class="table table-striped bootstrap-table snipe-table"
id="licenses-table"
data-url="{{ route('api.manufacturers.view', ['manufacturerId' => $manufacturer->id, 'itemtype' => 'consumables']) }}"
data-url="{{ route('api.manufacturers.show', ['manufacturerId' => $manufacturer->id, 'itemtype' => 'consumables']) }}"
data-cookie="true"
data-click-to-select="true"
data-cookie-id-table="maufacturerLicensesTable-{{config('version.hash_version') }}"

View file

@ -101,7 +101,13 @@ $('.snipe-table').bootstrapTable({
function assetFormatter(value, row) {
if (value) {
return '<a href={{ url('/') }}/hardware/' + row.id + '"> ' + value + '</a>';
return '<a href="{{ url('/') }}/hardware/' + row.id + '"> ' + value + '</a>';
}
}
function manufacturerFormatter(value, row) {
if (value) {
return '<a href="{{ url('/') }}/manufacturers/' + row.id + '"> ' + value.name + '</a>';
}
}
@ -117,6 +123,12 @@ $('.snipe-table').bootstrapTable({
}
}
function licenseFormatter(value, row) {
if (value) {
return '<a href="{{ url('/') }}/licenses/' + row.id + '"> ' + row.name + '</a>';
}
}
function categoryFormatter(value, row) {
if (value) {
return '<a href="{{ url('/') }}/categories/' + value.id + '"> ' + value.name + '</a>';

View file

@ -34,6 +34,21 @@ Route::group(['prefix' => 'v1','namespace' => 'Api'], function () {
);
Route::resource('licenses', 'LicensesController',
['names' =>
[
'index' => 'api.licenses.index',
'show' => 'api.licenses.show',
'update' => 'api.licenses.update',
'store' => 'api.licenses.store',
'destroy' => 'api.licenses.destroy'
],
'except' => ['edit'],
'parameters' => ['license' => 'license_id']
]
);
Route::resource('models', 'AssetModelsController',
['names' =>
[
@ -262,8 +277,6 @@ Route::group(['prefix' => 'v1','namespace' => 'Api'], function () {
});
/*---Suppliers API---*/
Route::group(array('prefix'=>'suppliers'), function () {
Route::get('list', array('as'=>'api.suppliers.list', 'uses'=>'SuppliersController@getDatatable'));
@ -280,13 +293,6 @@ Route::group(['prefix' => 'v1','namespace' => 'Api'], function () {
/*---Licenses API---*/
Route::group([ 'prefix' => 'licenses' ], function () {
Route::get('list', [ 'as' => 'api.licenses.list', 'uses' => 'LicensesController@getDatatable' ]);
});
Route::group([ 'prefix' => 'fields' ], function () {