Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
smradius
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
smradius
smradius
Commits
dd3abf5f
Commit
dd3abf5f
authored
15 years ago
by
Robert Anderson
Browse files
Options
Downloads
Patches
Plain Diff
Use sprintf.js, util.js from js/custom/
parent
eff8761a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
webgui/js/app/sprintf.js
+0
-55
0 additions, 55 deletions
webgui/js/app/sprintf.js
webgui/js/app/util.js
+0
-12
0 additions, 12 deletions
webgui/js/app/util.js
webgui/js/app/windows/AdminUserLogs.js
+85
-13
85 additions, 13 deletions
webgui/js/app/windows/AdminUserLogs.js
with
85 additions
and
80 deletions
webgui/js/app/sprintf.js
deleted
100644 → 0
+
0
−
55
View file @
eff8761a
/**
* sprintf() for JavaScript v.0.4
*
* Copyright (c) 2007 Alexandru Marasteanu <http://alexei.417.ro/>
* Thanks to David Baird (unit test and patch).
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
function
str_repeat
(
i
,
m
)
{
for
(
var
o
=
[];
m
>
0
;
o
[
--
m
]
=
i
);
return
(
o
.
join
(
''
));
}
function
sprintf
()
{
var
i
=
0
,
a
,
f
=
arguments
[
i
++
],
o
=
[],
m
,
p
,
c
,
x
;
while
(
f
)
{
if
(
m
=
/^
[^\x
25
]
+/
.
exec
(
f
))
o
.
push
(
m
[
0
]);
else
if
(
m
=
/^
\x
25
{2}
/
.
exec
(
f
))
o
.
push
(
'
%
'
);
else
if
(
m
=
/^
\x
25
(?:(\d
+
)\$)?(\+)?(
0|'
[^
$
])?(
-
)?(\d
+
)?(?:\.(\d
+
))?([
b-fosuxX
])
/
.
exec
(
f
))
{
if
(((
a
=
arguments
[
m
[
1
]
||
i
++
])
==
null
)
||
(
a
==
undefined
))
throw
(
"
Too few arguments.
"
);
if
(
/
[^
s
]
/
.
test
(
m
[
7
])
&&
(
typeof
(
a
)
!=
'
number
'
))
throw
(
"
Expecting number but found
"
+
typeof
(
a
));
switch
(
m
[
7
])
{
case
'
b
'
:
a
=
a
.
toString
(
2
);
break
;
case
'
c
'
:
a
=
String
.
fromCharCode
(
a
);
break
;
case
'
d
'
:
a
=
parseInt
(
a
);
break
;
case
'
e
'
:
a
=
m
[
6
]
?
a
.
toExponential
(
m
[
6
])
:
a
.
toExponential
();
break
;
case
'
f
'
:
a
=
m
[
6
]
?
parseFloat
(
a
).
toFixed
(
m
[
6
])
:
parseFloat
(
a
);
break
;
case
'
o
'
:
a
=
a
.
toString
(
8
);
break
;
case
'
s
'
:
a
=
((
a
=
String
(
a
))
&&
m
[
6
]
?
a
.
substring
(
0
,
m
[
6
])
:
a
);
break
;
case
'
u
'
:
a
=
Math
.
abs
(
a
);
break
;
case
'
x
'
:
a
=
a
.
toString
(
16
);
break
;
case
'
X
'
:
a
=
a
.
toString
(
16
).
toUpperCase
();
break
;
}
a
=
(
/
[
def
]
/
.
test
(
m
[
7
])
&&
m
[
2
]
&&
a
>
0
?
'
+
'
+
a
:
a
);
c
=
m
[
3
]
?
m
[
3
]
==
'
0
'
?
'
0
'
:
m
[
3
].
charAt
(
1
)
:
'
'
;
x
=
m
[
5
]
-
String
(
a
).
length
;
p
=
m
[
5
]
?
str_repeat
(
c
,
x
)
:
''
;
o
.
push
(
m
[
4
]
?
a
+
p
:
p
+
a
);
}
else
throw
(
"
Huh ?!
"
);
f
=
f
.
substring
(
m
[
0
].
length
);
}
return
o
.
join
(
''
);
}
This diff is collapsed.
Click to expand it.
webgui/js/app/util.js
deleted
100644 → 0
+
0
−
12
View file @
eff8761a
/* Generate a random password */
function
getRandomPass
(
len
)
{
var
keylist
=
"
abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789
"
var
ret
=
''
for
(
i
=
0
;
i
<
len
;
i
++
)
ret
+=
keylist
.
charAt
(
Math
.
floor
(
Math
.
random
()
*
keylist
.
length
)
)
return
ret
}
This diff is collapsed.
Click to expand it.
webgui/js/app/windows/AdminUserLogs.js
+
85
−
13
View file @
dd3abf5f
...
...
@@ -177,6 +177,10 @@ function showAdminUserLogsWindow(id) {
header
:
"
Output Mbyte
"
,
dataIndex
:
'
AcctOutputMbyte
'
},
{
header
:
"
Session Uptime
"
,
dataIndex
:
'
AcctSessionTime
'
},
{
header
:
"
Term. Reason
"
,
dataIndex
:
'
ConnectTermReason
'
...
...
@@ -219,6 +223,7 @@ function showAdminUserLogsWindow(id) {
{
type
:
'
string
'
,
dataIndex
:
'
FramedIPAddress
'
},
{
type
:
'
numeric
'
,
dataIndex
:
'
AcctInputMbyte
'
},
{
type
:
'
numeric
'
,
dataIndex
:
'
AcctOutputMbyte
'
},
{
type
:
'
numeric
'
,
dataIndex
:
'
AcctSessionTime
'
},
{
type
:
'
string
'
,
dataIndex
:
'
ConnectTermReason
'
}
]
}
...
...
@@ -229,22 +234,89 @@ function showAdminUserLogsWindow(id) {
store
.
on
(
'
load
'
,
function
()
{
var
inputTotal
=
store
.
sum
(
'
AcctInputMbyte
'
);
var
outputTotal
=
store
.
sum
(
'
AcctOutputMbyte
'
);
var
uptimeTotal
=
store
.
sum
(
'
AcctSessionTime
'
);
var
userCap
=
3000
;
var
userTopups
=
1000
;
// Total up into this ...
var
userTotalAllowed
=
userCap
+
userTopups
;
var
userUsage
=
inputTotal
+
outputTotal
;
var
userLeft
=
userTotalAllowed
-
userUsage
;
var
searchForm
=
adminUserLogsWindow
.
getComponent
(
'
search-form
'
);
var
afterField
=
(
searchForm
.
getForm
().
findField
(
'
after
'
)).
getValue
();
var
beforeField
=
(
searchForm
.
getForm
().
findField
(
'
before
'
)).
getValue
();
var
trafficCap
;
var
uptimeCap
;
var
trafficTopups
;
var
uptimeTopups
;
var
response
;
// Mask parent window
adminUserLogsWindow
.
getEl
().
mask
();
uxAjaxRequest
(
adminUserLogsWindow
,
{
params
:
{
From
:
afterField
,
To
:
beforeField
,
ID
:
id
,
SOAPUsername
:
globalConfig
.
soap
.
username
,
SOAPPassword
:
globalConfig
.
soap
.
password
,
SOAPAuthType
:
globalConfig
.
soap
.
authtype
,
SOAPModule
:
'
AdminUserLogs
'
,
SOAPFunction
:
'
getAdminUserLogsSummary
'
,
SOAPParams
:
'
0:ID,0:From,0:To
'
},
customSuccess
:
function
(
result
)
{
response
=
Ext
.
decode
(
result
.
responseText
);
var
form
=
adminUserLogsWindow
.
getComponent
(
'
summary-form
'
);
var
summaryTotal
=
form
.
getForm
().
findField
(
'
summaryTotal
'
);
trafficCap
=
response
.
data
.
trafficCap
;
uptimeCap
=
response
.
data
.
uptimeCap
;
trafficTopups
=
response
.
data
.
trafficTopups
;
uptimeTopups
=
response
.
data
.
uptimeTopups
;
summaryTotal
.
setValue
(
sprintf
(
'
Cap Total: %6d
\n
Topups : %6d
\n
-----------------
\n
%6d
\n
-----------------
\n
Usage : %6d
\n
=================
\n
Available: %6d
'
,
userCap
,
userTopups
,
userTotalAllowed
,
userUsage
,
userLeft
)
);
// Total up traffic
var
trafficTotalAllowed
;
if
(
trafficCap
<
0
)
{
trafficTotalAllowed
=
trafficTopups
;
}
else
{
trafficTotalAllowed
=
trafficCap
+
trafficTopups
;
}
var
trafficUsage
=
inputTotal
+
outputTotal
;
var
trafficRemaining
=
trafficTotalAllowed
-
trafficUsage
;
var
form
=
adminUserLogsWindow
.
getComponent
(
'
summary-form
'
);
var
summaryTotal
=
form
.
getForm
().
findField
(
'
summaryTotal
'
);
// Format string before printing
var
summaryString
=
''
;
if
(
trafficCap
==
-
1
)
{
trafficCap
=
'
Prepaid
'
;
summaryString
+=
sprintf
(
'
Traffic Cap: %s Traffic Topups: %d
\n
------------------------------------
\n
'
+
'
Allowed: %d Used: %d
\n
-------------------------------
\n
Remaining: %d
'
,
trafficCap
,
trafficTopups
,
trafficTotalAllowed
,
trafficUsage
,
trafficRemaining
);
}
else
if
(
trafficCap
==
0
)
{
summaryString
+=
sprintf
(
'
Traffic Cap: Uncapped
\n
---------------------------------
\n
Used: %d
'
,
trafficUsage
);
}
else
{
summaryString
+=
sprintf
(
'
Traffic Cap: %d Traffic Topups: %d
\n
------------------------------------
\n
'
+
'
Allowed: %d Used: %d
\n
-------------------------------
\n
Remaining: %d
'
,
trafficCap
,
trafficTopups
,
trafficTotalAllowed
,
trafficUsage
,
trafficRemaining
);
}
alert
(
summaryString
);
summaryTotal
.
setValue
(
summaryString
);
},
failure
:
function
(
result
)
{
Ext
.
MessageBox
.
alert
(
'
Failed
'
,
'
Couldn
\'
t fetch data:
'
+
result
.
date
);
},
});
});
adminUserLogsWindow
.
show
();
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment