PageSourceSearch

https://eva-social-robot.github.io/js/controllers/robot.js

js eva-social-robot.github.io collected 2026-10-03 09:10:59 UTC 3,312 bytes, 91 lines download raw bytes

1eva.controller('robot', ['$scope', '$http', function ($scope, $http) {
2    $scope.listado = [];
3    $scope.icon = true;
4    $scope.updateid;
5    $scope.accion = locale().COMMON.ADD;
6    Object.assign($scope, dataTableValues());
7
8    $scope.list = function () {
9        $http.get(`${URL}/api/robot`).then(function successCallback(response) {
10            $scope.listado = response.data;
11            $scope.dataTable();
12        }, function errorCallback(response) {
13            $scope.listado = []
14        });
15    }
16
17    $scope.create = function () {
18        if ($scope.validuuid($scope.robot) && !!$scope.alias && $scope.alias !== '') {
19            var json = { alias: $scope.alias, robot: $scope.robot };
20            $http.post(`${URL}/api/robot`, json).then(function successCallback(response) {
21                $scope.clear();
22                notify(locale().ROBOT.NOTIFY.POST.SUCCESS);
23            }, function errorCallback(response) {
24                notify(locale().ROBOT.NOTIFY.ERROR, 'danger');
25            });
26        } else {
27            notify(locale().ROBOT.NOTIFY.UUID, 'warning');
28        }
29    }
30
31    $scope.update = function (l) {
32        $scope.updateid = l.id;
33        $scope.alias = l.alias;
34        $scope.robot = l.robot;
35        $scope.icon = false;
36        $scope.accion = locale().COMMON.EDIT;
37        $('#myModal').modal('show');
38    }
39
40    $scope.updatesend = function () {
41        if ($scope.validuuid($scope.robot) && !!$scope.alias && $scope.alias !== '') {
42            var json = { alias: $scope.alias, robot: $scope.robot };
43            $http.put(`${URL}/api/robot/` + $scope.updateid, json).then(function successCallback(response) {
44                $scope.clear();
45                notify(locale().ROBOT.NOTIFY.UPDATE.SUCCESS);
46            }, function errorCallback(response) {
47                notify(locale().ROBOT.NOTIFY.ERROR, 'danger');
48            });
49        } else {
50            notify(locale().ROBOT.NOTIFY.UUID, 'warning');
51        }
52    }
53
54    $scope.enable = function (obj) {
55        obj.enabled = !(!!obj.enabled);
56        $http.put(`${URL}/api/robot/${obj.id}`, obj).then(function successCallback(response) {
57            $scope.clear();
58            notify(locale().ROBOT.NOTIFY.UPDATE.SUCCESS);
59        }, function errorCallback(response) {
60            notify(locale().ROBOT.NOTIFY.ERROR, 'danger');
61        });
62    }
63
64    $scope.clear = function () {
65        Object.assign($scope, { alias: '', robot: '', watson: '', icon: true, accion: locale().COMMON.ADD })
66        $('#myModal').modal('hide');
67        $scope.list();
68    }
69
70    $scope.delete = function (id) {
71        if (confirm(locale().COMMON.DELETE)) {
72            $http.delete(`${URL}/api/robot/${id}`).then(function successCallback(response) {
73                $scope.list();
74                notify(locale().ROBOT.NOTIFY.DELETE.SUCCESS);
75            }, function errorCallback(response) {
76                notify(locale().ROBOT.NOTIFY.ERROR, 'danger');
77            });
78        }
79    }
80    
81    $scope.dataTable = function (way = 0) {
82        let obj = dataTable($scope, way, 'alias', 'robot');
83        Object.assign($scope, obj);
84    }
85
86    $scope.validuuid = function (uuid) {
87        return (/^[0-9A-F]{8}-[0-9A-F]{4}-[1-5][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i.test(uuid));
88    }
89
90    $scope.list();
91}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.