function startOrStop()

in entity-browser-frontend/app/service/db.js [46:68]


            function startOrStop(db) {
                var isStart = db.opened;
                return $http.post('api/dbs/' + db.uuid, db, {
                    params: {
                        op: isStart ? "start" : "stop"
                    }
                }).then(function (response) {
                    var msg = isStart ? 'started' : 'stopped';
                    if (isStart !== response.data.opened) {
                        alert.error('Database cannot be ' + msg);
                    } else {
                        alert.success('Database is ' + msg);
                    }
                    var oldDb = service.databases.find(function (oldDb) {
                        return oldDb.uuid === db.uuid;
                    });
                    angular.extend(oldDb, response.data);
                    return response;
                }).catch(function (response) {
                    alert.showHttpError(response);
                    db.opened = !db.opened; // revert model
                });
            }