Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
0393bf07
authored
May 22, 2013
by
Bence Dányi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
firewall_gui: reload entity list after delete
parent
10ad5fcd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
77 additions
and
58 deletions
+77
-58
firewall_gui/static/js/project.js
+77
-58
No files found.
firewall_gui/static/js/project.js
View file @
0393bf07
...
@@ -225,10 +225,23 @@ function ListController(url) {
...
@@ -225,10 +225,23 @@ function ListController(url) {
$scope
.
prevPage
=
function
()
{
$scope
.
prevPage
=
function
()
{
$scope
.
page
=
Math
.
max
(
$scope
.
page
-
1
,
1
);
$scope
.
page
=
Math
.
max
(
$scope
.
page
-
1
,
1
);
};
};
$http
.
get
(
url
).
success
(
function
success
(
data
)
{
rules
=
data
;
$scope
.
deleteEntity
=
function
(
id
)
{
$scope
.
pages
=
range
(
1
,
Math
.
ceil
(
data
.
length
/
pageSize
));
$
.
ajax
({
});
url
:
url
.
split
(
'/'
)[
2
]
+
'/'
+
id
+
'/delete/'
,
type
:
'post'
,
success
:
reloadList
});
};
function
reloadList
()
{
$http
.
get
(
url
).
success
(
function
success
(
data
)
{
rules
=
data
;
$scope
.
pages
=
range
(
1
,
Math
.
ceil
(
data
.
length
/
pageSize
));
});
}
reloadList
();
}
}
}
}
...
@@ -275,7 +288,8 @@ function EntityController(url, init) {
...
@@ -275,7 +288,8 @@ function EntityController(url, init) {
console
.
log
(
data
);
console
.
log
(
data
);
$scope
.
$apply
(
function
()
{
$scope
.
$apply
(
function
()
{
$scope
.
errors
=
{};
$scope
.
errors
=
{};
})
});
window
.
location
.
hash
=
'/'
+
url
.
split
(
'/'
)[
2
]
+
'/'
+
data
+
'/'
;
}
}
}).
error
(
function
(
data
)
{
}).
error
(
function
(
data
)
{
try
{
try
{
...
@@ -293,61 +307,66 @@ function EntityController(url, init) {
...
@@ -293,61 +307,66 @@ function EntityController(url, init) {
}
}
})
})
}
}
$http
.
get
(
url
+
id
+
'/'
).
success
(
function
success
(
data
)
{
function
reloadEntity
(
)
{
$
scope
.
entity
=
data
;
$
http
.
get
(
url
+
id
+
'/'
).
success
(
function
success
(
data
)
{
$
(
'input[type=text], input[type=number], select, textarea, .has-tooltip'
).
tooltip
({
placement
:
'right'
})
;
$scope
.
entity
=
data
;
[
'vlan'
,
'vlangroup'
,
'host'
,
'hostgroup'
,
'firewall'
,
'owner'
,
'domain'
,
'record'
].
forEach
(
function
(
t
)
{
$
(
'input[type=text], input[type=number], select, textarea, .has-tooltip'
).
tooltip
(
{
$
(
'.'
+
t
).
typeahead
({
placement
:
'right'
/**
});
* Typeahead does AJAX queries
[
'vlan'
,
'vlangroup'
,
'host'
,
'hostgroup'
,
'firewall'
,
'owner'
,
'domain'
,
'record'
].
forEach
(
function
(
t
)
{
* @param {String} query Partial name of the entity
$
(
'.'
+
t
).
typeahead
({
* @param {Function} process Callback function after AJAX returned result
/**
*/
* Typeahead does AJAX queries
source
:
function
(
query
,
process
)
{
* @param {String} query Partial name of the entity
$
.
ajax
({
* @param {Function} process Callback function after AJAX returned result
url
:
'/firewall/autocomplete/'
+
t
+
'/'
,
*/
type
:
'post'
,
source
:
function
(
query
,
process
)
{
data
:
'name='
+
query
,
$
.
ajax
({
success
:
function
autocompleteSuccess
(
data
)
{
url
:
'/firewall/autocomplete/'
+
t
+
'/'
,
process
(
data
.
map
(
function
(
obj
)
{
type
:
'post'
,
return
obj
.
name
;
data
:
'name='
+
query
,
}));
success
:
function
autocompleteSuccess
(
data
)
{
}
process
(
data
.
map
(
function
(
obj
)
{
})
;
return
obj
.
name
;
},
}));
/**
}
* Filtering is done on server-side, show all results
});
* @return {Boolean} Always true, so all result are visible
},
*/
/**
matcher
:
function
()
{
* Filtering is done on server-side, show all results
return
true
;
* @return {Boolean} Always true, so all result are visible
},
*/
/**
matcher
:
function
()
{
* Typeahead does not trigger proper DOM events, so we have to refresh
return
true
;
* the model manually.
},
* @param {String} item Selected entity name
/**
* @return {String} Same as `item`, the input value is set to this
* Typeahead does not trigger proper DOM events, so we have to refresh
*/
* the model manually.
updater
:
function
(
item
)
{
* @param {String} item Selected entity name
var
self
=
this
;
* @return {String} Same as `item`, the input value is set to this
console
.
log
(
this
);
*/
$scope
.
$apply
(
function
(
)
{
updater
:
function
(
item
)
{
var
model
=
self
.
$element
[
0
].
getAttribute
(
'ng-model'
).
split
(
'.'
)[
1
]
;
var
self
=
this
;
console
.
log
(
self
.
$element
[
0
].
getAttribute
(
'ng-model'
),
model
);
console
.
log
(
this
);
try
{
$scope
.
$apply
(
function
()
{
$scope
.
entity
[
model
].
name
=
item
;
var
model
=
self
.
$element
[
0
].
getAttribute
(
'ng-model'
).
split
(
'.'
)[
1
]
;
}
catch
(
ex
)
{
console
.
log
(
self
.
$element
[
0
].
getAttribute
(
'ng-model'
),
model
);
try
{
try
{
$scope
[
self
.
$element
[
0
].
getAttribute
(
'ng-model'
)]
=
item
;
$scope
.
entity
[
model
].
name
=
item
;
}
catch
(
ex
)
{
}
catch
(
ex
)
{
try
{
$scope
[
self
.
$element
[
0
].
getAttribute
(
'ng-model'
)]
=
item
;
}
catch
(
ex
)
{
}
}
}
}
})
})
return
item
;
return
item
;
}
}
});
});
})
})
});
});
}
reloadEntity
();
}
}
}
}
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