const axios = require('axios');
export default {
    getProjects(index, count, callback) {
        axios.get('/api/project' + "/" + index + "/" + count)
            .then(response => callback(response));
    },
    getProjectsCount(callback) {
        axios.get('/api/project/count')
            .then(response => callback(response))
    },
    delProjects(projects, callback) {
        axios.delete('/api/project', {data: projects})
            .then(response => callback(response));
    },
    deployProjectZip(project, callback) {
        var url = '/api/project/deploy/zip?address=' + project.address + "&project=" + project.project + "&file=" + project.file;
        axios.get(url).then((response) => {
            callback(response);
        })
    },
    deployProjectEgg(project, callback) {
        var url = '/api/project/deploy/egg?address=' + project.address + "&project=" + project.project + "&file=" + project.file;
        axios.get(url).then((response) => {
            callback(response);
        })
    },
    saveProject(project, callback) {
        axios.post('/api/project', project).then((response) => {
            callback(response);
        })
    },
    getProjectsByNodeServer(server, callback) {
        axios.get('/api/project/nodeserver?nodeServer=' + server)
            .then(response => callback(response));
    },
    getSpidersOfProject(server, project, callback) {
        axios.get('/api/project/spider?nodeServer=' + server + '&project=' + project)
            .then(response => callback(response));
    },
    getAllProject(callback) {
        axios.get('/api/project')
            .then(response => callback(response));
    }
}