File size: 3,854 Bytes
dbf83e7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6b51d0f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
document.addEventListener('DOMContentLoaded', function() {
    // Sample activity data - in a real app this would come from an API
    const activities = [
        {
            type: 'Search Console',
            status: 'Completed',
            items: 142,
            date: new Date(Date.now() - 3600000).toLocaleString(),
            icon: 'search'
        },
        {
            type: 'Analytics',
            status: 'In Progress',
            items: 327,
            date: new Date(Date.now() - 7200000).toLocaleString(),
            icon: 'bar-chart-2'
        },
        {
            type: 'Search Console',
            status: 'Failed',
            items: 83,
            date: new Date(Date.now() - 86400000).toLocaleString(),
            icon: 'search'
        },
        {
            type: 'Analytics',
            status: 'Completed',
            items: 256,
            date: new Date(Date.now() - 172800000).toLocaleString(),
            icon: 'bar-chart-2'
        }
    ];

    const activityTable = document.getElementById('activityTable');
    
    // Populate the activity table
    activities.forEach(activity => {
        const row = document.createElement('tr');
        
        // Status color
        let statusColor = 'bg-green-100 text-green-800';
        if (activity.status === 'In Progress') {
            statusColor = 'bg-blue-100 text-blue-800';
        } else if (activity.status === 'Failed') {
            statusColor = 'bg-red-100 text-red-800';
        }
        
        row.innerHTML = `
            <td class="px-6 py-4 whitespace-nowrap">
                <div class="flex items-center">
                    <i data-feather="${activity.icon}" class="w-4 h-4 mr-2"></i>
                    <span class="text-sm font-medium text-gray-900">${activity.type}</span>
                </div>
            </td>
            <td class="px-6 py-4 whitespace-nowrap">
                <span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full ${statusColor}">
                    ${activity.status}
                </span>
            </td>
            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
                ${activity.items} items
            </td>
            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
                ${activity.date}
            </td>
        `;
        
        activityTable.appendChild(row);
    });
    
    // Initialize feather icons again after adding dynamic content
    feather.replace();
});
// Google Sign-In handler
async function handleGoogleSignIn(response) {
    try {
        const res = await fetch('/auth/google');
        if (res.redirected) {
            window.location.href = res.url;
        }
    } catch (error) {
        console.error('Google Sign-In error:', error);
    }
}

// Search Console Submit
async function submitSearchConsole(urls, siteUrl) {
    try {
        const response = await fetch('/api/search-console/submit', {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json'
            },
            body: JSON.stringify({ urls, siteUrl })
        });
        return await response.json();
    } catch (error) {
        console.error('Search Console submit error:', error);
        return { error: 'Failed to submit URLs' };
    }
}

// Analytics Submit
async function submitAnalyticsEvents(events, trackingId) {
    try {
        const response = await fetch('/api/analytics/submit', {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json'
            },
            body: JSON.stringify({ events, trackingId })
        });
        return await response.json();
    } catch (error) {
        console.error('Analytics submit error:', error);
        return { error: 'Failed to submit events' };
    }
}