Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/monarc-project/ng-anr
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricbonhomme committed Nov 10, 2022
2 parents aa49c61 + d7634e2 commit 2bcbe2e
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 27 deletions.
35 changes: 21 additions & 14 deletions src/AnrLayoutCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -3013,25 +3013,32 @@
}

$scope.loadCategs = async function() {
ObjlibService.getObjlibs({category: -1, model: $stateParams.modelId}).then(function(uncategorizedData) {
ObjlibService.getObjlibsCats({model: $stateParams.modelId}).then(async function(x) {
await buildItemRecurse(x.categories, "").then(data => {
let uncategorized = []
if (uncategorizedData.objects.length) {
uncategorized = [{
id: -1,
objects: uncategorizedData.objects
}];
for (let i = 1; i <= 4; i++) {
uncategorized[0]['label' + i] = gettextCatalog.getString("Uncategorized")
}
ObjlibService.getObjlibs({category: -1, model: $stateParams.modelId}).then(function(uncategorizedData) {
ObjlibService.getObjlibsCats({model: $stateParams.modelId}).then(async function(x) {
await buildItemRecurse(x.categories, "").then(data => {
let uncategorized = []
if (uncategorizedData.objects.length) {
uncategorized.id = -1;
uncategorizedData.objects.forEach(object => {
object.isLinkedToAnr = false
});
uncategorized.objects = uncategorizedData.objects

for (let i = 1; i <= 4; i++) {
uncategorized['label' + i] = gettextCatalog.getString("Uncategorized")
}
$scope.categories = uncategorized.concat(data);
});
uncategorized = [uncategorized];
}
$scope.categories = uncategorized.concat(data);
});
});
});
};

$scope.checkIsLinkedToAnr = function(category) {
return category.objects.map(object => object.isLinkedToAnr).some(link => !link);
}

$scope.changeCateg = async function() {
$scope.objlib.category = $scope.selected_categ
$scope.objlib.object = null;
Expand Down
12 changes: 5 additions & 7 deletions src/ImportFileDialogCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -489,8 +489,6 @@ function ImportFileDialogCtrl($scope, $http, $mdDialog, ConfigService, AssetServ
description1: row['vulnerability description2'] ? row['vulnerability description2'].trim() : null,
description1: row['vulnerability description3'] ? row['vulnerability description3'].trim() : null,
description1: row['vulnerability description4'] ? row['vulnerability description4'].trim() : null,
['label' + $scope.language]: row['vulnerability label'],
['description' + $scope.language]: row['vulnerability description']
}
}

Expand Down Expand Up @@ -825,12 +823,12 @@ function ImportFileDialogCtrl($scope, $http, $mdDialog, ConfigService, AssetServ
let themeLabel = row[extItemField];
if ($scope.OFFICE_MODE == 'BO') {
themeToCreate = {
label1: row['theme label1'] ? row['theme label1'].trim() : null,
label2: row['theme label2'] ? row['theme label2'].trim() : null,
label3: row['theme label3'] ? row['theme label3'].trim() : null,
label4: row['theme label4'] ? row['theme label4'].trim() : null,
label1: row['threat theme label1'] ? row['threat theme label1'].trim() : null,
label2: row['threat theme label2'] ? row['threat theme label2'].trim() : null,
label3: row['threat theme label3'] ? row['threat theme label3'].trim() : null,
label4: row['threat theme label4'] ? row['threat theme label4'].trim() : null,
};
themeLabel = row['theme label' + $scope.defaultLang];
themeLabel = row['threat theme label' + $scope.defaultLang];
}

ThreatService.createTheme(themeToCreate,
Expand Down
8 changes: 4 additions & 4 deletions views/add.objlib.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ <h3 translate>Loading library ...</h3>
</div>

<div class="md-dialog-content" layout="column" flex="75" ng-show="categories" >
<p translate>Pick an existing asset from the knowledge base</p>
<p translate>Pick an existing category or asset from the knowledge base</p>
<md-input-container class="md-block" flex>
<md-icon>class</md-icon>
<label translate>Category</label>
<md-select flex ng-model="selected_categ" ng-change="changeCateg()">
<md-option ng-repeat="cat in categories" ng-value="cat">{{ _langField(cat,'label') }}</md-option>
<md-option ng-repeat="cat in categories | filter: checkIsLinkedToAnr" ng-value="cat">{{ _langField(cat,'label') }}</md-option>
</md-select>
</md-input-container>
<md-input-container class="md-block" flex>
<md-icon>class</md-icon>
<label translate>Asset</label>
<md-select flex ng-model="selected_object" ng-change="changeObject()">
<md-option ng-repeat="object in objlib.category.objects" ng-value="object">{{ _langField(object,'name') }}</md-option>
<md-option ng-repeat="object in objlib.category.objects | filter: { isLinkedToAnr: false }" ng-value="object">{{ _langField(object,'name') }}</md-option>
</md-select>
</md-input-container>
</div>
Expand All @@ -38,7 +38,7 @@ <h3 translate>Loading library ...</h3>
<md-button ng-click="cancel()">
{{ 'Cancel' | translate }}
</md-button>
<md-button ng-click="createCategory()" ng-disabled="!objlib.category.id" type="submit" class="md-accent md-hue-3">
<md-button ng-click="createCategory()" ng-disabled="!objlib.category.id || objlib.category.id == -1" type="submit" class="md-accent md-hue-3">
{{ 'Add a whole category' | translate }}
</md-button>
<md-button ng-click="createObject()" ng-disabled="!objlib.object.uuid || !objlib.category.id" type="submit" class="md-accent md-hue-3">
Expand Down
2 changes: 1 addition & 1 deletion views/create.objlibs.categories.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ <h2 ng-if="category.id" translate>Edit category</h2>
<label translate>Parent category</label>
<md-select ng-model="parentCategory" ng-model-options="{trackBy: '$value.id'}" md-on-close="updateCategoryChildren()" required>
<md-option value="null">{{ 'Root (none)' | translate }}</md-option>
<md-option ng-repeat="cat in categories" ng-value="cat">{{ _langField(cat,'label') }}</md-option>
<md-option ng-repeat="cat in categories" ng-value="cat">{{ OFFICE_MODE == 'FO' ? _langField(cat,'label') : cat['label' + language] }}</md-option>
</md-select>
</md-input-container>

Expand Down
2 changes: 1 addition & 1 deletion views/import.instance.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ <h2 translate>Asset import center</h2>
<input type="file" name="file" ngf-drop ngf-select ng-repeat="i in range(0, file_range)"
ng-model="file[i]"
class="md-upload-dropbox md-padding md-whiteframe-3dp"
ngf-drag-over-class="'dragover'" ngf-multiple="false" ngf-allow-dir="false" ngf-pattern="'application/json,.json'" accept=".json,.bin">
ngf-drag-over-class="'dragover'" ngf-multiple="false" ngf-allow-dir="false" ngf-pattern="'application/json,.json,.bin'" accept=".json,.bin">
</input>

<md-input-container class="md-block">
Expand Down

0 comments on commit 2bcbe2e

Please sign in to comment.