Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
debomatic-webui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
debomatic-webui-admins
debomatic-webui
Commits
f7a4f04a
Commit
f7a4f04a
authored
Jun 06, 2014
by
Leo Iannacone
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into portable
parents
04380791
43903d3a
Changes
14
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
1431 additions
and
1435 deletions
+1431
-1435
debomatic-webui/debomatic-webui
debomatic-webui/debomatic-webui
+5
-0
debomatic-webui/lib/broadcaster.js
debomatic-webui/lib/broadcaster.js
+59
-59
debomatic-webui/lib/client.js
debomatic-webui/lib/client.js
+158
-161
debomatic-webui/lib/config.js
debomatic-webui/lib/config.js
+94
-97
debomatic-webui/lib/parser.js
debomatic-webui/lib/parser.js
+30
-29
debomatic-webui/lib/tail.js
debomatic-webui/lib/tail.js
+32
-30
debomatic-webui/lib/utils.js
debomatic-webui/lib/utils.js
+135
-131
debomatic-webui/public/javascripts/debug.js
debomatic-webui/public/javascripts/debug.js
+21
-20
debomatic-webui/public/javascripts/main.js
debomatic-webui/public/javascripts/main.js
+20
-19
debomatic-webui/public/javascripts/page_distribution.js
debomatic-webui/public/javascripts/page_distribution.js
+563
-577
debomatic-webui/public/javascripts/page_generic.js
debomatic-webui/public/javascripts/page_generic.js
+168
-171
debomatic-webui/public/javascripts/preferences.js
debomatic-webui/public/javascripts/preferences.js
+52
-50
debomatic-webui/public/javascripts/utils.js
debomatic-webui/public/javascripts/utils.js
+88
-89
debomatic-webui/views/distribution.ejs
debomatic-webui/views/distribution.ejs
+6
-2
No files found.
debomatic-webui/debomatic-webui
View file @
f7a4f04a
...
...
@@ -19,6 +19,11 @@ var express = require('express'),
Broadcaster = require('./lib/broadcaster.js');
// serve dsc files as octet-stream
serve_static.mime.define({
'application/octet-stream': ['dsc']
});
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.use(serve_static(__dirname + '/public'));
...
...
debomatic-webui/lib/broadcaster.js
View file @
f7a4f04a
var
config
=
require
(
'
./config.js
'
)
,
fs
=
require
(
'
fs
'
)
,
Tail
=
require
(
'
./tail.js
'
)
'
use strict
'
;
function
__watch_status_check_same_obj
(
obj1
,
obj2
)
{
var
config
=
require
(
'
./config.js
'
),
fs
=
require
(
'
fs
'
),
utils
=
require
(
'
./utils.js
'
),
Tail
=
require
(
'
./tail.js
'
);
function
__watch_status_check_same_obj
(
obj1
,
obj2
)
{
if
(
obj1
.
status
==
obj2
.
status
)
{
if
(
obj1
.
distribution
==
obj2
.
distribution
)
{
if
(
obj1
.
hasOwnProperty
(
'
package
'
)
&&
obj2
.
hasOwnProperty
(
'
package
'
))
{
obj2
.
hasOwnProperty
(
'
package
'
))
{
if
(
obj1
.
package
==
obj2
.
package
)
return
true
;
return
false
return
false
;
}
return
true
return
true
;
}
}
return
false
return
false
;
}
// watcher on build_status
function
__watch_status
(
socket
,
status
)
{
function
__watch_status
(
socket
,
status
)
{
var
watcher
=
new
Tail
(
config
.
debomatic
.
jsonfile
)
watcher
.
on
(
'
line
'
,
function
(
new_content
)
{
var
data
=
null
var
watcher
=
new
Tail
(
config
.
debomatic
.
jsonfile
);
watcher
.
on
(
'
line
'
,
function
(
new_content
)
{
var
data
=
null
;
try
{
data
=
JSON
.
parse
(
new_content
)
data
=
JSON
.
parse
(
new_content
);
}
catch
(
err
)
{
utils
.
errors_handler
(
'
Broadcaster:__watch_status:JSON.parse(new_content) -
'
,
err
,
socket
)
return
utils
.
errors_handler
(
'
Broadcaster:__watch_status:JSON.parse(new_content) -
'
,
err
,
socket
);
return
;
}
// looking for same status already in statuses lists
if
(
data
.
hasOwnProperty
(
'
success
'
))
{
for
(
i
=
0
;
i
<
status
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
status
.
length
;
i
++
)
{
if
(
__watch_status_check_same_obj
(
data
,
status
[
i
]))
{
status
.
splice
(
i
,
1
)
status
.
splice
(
i
,
1
);
break
;
}
else
}
else
continue
;
}
}
else
{
status
.
push
(
data
);
}
else
{
status
.
push
(
data
)
}
socket
.
emit
(
config
.
events
.
broadcast
.
status_update
,
data
)
})
watcher
.
on
(
'
error
'
,
function
(
msg
)
{
socket
.
emit
(
config
.
events
.
error
,
msg
)
})
socket
.
emit
(
config
.
events
.
broadcast
.
status_update
,
data
);
});
watcher
.
on
(
'
error
'
,
function
(
msg
)
{
socket
.
emit
(
config
.
events
.
error
,
msg
);
});
}
// watcher on new distributions
function
__watch_distributions
(
socket
)
{
fs
.
watch
(
config
.
debomatic
.
path
,
{
persistent
:
true
},
function
(
event
,
fileName
)
{
function
__watch_distributions
(
socket
)
{
fs
.
watch
(
config
.
debomatic
.
path
,
{
persistent
:
true
},
function
(
event
,
fileName
)
{
// wait half a second to get pool subdir created
setTimeout
(
function
()
{
utils
.
send_distributions
(
socket
)
},
500
)
})
setTimeout
(
function
()
{
utils
.
send_distributions
(
socket
);
},
500
);
});
}
function
Broadcaster
(
sockets
,
status
)
{
var
sockets
=
sockets
function
Broadcaster
(
sockets
,
status
)
{
__watch_status
(
sockets
,
status
)
__watch_status
(
sockets
,
status
);
__watch_distributions
(
sockets
)
__watch_distributions
(
sockets
);
return
{
}
};
}
module
.
exports
=
Broadcaster
module
.
exports
=
Broadcaster
;
debomatic-webui/lib/client.js
View file @
f7a4f04a
This diff is collapsed.
Click to expand it.
debomatic-webui/lib/config.js
View file @
f7a4f04a
'
use strict
'
;
/*
* Please DO NOT edit this file.
*
* Edit auto-generated
"user.config.js"
file instead.
* Edit auto-generated
'user.config.js'
file instead.
*
*/
// #start config-auto-export
var
config
=
{}
var
config
=
{}
;
/*
* Configure host and port.
* Please for ports < 1000 use authbind. DO NOT RUN nodejs as root.
* $ authbind nodejs index.js
*/
config
.
host
=
'
localhost
'
config
.
port
=
3000
config
.
host
=
'
localhost
'
;
config
.
port
=
3000
;
config
.
socket
=
{}
config
.
socket
.
log
=
false
config
.
socket
=
{}
;
config
.
socket
.
log
=
false
;
config
.
debomatic
=
{}
config
.
debomatic
.
path
=
'
/srv/debomatic-amd64
'
config
.
debomatic
.
jsonfile
=
'
/var/log/debomatic-json.log
'
config
.
debomatic
=
{}
;
config
.
debomatic
.
path
=
'
/srv/debomatic-amd64
'
;
config
.
debomatic
.
jsonfile
=
'
/var/log/debomatic-json.log
'
;
config
.
routes
=
{}
config
.
routes
.
debomatic
=
'
/debomatic
'
config
.
routes
.
distribution
=
'
/distribution
'
config
.
routes
.
preferences
=
'
/preferences
'
config
.
routes
=
{}
;
config
.
routes
.
debomatic
=
'
/debomatic
'
;
config
.
routes
.
distribution
=
'
/distribution
'
;
config
.
routes
.
preferences
=
'
/preferences
'
;
config
.
web
=
{}
config
.
web
.
title
=
"
Deb-o-Matic web.ui
"
config
.
web
.
description
=
"
This is a web interface for debomatic
"
config
.
web
=
{}
;
config
.
web
.
title
=
'
Deb-o-Matic web.ui
'
;
config
.
web
.
description
=
'
This is a web interface for debomatic
'
;
// debomatic configuration exportable for web
config
.
web
.
debomatic
=
{}
config
.
web
.
debomatic
.
admin
=
{}
config
.
web
.
debomatic
.
admin
.
name
=
"
Your Name
"
config
.
web
.
debomatic
.
admin
.
email
=
"
you AT debian DOT org
"
// please use this SPAMFREE form - it will be converted client side by javascript
config
.
web
.
debomatic
.
architecture
=
'
amd64
'
config
.
web
.
debomatic
.
dput
=
{}
config
.
web
.
debomatic
.
dput
.
incoming
=
config
.
debomatic
.
path
config
.
web
.
debomatic
.
dput
.
host
=
config
.
host
config
.
web
.
debomatic
.
dput
.
login
=
"
debomatic
"
config
.
web
.
debomatic
.
dput
.
method
=
"
scp
"
config
.
web
.
debomatic
.
dput
.
unsigned_uploads
=
false
config
.
web
.
debomatic
=
{}
;
config
.
web
.
debomatic
.
admin
=
{}
;
config
.
web
.
debomatic
.
admin
.
name
=
'
Your Name
'
;
config
.
web
.
debomatic
.
admin
.
email
=
'
you AT debian DOT org
'
;
// please use this SPAMFREE form - it will be converted client side by javascript
config
.
web
.
debomatic
.
architecture
=
'
amd64
'
;
config
.
web
.
debomatic
.
dput
=
{}
;
config
.
web
.
debomatic
.
dput
.
incoming
=
config
.
debomatic
.
path
;
config
.
web
.
debomatic
.
dput
.
host
=
config
.
host
;
config
.
web
.
debomatic
.
dput
.
login
=
'
debomatic
'
;
config
.
web
.
debomatic
.
dput
.
method
=
'
scp
'
;
config
.
web
.
debomatic
.
dput
.
unsigned_uploads
=
false
;
// default ui settings
config
.
web
.
preferences
=
{}
config
.
web
.
preferences
.
autoscroll
=
true
config
.
web
.
preferences
.
header
=
true
config
.
web
.
preferences
.
sidebar
=
true
config
.
web
.
preferences
.
glossy_theme
=
true
config
.
web
.
preferences
.
file_background
=
true
config
.
web
.
preferences
.
file_fontsize
=
13
// valid values are [13..16]
config
.
web
.
preferences
.
debug
=
0
// debug level - 0 means disabled
config
.
web
.
preferences
=
{}
;
config
.
web
.
preferences
.
autoscroll
=
true
;
config
.
web
.
preferences
.
header
=
true
;
config
.
web
.
preferences
.
sidebar
=
true
;
config
.
web
.
preferences
.
glossy_theme
=
true
;
config
.
web
.
preferences
.
file_background
=
true
;
config
.
web
.
preferences
.
file_fontsize
=
13
;
// valid values are [13..16]
config
.
web
.
preferences
.
debug
=
0
;
// debug level - 0 means disabled
// #end config-auto-export
// DO NOT TOUCH these ones
config
.
version
=
'
0.2.
2
'
config
.
version
=
'
0.2.
3
'
;
// A simple function to quickly have
// get and set strings for client events
...
...
@@ -69,78 +70,74 @@ function _event_get_set(event_name) {
return
{
set
:
event_name
,
get
:
'
get_
'
+
event_name
}
};
}
config
.
events
=
{}
config
.
events
.
error
=
'
error
'
config
.
events
.
broadcast
=
{}
config
.
events
.
broadcast
.
distributions
=
'
distributions
'
config
.
events
.
broadcast
.
status_update
=
'
status_update
'
config
.
events
=
{}
;
config
.
events
.
error
=
'
error
'
;
config
.
events
.
broadcast
=
{}
;
config
.
events
.
broadcast
.
distributions
=
'
distributions
'
;
config
.
events
.
broadcast
.
status_update
=
'
status_update
'
;
config
.
events
.
client
=
{}
config
.
events
.
client
.
distribution_packages
=
_event_get_set
(
'
distribution_packages
'
)
config
.
events
.
client
.
distribution_packages
.
status
=
'
package_status
'
config
.
events
.
client
.
package_files_list
=
_event_get_set
(
'
package_files_list
'
)
config
.
events
.
client
.
file
=
_event_get_set
(
'
file
'
)
config
.
events
.
client
.
file_newcontent
=
'
file_newcontent
'
config
.
events
.
client
.
status
=
'
status
'
config
.
events
.
client
=
{}
;
config
.
events
.
client
.
distribution_packages
=
_event_get_set
(
'
distribution_packages
'
)
;
config
.
events
.
client
.
distribution_packages
.
status
=
'
package_status
'
;
config
.
events
.
client
.
package_files_list
=
_event_get_set
(
'
package_files_list
'
)
;
config
.
events
.
client
.
file
=
_event_get_set
(
'
file
'
)
;
config
.
events
.
client
.
file_newcontent
=
'
file_newcontent
'
;
config
.
events
.
client
.
status
=
'
status
'
;
// debomatic status according with JSONLogger.py module
config
.
status
=
{}
config
.
status
.
build
=
'
build
'
config
.
status
.
create
=
'
create
'
config
.
status
.
update
=
'
update
'
config
.
status
.
success
=
true
config
.
status
.
fail
=
false
config
.
status
=
{}
;
config
.
status
.
build
=
'
build
'
;
config
.
status
.
create
=
'
create
'
;
config
.
status
.
update
=
'
update
'
;
config
.
status
.
success
=
true
;
config
.
status
.
fail
=
false
;
// read user configuration and merge it
/*
* update object1 with object2 values
*/
function
_merge
(
object1
,
object2
)
{
var
result
=
{}
for
(
p
in
object1
)
{
var
result
=
{};
for
(
var
p
in
object1
)
{
if
(
object2
.
hasOwnProperty
(
p
))
{
if
(
typeof
object1
[
p
]
===
'
object
'
&&
typeof
object2
[
p
]
===
'
object
'
)
{
result
[
p
]
=
_merge
(
object1
[
p
],
object2
[
p
])
}
else
{
result
[
p
]
=
object2
[
p
]
}
result
[
p
]
=
_merge
(
object1
[
p
],
object2
[
p
]);
}
else
{
result
[
p
]
=
object2
[
p
];
}
else
{
result
[
p
]
=
object1
[
p
]
}
else
{
result
[
p
]
=
object1
[
p
];
}
}
return
result
return
result
;
}
try
{
var
Parser
=
require
(
'
./parser.js
'
)
var
parser
=
new
Parser
()
var
user_config
=
parser
.
getUserConfig
()
var
Parser
=
require
(
'
./parser.js
'
);
var
parser
=
new
Parser
();
var
user_config
=
parser
.
getUserConfig
();
if
(
user_config
)
{
console
.
log
(
"
Reading user configutation ...
"
)
config
=
_merge
(
config
,
require
(
user_config
))
}
else
{
console
.
log
(
"
No user config specified. Using global settings.
"
)
console
.
log
(
'
Reading user configutation ...
'
);
config
=
_merge
(
config
,
require
(
user_config
));
}
else
{
console
.
log
(
'
No user config specified. Using global settings.
'
);
}
}
catch
(
err
)
{
if
(
err
.
code
==
'
MODULE_NOT_FOUND
'
)
{
console
.
log
(
"
File %s not found.
"
,
user_config
)
process
.
exit
(
1
)
}
else
{
console
.
error
(
"
Error reading user configutation
"
,
err
);
process
.
exit
(
1
)
console
.
log
(
'
File %s not found.
'
,
user_config
);
process
.
exit
(
1
);
}
else
{
console
.
error
(
'
Error reading user configutation
'
,
err
);
process
.
exit
(
1
);
}
}
finally
{
// export some variable
config
.
web
.
paths
=
config
.
routes
config
.
web
.
events
=
config
.
events
config
.
web
.
status
=
config
.
status
config
.
web
.
host
=
config
.
host
module
.
exports
=
config
config
.
web
.
paths
=
config
.
routes
;
config
.
web
.
events
=
config
.
events
;
config
.
web
.
status
=
config
.
status
;
config
.
web
.
host
=
config
.
host
;
module
.
exports
=
config
;
}
debomatic-webui/lib/parser.js
View file @
f7a4f04a
function
Parser
()
{
'
use strict
'
;
function
Parser
()
{
var
args
=
process
.
argv
.
slice
(
2
);
var
help
=
function
()
{
console
.
log
(
"
\
var
help
=
function
()
{
console
.
log
(
'
\
Usage: %s [-c config]
\n\
-h print this help
\n\
-c set user configuration file
"
,
-c set user configuration file
'
,
process
.
argv
[
1
].
split
(
'
/
'
).
pop
());
process
.
exit
(
0
);
}
};
this
.
getUserConfig
=
function
()
{
this
.
getUserConfig
=
function
()
{
var
configFile
=
null
;
args
.
forEach
(
function
(
val
,
index
)
{
if
(
val
==
'
-c
'
)
{
configFile
=
args
[
index
+
1
]
return
configFile
=
args
[
index
+
1
];
return
;
}
})
});
if
(
configFile
)
return
process
.
cwd
()
+
'
/
'
+
configFile
;
else
return
null
}
return
null
;
};
args
.
forEach
(
function
(
val
,
index
)
{
if
(
val
==
'
-h
'
)
{
help
()
help
();
}
})
});
}
module
.
exports
=
Parser
debomatic-webui/lib/tail.js
View file @
f7a4f04a
var
fs
=
require
(
'
fs
'
)
,
Tail
=
require
(
'
tail
'
).
Tail
'
use strict
'
;
Tail
.
prototype
.
watchEvent
=
function
(
e
)
{
var
fs
=
require
(
'
fs
'
),
Tail
=
require
(
'
tail
'
).
Tail
;
Tail
.
prototype
.
watchEvent
=
function
(
e
)
{
var
_this
=
this
;
if
(
e
===
'
change
'
)
{
return
fs
.
stat
(
this
.
filename
,
function
(
err
,
stats
)
{
return
fs
.
stat
(
this
.
filename
,
function
(
err
,
stats
)
{
if
(
err
)
{
_this
.
emit
(
'
error
'
,
err
);
}
...
...
@@ -19,18 +21,18 @@ Tail.prototype.watchEvent = function(e) {
});
_this
.
pos
=
stats
.
size
;
if
(
_this
.
queue
.
length
===
1
)
{
return
_this
.
internalDispatcher
.
emit
(
"
next
"
);
return
_this
.
internalDispatcher
.
emit
(
'
next
'
);
}
}
});
}
else
if
(
e
===
'
rename
'
)
{
this
.
unwatch
();
_this
.
emit
(
'
error
'
,
"
File
"
+
this
.
filename
+
"
deleted.
"
);
_this
.
emit
(
'
error
'
,
'
File
'
+
this
.
filename
+
'
deleted.
'
);
}
};
Tail
.
prototype
.
close
=
function
()
{
this
.
unwatch
()
}
Tail
.
prototype
.
close
=
function
()
{
this
.
unwatch
();
}
;
module
.
exports
=
Tail
\ No newline at end of file
module
.
exports
=
Tail
;
debomatic-webui/lib/utils.js
View file @
f7a4f04a
This diff is collapsed.
Click to expand it.
debomatic-webui/public/javascripts/debug.js
View file @
f7a4f04a
"
use strict
"
;
/*
General information about debugging:
...
...
@@ -10,17 +11,17 @@
3 - socket emit data
4 - socket received data
*/
var
debug
=
function
()
{
var
debug
=
function
()
{
if
(
arguments
.
length
<
2
)
{
return
return
;
}
var
level
=
arguments
[
0
]
arguments
[
0
]
=
"
debug [
"
+
level
+
"
]:
"
var
level
=
arguments
[
0
];
arguments
[
0
]
=
"
debug [
"
+
level
+
"
]:
"
;
if
(
level
<=
config
.
preferences
.
debug
)
{
if
(
console
.
debug
)
console
.
debug
.
apply
(
console
,
arguments
)
console
.
debug
.
apply
(
console
,
arguments
);
else
console
.
log
.
apply
(
console
,
arguments
)
console
.
log
.
apply
(
console
,
arguments
);
}
}
...
...
@@ -30,11 +31,11 @@ var debug = function() {
usage: debug_socket("emit"|"received", event_name, data)
*/
var
debug_socket
=
function
()
{
var
debug_socket
=
function
()
{
if
(
arguments
.
length
!=
3
)
return
return
;
var
level
=
3
;
if
(
arguments
[
0
]
==
"
received
"
)
level
=
4
debug
(
level
,
"
socket
"
,
arguments
[
0
],
"
event:
"
,
arguments
[
1
],
"
data:
"
,
arguments
[
2
])
level
=
4
;
debug
(
level
,
"
socket
"
,
arguments
[
0
],
"
event:
"
,
arguments
[
1
],
"
data:
"
,
arguments
[
2
]);
}
debomatic-webui/public/javascripts/main.js
View file @
f7a4f04a
// main client javascript
'
use strict
'
;
var
preferences
=
new
Preferences
()
var
preferences
=
new
Preferences
()
;
var
page_generic
=
new
Page_Generic
()
var
page_generic
=
new
Page_Generic
()
;
if
(
window
.
location
.
pathname
==
config
.
paths
.
preferences
)
{
preferences
.
initPage
()
preferences
.
initPage
();
}
if
(
window
.
location
.
pathname
==
'
/
'
)
{
// convert email addresses in the right format
var
emails
=
$
(
"
.email
"
)
$
.
each
(
emails
,
function
()
{
var
subject
=
''
var
emails
=
$
(
'
.email
'
);
$
.
each
(
emails
,
function
()
{
var
subject
=
''
;
if
(
$
(
this
).
attr
(
'
subject
'
))
{
subject
=
'
?subject=
'
+
$
(
this
).
attr
(
'
subject
'
)
subject
=
'
?subject=
'
+
$
(
this
).
attr
(
'
subject
'
);
}
var
real_email
=
$
(
this
).
attr
(
'
address
'
).
replace
(
'
AT
'
,
'
@
'
).
replace
(
'
DOT
'
,
'
.
'
).
replace
(
/ /g
,
''
)
var
label
=
real_email
if
(
config
.
debomatic
.
admin
.
name
&&
config
.
debomatic
.
admin
.
name
!=
'
Your Name
'
)
label
=
config
.
debomatic
.
admin
.
name
real_email
=
'
<a href="mailto:
'
+
real_email
+
subject
+
'
">
'
+
label
+
'
</a>
'
$
(
this
).
html
(
real_email
)
var
real_email
=
$
(
this
).
attr
(
'
address
'
).
replace
(
'
AT
'
,
'
@
'
).
replace
(
'
DOT
'
,
'
.
'
).
replace
(
/ /g
,
''
);
var
label
=
real_email
;
if
(
config
.
debomatic
.
admin
.
name
&&
config
.
debomatic
.
admin
.
name
!=
'
Your Name
'
);
label
=
config
.
debomatic
.
admin
.
name
;
real_email
=
'
<a href="mailto:
'
+
real_email
+
subject
+
'
">
'
+
label
+
'
</a>
'
;
$
(
this
).
html
(
real_email
);
})
}
var
socket
=
io
.
connect
(
'
/
'
);
page_generic
.
start
(
socket
)
page_generic
.
start
(
socket
)
;
if
(
window
.
location
.
pathname
==
config
.
paths
.
distribution
)
{
new
Page_Distrubion
(
socket
).
start
()
new
Page_Distrubion
(
socket
).
start
();
}
debomatic-webui/public/javascripts/page_distribution.js
View file @
f7a4f04a
This diff is collapsed.
Click to expand it.
debomatic-webui/public/javascripts/page_generic.js
View file @
f7a4f04a
This diff is collapsed.
Click to expand it.
debomatic-webui/public/javascripts/preferences.js
View file @
f7a4f04a
'
use strict
'
;
function
Preferences
()
{
// update config.preferences according with user choices
var
load
=
function
()
{
for
(
key
in
config
.
preferences
)
{
if
((
value
=
localStorage
.
getItem
(
key
)))
{
debug
(
2
,
'
loading preference
'
,
key
,
value
)
config
.
preferences
[
key
]
=
JSON
.
parse
(
value
)
}
for
(
var
key
in
config
.
preferences
)
{
var
value
=
localStorage
.
getItem
(
key
);
if
(
value
)
{
debug
(
2
,
'
loading preference
'
,
key
,
value
);
config
.
preferences
[
key
]
=
JSON
.
parse
(
value
);
}
}
};
// set prefence
var
set
=
function
(
key
,
value
)
{
if
(
config
.
preferences
.
hasOwnProperty
(
key
))
{
debug
(
1
,
'
setting preference
'
,
key
,
value
)
localStorage
.
setItem
(
key
,
value
)
config
.
preferences
[
key
]
=
JSON
.
parse
(
value
)
}
debug
(
1
,
'
setting preference
'
,
key
,
value
);
localStorage
.
setItem
(
key
,
value
);
config
.
preferences
[
key
]
=
JSON
.
parse
(
value
);
}
};
// init prefence page
this
.
initPage
=
function
()
{
this
.
initPage
=
function
()
{
page_generic
.
set_window_title
(
"
Preferences
"
)
page_generic
.
set_window_title
(
'
Preferences
'
);
// set view according with config.preferences
for
(
key
in
config
.
preferences
)
{
var
element
=
$
(
"
#preferences #
"
+
key
)
if
(
element
.
attr
(
'
type
'
)
==
"
checkbox
"
)
{
element
.
prop
(
'
checked
'
,
config
.
preferences
[
key
])
}
else
{
element
.
val
(
config
.
preferences
[
key
])
for
(
var
key
in
config
.
preferences
)
{
var
element
=
$
(
'
#preferences #
'
+
key
);
if
(
element
.
attr
(
'
type
'
)
==
'
checkbox
'
)
{
element
.
prop
(
'
checked
'
,
config
.
preferences
[
key
]);
}
else
{
element
.
val
(
config
.
preferences
[
key
]);
}
}
// on input change, set prefence
$
(
"
#preferences input, #preferences select
"
).
change
(
function
()
{
var
key
=
$
(
this
).
attr
(
'
id
'
)
var
value
=
$
(
this
).
val
()
$
(
'
#preferences input, #preferences select
'
).
change
(
function
()
{
var
key
=
$
(
this
).
attr
(
'
id
'
);
var
value
=
$
(
this
).
val
();
if
(
$
(
this
).
attr
(
'
type
'
)
==
'
checkbox
'
)
value
=
$
(
this
).
is
(
'
:checked
'
)
set
(
key
,
value
)
value
=
$
(
this
).
is
(
'
:checked
'
);
set
(
key
,
value
);
// give to user an immediate feedback changing preferences
page_generic
.
preferences
()
})
}
page_generic
.
preferences
();
});
};
load
()
load
();
}
debomatic-webui/public/javascripts/utils.js
View file @
f7a4f04a
'
use strict
'
;
var
Utils
=
{
from_hash_to_view
:
function
(
hash
)
{
if
(
!
hash
)
hash
=
window
.
location
.
hash
hash
=
hash
.
replace
(
'
#
'
,
''
)
info
=
hash
.
split
(
'
/
'
);
var
view
=
{}
view
.
distribution
=
{}
view
.
packages
=
{}
view
.
package
=
{}
view
.
file
=
{}
if
(
!
hash
)
hash
=
window
.
location
.
hash
;
hash
=
hash
.
replace
(
'
#
'
,
''
);
var
info
=
hash
.
split
(
'
/
'
);
var
view
=
{};
view
.
distribution
=
{};
view
.
packages
=
{};
view
.
package
=
{};
view
.
file
=
{};
if
(
info
.
length
>=
1
)
{
view
.
distribution
.
name
=
info
[
0
];
}
if
(
info
.
length
>=
3
)
{
if
(
info
.
length
>=
3
)
{
view
.
package
.
name
=
info
[
1
];
view
.
package
.
version
=
info
[
2
];
view
.
package
.
orig_name
=
view
.
package
.
name
+
'
_
'
+
view
.
package
.
version
view
.
package
.
orig_name
=
view
.
package
.
name
+
'
_
'
+
view
.
package
.
version
;
}
if
(
info
.
length
>=
4
)
{
view
.
file
.
name
=
info
[
3
]
view
.
file
.
orig_name
=
view
.
package
.
orig_name
+
'
.
'
+
view
.
file
.
name
view
.
file
.
name
=
info
[
3
];
view
.
file
.
orig_name
=
view
.
package
.
orig_name
+
'
.
'
+
view
.
file
.
name
;
}
return
view
return
view
;
},
from_view_to_hash
:
function
(
view
)
{
hash
=
"
#
"
var
hash
=
'
#
'
;
if
(
Utils
.
check_view_distribution
(
view
))
{
hash
=
hash
+
view
.
distribution
.
name
hash
=
hash
+
view
.
distribution
.
name
;
if
(
Utils
.
check_view_package
(
view
))
{
hash
=
hash
+
'
/
'
+
view
.
package
.
name
+
"
/
"
+
view
.
package
.
version
hash
=
hash
+
'
/
'
+
view
.
package
.
name
+
'
/
'
+
view
.
package
.
version
;
if
(
Utils
.
check_view_file
(
view
))
hash
=
hash
+
'
/
'
+
view
.
file
.
name
hash
=
hash
+
'
/
'
+
view
.
file
.
name
;
}
}
return
hash
return
hash
;
},
check_view_distribution
:
function
(
view
)
{
return
view
&&
view
.
distribution
&&
view
.
distribution
.
name
check_view_distribution
:
function
(
view
)
{
return
view
&&
view
.
distribution
&&
view
.
distribution
.
name
;
},
check_view_package
:
function
(
view
)
{
return
Utils
.
check_view_distribution
(
view
)
&&
view
.
package
&&
view
.
package
.
name
&&
view
.
package
.
version
&&
view
.
package
.
orig_name
check_view_package
:
function
(
view
)
{
return
Utils
.
check_view_distribution
(
view
)
&&
view
.
package
&&
view
.
package
.
name
&&
view
.
package
.
version
&&
view
.
package
.
orig_name
;
},
check_view_file
:
function
(
view
)
{
return
Utils
.
check_view_package
(
view
)
&&
view
.
file
&&
view
.
file
.
name
check_view_file
:
function
(
view
)
{
return
Utils
.
check_view_package
(
view
)
&&
view
.
file
&&
view
.
file
.
name
;
},
get_status_icon_and_class
:
function
(
status_data
)
{
var
_c
=
config
.
status
.
className
var
_i
=
config
.
status
.
icons
var
_s
=
status_data
var
className
=
null
var
icon
=
null
var
_c
=
config
.
status
.
className
;
var
_i
=
config
.
status
.
icons
;
var
_s
=
status_data
;
var
className
=
null
;
var
icon
=
null
;
if
(
_s
.
hasOwnProperty
(
'
success
'
))
{
if
(
_s
.
success
==
true
)
{
className
=
_c
.
success
icon
=
_i
.
success
}
else
{
className
=
_c
.
fail
icon
=
_i
.
fail
if
(
_s
.
success
===
true
)
{
className
=
_c
.
success
;
icon
=
_i
.
success
;
}
else
{
className
=
_c
.
fail
;
icon
=
_i
.
fail
;
}
}
else
{
className
=
_c
[
_s
.
status
]
icon
=
_i
[
_s
.
status
]
}
else
{
className
=
_c
[
_s
.
status
];
icon
=
_i
[
_s
.
status
];
}
// do not change color if update or create and successed
if
(
_s
.
success
==
true
&&
_s
.
status
!=
config
.
status
.
build
)
{
className
=
_c
[
_s
.
status
]
if
(
_s
.
success
===
true
&&
_s
.
status
!=
config
.
status
.
build
)
{
className
=
_c
[
_s
.
status
];
}
return
{
className
:
className
,
icon
:
icon
}
};
},
get_status_icon_html
:
function
(
status_data
)
{
info
=
Utils
.
get_status_icon_and_class
(
status_data
)
return
'
<span class="icon glyphicon glyphicon-
'
+
info
.
icon
+
'
"></span>
'
var
info
=
Utils
.
get_status_icon_and_class
(
status_data
);
return
'
<span class="icon glyphicon glyphicon-
'
+
info
.
icon
+
'
"></span>
'
;
},
// clone an object via JSON
clone
:
function
(
object
)
{
return
JSON
.
parse
(
JSON
.
stringify
(
object
));
}
}
}
;
debomatic-webui/views/distribution.ejs
View file @
f7a4f04a
...
...
@@ -24,7 +24,11 @@
</nav>
<div class="others">
<nav id="sources">
<h4>Sources</h4>
<h4>Sources
<a class="btn btn-link" title="Get all sources in one click" onclick="download_all('#sources')">
<span class="glyphicon glyphicon-download-alt"></span>
</a>
</h4>
<ul></ul>
</nav>
<nav id="debs">
...
...
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