Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
douban-api-proxy
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
captainwong
douban-api-proxy
Commits
a1942165
Commit
a1942165
authored
Apr 05, 2020
by
Ozzieisaacs
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
8bee424c
25ab3cab
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
53 additions
and
28 deletions
+53
-28
bug_report.md
.github/ISSUE_TEMPLATE/bug_report.md
+3
-0
admin.py
cps/admin.py
+5
-3
caliBlur.min.css
cps/static/css/caliBlur.min.css
+1
-1
main.js
cps/static/js/main.js
+30
-13
admin.html
cps/templates/admin.html
+7
-7
web.py
cps/web.py
+7
-4
No files found.
.github/ISSUE_TEMPLATE/bug_report.md
View file @
a1942165
...
@@ -17,6 +17,9 @@ Steps to reproduce the behavior:
...
@@ -17,6 +17,9 @@ Steps to reproduce the behavior:
3.
Scroll down to '....'
3.
Scroll down to '....'
4.
See error
4.
See error
**Logfile**
Add content of calibre-web.log file or the relevant error, try to reproduce your problem with "debug" log-level to get more output.
**Expected behavior**
**Expected behavior**
A clear and concise description of what you expected to happen.
A clear and concise description of what you expected to happen.
...
...
cps/admin.py
View file @
a1942165
...
@@ -79,12 +79,12 @@ def admin_forbidden():
...
@@ -79,12 +79,12 @@ def admin_forbidden():
@
admin_required
@
admin_required
def
shutdown
():
def
shutdown
():
task
=
int
(
request
.
args
.
get
(
"parameter"
)
.
strip
())
task
=
int
(
request
.
args
.
get
(
"parameter"
)
.
strip
())
showtext
=
{}
if
task
in
(
0
,
1
):
# valid commandos received
if
task
in
(
0
,
1
):
# valid commandos received
# close all database connections
# close all database connections
db
.
dispose
()
db
.
dispose
()
ub
.
dispose
()
ub
.
dispose
()
showtext
=
{}
if
task
==
0
:
if
task
==
0
:
showtext
[
'text'
]
=
_
(
u'Server restarted, please reload page'
)
showtext
[
'text'
]
=
_
(
u'Server restarted, please reload page'
)
else
:
else
:
...
@@ -96,9 +96,11 @@ def shutdown():
...
@@ -96,9 +96,11 @@ def shutdown():
if
task
==
2
:
if
task
==
2
:
log
.
warning
(
"reconnecting to calibre database"
)
log
.
warning
(
"reconnecting to calibre database"
)
db
.
setup_db
(
config
)
db
.
setup_db
(
config
)
return
'{}'
showtext
[
'text'
]
=
_
(
u'Reconnect successful'
)
return
json
.
dumps
(
showtext
)
abort
(
404
)
showtext
[
'text'
]
=
_
(
u'Unknown command'
)
return
json
.
dumps
(
showtext
),
400
@
admi
.
route
(
"/admin/view"
)
@
admi
.
route
(
"/admin/view"
)
...
...
cps/static/css/caliBlur.min.css
View file @
a1942165
This source diff could not be displayed because it is too large. You can
view the blob
instead.
cps/static/js/main.js
View file @
a1942165
...
@@ -76,7 +76,7 @@ $(function() {
...
@@ -76,7 +76,7 @@ $(function() {
function
cleanUp
()
{
function
cleanUp
()
{
clearInterval
(
updateTimerID
);
clearInterval
(
updateTimerID
);
$
(
"#spinner2"
).
hide
();
$
(
"#spinner2"
).
hide
();
$
(
"#
update
Finished"
).
removeClass
(
"hidden"
);
$
(
"#
Dialog
Finished"
).
removeClass
(
"hidden"
);
$
(
"#check_for_update"
).
removeClass
(
"hidden"
);
$
(
"#check_for_update"
).
removeClass
(
"hidden"
);
$
(
"#perform_update"
).
addClass
(
"hidden"
);
$
(
"#perform_update"
).
addClass
(
"hidden"
);
$
(
"#message"
).
alert
(
"close"
);
$
(
"#message"
).
alert
(
"close"
);
...
@@ -93,13 +93,13 @@ $(function() {
...
@@ -93,13 +93,13 @@ $(function() {
url
:
window
.
location
.
pathname
+
"/../../get_updater_status"
,
url
:
window
.
location
.
pathname
+
"/../../get_updater_status"
,
success
:
function
success
(
data
)
{
success
:
function
success
(
data
)
{
// console.log(data.status);
// console.log(data.status);
$
(
"#
Updatec
ontent"
).
html
(
updateText
[
data
.
status
]);
$
(
"#
DialogC
ontent"
).
html
(
updateText
[
data
.
status
]);
if
(
data
.
status
>
6
)
{
if
(
data
.
status
>
6
)
{
cleanUp
();
cleanUp
();
}
}
},
},
error
:
function
error
()
{
error
:
function
error
()
{
$
(
"#
Updatec
ontent"
).
html
(
updateText
[
7
]);
$
(
"#
DialogC
ontent"
).
html
(
updateText
[
7
]);
cleanUp
();
cleanUp
();
},
},
timeout
:
2000
timeout
:
2000
...
@@ -158,8 +158,8 @@ $(function() {
...
@@ -158,8 +158,8 @@ $(function() {
var
$this
=
$
(
this
);
var
$this
=
$
(
this
);
var
buttonText
=
$this
.
html
();
var
buttonText
=
$this
.
html
();
$this
.
html
(
"..."
);
$this
.
html
(
"..."
);
$
(
"#
Updatec
ontent"
).
html
(
""
);
$
(
"#
DialogC
ontent"
).
html
(
""
);
$
(
"#
update
Finished"
).
addClass
(
"hidden"
);
$
(
"#
Dialog
Finished"
).
addClass
(
"hidden"
);
$
(
"#update_error"
).
addClass
(
"hidden"
);
$
(
"#update_error"
).
addClass
(
"hidden"
);
if
(
$
(
"#message"
).
length
)
{
if
(
$
(
"#message"
).
length
)
{
$
(
"#message"
).
alert
(
"close"
);
$
(
"#message"
).
alert
(
"close"
);
...
@@ -201,13 +201,24 @@ $(function() {
...
@@ -201,13 +201,24 @@ $(function() {
});
});
});
});
$
(
"#restart_database"
).
click
(
function
()
{
$
(
"#restart_database"
).
click
(
function
()
{
$
(
"#DialogHeader"
).
addClass
(
"hidden"
);
$
(
"#DialogFinished"
).
addClass
(
"hidden"
);
$
(
"#DialogContent"
).
html
(
""
);
$
(
"#spinner2"
).
show
();
$
.
ajax
({
$
.
ajax
({
dataType
:
"json"
,
dataType
:
"json"
,
url
:
window
.
location
.
pathname
+
"/../../shutdown"
,
url
:
window
.
location
.
pathname
+
"/../../shutdown"
,
data
:
{
"parameter"
:
2
}
data
:
{
"parameter"
:
2
},
success
:
function
success
(
data
)
{
$
(
"#spinner2"
).
hide
();
ResultText
=
data
.
text
;
$
(
"#DialogContent"
).
html
(
ResultText
);
$
(
"#DialogFinished"
).
removeClass
(
"hidden"
);
}
});
});
});
});
$
(
"#perform_update"
).
click
(
function
()
{
$
(
"#perform_update"
).
click
(
function
()
{
$
(
"#DialogHeader"
).
removeClass
(
"hidden"
);
$
(
"#spinner2"
).
show
();
$
(
"#spinner2"
).
show
();
$
.
ajax
({
$
.
ajax
({
type
:
"POST"
,
type
:
"POST"
,
...
@@ -216,7 +227,7 @@ $(function() {
...
@@ -216,7 +227,7 @@ $(function() {
url
:
window
.
location
.
pathname
+
"/../../get_updater_status"
,
url
:
window
.
location
.
pathname
+
"/../../get_updater_status"
,
success
:
function
success
(
data
)
{
success
:
function
success
(
data
)
{
updateText
=
data
.
text
;
updateText
=
data
.
text
;
$
(
"#
Updatec
ontent"
).
html
(
updateText
[
data
.
status
]);
$
(
"#
DialogC
ontent"
).
html
(
updateText
[
data
.
status
]);
// console.log(data.status);
// console.log(data.status);
updateTimerID
=
setInterval
(
updateTimer
,
2000
);
updateTimerID
=
setInterval
(
updateTimer
,
2000
);
}
}
...
@@ -288,17 +299,23 @@ $(function() {
...
@@ -288,17 +299,23 @@ $(function() {
});
});
$
(
'#import_ldap_users'
).
click
(
function
()
{
$
(
'#import_ldap_users'
).
click
(
function
()
{
$
(
"#DialogHeader"
).
addClass
(
"hidden"
);
$
(
"#DialogFinished"
).
addClass
(
"hidden"
);
$
(
"#DialogContent"
).
html
(
""
);
$
(
"#spinner2"
).
show
();
var
pathname
=
document
.
getElementsByTagName
(
"script"
),
src
=
pathname
[
pathname
.
length
-
1
].
src
;
var
pathname
=
document
.
getElementsByTagName
(
"script"
),
src
=
pathname
[
pathname
.
length
-
1
].
src
;
var
path
=
src
.
substring
(
0
,
src
.
lastIndexOf
(
"/"
));
var
path
=
src
.
substring
(
0
,
src
.
lastIndexOf
(
"/"
));
/*
$.ajax({
$
.
ajax
({
method
:
"get"
,
method
:
"get"
,
dataType
:
"json"
,
url
:
path
+
"/../../import_ldap_users"
,
url
:
path
+
"/../../import_ldap_users"
,
});*/
success
:
function
success
(
data
)
{
$
.
getJSON
(
path
+
"/../../import_ldap_users"
,
$
(
"#spinner2"
).
hide
();
function
(
data
)
{
ResultText
=
data
.
text
;
location
.
reload
();
$
(
"#DialogContent"
).
html
(
ResultText
);
$
(
"#DialogFinished"
).
removeClass
(
"hidden"
);
}
}
);
}
);
});
});
$
(
".author-expand"
).
click
(
function
()
{
$
(
".author-expand"
).
click
(
function
()
{
...
...
cps/templates/admin.html
View file @
a1942165
...
@@ -38,7 +38,7 @@
...
@@ -38,7 +38,7 @@
{% if not (config.config_login_type == 1) %}
{% if not (config.config_login_type == 1) %}
<div
class=
"btn btn-default"
id=
"admin_new_user"
><a
href=
"{{url_for('admin.new_user')}}"
>
{{_('Add New User')}}
</a></div>
<div
class=
"btn btn-default"
id=
"admin_new_user"
><a
href=
"{{url_for('admin.new_user')}}"
>
{{_('Add New User')}}
</a></div>
{% else %}
{% else %}
<div
class=
"btn btn-default"
id=
"import_ldap_users"
>
{{_('Import LDAP Users')}}
</div>
<div
class=
"btn btn-default"
id=
"import_ldap_users"
data-toggle=
"modal"
data-target=
"#StatusDialog"
>
{{_('Import LDAP Users')}}
</div>
<!--a href="#" id="import_ldap_users" name="import_ldap_users"><button type="submit" class="btn btn-default">{{_('Import LDAP Users')}}</button></a-->
<!--a href="#" id="import_ldap_users" name="import_ldap_users"><button type="submit" class="btn btn-default">{{_('Import LDAP Users')}}</button></a-->
{% endif %}
{% endif %}
</div>
</div>
...
@@ -125,7 +125,7 @@
...
@@ -125,7 +125,7 @@
<div
class=
"col"
>
<div
class=
"col"
>
<h2>
{{_('Administration')}}
</h2>
<h2>
{{_('Administration')}}
</h2>
<div
class=
"btn btn-default"
><a
id=
"logfile"
href=
"{{url_for('admin.view_logfile')}}"
>
{{_('View Logs')}}
</a></div>
<div
class=
"btn btn-default"
><a
id=
"logfile"
href=
"{{url_for('admin.view_logfile')}}"
>
{{_('View Logs')}}
</a></div>
<div
class=
"btn btn-default"
id=
"restart_database"
>
{{_('Reconnect Calibre Database')}}
</div>
<div
class=
"btn btn-default"
id=
"restart_database"
data-toggle=
"modal"
data-target=
"#StatusDialog"
>
{{_('Reconnect Calibre Database')}}
</div>
<div
class=
"btn btn-default"
id=
"admin_restart"
data-toggle=
"modal"
data-target=
"#RestartDialog"
>
{{_('Restart')}}
</div>
<div
class=
"btn btn-default"
id=
"admin_restart"
data-toggle=
"modal"
data-target=
"#RestartDialog"
>
{{_('Restart')}}
</div>
<div
class=
"btn btn-default"
id=
"admin_stop"
data-toggle=
"modal"
data-target=
"#ShutdownDialog"
>
{{_('Shutdown')}}
</div>
<div
class=
"btn btn-default"
id=
"admin_stop"
data-toggle=
"modal"
data-target=
"#ShutdownDialog"
>
{{_('Shutdown')}}
</div>
</div>
</div>
...
@@ -151,7 +151,7 @@
...
@@ -151,7 +151,7 @@
<div
class=
"hidden"
id=
"update_error"
>
<span>
{{update_error}}
</span></div>
<div
class=
"hidden"
id=
"update_error"
>
<span>
{{update_error}}
</span></div>
<div
class=
"btn btn-default"
id=
"check_for_update"
>
{{_('Check for Update')}}
</div>
<div
class=
"btn btn-default"
id=
"check_for_update"
>
{{_('Check for Update')}}
</div>
<div
class=
"btn btn-default hidden"
id=
"perform_update"
data-toggle=
"modal"
data-target=
"#
Updateprogres
sDialog"
>
{{_('Perform Update')}}
</div>
<div
class=
"btn btn-default hidden"
id=
"perform_update"
data-toggle=
"modal"
data-target=
"#
Statu
sDialog"
>
{{_('Perform Update')}}
</div>
</div>
</div>
</div>
</div>
</div>
</div>
...
@@ -188,21 +188,21 @@
...
@@ -188,21 +188,21 @@
</div>
</div>
</div>
</div>
</div>
</div>
<div
id=
"
Updateprogres
sDialog"
class=
"modal fade"
role=
"dialog"
>
<div
id=
"
Statu
sDialog"
class=
"modal fade"
role=
"dialog"
>
<div
class=
"modal-dialog modal-sm"
>
<div
class=
"modal-dialog modal-sm"
>
<!-- Modal content-->
<!-- Modal content-->
<div
class=
"modal-content"
>
<div
class=
"modal-content"
>
<div
class=
"modal-header bg-info text-center"
>
<div
class=
"modal-header bg-info text-center"
>
<span>
{{_('Updating, please do not reload this page')}}
</span>
<span
id=
"DialogHeader"
>
{{_('Updating, please do not reload this page')}}
</span>
</div>
</div>
<div
class=
"modal-body text-center"
>
<div
class=
"modal-body text-center"
>
<div
id=
"spinner2"
class=
"spinner2"
style=
"display:none;"
>
<div
id=
"spinner2"
class=
"spinner2"
style=
"display:none;"
>
<img
id=
"img-spinner2"
src=
"{{ url_for('static', filename='css/libs/images/loading-icon.gif') }}"
/>
<img
id=
"img-spinner2"
src=
"{{ url_for('static', filename='css/libs/images/loading-icon.gif') }}"
/>
</div>
</div>
<p></p>
<p></p>
<div
id=
"
Updatec
ontent"
></div>
<div
id=
"
DialogC
ontent"
></div>
<p></p>
<p></p>
<button
type=
"button"
class=
"btn btn-default hidden"
id=
"
update
Finished"
data-dismiss=
"modal"
>
{{_('OK')}}
</button>
<button
type=
"button"
class=
"btn btn-default hidden"
id=
"
Dialog
Finished"
data-dismiss=
"modal"
>
{{_('OK')}}
</button>
</div>
</div>
</div>
</div>
</div>
</div>
...
...
cps/web.py
View file @
a1942165
...
@@ -275,13 +275,13 @@ def before_request():
...
@@ -275,13 +275,13 @@ def before_request():
@
app
.
route
(
'/import_ldap_users'
)
@
app
.
route
(
'/import_ldap_users'
)
def
import_ldap_users
():
def
import_ldap_users
():
showtext
=
{}
try
:
try
:
new_users
=
services
.
ldap
.
get_group_members
(
config
.
config_ldap_group_name
)
new_users
=
services
.
ldap
.
get_group_members
(
config
.
config_ldap_group_name
)
except
services
.
ldap
.
LDAPException
as
e
:
except
services
.
ldap
.
LDAPException
as
e
:
log
.
debug
(
e
)
log
.
debug
(
e
)
return
""
showtext
[
'text'
]
=
_
(
u'Error :
%(ldaperror)
s'
,
ldaperror
=
e
)
except
Exception
as
e
:
return
json
.
dumps
(
showtext
)
print
(
'pass'
)
for
username
in
new_users
:
for
username
in
new_users
:
user_data
=
services
.
ldap
.
get_object_details
(
user
=
username
,
group
=
None
,
query_filter
=
None
,
dn_only
=
False
)
user_data
=
services
.
ldap
.
get_object_details
(
user
=
username
,
group
=
None
,
query_filter
=
None
,
dn_only
=
False
)
...
@@ -300,7 +300,10 @@ def import_ldap_users():
...
@@ -300,7 +300,10 @@ def import_ldap_users():
except
Exception
as
e
:
except
Exception
as
e
:
log
.
warning
(
"Failed to create LDAP user:
%
s -
%
s"
,
username
,
e
)
log
.
warning
(
"Failed to create LDAP user:
%
s -
%
s"
,
username
,
e
)
ub
.
session
.
rollback
()
ub
.
session
.
rollback
()
return
""
showtext
[
'text'
]
=
_
(
u'Failed to create at least one LDAP user'
)
if
not
showtext
:
showtext
[
'text'
]
=
_
(
u'User successfully imported'
)
return
json
.
dumps
(
showtext
)
# ################################### data provider functions #########################################################
# ################################### data provider functions #########################################################
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment