snow-flow 2.0.4 → 2.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/snow-flow-config.d.ts +1492 -0
- package/dist/config/snow-flow-config.js +938 -0
- package/dist/coordination/coordination-engine.d.ts +41 -0
- package/dist/coordination/coordination-engine.js +324 -0
- package/dist/coordination/coordination.test.d.ts +6 -0
- package/dist/coordination/example.d.ts +31 -0
- package/dist/coordination/example.js +394 -0
- package/dist/coordination/execution-patterns.d.ts +43 -0
- package/dist/coordination/execution-patterns.js +507 -0
- package/dist/coordination/factory.d.ts +94 -0
- package/dist/coordination/factory.js +433 -0
- package/dist/coordination/index.d.ts +71 -0
- package/dist/coordination/index.js +135 -0
- package/dist/coordination/progress-monitor.d.ts +71 -0
- package/dist/coordination/progress-monitor.js +505 -0
- package/dist/coordination/quality-gates.d.ts +124 -0
- package/dist/coordination/quality-gates.js +577 -0
- package/dist/coordination/shared-memory.d.ts +39 -0
- package/dist/coordination/shared-memory.js +289 -0
- package/dist/coordination/task-dependencies.d.ts +50 -0
- package/dist/coordination/task-dependencies.js +407 -0
- package/dist/coordination/team-coordinator.d.ts +59 -0
- package/dist/coordination/team-coordinator.js +550 -0
- package/dist/coordination/types.d.ts +152 -0
- package/dist/coordination/types.js +3 -0
- package/dist/memory/hierarchical-memory-system.d.ts +90 -0
- package/dist/memory/hierarchical-memory-system.js +400 -0
- package/dist/memory/index.d.ts +9 -0
- package/dist/memory/index.js +20 -0
- package/dist/memory/mcp-integration-example.d.ts +6 -0
- package/dist/memory/mcp-integration-example.js +281 -0
- package/dist/memory/memory-client.d.ts +199 -0
- package/dist/memory/memory-client.js +364 -0
- package/dist/memory/memory-manager.d.ts +29 -0
- package/dist/memory/memory-manager.js +280 -0
- package/dist/memory/memory-operations.d.ts +179 -0
- package/dist/memory/memory-operations.js +691 -0
- package/dist/memory/memory-system.d.ts +152 -0
- package/dist/memory/memory-system.js +632 -0
- package/dist/memory/memory-test.d.ts +6 -0
- package/dist/memory/memory-test.js +161 -0
- package/dist/memory/servicenow-artifact-indexer.d.ts +119 -0
- package/dist/memory/servicenow-artifact-indexer.js +560 -0
- package/dist/memory/snow-flow-memory-patterns.d.ts +213 -0
- package/dist/memory/snow-flow-memory-patterns.js +200 -0
- package/dist/memory/snow-memory.d.ts +54 -0
- package/dist/memory/snow-memory.js +301 -0
- package/dist/memory/swarm-memory.d.ts +135 -0
- package/dist/memory/swarm-memory.js +378 -0
- package/memory/claude-flow-data.json +5 -0
- package/memory/servicenow_artifacts/000d9224c895221055906c7518aa2d3d.json +30 -0
- package/memory/servicenow_artifacts/0196b66173303010e46b4a2214f6a7a2.json +36 -0
- package/memory/servicenow_artifacts/125e5d1d837e2a102a7ea130ceaad397.json +30 -0
- package/memory/servicenow_artifacts/7637c1f2b7112210a5e5911cde11a972.json +30 -0
- package/memory/servicenow_artifacts/default_documentation_tables_1754056582292.json +55 -0
- package/memory/servicenow_artifacts/default_documentation_tables_1754057477189.json +55 -0
- package/memory/sessions/README.md +32 -0
- package/memory/update-set-sessions/01f82af583faea102a7ea130ceaad3d4.json +9 -0
- package/memory/update-set-sessions/27718fb983faea102a7ea130ceaad34b.json +9 -0
- package/memory/update-set-sessions/412e9bf6833e22502a7ea130ceaad30a.json +8 -0
- package/memory/update-set-sessions/66fc5a79837aea102a7ea130ceaad3ab.json +9 -0
- package/memory/update-set-sessions/71a30ff5837eea102a7ea130ceaad37f.json +9 -0
- package/memory/update-set-sessions/74fba27983faea102a7ea130ceaad3bd.json +9 -0
- package/memory/update-set-sessions/a0b147b5837eea102a7ea130ceaad344.json +58 -0
- package/memory/update-set-sessions/b13f5eb983baea102a7ea130ceaad33e.json +9 -0
- package/package.json +1 -1
- package/reports/swarm-auto-centralized-1752649029776.json +13 -0
- package/scripts/postinstall.js +30 -0
- package/scripts/update-version.js +31 -0
- package/servicenow/widgets/openai_incident_classifier/client_controller.js +284 -0
- package/servicenow/widgets/openai_incident_classifier/server_script.js +314 -0
- package/servicenow/widgets/openai_incident_classifier/style.css +354 -0
- package/servicenow/widgets/openai_incident_classifier/template.html +167 -0
- package/servicenow/widgets/openai_incident_classifier/widget.json +86 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"update_set_id": "27718fb983faea102a7ea130ceaad34b",
|
|
3
|
+
"name": "iPhone 6 Approval Flow",
|
|
4
|
+
"description": "Flow to require admin approval for iPhone 6 requests. Includes condition checking, approval routing, and notifications for approval/rejection.",
|
|
5
|
+
"user_story": "FLOW-001",
|
|
6
|
+
"created_at": "2025-07-18T14:17:25.143Z",
|
|
7
|
+
"state": "in_progress",
|
|
8
|
+
"artifacts": []
|
|
9
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{
|
|
2
|
+
"update_set_id": "412e9bf6833e22502a7ea130ceaad30a",
|
|
3
|
+
"name": "Auto-HTTP request tracking development (2025-07-21 18:56)",
|
|
4
|
+
"description": "Automatically created Update Set for HTTP request tracking development",
|
|
5
|
+
"created_at": "2025-07-21 18:56:29",
|
|
6
|
+
"state": "in progress",
|
|
7
|
+
"artifacts": []
|
|
8
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"update_set_id": "66fc5a79837aea102a7ea130ceaad3ab",
|
|
3
|
+
"name": "iPhone 6 Admin Approval Flow",
|
|
4
|
+
"description": "Flow to check if a request is for iPhone 6 and route to admin approval if true. Includes flow designer workflow, approval configurations, and notification templates.",
|
|
5
|
+
"user_story": "REQ-001",
|
|
6
|
+
"created_at": "2025-07-18T11:37:52.906Z",
|
|
7
|
+
"state": "in_progress",
|
|
8
|
+
"artifacts": []
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"update_set_id": "71a30ff5837eea102a7ea130ceaad37f",
|
|
3
|
+
"name": "iPhone 6 Approval Flow",
|
|
4
|
+
"description": "Flow to check for iPhone 6 requests and require admin approval. Includes flow design, approval routing, and notifications.",
|
|
5
|
+
"user_story": "TASK-001",
|
|
6
|
+
"created_at": "2025-07-18T14:26:50.683Z",
|
|
7
|
+
"state": "in_progress",
|
|
8
|
+
"artifacts": []
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"update_set_id": "74fba27983faea102a7ea130ceaad3bd",
|
|
3
|
+
"name": "iPhone 6 Approval Flow",
|
|
4
|
+
"description": "Implementation of approval flow for iPhone 6 requests. When a request is for an iPhone 6, it requires admin approval before proceeding.",
|
|
5
|
+
"user_story": "FLOW-001",
|
|
6
|
+
"created_at": "2025-07-18T12:43:17.671Z",
|
|
7
|
+
"state": "in_progress",
|
|
8
|
+
"artifacts": []
|
|
9
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"update_set_id": "a0b147b5837eea102a7ea130ceaad344",
|
|
3
|
+
"name": "iPhone 6 Testing - Flow Validation",
|
|
4
|
+
"description": "Testing and validation of iPhone 6 approval flow functionality including detection logic, approval routing, notifications, and edge cases",
|
|
5
|
+
"user_story": "TEST-001",
|
|
6
|
+
"created_at": "2025-07-18T14:18:18.118Z",
|
|
7
|
+
"state": "complete",
|
|
8
|
+
"artifacts": [
|
|
9
|
+
{
|
|
10
|
+
"type": "business_rule",
|
|
11
|
+
"sys_id": "07e18bb5837eea102a7ea130ceaad330",
|
|
12
|
+
"name": "iPhone 6 Test Request Creator",
|
|
13
|
+
"created_at": "2025-07-18T14:19:22.675Z"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"type": "script_include",
|
|
17
|
+
"sys_id": "89128fb5837eea102a7ea130ceaad312",
|
|
18
|
+
"name": "iPhone6ApprovalFlowTester",
|
|
19
|
+
"created_at": "2025-07-18T14:20:04.704Z"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"type": "ui_action",
|
|
23
|
+
"sys_id": "6b228fb5837eea102a7ea130ceaad31a",
|
|
24
|
+
"name": "Run iPhone 6 Flow Tests",
|
|
25
|
+
"created_at": "2025-07-18T14:20:27.725Z"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"type": "business_rule",
|
|
29
|
+
"sys_id": "ba3243f5837eea102a7ea130ceaad39d",
|
|
30
|
+
"name": "iPhone 6 Approval Routing Test",
|
|
31
|
+
"created_at": "2025-07-18T14:20:58.345Z"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"type": "notification",
|
|
35
|
+
"sys_id": "c94243f5837eea102a7ea130ceaad3a5",
|
|
36
|
+
"name": "iPhone 6 Approval Required",
|
|
37
|
+
"created_at": "2025-07-18T14:21:02.112Z"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"type": "notification",
|
|
41
|
+
"sys_id": "3a4283f5837eea102a7ea130ceaad342",
|
|
42
|
+
"name": "iPhone 6 Request Submitted",
|
|
43
|
+
"created_at": "2025-07-18T14:21:06.169Z"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"type": "script_include",
|
|
47
|
+
"sys_id": "117247b5837eea102a7ea130ceaad3a6",
|
|
48
|
+
"name": "iPhone6EdgeCaseTester",
|
|
49
|
+
"created_at": "2025-07-18T14:22:54.361Z"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"type": "script_include",
|
|
53
|
+
"sys_id": "86b283f5837eea102a7ea130ceaad33a",
|
|
54
|
+
"name": "iPhone6TestReportGenerator",
|
|
55
|
+
"created_at": "2025-07-18T14:22:57.448Z"
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"update_set_id": "b13f5eb983baea102a7ea130ceaad33e",
|
|
3
|
+
"name": "iPhone 6 Admin Approval Flow",
|
|
4
|
+
"description": "Implements a flow that checks if a service catalog request is for an iPhone 6. If it is, the request requires admin approval before proceeding.",
|
|
5
|
+
"user_story": "REQ-001",
|
|
6
|
+
"created_at": "2025-07-18T11:47:39.398Z",
|
|
7
|
+
"state": "in_progress",
|
|
8
|
+
"artifacts": []
|
|
9
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "snow-flow",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.6",
|
|
4
4
|
"description": "Snow-Flow: ServiceNow Advanced Intelligence Platform - 100+ real MCP tools with AI-powered swarm orchestration. Zero Mock Data, 100% Real API Integration. Natural language interface for ServiceNow operations.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"objective": "create a multi agent implementation of claude-flow for a servicenow instance. As in the way that we do exactly the same as what claude-flow already does, multi agent orchestration of claude-code, but then for SerivceNow, for example I want that this cmd: [snow-flow swarm 'create a widget for X'] a multi agent orchestration spawns with multiple agents that would create a widget in servicenow, or anything ofcourse. We should look at claude-flows github and should duplicate as best as we could to get this product: https://github.com/ruvnet/claude-flow - this would be called snow-flow as a reference to servicenow that everyone calls snow wrongly and flow as in claude-flow. Just like claude-flow this snow-flow would live in the cli, orchestrating claude-code how to build, but then it would be always pointed towards servicenow. The user should give their OAuth or basic authentication and should be able to, kist like claude-flow, use their claude-code subscription to save on token costs. Claude-flow only orchestrates, claude-code creates so its important that we keep that aspect of the tool",
|
|
3
|
+
"strategy": "auto",
|
|
4
|
+
"mode": "centralized",
|
|
5
|
+
"maxAgents": 5,
|
|
6
|
+
"timeout": 60,
|
|
7
|
+
"parallel": false,
|
|
8
|
+
"monitor": false,
|
|
9
|
+
"output": "json",
|
|
10
|
+
"outputDir": "./reports",
|
|
11
|
+
"timestamp": "2025-07-16T06:57:09.774Z",
|
|
12
|
+
"id": "swarm-auto-centralized-1752649029776"
|
|
13
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const os = require('os');
|
|
6
|
+
|
|
7
|
+
console.log('🚀 Setting up Snow-Flow...');
|
|
8
|
+
|
|
9
|
+
// Check if we're in a global install
|
|
10
|
+
const isGlobalInstall = process.env.npm_config_global === 'true' ||
|
|
11
|
+
process.env.npm_config_global === true;
|
|
12
|
+
|
|
13
|
+
if (isGlobalInstall) {
|
|
14
|
+
console.log('✅ Snow-Flow installed globally');
|
|
15
|
+
console.log('📁 Run "snow-flow init" in your project directory to initialize');
|
|
16
|
+
|
|
17
|
+
// Create global config directory
|
|
18
|
+
const globalConfigDir = path.join(os.homedir(), '.snow-flow');
|
|
19
|
+
if (!fs.existsSync(globalConfigDir)) {
|
|
20
|
+
fs.mkdirSync(globalConfigDir, { recursive: true });
|
|
21
|
+
console.log(`✅ Created global config directory at ${globalConfigDir}`);
|
|
22
|
+
}
|
|
23
|
+
} else {
|
|
24
|
+
// Local installation - don't create directories automatically
|
|
25
|
+
console.log('✅ Snow-Flow installed locally');
|
|
26
|
+
console.log('🔧 Run "snow-flow init" to initialize your project');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
console.log('\n📚 Documentation: https://github.com/groeimetai/snow-flow#readme');
|
|
30
|
+
console.log('🆘 Get help: snow-flow --help');
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Update version.ts with the current version from package.json
|
|
5
|
+
* This script runs automatically after npm version
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
const path = require('path');
|
|
10
|
+
|
|
11
|
+
// Read package.json
|
|
12
|
+
const packageJsonPath = path.join(__dirname, '..', 'package.json');
|
|
13
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
14
|
+
const version = packageJson.version;
|
|
15
|
+
|
|
16
|
+
// Path to version.ts
|
|
17
|
+
const versionTsPath = path.join(__dirname, '..', 'src', 'version.ts');
|
|
18
|
+
|
|
19
|
+
// Read current version.ts content
|
|
20
|
+
const versionTsContent = fs.readFileSync(versionTsPath, 'utf8');
|
|
21
|
+
|
|
22
|
+
// Replace the VERSION constant
|
|
23
|
+
const updatedContent = versionTsContent.replace(
|
|
24
|
+
/export const VERSION = '[^']+';/,
|
|
25
|
+
`export const VERSION = '${version}';`
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
// Write updated content back
|
|
29
|
+
fs.writeFileSync(versionTsPath, updatedContent, 'utf8');
|
|
30
|
+
|
|
31
|
+
console.log(`✅ Updated version.ts to ${version}`);
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
function OpenAIIncidentClassifierController($scope, $http, spUtil) {
|
|
2
|
+
var c = this;
|
|
3
|
+
|
|
4
|
+
// Initialize variables
|
|
5
|
+
c.incidents = [];
|
|
6
|
+
c.statistics = {
|
|
7
|
+
totalIncidents: 0,
|
|
8
|
+
classifiedIncidents: 0,
|
|
9
|
+
averageConfidence: 0,
|
|
10
|
+
processingTime: 0
|
|
11
|
+
};
|
|
12
|
+
c.isLoading = false;
|
|
13
|
+
c.error = null;
|
|
14
|
+
c.charts = {};
|
|
15
|
+
|
|
16
|
+
// Date range and filtering
|
|
17
|
+
c.dateRange = {
|
|
18
|
+
start: new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toISOString().split('T')[0],
|
|
19
|
+
end: new Date().toISOString().split('T')[0]
|
|
20
|
+
};
|
|
21
|
+
c.selectedPriority = '';
|
|
22
|
+
|
|
23
|
+
// Pagination
|
|
24
|
+
c.pagination = {
|
|
25
|
+
currentPage: 1,
|
|
26
|
+
pageSize: 10,
|
|
27
|
+
totalPages: 1,
|
|
28
|
+
totalRecords: 0,
|
|
29
|
+
pages: []
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// Initialize widget
|
|
33
|
+
c.initialize = function() {
|
|
34
|
+
c.loadData();
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// Load data from server
|
|
38
|
+
c.loadData = function() {
|
|
39
|
+
c.isLoading = true;
|
|
40
|
+
c.error = null;
|
|
41
|
+
|
|
42
|
+
var params = {
|
|
43
|
+
start_date: c.dateRange.start,
|
|
44
|
+
end_date: c.dateRange.end,
|
|
45
|
+
priority: c.selectedPriority,
|
|
46
|
+
page: c.pagination.currentPage,
|
|
47
|
+
page_size: c.pagination.pageSize
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
$http.post('/api/now/sp/widget/' + c.widget.id, {
|
|
51
|
+
action: 'get_incidents',
|
|
52
|
+
params: params
|
|
53
|
+
}).then(function(response) {
|
|
54
|
+
if (response.data.result.success) {
|
|
55
|
+
c.incidents = response.data.result.incidents;
|
|
56
|
+
c.statistics = response.data.result.statistics;
|
|
57
|
+
c.pagination.totalRecords = response.data.result.total_records;
|
|
58
|
+
c.pagination.totalPages = Math.ceil(c.pagination.totalRecords / c.pagination.pageSize);
|
|
59
|
+
c.updatePaginationPages();
|
|
60
|
+
c.updateCharts();
|
|
61
|
+
} else {
|
|
62
|
+
c.error = response.data.result.error || 'Failed to load incidents';
|
|
63
|
+
}
|
|
64
|
+
}).catch(function(error) {
|
|
65
|
+
c.error = 'Error loading data: ' + (error.data && error.data.error ? error.data.error : error.message);
|
|
66
|
+
}).finally(function() {
|
|
67
|
+
c.isLoading = false;
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// Update pagination pages array
|
|
72
|
+
c.updatePaginationPages = function() {
|
|
73
|
+
c.pagination.pages = [];
|
|
74
|
+
var startPage = Math.max(1, c.pagination.currentPage - 2);
|
|
75
|
+
var endPage = Math.min(c.pagination.totalPages, c.pagination.currentPage + 2);
|
|
76
|
+
|
|
77
|
+
for (var i = startPage; i <= endPage; i++) {
|
|
78
|
+
c.pagination.pages.push(i);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
// Go to specific page
|
|
83
|
+
c.goToPage = function(page) {
|
|
84
|
+
if (page >= 1 && page <= c.pagination.totalPages && page !== c.pagination.currentPage) {
|
|
85
|
+
c.pagination.currentPage = page;
|
|
86
|
+
c.loadData();
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
// Date range change handler
|
|
91
|
+
c.onDateRangeChange = function() {
|
|
92
|
+
c.pagination.currentPage = 1;
|
|
93
|
+
c.loadData();
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
// Priority change handler
|
|
97
|
+
c.onPriorityChange = function() {
|
|
98
|
+
c.pagination.currentPage = 1;
|
|
99
|
+
c.loadData();
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
// Refresh data
|
|
103
|
+
c.refreshData = function() {
|
|
104
|
+
c.loadData();
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
// Reclassify incident
|
|
108
|
+
c.reclassifyIncident = function(incident) {
|
|
109
|
+
c.isLoading = true;
|
|
110
|
+
|
|
111
|
+
$http.post('/api/now/sp/widget/' + c.widget.id, {
|
|
112
|
+
action: 'reclassify_incident',
|
|
113
|
+
incident_id: incident.sys_id
|
|
114
|
+
}).then(function(response) {
|
|
115
|
+
if (response.data.result.success) {
|
|
116
|
+
spUtil.addInfoMessage('Incident reclassified successfully');
|
|
117
|
+
c.loadData();
|
|
118
|
+
} else {
|
|
119
|
+
c.error = response.data.result.error || 'Failed to reclassify incident';
|
|
120
|
+
}
|
|
121
|
+
}).catch(function(error) {
|
|
122
|
+
c.error = 'Error reclassifying incident: ' + (error.data && error.data.error ? error.data.error : error.message);
|
|
123
|
+
}).finally(function() {
|
|
124
|
+
c.isLoading = false;
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
// Update charts
|
|
129
|
+
c.updateCharts = function() {
|
|
130
|
+
c.createClassificationChart();
|
|
131
|
+
c.createPriorityChart();
|
|
132
|
+
c.createTrendChart();
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
// Create classification distribution chart
|
|
136
|
+
c.createClassificationChart = function() {
|
|
137
|
+
var ctx = document.getElementById('classificationChart');
|
|
138
|
+
if (!ctx) return;
|
|
139
|
+
|
|
140
|
+
// Destroy existing chart
|
|
141
|
+
if (c.charts.classification) {
|
|
142
|
+
c.charts.classification.destroy();
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Aggregate classification data
|
|
146
|
+
var classificationData = {};
|
|
147
|
+
c.incidents.forEach(function(incident) {
|
|
148
|
+
var classification = incident.ai_classification || 'Unclassified';
|
|
149
|
+
classificationData[classification] = (classificationData[classification] || 0) + 1;
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
var labels = Object.keys(classificationData);
|
|
153
|
+
var data = Object.values(classificationData);
|
|
154
|
+
var colors = ['#dc3545', '#007bff', '#28a745', '#fd7e14', '#6f42c1', '#6c757d'];
|
|
155
|
+
|
|
156
|
+
c.charts.classification = new Chart(ctx, {
|
|
157
|
+
type: 'doughnut',
|
|
158
|
+
data: {
|
|
159
|
+
labels: labels,
|
|
160
|
+
datasets: [{
|
|
161
|
+
data: data,
|
|
162
|
+
backgroundColor: colors.slice(0, labels.length),
|
|
163
|
+
borderWidth: 2,
|
|
164
|
+
borderColor: '#fff'
|
|
165
|
+
}]
|
|
166
|
+
},
|
|
167
|
+
options: {
|
|
168
|
+
responsive: true,
|
|
169
|
+
maintainAspectRatio: false,
|
|
170
|
+
plugins: {
|
|
171
|
+
legend: {
|
|
172
|
+
position: 'bottom'
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
// Create priority distribution chart
|
|
180
|
+
c.createPriorityChart = function() {
|
|
181
|
+
var ctx = document.getElementById('priorityChart');
|
|
182
|
+
if (!ctx) return;
|
|
183
|
+
|
|
184
|
+
// Destroy existing chart
|
|
185
|
+
if (c.charts.priority) {
|
|
186
|
+
c.charts.priority.destroy();
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// Aggregate priority data
|
|
190
|
+
var priorityData = {};
|
|
191
|
+
var priorityLabels = {'1': 'Critical', '2': 'High', '3': 'Moderate', '4': 'Low'};
|
|
192
|
+
|
|
193
|
+
c.incidents.forEach(function(incident) {
|
|
194
|
+
var priority = incident.priority || '4';
|
|
195
|
+
var label = priorityLabels[priority] || 'Unknown';
|
|
196
|
+
priorityData[label] = (priorityData[label] || 0) + 1;
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
var labels = Object.keys(priorityData);
|
|
200
|
+
var data = Object.values(priorityData);
|
|
201
|
+
var colors = ['#dc3545', '#fd7e14', '#ffc107', '#28a745'];
|
|
202
|
+
|
|
203
|
+
c.charts.priority = new Chart(ctx, {
|
|
204
|
+
type: 'bar',
|
|
205
|
+
data: {
|
|
206
|
+
labels: labels,
|
|
207
|
+
datasets: [{
|
|
208
|
+
label: 'Number of Incidents',
|
|
209
|
+
data: data,
|
|
210
|
+
backgroundColor: colors.slice(0, labels.length),
|
|
211
|
+
borderWidth: 1
|
|
212
|
+
}]
|
|
213
|
+
},
|
|
214
|
+
options: {
|
|
215
|
+
responsive: true,
|
|
216
|
+
maintainAspectRatio: false,
|
|
217
|
+
scales: {
|
|
218
|
+
y: {
|
|
219
|
+
beginAtZero: true
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
// Create trend chart
|
|
227
|
+
c.createTrendChart = function() {
|
|
228
|
+
var ctx = document.getElementById('trendChart');
|
|
229
|
+
if (!ctx) return;
|
|
230
|
+
|
|
231
|
+
// Destroy existing chart
|
|
232
|
+
if (c.charts.trend) {
|
|
233
|
+
c.charts.trend.destroy();
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Aggregate trend data by date
|
|
237
|
+
var trendData = {};
|
|
238
|
+
c.incidents.forEach(function(incident) {
|
|
239
|
+
var date = new Date(incident.created_date).toISOString().split('T')[0];
|
|
240
|
+
trendData[date] = (trendData[date] || 0) + 1;
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
var labels = Object.keys(trendData).sort();
|
|
244
|
+
var data = labels.map(function(date) {
|
|
245
|
+
return trendData[date];
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
c.charts.trend = new Chart(ctx, {
|
|
249
|
+
type: 'line',
|
|
250
|
+
data: {
|
|
251
|
+
labels: labels,
|
|
252
|
+
datasets: [{
|
|
253
|
+
label: 'Incidents per Day',
|
|
254
|
+
data: data,
|
|
255
|
+
borderColor: '#007bff',
|
|
256
|
+
backgroundColor: 'rgba(0, 123, 255, 0.1)',
|
|
257
|
+
borderWidth: 2,
|
|
258
|
+
fill: true
|
|
259
|
+
}]
|
|
260
|
+
},
|
|
261
|
+
options: {
|
|
262
|
+
responsive: true,
|
|
263
|
+
maintainAspectRatio: false,
|
|
264
|
+
scales: {
|
|
265
|
+
y: {
|
|
266
|
+
beginAtZero: true
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
// Cleanup function
|
|
274
|
+
c.$onDestroy = function() {
|
|
275
|
+
Object.values(c.charts).forEach(function(chart) {
|
|
276
|
+
if (chart) {
|
|
277
|
+
chart.destroy();
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
// Initialize widget when loaded
|
|
283
|
+
c.initialize();
|
|
284
|
+
}
|