Skip to content

Commit

Permalink
Bug fix ver 5.0.rc; views, deletion of techs
Browse files Browse the repository at this point in the history
  • Loading branch information
VedranKapor committed Sep 15, 2024
1 parent 0c76b79 commit 79eb27c
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 10 deletions.
29 changes: 24 additions & 5 deletions API/Routes/Case/CaseRoute.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,26 @@ def saveCase():
casename = genData['osy-casename']
case = session.get('osycase', None)

# configPath = Path(Config.DATA_STORAGE, 'Variables.json')
# vars = File.readParamFile(configPath)
# viewDef = {}
# for group, lists in vars.items():
# for list in lists:
# viewDef[list['id']] = []

#ukoliko dodamo varijablu onda se prilikom update case treba taj var dodati defaultno u view Definition
viewDataPath = Path(Config.DATA_STORAGE,casename,'view','viewDefinitions.json')
viewDefExisting = File.readParamFile(viewDataPath)
configPath = Path(Config.DATA_STORAGE, 'Variables.json')
vars = File.readParamFile(configPath)
viewDef = {}
for group, lists in vars.items():
for list in lists:
viewDef[list['id']] = []
if list['id'] not in viewDefExisting["osy-views"]:
viewDef[list['id']] = []
else:
viewDef[list['id']] = viewDefExisting["osy-views"][list['id']]


#ako je izabran case, edit mode
if case != None and case != '':
Expand All @@ -253,19 +267,24 @@ def saveCase():
viewPath = Path(Config.DATA_STORAGE,case,'view')
resDataPath = Path(Config.DATA_STORAGE,case,'view','resData.json')
viewDataPath = Path(Config.DATA_STORAGE,case,'view','viewDefinitions.json')

viewData = {
"osy-views": viewDef
}
File.writeFile( viewData, viewDataPath)

if not os.path.exists(resPath):
os.makedirs(resPath, mode=0o777, exist_ok=False)

if not os.path.exists(viewPath):
os.makedirs(viewPath, mode=0o777, exist_ok=False)
resData = {
"osy-cases":[]
}
File.writeFile( resData, resDataPath)

viewData = {
"osy-views": viewDef
}
File.writeFile( viewData, viewDataPath)



#edit case sa istim imenom
if case == casename:
Expand Down
22 changes: 22 additions & 0 deletions API/Routes/Upload/UploadRoute.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,25 @@ def updateStorageSet(casename):

File.writeFile( genData, genDataPath)

def updateViewDefintions(casename):
viewDataPath = Path(Config.DATA_STORAGE,casename,'view','viewDefinitions.json')
viewDefExisting = File.readParamFile(viewDataPath)
configPath = Path(Config.DATA_STORAGE, 'Variables.json')
vars = File.readParamFile(configPath)
viewDef = {}
for group, lists in vars.items():
for list in lists:
if list['id'] not in viewDefExisting["osy-views"]:
viewDef[list['id']] = []
else:
viewDef[list['id']] = viewDefExisting["osy-views"][list['id']]


viewData = {
"osy-views": viewDef
}
File.writeFile( viewData, viewDataPath)

def updateTimeslices_OnlyTs(casename):
genDataPath = Path(Config.DATA_STORAGE, casename, 'genData.json')
genData = File.readParamFile(genDataPath)
Expand Down Expand Up @@ -318,6 +337,7 @@ def uploadCase():
#update for dynamic timeslicec
updateTimeslices(casename)
updateStorageSet(casename)
updateViewDefintions(casename)

msg.append({
"message": "Model " + casename +" have been uploaded!",
Expand All @@ -330,6 +350,7 @@ def uploadCase():
#update for dynamic timeslicec
updateTimeslices(casename)
updateStorageSet(casename)
updateViewDefintions(casename)
#u 4.5 ver dodani paramteri i varijable
# u 4.9 versiji dodano param DiscountRateIdv
msg.append({
Expand All @@ -353,6 +374,7 @@ def uploadCase():

elif name == '5.0':
zf.extractall(os.path.join(Config.EXTRACT_FOLDER))
updateViewDefintions(casename)
msg.append({
"message": "Model " + casename +" have been uploaded!",
"status_code": "success",
Expand Down
28 changes: 23 additions & 5 deletions WebAPP/App/Controller/AddCase.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,14 +318,31 @@ export default class AddCase {
e.preventDefault();
e.stopImmediatePropagation();
var id = $(this).attr('data-id');
console.log('id ', id)

if (id != 0) {
var rows = $divTech.jqxGrid('getboundrows');
var techId = $divTech.jqxGrid('getcellvalue', id, 'TechId');
console.log('techId ', techId)
console.log('tech name', model.techNames[techId])
//ovdje moramo korisit id ne rowID koji ostaje nepromjenjen nakon brisanja
var rowid = $divTech.jqxGrid('getrowid', id);
console.log('model.techs ',model.techs[rowid])
console.log("TG ", model.techs[rowid].TG.length)
if(model.techs[rowid].TG.length>0){

Message.confirmationDialog('Technology deletion warning', `Technology <b>${model.techs[rowid].Tech}</b> has technology group membership(s). Deleting the technology could impact visalisation of results for previously run cases. Are you sure you want to proceed?`, model, $divTech, id, rowid, techId)
//var rowid = id;


console.log('rowid ', rowid)

// console.log('rows[rowId].uid ', rows[rowid].uid);
// console.log('rows[id]].uid ', rows[id].uid);
console.log('model.techs ',model.techs)
console.log('rows ', rows)
//console.log('model.techs rowid ',model.techs[rowid])
console.log('model.techs TECH ',model.techs[id].Tech)
// console.log("TG ", model.techs[rowid].TG.length)


if(model.techs[id].TG.length>0){
Message.confirmationDialog('Technology deletion warning', `Technology <b>${model.techs[id].Tech}</b> has technology group membership(s). Deleting the technology could impact visalisation of results for previously run cases. Are you sure you want to proceed?`, model, $divTech, id, rowid, techId)
}
else{
$divTech.jqxGrid('deleterow', rowid);
Expand All @@ -335,6 +352,7 @@ export default class AddCase {
//update count
model.techCount--;
$("#techCount").text(model.techCount);
//$divTech.jqxGrid('updatebounddata');
//izbrisati iz model constraints eventualne tehnologijel koje smo izbrisali
$.each(model.constraints, function (id, conObj) {
conObj['CM'] = conObj['CM'].filter(item => item !== techId);
Expand Down
4 changes: 4 additions & 0 deletions WebAPP/App/View/Versions.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<h3>MUIO ver.5.0.0, <small>release candidate</small></h3>
<ol style="font-style: italic; font-weight: normal;">
<li><kbd style="font-weight: bold; background-color:#6FB3E0">Func</kbd>&nbsp;Creation of views for the annualized investment cost variable fixed. Requires update of model configuration.</li>
<li><kbd style="font-weight: bold; background-color:#6FB3E0">Func</kbd>&nbsp;Accessing recently created views bug fixxed.</li>
<li><kbd style="font-weight: bold; background-color:#6FB3E0">Func</kbd>&nbsp;SETS deletions on configuration page bug fixed.</li>

<li><kbd style="font-weight: bold; background-color:#6FB3E0">Func</kbd>&nbsp;PvAnnuity parameter is calculated using global discount rate</li>
<li><kbd style="font-weight: bold; background-color:#6FB3E0">Func</kbd>&nbsp;Handling deleted SET in existing case runs</li>
<li><kbd style="font-weight: bold; background-color:#6FB3E0">Func</kbd>&nbsp;Postprocessing fix for RateOfActivity adn CapitalInvestment variables</li>
Expand Down
7 changes: 7 additions & 0 deletions WebAPP/AppResults/Controller/Pivot.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,8 @@ export default class Pivot {

static initEvents(model, app) {


console.log('model ', model)
$("#casePicker").off('click');
$("#casePicker").on('click', '.selectCS', function (e) {
e.preventDefault();
Expand Down Expand Up @@ -414,6 +416,7 @@ export default class Pivot {
.then(response => {
Message.clearMessages();
Message.bigBoxSuccess('Model message', response.message, 3000);
POSTDATA['osy-varId'] = param;
model.VIEWS.push(POSTDATA);
// Html.ddlViews(model.VIEWS[model.param]);
//Html.ddlViews(model.VIEWS);
Expand Down Expand Up @@ -612,6 +615,10 @@ export default class Pivot {
$.each(model.VIEWS, function (id, obj) {
if(obj['osy-viewId'] == model.VIEW){
let param = obj['osy-varId'];
console.log('model.VIEW ', model.VIEW)
console.log('model.VIEWS ', model.VIEWS)
console.log('obj ', obj)
console.log('param ', param)
if (model.VAR_IDS.includes(param)){

if(param != model.param){
Expand Down

0 comments on commit 79eb27c

Please sign in to comment.