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
4eacb212
Commit
4eacb212
authored
Mar 29, 2020
by
Ozzieisaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update updater
Update change logfile code cosmetics js files
parent
6d907094
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
153 additions
and
104 deletions
+153
-104
__init__.py
cps/__init__.py
+1
-3
admin.py
cps/admin.py
+3
-3
helper.py
cps/helper.py
+1
-1
server.py
cps/server.py
+4
-1
logviewer.js
cps/static/js/logviewer.js
+1
-2
main.js
cps/static/js/main.js
+21
-14
table.js
cps/static/js/table.js
+41
-49
updater.py
cps/updater.py
+81
-31
No files found.
cps/__init__.py
View file @
4eacb212
...
@@ -134,6 +134,4 @@ def get_timezone():
...
@@ -134,6 +134,4 @@ def get_timezone():
from
.updater
import
Updater
from
.updater
import
Updater
updater_thread
=
Updater
()
updater_thread
=
Updater
()
updater_thread
.
start
()
__all__
=
[
'app'
]
cps/admin.py
View file @
4eacb212
...
@@ -604,8 +604,8 @@ def _configuration_update_helper():
...
@@ -604,8 +604,8 @@ def _configuration_update_helper():
{
"active"
:
0
})
{
"active"
:
0
})
element
[
"active"
]
=
0
element
[
"active"
]
=
0
_config_int
(
"config_log_level"
)
reboot_required
|=
_config_int
(
"config_log_level"
)
_config_string
(
"config_logfile"
)
reboot_required
|=
_config_string
(
"config_logfile"
)
if
not
logger
.
is_valid_logfile
(
config
.
config_logfile
):
if
not
logger
.
is_valid_logfile
(
config
.
config_logfile
):
return
_configuration_result
(
'Logfile location is not valid, please enter correct path'
,
gdriveError
)
return
_configuration_result
(
'Logfile location is not valid, please enter correct path'
,
gdriveError
)
...
@@ -968,7 +968,7 @@ def get_updater_status():
...
@@ -968,7 +968,7 @@ def get_updater_status():
}
}
status
[
'text'
]
=
text
status
[
'text'
]
=
text
updater_thread
.
status
=
0
updater_thread
.
status
=
0
updater_thread
.
start
()
updater_thread
.
resume
()
status
[
'status'
]
=
updater_thread
.
get_update_status
()
status
[
'status'
]
=
updater_thread
.
get_update_status
()
elif
request
.
method
==
"GET"
:
elif
request
.
method
==
"GET"
:
try
:
try
:
...
...
cps/helper.py
View file @
4eacb212
...
@@ -492,7 +492,7 @@ def get_book_cover_internal(book,
...
@@ -492,7 +492,7 @@ def get_book_cover_internal(book,
# saves book cover from url
# saves book cover from url
def
save_cover_from_url
(
url
,
book_path
):
def
save_cover_from_url
(
url
,
book_path
):
img
=
requests
.
get
(
url
)
img
=
requests
.
get
(
url
,
timeout
=
10
)
# ToDo: Error Handling
return
save_cover
(
img
,
book_path
)
return
save_cover
(
img
,
book_path
)
...
...
cps/server.py
View file @
4eacb212
...
@@ -24,7 +24,7 @@ import signal
...
@@ -24,7 +24,7 @@ import signal
import
socket
import
socket
try
:
try
:
from
gevent.pywsgi
import
WSGIServer
from
gevent.py
e
wsgi
import
WSGIServer
from
gevent.pool
import
Pool
from
gevent.pool
import
Pool
from
gevent
import
__version__
as
_version
from
gevent
import
__version__
as
_version
VERSION
=
'Gevent '
+
_version
VERSION
=
'Gevent '
+
_version
...
@@ -193,6 +193,9 @@ class WebServer(object):
...
@@ -193,6 +193,9 @@ class WebServer(object):
self
.
stop
()
self
.
stop
()
def
stop
(
self
,
restart
=
False
):
def
stop
(
self
,
restart
=
False
):
from
.
import
updater_thread
updater_thread
.
stop
()
log
.
info
(
"webserver stop (restart=
%
s)"
,
restart
)
log
.
info
(
"webserver stop (restart=
%
s)"
,
restart
)
self
.
restart
=
restart
self
.
restart
=
restart
if
self
.
wsgiserver
:
if
self
.
wsgiserver
:
...
...
cps/static/js/logviewer.js
View file @
4eacb212
...
@@ -17,8 +17,7 @@
...
@@ -17,8 +17,7 @@
// Upon loading load the logfile for the first option (event log)
// Upon loading load the logfile for the first option (event log)
$
(
function
()
{
$
(
function
()
{
if
(
$
(
"#log_group input"
).
length
)
if
(
$
(
"#log_group input"
).
length
)
{
{
var
element
=
$
(
"#log_group input[type='radio']:checked"
).
val
();
var
element
=
$
(
"#log_group input[type='radio']:checked"
).
val
();
init
(
element
);
init
(
element
);
}
}
...
...
cps/static/js/main.js
View file @
4eacb212
...
@@ -61,6 +61,20 @@ $(function() {
...
@@ -61,6 +61,20 @@ $(function() {
$
(
"#RestartDialog"
).
modal
(
"hide"
);
$
(
"#RestartDialog"
).
modal
(
"hide"
);
}
}
function
cleanUp
()
{
clearInterval
(
updateTimerID
);
$
(
"#spinner2"
).
hide
();
$
(
"#updateFinished"
).
removeClass
(
"hidden"
);
$
(
"#check_for_update"
).
removeClass
(
"hidden"
);
$
(
"#perform_update"
).
addClass
(
"hidden"
);
$
(
"#message"
).
alert
(
"close"
);
$
(
"#update_table > tbody > tr"
).
each
(
function
()
{
if
(
$
(
this
).
attr
(
"id"
)
!==
"current_version"
)
{
$
(
this
).
closest
(
"tr"
).
remove
();
}
});
}
function
updateTimer
()
{
function
updateTimer
()
{
$
.
ajax
({
$
.
ajax
({
dataType
:
"json"
,
dataType
:
"json"
,
...
@@ -69,21 +83,12 @@ $(function() {
...
@@ -69,21 +83,12 @@ $(function() {
// console.log(data.status);
// console.log(data.status);
$
(
"#Updatecontent"
).
html
(
updateText
[
data
.
status
]);
$
(
"#Updatecontent"
).
html
(
updateText
[
data
.
status
]);
if
(
data
.
status
>
6
)
{
if
(
data
.
status
>
6
)
{
clearInterval
(
updateTimerID
);
cleanUp
();
$
(
"#spinner2"
).
hide
();
$
(
"#updateFinished"
).
removeClass
(
"hidden"
);
$
(
"#check_for_update"
).
removeClass
(
"hidden"
);
$
(
"#perform_update"
).
addClass
(
"hidden"
);
}
}
},
},
error
:
function
error
()
{
error
:
function
error
()
{
// console.log('Done');
clearInterval
(
updateTimerID
);
$
(
"#spinner2"
).
hide
();
$
(
"#Updatecontent"
).
html
(
updateText
[
7
]);
$
(
"#Updatecontent"
).
html
(
updateText
[
7
]);
$
(
"#updateFinished"
).
removeClass
(
"hidden"
);
cleanUp
();
$
(
"#check_for_update"
).
removeClass
(
"hidden"
);
$
(
"#perform_update"
).
addClass
(
"hidden"
);
},
},
timeout
:
2000
timeout
:
2000
});
});
...
@@ -141,6 +146,8 @@ $(function() {
...
@@ -141,6 +146,8 @@ $(function() {
var
$this
=
$
(
this
);
var
$this
=
$
(
this
);
var
buttonText
=
$this
.
html
();
var
buttonText
=
$this
.
html
();
$this
.
html
(
"..."
);
$this
.
html
(
"..."
);
$
(
"#Updatecontent"
).
html
(
""
);
$
(
"#updateFinished"
).
addClass
(
"hidden"
);
$
(
"#update_error"
).
addClass
(
"hidden"
);
$
(
"#update_error"
).
addClass
(
"hidden"
);
if
(
$
(
"#message"
).
length
)
{
if
(
$
(
"#message"
).
length
)
{
$
(
"#message"
).
alert
(
"close"
);
$
(
"#message"
).
alert
(
"close"
);
...
@@ -246,13 +253,13 @@ $(function() {
...
@@ -246,13 +253,13 @@ $(function() {
})
})
.
on
(
"hidden.bs.modal"
,
function
()
{
.
on
(
"hidden.bs.modal"
,
function
()
{
$
(
this
).
find
(
".modal-body"
).
html
(
"..."
);
$
(
this
).
find
(
".modal-body"
).
html
(
"..."
);
$
(
"#config_delete_kobo_token"
).
show
();
$
(
"#config_delete_kobo_token"
).
show
();
});
});
$
(
"#btndeletetoken"
).
click
(
function
()
{
$
(
"#btndeletetoken"
).
click
(
function
()
{
//get data-id attribute of the clicked element
//get data-id attribute of the clicked element
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
(
"/"
));
// var domainId = $(this).value("domainId");
// var domainId = $(this).value("domainId");
$
.
ajax
({
$
.
ajax
({
method
:
"get"
,
method
:
"get"
,
...
...
cps/static/js/table.js
View file @
4eacb212
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
/* exported TableActions
*/
/* exported TableActions
, RestrictionActions
*/
$
(
function
()
{
$
(
function
()
{
...
@@ -94,46 +94,44 @@ $(function() {
...
@@ -94,46 +94,44 @@ $(function() {
$
(
e
.
currentTarget
).
find
(
"#btndeletedomain"
).
data
(
"domainId"
,
domainId
);
$
(
e
.
currentTarget
).
find
(
"#btndeletedomain"
).
data
(
"domainId"
,
domainId
);
});
});
$
(
'#restrictModal'
).
on
(
'hidden.bs.modal'
,
function
()
{
$
(
"#restrictModal"
).
on
(
"hidden.bs.modal"
,
function
()
{
// Destroy table and remove hooks for buttons
// Destroy table and remove hooks for buttons
$
(
"#restrict-elements-table"
).
unbind
();
$
(
"#restrict-elements-table"
).
unbind
();
$
(
'#restrict-elements-table'
).
bootstrapTable
(
'destroy'
);
$
(
"#restrict-elements-table"
).
bootstrapTable
(
"destroy"
);
$
(
"[id^=submit_]"
).
unbind
();
$
(
"[id^=submit_]"
).
unbind
();
$
(
'#h1'
).
addClass
(
'hidden'
);
$
(
"#h1"
).
addClass
(
"hidden"
);
$
(
'#h2'
).
addClass
(
'hidden'
);
$
(
"#h2"
).
addClass
(
"hidden"
);
$
(
'#h3'
).
addClass
(
'hidden'
);
$
(
"#h3"
).
addClass
(
"hidden"
);
$
(
'#h4'
).
addClass
(
'hidden'
);
$
(
"#h4"
).
addClass
(
"hidden"
);
});
});
function
startTable
(
type
){
function
startTable
(
type
)
{
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
(
"/"
));
$
(
"#restrict-elements-table"
).
bootstrapTable
({
$
(
"#restrict-elements-table"
).
bootstrapTable
({
formatNoMatches
:
function
()
{
formatNoMatches
:
function
()
{
return
""
;
return
""
;
},
},
url
:
path
+
"/../../ajax/listrestriction/"
+
type
,
url
:
path
+
"/../../ajax/listrestriction/"
+
type
,
rowStyle
:
function
(
row
,
index
)
{
rowStyle
:
function
(
row
,
index
)
{
console
.
log
(
'Reihe :'
+
row
+
' Index :'
+
index
);
// console.log('Reihe :' + row + " Index :" + index);
if
(
row
.
id
.
charAt
(
0
)
==
'a'
)
{
if
(
row
.
id
.
charAt
(
0
)
===
"a"
)
{
return
{
classes
:
'bg-primary'
}
return
{
classes
:
"bg-primary"
};
}
}
else
{
else
{
return
{
classes
:
"bg-dark-danger"
};
return
{
classes
:
'bg-dark-danger'
}
}
}
},
},
onClickCell
:
function
(
field
,
value
,
row
,
$element
)
{
onClickCell
:
function
(
field
,
value
,
row
,
$element
)
{
if
(
field
==
3
){
if
(
field
==
3
)
{
console
.
log
(
"element"
)
$
.
ajax
({
$
.
ajax
({
type
:
'Post'
,
type
:
"Post"
,
data
:
'id='
+
row
.
id
+
'&type='
+
row
.
type
+
"&Element="
+
row
.
Element
,
data
:
"id="
+
row
.
id
+
"&type="
+
row
.
type
+
"&Element="
+
row
.
Element
,
url
:
path
+
"/../../ajax/deleterestriction/"
+
type
,
url
:
path
+
"/../../ajax/deleterestriction/"
+
type
,
async
:
true
,
async
:
true
,
timeout
:
900
,
timeout
:
900
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
$
.
ajax
({
$
.
ajax
({
method
:
"get"
,
method
:
"get"
,
url
:
path
+
"/../../ajax/listrestriction/"
+
type
,
url
:
path
+
"/../../ajax/listrestriction/"
+
type
,
async
:
true
,
async
:
true
,
timeout
:
900
,
timeout
:
900
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
...
@@ -146,12 +144,11 @@ $(function() {
...
@@ -146,12 +144,11 @@ $(function() {
},
},
striped
:
false
striped
:
false
});
});
$
(
"#restrict-elements-table"
).
removeClass
(
'table-hover'
);
$
(
"#restrict-elements-table"
).
removeClass
(
"table-hover"
);
$
(
"#restrict-elements-table"
).
on
(
'editable-save.bs.table'
,
function
(
e
,
field
,
row
,
old
,
$el
)
{
$
(
"#restrict-elements-table"
).
on
(
"editable-save.bs.table"
,
function
(
e
,
field
,
row
,
old
,
$el
)
{
console
.
log
(
"Hallo"
);
$
.
ajax
({
$
.
ajax
({
url
:
path
+
"/../../ajax/editrestriction/"
+
type
,
url
:
path
+
"/../../ajax/editrestriction/"
+
type
,
type
:
'Post'
,
type
:
"Post"
,
data
:
row
//$(this).closest("form").serialize() + "&" + $(this)[0].name + "=",
data
:
row
//$(this).closest("form").serialize() + "&" + $(this)[0].name + "=",
});
});
});
});
...
@@ -159,48 +156,43 @@ $(function() {
...
@@ -159,48 +156,43 @@ $(function() {
// event.stopPropagation();
// event.stopPropagation();
// event.preventDefault();
// event.preventDefault();
$
(
this
)[
0
].
blur
();
$
(
this
)[
0
].
blur
();
console
.
log
(
$
(
this
)[
0
].
name
);
$
.
ajax
({
$
.
ajax
({
url
:
path
+
"/../../ajax/addrestriction/"
+
type
,
url
:
path
+
"/../../ajax/addrestriction/"
+
type
,
type
:
'Post'
,
type
:
"Post"
,
data
:
$
(
this
).
closest
(
"form"
).
serialize
()
+
"&"
+
$
(
this
)[
0
].
name
+
"="
,
data
:
$
(
this
).
closest
(
"form"
).
serialize
()
+
"&"
+
$
(
this
)[
0
].
name
+
"="
,
success
:
function
()
{
success
:
function
()
{
$
.
ajax
({
$
.
ajax
({
method
:
"get"
,
method
:
"get"
,
url
:
path
+
"/../../ajax/listrestriction/"
+
type
,
url
:
path
+
"/../../ajax/listrestriction/"
+
type
,
async
:
true
,
async
:
true
,
timeout
:
900
,
timeout
:
900
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
$
(
"#restrict-elements-table"
).
bootstrapTable
(
"load"
,
data
);
$
(
"#restrict-elements-table"
).
bootstrapTable
(
"load"
,
data
);
}
}
});
});
}
}
});
});
return
;
return
;
});
});
}
}
$
(
'#get_column_values'
).
on
(
'click'
,
function
()
$
(
"#get_column_values"
).
on
(
"click"
,
function
()
{
{
startTable
(
1
);
startTable
(
1
);
$
(
'#h2'
).
removeClass
(
'hidden'
);
$
(
"#h2"
).
removeClass
(
"hidden"
);
});
});
$
(
'#get_tags'
).
on
(
'click'
,
function
()
$
(
"#get_tags"
).
on
(
"click"
,
function
()
{
{
startTable
(
0
);
startTable
(
0
);
$
(
'#h1'
).
removeClass
(
'hidden'
);
$
(
"#h1"
).
removeClass
(
"hidden"
);
});
});
$
(
'#get_user_column_values'
).
on
(
'click'
,
function
()
$
(
"#get_user_column_values"
).
on
(
"click"
,
function
()
{
{
startTable
(
3
);
startTable
(
3
);
$
(
'#h4'
).
removeClass
(
'hidden'
);
$
(
"#h4"
).
removeClass
(
"hidden"
);
});
});
$
(
'#get_user_tags'
).
on
(
'click'
,
function
()
$
(
"#get_user_tags"
).
on
(
"click"
,
function
()
{
{
startTable
(
2
);
startTable
(
2
);
$
(
this
)[
0
].
blur
();
$
(
this
)[
0
].
blur
();
$
(
'#h3'
).
removeClass
(
'hidden'
);
$
(
"#h3"
).
removeClass
(
"hidden"
);
});
});
});
});
...
...
cps/updater.py
View file @
4eacb212
This diff is collapsed.
Click to expand it.
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