This commit is contained in:
Lucas committed 2026-09-16 15:22:36 +02:00
1 parent 80bf0fa42f
commit 140d51f248
7 files changed
+17 -14

No files matched your search

+2 -1
View File
@@ -24,7 +24,8 @@ class ChangePasswordForm(FlaskForm):
is_readonly = SelectField(choices=[(0,'No'),(1,'Yes')],validators=[DataRequired()]) is_readonly = SelectField(choices=[(0,'No'),(1,'Yes')],validators=[DataRequired()])
class ChangeAllocationForm(FlaskForm): class ChangeAllocationForm(FlaskForm):
hostname = StringField(validators=[Length(max=128)]) shortname = StringField(validators=[Length(max=128)])
fqdn = StringField(validators=[Length(max=128)])
description = StringField(validators=[Length(max=128)]) description = StringField(validators=[Length(max=128)])
is_special = SelectField(choices=[(0,'None'),(1,'DHCP'),(2,'Gateway')],validators=[DataRequired()],label='Special USE ?') is_special = SelectField(choices=[(0,'None'),(1,'DHCP'),(2,'Gateway')],validators=[DataRequired()],label='Special USE ?')
+7 -3
View File
@@ -66,7 +66,6 @@ def allocations(net_id):
else: else:
session['hide_dhcp'] = False session['hide_dhcp'] = False
return redirect(url_for('network.allocations',net_id=net_id)) return redirect(url_for('network.allocations',net_id=net_id))
print(session['hide_dhcp'])
# PAGINATION MODE # PAGINATION MODE
if current_user.ui_lmode == False: if current_user.ui_lmode == False:
active_page = request.args.get('page', type=int) active_page = request.args.get('page', type=int)
@@ -136,7 +135,8 @@ def allocation_edit_modal(net_id, ipv4):
form = ChangeAllocationForm() form = ChangeAllocationForm()
if form.validate_on_submit() and request.method == 'POST': if form.validate_on_submit() and request.method == 'POST':
db_alloc.hostname = str(form.hostname.data) db_alloc.hostname = str(form.shortname.data)
db_alloc.hostname_full = str(form.fqdn.data)
db_alloc.description = str(form.description.data) db_alloc.description = str(form.description.data)
db_alloc.is_used = True db_alloc.is_used = True
# Special Allocation # Special Allocation
@@ -145,6 +145,7 @@ def allocation_edit_modal(net_id, ipv4):
db_alloc.is_dhcp = True db_alloc.is_dhcp = True
db_alloc.is_gateway = False db_alloc.is_gateway = False
db_alloc.hostname = None db_alloc.hostname = None
db_alloc.hostname_full = None
db_alloc.description = "DHCP Allocation" db_alloc.description = "DHCP Allocation"
elif int(form.is_special.data) == 2: elif int(form.is_special.data) == 2:
# Gateway # Gateway
@@ -172,7 +173,9 @@ def allocation_edit_modal(net_id, ipv4):
if old_page == 0: if old_page == 0:
old_page = 1 old_page = 1
form.hostname.default = db_alloc.hostname form.shortname.default = db_alloc.hostname
form.fqdn.default = db_alloc.hostname_full
form.description.default = db_alloc.description form.description.default = db_alloc.description
if db_alloc.is_dhcp: if db_alloc.is_dhcp:
form.is_special.default = 1 form.is_special.default = 1
@@ -192,6 +195,7 @@ def allocation_delete(net_id,ipv4):
db_alloc = Allocation.query.filter_by(net_id=net_id,ipv4=ipv4).first() db_alloc = Allocation.query.filter_by(net_id=net_id,ipv4=ipv4).first()
db_alloc.is_used = False db_alloc.is_used = False
db_alloc.hostname = None db_alloc.hostname = None
db_alloc.hostname_full = None
db_alloc.description = None db_alloc.description = None
db_alloc.is_dhcp = False db_alloc.is_dhcp = False
db_alloc.is_gateway = False db_alloc.is_gateway = False
+2 -1
View File
@@ -1 +1,2 @@
var htmx=function(){"use strict";const Q={onLoad:null,process:null,on:null,off:null,trigger:null,ajax:null,find:null,findAll:null,closest:null,values:function(e,t){const n=dn(e,t||"post");return n.values},remove:null,addClass:null,removeClass:null,toggleClass:null,takeClass:null,swap:null,defineExtension:null,removeExtension:null,logAll:null,logNone:null,logger:null,config:{historyEnabled:true,historyCacheSize:10,refreshOnHistoryMiss:false,defaultSwapStyle:"innerHTML",defaultSwapDelay:0,defaultSettleDelay:20,includeIndicatorStyles:true,indicatorClass:"htmx-indicator",requestClass:"htmx-request",addedClass:"htmx-added",settlingClass:"htmx-settling",swappingClass:"htmx-swapping",allowEval:true,allowScriptTags:true,inlineScriptNonce:"",inlineStyleNonce:"",attributesToSettle:["class","style","width","height"],withCredentials:false,timeout:0,wsReconnectDelay:"full-jitter",wsBinaryType:"blob",disableSelector:"[hx-disable], [data-hx-disable]",scrollBehavior:"instant",defaultFocusScroll:false,getCacheBusterParam:false,globalViewTransitions:false,methodsThatUseUrlParams:["get","delete"],selfRequestsOnly:true,ignoreTitle:false,scrollIntoViewOnBoost:true,triggerSpecsCache:null,disableInheritance:false,responseHandling:[{code:"204",swap:false},{code:"[23]..",swap:true},{code:"[45]..",swap:false,error:true}],allowNestedOobSwaps:true,historyRestoreAsHxRequest:true,reportValidityOfForms:false},parseInterval:null,location:location,_:null,version:"2.0.8"};Q.onLoad=V;Q.process=Ft;Q.on=xe;Q.off=be;Q.trigger=ae;Q.ajax=Ln;Q.find=f;Q.findAll=x;Q.closest=g;Q.remove=_;Q.addClass=K;Q.removeClass=G;Q.toggleClass=W;Q.takeClass=Z;Q.swap=ze;Q.defineExtension=_n;Q.removeExtension=zn;Q.logAll=j;Q.logNone=$;Q.parseInterval=d;Q._=e;const n={addTriggerHandler:St,bodyContains:se,canAccessLocalStorage:X,findThisElement:Se,filterValues:yn,swap:ze,hasAttribute:s,getAttributeValue:a,getClosestAttributeValue:ne,getClosestMatch:q,getExpressionVars:Rn,getHeaders:mn,getInputValues:dn,getInternalData:oe,getSwapSpecification:bn,getTriggerSpecs:st,getTarget:Ee,makeFragment:D,mergeObjects:le,makeSettleInfo:Sn,oobSwap:Te,querySelectorExt:ue,settleImmediately:Yt,shouldCancel:ht,triggerEvent:ae,triggerErrorEvent:fe,withExtensions:Vt};const de=["get","post","put","delete","patch"];const R=de.map(function(e){return"[hx-"+e+"], [data-hx-"+e+"]"}).join(", ");function d(e){if(e==undefined){return undefined}let t=NaN;if(e.slice(-2)=="ms"){t=parseFloat(e.slice(0,-2))}else if(e.slice(-1)=="s"){t=parseFloat(e.slice(0,-1))*1e3}else if(e.slice(-1)=="m"){t=parseFloat(e.slice(0,-1))*1e3*60}else{t=parseFloat(e)}return isNaN(t)?undefined:t}function ee(e,t){return e instanceof Element&&e.getAttribute(t)}function s(e,t){return!!e.hasAttribute&&(e.hasAttribute(t)||e.hasAttribute("data-"+t))}function a(e,t){return ee(e,t)||ee(e,"data-"+t)}function u(e){const t=e.parentElement;if(!t&&e.parentNode instanceof ShadowRoot)return e.parentNode;return t}function te(){return document}function y(e,t){return e.getRootNode?e.getRootNode({composed:t}):te()}function q(e,t){while(e&&!t(e)){e=u(e)}return e||null}function o(e,t,n){const r=a(t,n);const o=a(t,"hx-disinherit");var i=a(t,"hx-inherit");if(e!==t){if(Q.config.disableInheritance){if(i&&(i==="*"||i.split(" ").indexOf(n)>=0)){return r}else{return null}}if(o&&(o==="*"||o.split(" ").indexOf(n)>=0)){return"unset"}}return r}function ne(t,n){let r=null;q(t,function(e){return!!(r=o(t,ce(e),n))});if(r!=="unset"){return r}}function h(e,t){return e instanceof Element&&e.matches(t)}function A(e){const t=/<([a-z][^\/\0>\x20\t\r\n\f]*)/i;const n=t.exec(e);if(n){return n[1].toLowerCase()}else{return""}}function L(e){if("parseHTMLUnsafe"in Document){return Document.parseHTMLUnsafe(e)}const t=new DOMParser;return t.parseFromString(e,"text/html")}function N(e,t){while(t.childNodes.length>0){e.append(t.childNodes[0])}}function r(e){const t=te().createElement("script");ie(e.attributes,function(e){t.setAttribute(e.name,e.value)});t.textContent=e.textContent;t.async=false;if(Q.config.inlineScriptNonce){t.nonce=Q.config.inlineScriptNonce}return t}function i(e){return e.matches("script")&&(e.type==="text/javascript"||e.type==="module"||e.type==="")}function I(e){Array.from(e.querySelectorAll("script")).forEach(e=>{if(i(e)){const t=r(e);const n=e.parentNode;try{n.insertBefore(t,e)}catch(e){H(e)}finally{e.remove()}}})}function D(e){const t=e.replace(/<head(\s[^>]*)?>[\s\S]*?<\/head>/i,"");const n=A(t);let r;if(n==="html"){r=new DocumentFragment;const i=L(e);N(r,i.body);r.title=i.title}else if(n==="body"){r=new DocumentFragment;const i=L(t);N(r,i.body);r.title=i.title}else{const i=L('<body><template class="internal-htmx-wrapper">'+t+"</template></body>");r=i.querySelector("template").content;r.title=i.title;var o=r.querySelector("title");if(o&&o.parentNode===r){o.remove();r.title=o.innerText}}if(r){if(Q.config.allowScriptTags){I(r)}else{r.querySelectorAll("script").forEach(e=>e.remove())}}return r}function re(e){if(e){e()}}function t(e,t){return Object.protoLine truncated // HTMX v4.0.0
var htmx=(()=>{const e={parse(t){if(!t)return{};if(t.startsWith("{"))return JSON.parse(t);let r=/(?:"([^"]+)"|'([^']+)'|([^\s,:]+))(?:\s*:\s*(?:"([^"]*)"|'([^']*)'|<((?:[^/]|\/(?!>))+)\/>|([^\s,]+)))?(?=\s|,|$)/g,i={};for(let s of t.matchAll(r)){let[,t,r,n,o,a,l,h]=s,c=t??r??n,u=(o??a??l??h??"true").trim();try{u=JSON.parse(u)}catch{}let d=n?.includes("."),f=d?c.split(".").reduceRight((e,t)=>({[t]:e}),u):{[c]:u};e.merge(f,i)}return i},split:e=>e.split(/,(?![^\[]*\])(?![^(]*\))(?![^<]*\/>)(?=(?:[^"']|"[^"]*"|'[^']*')*$)/),merge(t,r){"string"==typeof t&&(t=e.parse(t));for(let[i,s]of Object.entries(t)){if(["__proto__","constructor","prototype"].includes(i))continue;let t=s?.constructor===Object,n=r[i]?.constructor===Object;t&&n?e.merge(s,r[i]):r[i]=s}return r}};class t{#e=null;#t=[];admit(e,t,r){if(!this.#e)return this.#e={strategy:e,abort:r},"run";if("replace"===e||"abort"!==e&&"abort"===this.#e.strategy)return this.#t=[],this.#e.abort?.(),this.#e={strategy:e,abort:r},"run";if("queue all"===e)this.#t.push(t);else if("queue last"===e)this.#t=[t];else{if("abort"===e||"drop"===e||0!==this.#t.length)return"dropped";this.#t.push(t)}return"queued"}continue(){this.#e=null,this.#t.shift()?.()}abort(){this.#e?.abort?.()}}return new class{#r=e;#i=new Map;#s="";#n=new Set;_loc=window.location;#o;#a=Function;#l=Object.getPrototypeOf(async function(){}).constructor;#h={createHTML:e=>e,createScript:e=>e};#c;#u="a,form";#d=["get","post","put","patch","delete","query"];#f;#m;#p;#g;#x;constructor(){this.#b(),this.#y(),this.#c=this.#S("[hx-action],[hx-get],[hx-post],[hx-put],[hx-patch],[hx-delete],[hx-query]"),this.#f=(new XPathEvaluator).createExpression(`.//*[@*[${this.#v("hx-on").map(e=>`starts-with(name(), "${e}")`).join(" or ")}]]`),this.#o={HCON:e,attributeValue:this.#E.bind(this),parseTriggerSpecs:this.#w.bind(this),determineMethodAndAction:this.#A.bind(this),createRequestContext:this.#T.bind(this),collectFormData:this.#C.bind(this),getAttributeObject:this.#q.bind(this),insertContent:this.#N.bind(this),morph:this.#I.bind(this),isSoftMatch:this.#M.bind(this),initSecurity:(e,t,r)=>{e&&(this.#h=e),t&&(this.#a=t),r&&(this.#l=r)},onTrigger:this.#O.bind(this),htmxProp:this.#H.bind(this),triggerHtmxEvent:this.#L.bind(this),executeJavaScript:this.#k.bind(this)};let t=()=>this.initialize();"loading"===document.readyState?document.addEventListener("DOMContentLoaded",t):setTimeout(t)}#b(){this.version="4.0.0",this.config={logAll:!1,prefix:"data-hx-",transitions:!1,history:!0,mode:"same-origin",defaultSwap:"innerHTML",defaultFocusScroll:!1,indicatorClass:"htmx-indicator",requestClass:"htmx-request",includeIndicatorCSS:!0,defaultTimeout:6e4,extensions:"",morphIgnore:["data-htmx-powered"],morphSkip:"[hx-morph-skip]",morphSkipChildren:"[hx-morph-skip-children]",morphScanLimit:10,noSwap:[204,304],implicitInheritance:!1,defaultSettleDelay:1,allowEmptySwapAfterOOB:!1};let t=document.querySelector('meta[name="htmx-config"]');t&&e.merge(t.content,this.config),this.#s=this.config.extensions}#y(){if(!1!==this.config.includeIndicatorCSS){let e=this.config.indicatorClass,t=this.config.requestClass,r=new CSSStyleSheet;r.replaceSync(`.${e}{opacity:0;visibility: hidden} .${t} .${e}, .${t}.${e}{opacity:1;visibility: visible;transition: opacity 200ms ease-in}`),document.adoptedStyleSheets=[...document.adoptedStyleSheets,r]}}registerExtension(e,t){return!(this.#s&&!this.#s.split(/,\s*/).includes(e))&&(!this.#n.has(e)&&(this.#n.add(e),t.init&&t.init(this.#o),void Object.entries(t).forEach(([e,t])=>{this.#i.get(e)?.push(t)||this.#i.set(e,[t])})))}#V(e){let t=this.config.prefix;return!e.closest||null!=e.closest("[hx-ignore]")||t&&null!=e.closest(`[${t}ignore]`)}#P(e,t){let r=this.config.prefix;return e.getAttribute(t)??(r?e.getAttribute(t.replace("hx-",r)):null)}#R(e,t){let r=this.config.prefix&&t.replace("hx-",this.config.prefix);return e.hasAttribute(t)?t:r&&e.hasAttribute(r)?r:null}#S(e){return this.#v(e).join(",")}#v(e){let t=[e];return this.config.prefix&&t.push(e.replaceAll("hx-",this.config.prefix)),t}#j(e,t){let r=[...e.querySelectorAll?.(t)??[]];return e.matches?.(t)&&r.unshift(e),r}#B(e){return"before"===e?"beforebegin":"after"===e?"afterend":"prepend"===e?"afterbegin":"append"===e?"beforeend":e}#F(e,t){let r=[];return this.#E(e,t,void 0,(e,t)=>{e?.split(/\s*[,:]\s*/).includes("this")&&r.push(t)}),r}#E(e,t,r,i){t=this.#z(t);let s=this.#z(":inherited"),n=this.#z(":append"),o=this.#P(e,t)??this.#P(e,t+s);if(null!=o)return i?i(o,e):o;let a=CSS.escape(this.config.implicitInheritance?t:t+s),l=CSS.escape(t+s+n),h=this.#S(`[${a}],[${l}]`),c=this.#R(e,t+n)??this.#R(e,t+s+n);if(c){let r=e.getAttribute(c),s=e.parentNode?.closest?.(h);if(i&&i(r,e),s){let e=this.#E(s,t,void 0,i);return e?(e+","+r).replace(/[{}]/g,""):r}return r}let u=e.parentNode?.closest?.(h);return u?(o=this.#E(u,t,void 0,i),!i&&o&&this.config.implicitInheritance&&this.#_(e,"htmx:after:implicitInheritance",{elt:e,name:t,parent:u}),o):r}#w(t){return e.split(t).flatMap(t=>{let[,r,i]=t.maLine truncated
+1 -1
View File
@@ -1 +1 @@
<footer class="test-center footer mt-auto py-3 bg-light" style="text-align: center;">Flask IPAM - {{app_version}}</footer> <footer class="footer mt-auto py-3" style="text-align: center;">Flask IPAM - {{app_version}}</footer>
+2 -3
View File
@@ -4,6 +4,7 @@
<tr> <tr>
<td id="{{allocation.ipv4}}"><b>{{allocation.ipv4}}</b></td> <td id="{{allocation.ipv4}}"><b>{{allocation.ipv4}}</b></td>
<td>{{allocation.hostname}}</td> <td>{{allocation.hostname}}</td>
<td>{{allocation.hostname_full}}</td>
<td>{{allocation.description}}</td> <td>{{allocation.description}}</td>
<td> <td>
{% if Inventory.query.filter_by(id=allocation.device_id).first() %} {% if Inventory.query.filter_by(id=allocation.device_id).first() %}
@@ -21,9 +22,7 @@
N/A N/A
{% endif %} {% endif %}
</td> </td>
<td>{{allocation.is_dhcp}}</td> <td>{% if allocation.is_dhcp %}<span class="badge text-bg-secondary" style="margin-right: 0.5rem;">DHCP</span>{% endif %}{% if allocation.is_gateway %}<span class="badge text-bg-primary" style="margin-right: 0.5rem;">GATEWAY</span>{% endif %}{% if allocation.is_decom %}<span class="badge text-bg-warning" style="margin-right: 0.5rem;">DECOM</span>{% endif %}</td>
<td>{{allocation.is_gateway}}</td>
<td>{{allocation.is_decom}}</td>
{% if current_user.is_reado == False %} {% if current_user.is_reado == False %}
<td> <td>
{% if allocation.is_used %} {% if allocation.is_used %}
+3 -4
View File
@@ -24,12 +24,11 @@
<thead> <thead>
<tr> <tr>
<th scope="col">IPv4</th> <th scope="col">IPv4</th>
<th scope="col">Hostname</th> <th scope="col">Shortname</th>
<th scope="col">FQDN</th>
<th scope="col">Description</th> <th scope="col">Description</th>
<th scope="col">Device</th> <th scope="col">Device</th>
<th scope="col">DHCP</th> <th scope="col">TAG(s)</th>
<th scope="col">GATEWAY</th>
<th scope="col">DECOM</th>
{% if current_user.is_reado == False %}<th scope="col">Actions</th>{% endif %} {% if current_user.is_reado == False %}<th scope="col">Actions</th>{% endif %}
</tr> </tr>
</thead> </thead>
-1
View File
@@ -51,7 +51,6 @@
</div> </div>
<div class="col-2"></div> <div class="col-2"></div>
</div> </div>
<hr>
</div> </div>
<script src="{{ url_for('static',filename='js/chart.umd.js') }}"></script> <script src="{{ url_for('static',filename='js/chart.umd.js') }}"></script>
<script> <script>