mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
service templates - move to blade -wip
This commit is contained in:
@@ -1,47 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* LibreNMS
|
||||
*
|
||||
* Copyright (c) 2016 Aaron Daniels <[email protected]>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version. Please see LICENSE.txt at the top level of
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
if (! Auth::user()->hasGlobalAdmin()) {
|
||||
exit('ERROR: You need to be admin');
|
||||
}
|
||||
|
||||
$service_template_id = $vars['service_template_id'];
|
||||
$device_group_id = $vars['device_group_id'];
|
||||
$type = $vars['stype'];
|
||||
$desc = $vars['desc'];
|
||||
$ip = $vars['ip'];
|
||||
$param = $vars['param'];
|
||||
$ignore = isset($vars['ignore']) ? 1 : 0;
|
||||
$disabled = isset($vars['disabled']) ? 1 : 0;
|
||||
$name = $vars['name'];
|
||||
|
||||
if (is_numeric($service_template_id) && $service_template_id > 0) {
|
||||
// Need to edit.
|
||||
$update = ['device_group_id' => $device_group_id, 'service_template_type' => $type, 'service_template_desc' => $desc, 'service_template_ip' => $ip, 'service_template_param' => $param, 'service_template_ignore' => $ignore, 'service_template_disabled' => $disabled, 'service_template_name' => $name, 'service_template_changed' => ['UNIX_TIMESTAMP(NOW())']];
|
||||
if (is_numeric(edit_service_template($update, $service_template_id))) {
|
||||
$status = ['status' =>0, 'message' => 'Modified Service Template: <i>' . $service_template_id . ': ' . $type . '</i>'];
|
||||
} else {
|
||||
$status = ['status' =>1, 'message' => 'ERROR: Failed to modify Service Template: <i>' . $service_template_id . '</i>'];
|
||||
}
|
||||
} else {
|
||||
// Need to add.
|
||||
$service_template_id = add_service_template($device_group_id, $type, $desc, $ip, $param, $ignore, $disabled, $name);
|
||||
if ($service_template_id === null) {
|
||||
$status = ['status' =>1, 'message' => 'ERROR: Failed to add Service Template: <i>' . $service_template_id . ': ' . $type . '</i>'];
|
||||
} else {
|
||||
$status = ['status' =>0, 'message' => 'Added Service Template: <i>' . $service_template_id . ': ' . $type . '</i>'];
|
||||
}
|
||||
}
|
||||
header('Content-Type: application/json');
|
||||
echo _json_encode($status);
|
||||
@@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* LibreNMS
|
||||
*
|
||||
* Copyright (c) 2016 Aaron Daniels <[email protected]>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version. Please see LICENSE.txt at the top level of
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
if (! Auth::user()->hasGlobalAdmin()) {
|
||||
exit('ERROR: You need to be admin');
|
||||
}
|
||||
|
||||
$service_template_id = $vars['service_template_id'];
|
||||
|
||||
if (is_numeric($service_template_id) && $service_template_id > 0) {
|
||||
$service_template = service_template_get($service_template_id);
|
||||
|
||||
$output = [
|
||||
'device_group_id' => $service_template[0]['device_group_id'],
|
||||
'stype' => $service_template[0]['service_template_type'],
|
||||
'desc' => $service_template[0]['service_template_desc'],
|
||||
'ip' => $service_template[0]['service_template_ip'],
|
||||
'param' => $service_template[0]['service_template_param'],
|
||||
'ignore' => $service_template[0]['service_template_ignore'],
|
||||
'disabled' => $service_template[0]['service_template_disabled'],
|
||||
'name' => $service_template[0]['service_template_name'],
|
||||
];
|
||||
|
||||
header('Content-Type: application/json');
|
||||
echo _json_encode($output);
|
||||
}
|
||||
@@ -19,19 +19,18 @@ if (Auth::user()->hasGlobalAdmin()) {
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h2 class="modal-title" id="Delete">Delete Service</h2>
|
||||
<h5 class="modal-title" id="Delete">Confirm Delete</h5>
|
||||
</div>
|
||||
<div class='alert alert-info'>Service will be deleted.</div>
|
||||
<div class='well well-lg'>
|
||||
<div class="modal-body">
|
||||
<p>Please confirm that you would like to delete this service.</p>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="modal-body">
|
||||
<p>Please confirm that you would like to delete this service.</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<form role="form" class="remove_token_form">
|
||||
<?php echo csrf_field() ?>
|
||||
<center><button type="submit" class="btn btn-danger danger" id="service-removal"
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
|
||||
<button type="submit" class="btn btn-danger danger" id="service-removal"
|
||||
data-target="service-removal">Delete
|
||||
</button></center>
|
||||
</button>
|
||||
<input type="hidden" name="service_id" id="service_id" value="">
|
||||
<input type="hidden" name="confirm" id="confirm" value="yes">
|
||||
</form>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
@extends('layouts.librenmsv1')
|
||||
|
||||
@section('title', __('Edit Device Group'))
|
||||
@section('title', __('Edit Service Template'))
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
|
||||
Reference in New Issue
Block a user