Initial commit
This commit is contained in:
commit
880e39de2e
511 files changed
+38363
No files matched your search
@@ -0,0 +1,87 @@
|
||||
<md-dialog flex>
|
||||
<form name="fileInfoForm" ng-submit="fileInfoForm.$valid && (moveFile ? relocate(): validate())">
|
||||
<md-toolbar>
|
||||
<div class="md-toolbar-tools md-portal">
|
||||
<span>{{header}}</span>
|
||||
<span flex></span>
|
||||
<md-button class="md-icon-button" ng-click="cancel()">
|
||||
<md-icon>close</md-icon>
|
||||
</md-button>
|
||||
</div>
|
||||
</md-toolbar>
|
||||
|
||||
<md-dialog-content flex>
|
||||
<md-content class="md-padding" flex>
|
||||
<md-list>
|
||||
<md-list-item ng-if="!file.valid">
|
||||
<div layout="row" layout-align="center start">
|
||||
<p class="text-danger">Please enter hash value and file location to validate the file</p>
|
||||
</div>
|
||||
</md-list-item>
|
||||
<md-list-item ng-if="file.valid && moveFile">
|
||||
<div layout="row" layout-align="center start">
|
||||
<p class="text-danger">Please enter new file location to move the file to</p>
|
||||
</div>
|
||||
</md-list-item>
|
||||
<md-list-item>
|
||||
<div layout="row" layout-align="center start" flex>
|
||||
<md-input-container flex>
|
||||
<label>File Name</label>
|
||||
<input ng-model="file.fileName" ng-disabled="true" class="md-disabled-input"/>
|
||||
</md-input-container>
|
||||
<md-input-container flex>
|
||||
<label>File Location</label>
|
||||
<input ng-model="file.fileLocation" name="location" id="location" ng-required="!file.valid || moveFile" ng-disabled="file.valid && !moveFile" class="md-disabled-input"/>
|
||||
<div ng-messages="fileInfoForm.location.$error" ng-show="fileInfoForm.location.$invalid && submitted || fileInfoForm.location.$touched">
|
||||
<div ng-message="required">File location is required</div>
|
||||
</div>
|
||||
</md-input-container>
|
||||
<md-input-container flex>
|
||||
<label>Date Created</label>
|
||||
<input ng-model="file.dateCreated" ng-disabled="true" class="md-disabled-input"/>
|
||||
</md-input-container>
|
||||
</div>
|
||||
</md-list-item>
|
||||
<md-list-item ng-if="!file.valid">
|
||||
<md-input-container flex>
|
||||
<label>Hash Value</label>
|
||||
<input ng-model="file.newHash" name="newHash" id="newHash" class="md-disabled-input" ng-required="!file.valid"/>
|
||||
<div ng-messages="fileInfoForm.newHash.$error" ng-show="fileInfoForm.newHash.$invalid && submitted || fileInfoForm.newHash.$touched">
|
||||
<div ng-message="required">Hash value required</div>
|
||||
</div>
|
||||
</md-input-container>
|
||||
</md-list-item>
|
||||
<md-list-item ng-if="file.valid && !moveFile">
|
||||
<md-input-container flex>
|
||||
<label>MD5</label>
|
||||
<input ng-model="file.md5" ng-readonly="file.valid" class="md-disabled-input"/>
|
||||
</md-input-container>
|
||||
</md-list-item>
|
||||
<md-list-item ng-if="file.valid && !moveFile">
|
||||
<md-input-container flex>
|
||||
<label>SHA1</label>
|
||||
<input ng-model="file.sha1" ng-readonly="file.valid" class="md-disabled-input"/>
|
||||
</md-input-container>
|
||||
</md-list-item>
|
||||
<md-list-item ng-if="file.valid && !moveFile">
|
||||
<md-input-container flex>
|
||||
<label>SHA512</label>
|
||||
<input ng-model="file.sha512" ng-readonly="file.valid" class="md-disabled-input"/>
|
||||
</md-input-container>
|
||||
</md-list-item>
|
||||
</md-list>
|
||||
</md-content>
|
||||
<div ng-show="loadingBlock" class="loadingFade"></div>
|
||||
<div class="loadingModal" ng-show="loadingBlock">
|
||||
<md-progress-circular md-mode="indeterminate" md-diameter="80" class="md-hue-2"></md-progress-circular>
|
||||
</div>
|
||||
</md-dialog-content>
|
||||
<md-dialog-actions layout="row" class="modal-footer">
|
||||
<div class="text-danger">{{error}}</div>
|
||||
<md-button id="verifButton" type="submit" class="md-raised md-primary" ng-if="!file.valid">Validate</md-button>
|
||||
<md-button id="verifButton" type="submit" class="md-raised md-primary" ng-if="moveFile">Move</md-button>
|
||||
<md-button id="downloadButton" class="md-raised md-primary" ng-click="download()" ng-if="file.valid && !moveFile">Download</md-button>
|
||||
<md-button id="okButton" class="md-raised md-warn" ng-click="ok()">Close</md-button>
|
||||
</md-dialog-actions>
|
||||
</form>
|
||||
</md-dialog>
|
||||
@@ -0,0 +1,111 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* MODULE DESCRIPTION:
|
||||
*
|
||||
* TODO: Write description here.
|
||||
*/
|
||||
angular.module('portal.common.partials.fileinfo', ['ui.router']).controller('FileInfoCtrl', fileInfoController);
|
||||
|
||||
function fileInfoController($scope, modalInstance, $state, cache, $mdDialog, PatchFile, portalUtils, fileProvider) {
|
||||
|
||||
$scope.submitted = false;
|
||||
$scope.loadingBlock = false;
|
||||
$scope.moveFile = modalInstance.moveFile;
|
||||
|
||||
$scope.header = modalInstance.header;
|
||||
$scope.originalFile = modalInstance.file;
|
||||
$scope.file = new PatchFile(modalInstance.file);
|
||||
if (!$scope.file.valid) {
|
||||
$scope.file.md5 = '';
|
||||
$scope.file.sha1 = '';
|
||||
$scope.file.sha512 = '';
|
||||
$scope.file.fileLocation = '';
|
||||
}
|
||||
|
||||
$scope.ok = function () {
|
||||
$mdDialog.hide();
|
||||
};
|
||||
|
||||
$scope.download = function() {
|
||||
var url = '/portal/file/download.do?hashValue=' + $scope.file.sha512;
|
||||
window.open(url, '');
|
||||
};
|
||||
|
||||
$scope.relocate = function() {
|
||||
portalUtils.confirmBox('relocateFile', 'Relocate File', ['Are you sure you want to relocate file:', $scope.file.fileName, 'To directory:', $scope.file.fileLocation],
|
||||
false, function(value) {
|
||||
if (value.confirm) {
|
||||
$scope.loadingBlock = true;
|
||||
fileProvider.moveFile($scope.file).then(function() {
|
||||
$scope.loadingBlock = false;
|
||||
portalUtils.toast('File ' + $scope.file.fileName + ' update successfully', ['top', 'left'], 2000);
|
||||
}).catch(function(err) {
|
||||
$scope.loadingBlock = false;
|
||||
$scope.error = err.message;
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.validate = function() {
|
||||
$scope.submitted = true;
|
||||
if ($scope.file.valid) {
|
||||
$mdDialog.hide();
|
||||
return true;
|
||||
}
|
||||
|
||||
$scope.error = '';
|
||||
if ($scope.file.fileLocation.trim() === '') {
|
||||
$scope.error = 'File location needed to validate';
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($scope.file.newHash.trim() === '') {
|
||||
$scope.error = 'Hash value needed';
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($scope.file.newHash.trim().length === 32) {
|
||||
$scope.file.md5 = $scope.file.newHash;
|
||||
$scope.file.sha1 = $scope.originalFile.sha1;
|
||||
$scope.file.sha512 = $scope.originalFile.sha512;
|
||||
} else if ($scope.file.newHash.trim().length === 40) {
|
||||
$scope.file.sha1 = $scope.file.newHash;
|
||||
$scope.file.sha512 = $scope.originalFile.sha512;
|
||||
$scope.file.md5 = $scope.originalFile.md5;
|
||||
} else if ($scope.file.newHash.trim().length === 128) {
|
||||
$scope.file.sha512 = $scope.file.newHash;
|
||||
$scope.file.md5 = $scope.originalFile.md5;
|
||||
$scope.file.sha512 = $scope.originalFile.sha512;
|
||||
} else {
|
||||
$scope.error = 'Invalid hash provided';
|
||||
return false;
|
||||
}
|
||||
|
||||
$scope.loadingBlock = true;
|
||||
fileProvider.validate($scope.file).then(function(data) {
|
||||
$scope.loadingBlock = false;
|
||||
portalUtils.toast('File ' + $scope.file.fileName + ' update successfully', ['top', 'left'], 2000);
|
||||
$scope.ok();
|
||||
return true;
|
||||
}).catch(function(err) {
|
||||
$scope.loadingBlock = false;
|
||||
$scope.error = err.message;
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Cancel button handler.
|
||||
* @returns {undefined}
|
||||
*/
|
||||
$scope.cancel = function () {
|
||||
//Dismiss the modal
|
||||
$mdDialog.cancel();
|
||||
};
|
||||
|
||||
} //end fileInfoController function
|
||||
|
||||
})();
|
||||
Reference in new issue
Block a user