secubox-openwrt/package/secubox/luci-app-cdn-cache/htdocs/luci-static/resources/cdn-cache/api.js
CyberMind-FR 31a87c5d7a feat(structure): reorganize luci-app packages into package/secubox/ + appstore migration
Major structural reorganization and feature additions:

## Folder Reorganization
- Move 17 luci-app-* packages to package/secubox/ (except luci-app-secubox core hub)
- Update all tooling to support new structure:
  - secubox-tools/quick-deploy.sh: search both locations
  - secubox-tools/validate-modules.sh: validate both directories
  - secubox-tools/fix-permissions.sh: fix permissions in both locations
  - .github/workflows/test-validate.yml: build from both paths
- Update README.md links to new package/secubox/ paths

## AppStore Migration (Complete)
- Add catalog entries for all remaining luci-app packages:
  - network-tweaks.json: Network optimization tools
  - secubox-bonus.json: Documentation & demos hub
- Total: 24 apps in AppStore catalog (22 existing + 2 new)
- New category: 'documentation' for docs/demos/tutorials

## VHost Manager v2.0 Enhancements
- Add profile activation system for Internal Services and Redirects
- Implement createVHost() API wrapper for template-based deployment
- Fix Virtual Hosts view rendering with proper LuCI patterns
- Fix RPCD backend shell script errors (remove invalid local declarations)
- Extend backend validation for nginx return directives (redirect support)
- Add section_id parameter for named VHost profiles
- Add Remove button to Redirects page for feature parity
- Update README to v2.0 with comprehensive feature documentation

## Network Tweaks Dashboard
- Close button added to component details modal

Files changed: 340+ (336 renames with preserved git history)
Packages affected: 19 luci-app, 2 secubox-app, 1 theme, 4 tools

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-01 14:59:38 +01:00

158 lines
3.4 KiB
JavaScript

'use strict';
'require baseclass';
'require rpc';
/**
* CDN Cache API
* Package: luci-app-cdn-cache
* RPCD object: luci.cdn-cache
*/
// Version: 0.5.0
var callStatus = rpc.declare({
object: 'luci.cdn-cache',
method: 'status',
expect: { }
});
var callStats = rpc.declare({
object: 'luci.cdn-cache',
method: 'stats',
expect: { }
});
var callCacheList = rpc.declare({
object: 'luci.cdn-cache',
method: 'cache_list',
params: ['path', 'limit'],
expect: { files: [] }
});
var callTopDomains = rpc.declare({
object: 'luci.cdn-cache',
method: 'top_domains',
params: ['limit'],
expect: { domains: [] }
});
var callBandwidthSavings = rpc.declare({
object: 'luci.cdn-cache',
method: 'bandwidth_savings',
params: ['period'],
expect: { }
});
var callPurgeCache = rpc.declare({
object: 'luci.cdn-cache',
method: 'purge_cache'
});
var callPurgeDomain = rpc.declare({
object: 'luci.cdn-cache',
method: 'purge_domain',
params: ['domain']
});
var callPreloadUrl = rpc.declare({
object: 'luci.cdn-cache',
method: 'preload_url',
params: ['url']
});
var callGetPolicies = rpc.declare({
object: 'luci.cdn-cache',
method: 'policies',
expect: { policies: [] }
});
var callAddPolicy = rpc.declare({
object: 'luci.cdn-cache',
method: 'add_policy',
params: ['name', 'domains', 'extensions', 'cache_time', 'max_size'],
expect: { }
});
var callRemovePolicy = rpc.declare({
object: 'luci.cdn-cache',
method: 'remove_policy',
params: ['id'],
expect: { }
});
// Specification-compliant methods (rules = policies)
var callListRules = rpc.declare({
object: 'luci.cdn-cache',
method: 'list_rules',
expect: { policies: [] }
});
var callAddRule = rpc.declare({
object: 'luci.cdn-cache',
method: 'add_rule',
params: ['name', 'domains', 'extensions', 'cache_time', 'max_size'],
expect: { }
});
var callDeleteRule = rpc.declare({
object: 'luci.cdn-cache',
method: 'delete_rule',
params: ['id'],
expect: { }
});
var callSetLimits = rpc.declare({
object: 'luci.cdn-cache',
method: 'set_limits',
params: ['max_size_mb', 'cache_valid'],
expect: { }
});
function formatBytes(bytes) {
if (!bytes || bytes === 0) return '0 B';
var k = 1024;
var sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
var i = Math.floor(Math.log(bytes) / Math.log(k));
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
}
function formatUptime(seconds) {
if (!seconds) return '0s';
var d = Math.floor(seconds / 86400);
var h = Math.floor((seconds % 86400) / 3600);
var m = Math.floor((seconds % 3600) / 60);
if (d > 0) return d + 'd ' + h + 'h';
if (h > 0) return h + 'h ' + m + 'm';
return m + 'm';
}
function formatHitRatio(hits, misses) {
var total = hits + misses;
if (total === 0) return '0%';
return ((hits / total) * 100).toFixed(1) + '%';
}
return baseclass.extend({
getStatus: callStatus,
getStats: callStats,
getCacheList: callCacheList,
getTopDomains: callTopDomains,
getBandwidthSavings: callBandwidthSavings,
purgeCache: callPurgeCache,
purgeDomain: callPurgeDomain,
preloadUrl: callPreloadUrl,
// Policy methods
getPolicies: callGetPolicies,
addPolicy: callAddPolicy,
removePolicy: callRemovePolicy,
// Specification-compliant methods (rules = policies)
listRules: callListRules,
addRule: callAddRule,
deleteRule: callDeleteRule,
setLimits: callSetLimits,
// Utility functions
formatBytes: formatBytes,
formatUptime: formatUptime,
formatHitRatio: formatHitRatio
});