Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
baas
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
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
itminedu
baas
Commits
47449f8f
Commit
47449f8f
authored
Nov 27, 2015
by
Efthymia Bika
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean code
Move cloud loading to a single function
parent
d2b1d1a7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
83 deletions
+48
-83
baas/backup-list.html
baas/backup-list.html
+31
-60
baas/backup.js
baas/backup.js
+16
-0
baas/restore.html
baas/restore.html
+1
-23
No files found.
baas/backup-list.html
View file @
47449f8f
...
...
@@ -34,17 +34,43 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
}
}
function
populate_template_list
(
data
)
{
if
(
typeof
templates
===
'
undefined
'
)
{
if
(
data
!=
""
)
{
templates
=
JSON
.
parse
(
data
);
}
else
{
templates
=
new
Object
();
}
}
$
(
"
#template_list
"
).
empty
();
var
ul
=
$
(
"
<ul></ul>
"
)
.
attr
(
"
class
"
,
"
no-bullet template-list
"
);
var
li
=
$
(
"
<li>Load Template:</li>
"
)
.
attr
(
"
class
"
,
"
template-list-title
"
);
ul
.
append
(
li
);
$
.
each
(
templates
,
function
(
i
,
template
)
{
var
li
=
$
(
"
<li></li>
"
);
var
a
=
$
(
"
<a>
"
+
template
.
name
+
"
<i class='fa fa-arrow-circle-right'></a>
"
)
.
attr
(
"
href
"
,
"
#
"
)
.
click
(
function
()
{
load_backup
(
template
);
$
(
"
#template_list
"
).
hide
();
});
li
.
append
(
a
);
ul
.
append
(
li
);
});
$
(
"
#template_list
"
).
append
(
ul
);
}
if
(
typeof
templates
===
'
undefined
'
)
{
load_data_from_file
(
TEMPLATES_FILE
,
populate_template_list
);
}
else
{
populate_template_list
(
""
);
}
if
(
typeof
clouds
===
'
undefined
'
)
{
load_data_from_file
(
CLOUDS_CONF_FILE
,
populate_clouds
);
}
else
{
populate_clouds
(
""
);
}
populate_clouds
(
"
cloud
"
,
""
);
if
(
typeof
selected_backup
!=
'
undefined
'
&&
selected_backup
&&
typeof
backups
[
selected_backup
]
!=
'
undefined
'
)
{
$
(
"
#selected-bar
"
).
html
(
selected_backup
);
...
...
@@ -70,16 +96,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
load_backup
();
}
function
activate_li
(
id
)
{
$
(
"
li
"
).
each
(
function
(
i
,
li
)
{
if
(
$
(
this
).
is
(
"
#
"
+
id
))
{
$
(
this
).
addClass
(
"
active-li
"
);
}
else
{
$
(
this
).
removeClass
(
"
active-li
"
);
}
});
}
function
check_backup_name
()
{
var
backup_name
=
$
(
'
#backup-name
'
).
val
().
replace
(
/^
\s
+|
\s
+$/gm
,
''
);
if
(
!
backup_name
)
{
...
...
@@ -123,51 +139,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
return
true
;
}
function
populate_clouds
(
data
)
{
if
(
typeof
clouds
===
'
undefined
'
)
{
if
(
data
!=
""
)
{
clouds
=
JSON
.
parse
(
data
);
}
else
{
clouds
=
new
Object
();
}
}
var
cloud_sel
=
$
(
"
#cloud
"
);
$
.
each
(
clouds
,
function
(
i
,
cloud
)
{
cloud_sel
.
append
(
$
(
"
<option></option>
"
)
.
attr
(
"
value
"
,
cloud
.
name
)
.
text
(
cloud
.
name
));
});
}
function
populate_template_list
(
data
)
{
if
(
typeof
templates
===
'
undefined
'
)
{
if
(
data
!=
""
)
{
templates
=
JSON
.
parse
(
data
);
}
else
{
templates
=
new
Object
();
}
}
$
(
"
#template_list
"
).
empty
();
var
ul
=
$
(
"
<ul></ul>
"
)
.
attr
(
"
class
"
,
"
no-bullet template-list
"
);
var
li
=
$
(
"
<li>Load Template:</li>
"
)
.
attr
(
"
class
"
,
"
template-list-title
"
);
ul
.
append
(
li
);
$
.
each
(
templates
,
function
(
i
,
template
)
{
var
li
=
$
(
"
<li></li>
"
);
var
a
=
$
(
"
<a>
"
+
template
.
name
+
"
<i class='fa fa-arrow-circle-right'></a>
"
)
.
attr
(
"
href
"
,
"
#
"
)
.
click
(
function
()
{
load_backup
(
template
);
$
(
"
#template_list
"
).
hide
();
});
li
.
append
(
a
);
ul
.
append
(
li
);
});
$
(
"
#template_list
"
).
append
(
ul
);
}
function
disable_form
(
disable
)
{
$
(
"
#backup-name
"
).
prop
(
"
disabled
"
,
disable
);
$
(
"
#choose-dir
"
).
prop
(
"
disabled
"
,
disable
);
...
...
baas/backup.js
View file @
47449f8f
...
...
@@ -39,6 +39,22 @@ function toggle_error(error, msg) {
}
}
function
populate_clouds
(
cloud_field
,
data
)
{
if
(
typeof
clouds
===
'
undefined
'
)
{
if
(
data
!=
""
)
{
clouds
=
JSON
.
parse
(
data
);
}
else
{
clouds
=
new
Object
();
}
}
var
cloud_sel
=
$
(
"
#
"
+
cloud_field
);
$
.
each
(
clouds
,
function
(
i
,
cloud
)
{
cloud_sel
.
append
(
$
(
"
<option></option>
"
)
.
attr
(
"
value
"
,
cloud
.
name
)
.
text
(
cloud
.
name
));
});
}
function
check_directory
(
dir_id
)
{
if
(
!
$
(
'
#
'
+
dir_id
).
html
())
{
$
(
'
#
'
+
dir_id
+
'
-error small
'
).
text
(
errors
.
dir_not_chosen
);
...
...
baas/restore.html
View file @
47449f8f
...
...
@@ -17,13 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<script
type=
"text/javascript"
>
$
(
document
).
ready
(
function
()
{
if
(
typeof
clouds
===
'
undefined
'
)
{
load_data_from_file
(
CLOUDS_CONF_FILE
,
populate_clouds
);
}
else
{
populate_clouds
(
""
);
}
});
populate_clouds
(
"
res-cloud
"
,
""
);
hide_error_divs
();
function
load_field_values
()
{
...
...
@@ -70,22 +64,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
return
true
;
}
function
populate_clouds
(
data
)
{
if
(
typeof
clouds
===
'
undefined
'
)
{
if
(
data
!=
""
)
{
clouds
=
JSON
.
parse
(
data
).
clouds
;
}
else
{
clouds
=
[];
}
}
var
cloud_sel
=
$
(
"
#res-cloud
"
);
$
.
each
(
clouds
,
function
(
i
,
cloud
)
{
cloud_sel
.
append
(
$
(
"
<option></option>
"
)
.
attr
(
"
value
"
,
cloud
.
name
)
.
text
(
cloud
.
name
));
});
}
function
check_res_fields
()
{
return
(
check_res_backup_name
()
&&
check_directory
(
"
res-directory
"
)
...
...
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