Added ask-confirm layer on file manager
This commit is contained in:
@@ -462,7 +462,6 @@ namespace Active_Client.Browser_Tools
|
||||
public async void uploadAndActivateProgram(object sender, CfrV8HandlerExecuteEventArgs e)
|
||||
{
|
||||
string fileToUpload = "";
|
||||
bool uploadAllFiles = false;
|
||||
byte[] filecontent = null, imagecontent = null;
|
||||
string fileNameNoExt;
|
||||
string imageName = "";
|
||||
@@ -486,7 +485,8 @@ namespace Active_Client.Browser_Tools
|
||||
}
|
||||
|
||||
// Check if must be uploaded all files
|
||||
uploadAllFiles = e.Arguments[1].BoolValue;
|
||||
bool uploadAllFiles = e.Arguments[1].BoolValue;
|
||||
bool uploadRecents = e.Arguments[2].BoolValue;
|
||||
|
||||
// Get names and content of the file
|
||||
fileNameNoExt = Path.GetFileNameWithoutExtension(fileToUpload);
|
||||
@@ -511,21 +511,33 @@ namespace Active_Client.Browser_Tools
|
||||
// Create the new FORM
|
||||
MultipartFormDataContent form = new MultipartFormDataContent
|
||||
{
|
||||
// Add the content to the form
|
||||
// Add the main program to the form
|
||||
{ new ByteArrayContent(filecontent), "main", fileName }
|
||||
};
|
||||
|
||||
if (uploadAllFiles)
|
||||
{
|
||||
// Load all the programs in the selected folder
|
||||
dirName = Path.GetDirectoryName(fileToUpload);
|
||||
string[] fileEntries = Directory.GetFiles(dirName);
|
||||
foreach (string subfileName in fileEntries)
|
||||
{
|
||||
if (fileToUpload.ToLower() != subfileName.ToLower() && _validExtensions.Contains(Path.GetExtension(subfileName).ToLower()))
|
||||
{
|
||||
form.Add(new ByteArrayContent(File.ReadAllBytes(subfileName)), "file", Path.GetFileName(subfileName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (uploadRecents)
|
||||
{
|
||||
List<FileModel> files = GetLastUploadedFiles();
|
||||
|
||||
foreach(FileModel file in files)
|
||||
{
|
||||
if(file.FileExist)
|
||||
form.Add(new ByteArrayContent(File.ReadAllBytes(file.AbsolutePath)), "file", file.Name);
|
||||
}
|
||||
}
|
||||
|
||||
if (imagecontent != null)
|
||||
form.Add(new ByteArrayContent(imagecontent), "image", imageName);
|
||||
|
||||
@@ -557,7 +569,7 @@ namespace Active_Client.Browser_Tools
|
||||
string imageDirectory;
|
||||
int reps = 0;
|
||||
|
||||
//Check the arguments numbers
|
||||
// Check the arguments numbers
|
||||
if (e.Arguments.Length < 1 || e.Arguments[0] == null)
|
||||
{
|
||||
e.SetReturnValue(UPLOAD_ADD_QUEUE + "INVALID_ARGUMENTS");
|
||||
@@ -574,12 +586,12 @@ namespace Active_Client.Browser_Tools
|
||||
return;
|
||||
}
|
||||
|
||||
//Get names and content of the file
|
||||
// Get names and content of the file
|
||||
fileNameNoExt = Path.GetFileNameWithoutExtension(fileToUpload);
|
||||
fileName = Path.GetFileName(fileToUpload); ;
|
||||
filecontent = File.ReadAllBytes(fileToUpload);
|
||||
|
||||
//Get all bytes of the image (if exists)
|
||||
// Get all bytes of the image (if exists)
|
||||
imageDirectory = Path.GetDirectoryName(fileToUpload);
|
||||
foreach (string ext in _validImages)
|
||||
{
|
||||
@@ -591,7 +603,7 @@ namespace Active_Client.Browser_Tools
|
||||
}
|
||||
}
|
||||
|
||||
//Send all to the server
|
||||
// Send all to the server
|
||||
using (HttpClient httpClient = new HttpClient())
|
||||
{
|
||||
//Create the new FORM
|
||||
@@ -680,7 +692,7 @@ namespace Active_Client.Browser_Tools
|
||||
e.SetReturnValue(JsonConvert.SerializeObject(file));
|
||||
}
|
||||
|
||||
// launch FIle editor
|
||||
// Launch file editor
|
||||
public void editProgram(object sender, CfrV8HandlerExecuteEventArgs e)
|
||||
{
|
||||
if (e.Arguments.Count() < 2)
|
||||
@@ -778,42 +790,6 @@ namespace Active_Client.Browser_Tools
|
||||
CallJSFunction(_currentEditorObject.func, null, _currentEditorObject.context);
|
||||
}
|
||||
|
||||
// Private functions
|
||||
private string ElaborateName(string name, string letter, DriveType type)
|
||||
{
|
||||
var retName = "";
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(name))
|
||||
retName = name;
|
||||
else
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case DriveType.Fixed: retName = "Hard_Disk";break;
|
||||
case DriveType.Removable: retName = "Usb_Disk"; break;
|
||||
case DriveType.Network: retName = "Netword_Disk"; break;
|
||||
default: retName = "Undefined"; break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(letter))
|
||||
retName = retName + " (" + letter + ")";
|
||||
|
||||
return retName;
|
||||
}
|
||||
|
||||
private string ElaborateType(DriveType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case DriveType.Fixed: return "HD";
|
||||
case DriveType.Removable: return "USB";
|
||||
case DriveType.Network: return "NTW";
|
||||
}
|
||||
return "SPFO";
|
||||
}
|
||||
|
||||
private void WriteLastUploadedFile(string main, bool uploadAllFiles)
|
||||
{
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
@@ -864,11 +840,47 @@ namespace Active_Client.Browser_Tools
|
||||
return files;
|
||||
}
|
||||
|
||||
private string ElaborateType(DriveType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case DriveType.Fixed: return "HD";
|
||||
case DriveType.Removable: return "USB";
|
||||
case DriveType.Network: return "NTW";
|
||||
}
|
||||
return "SPFO";
|
||||
}
|
||||
|
||||
// Private functions
|
||||
private string ElaborateName(string name, string letter, DriveType type)
|
||||
{
|
||||
var retName = "";
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(name))
|
||||
retName = name;
|
||||
else
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case DriveType.Fixed: retName = "Hard_Disk"; break;
|
||||
case DriveType.Removable: retName = "Usb_Disk"; break;
|
||||
case DriveType.Network: retName = "Netword_Disk"; break;
|
||||
default: retName = "Undefined"; break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(letter))
|
||||
retName = retName + " (" + letter + ")";
|
||||
|
||||
return retName;
|
||||
}
|
||||
|
||||
#endregion FILESYSTEM_METHODS
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#region RECALL_METHOD
|
||||
|
||||
|
||||
private static void CallJSFunction(CfrV8Value functionIstance, string arguments, CfrV8Context context)
|
||||
{
|
||||
//Create & enter function context
|
||||
|
||||
@@ -1371,6 +1371,7 @@
|
||||
position: relative;
|
||||
flex-flow: row;
|
||||
|
||||
.ask-confirm,
|
||||
.cleanTempFolder {
|
||||
top: 0;
|
||||
left: 0;
|
||||
|
||||
@@ -1313,6 +1313,10 @@
|
||||
position: relative;
|
||||
flex-flow: row;
|
||||
}
|
||||
.modal.modal-load-program .modal-load-program-body .ask-confirm,
|
||||
.modal.modal-add-element-queue .modal-load-program-body .ask-confirm,
|
||||
.modal.modal-load-program .modal-add-element-queue-body .ask-confirm,
|
||||
.modal.modal-add-element-queue .modal-add-element-queue-body .ask-confirm,
|
||||
.modal.modal-load-program .modal-load-program-body .cleanTempFolder,
|
||||
.modal.modal-add-element-queue .modal-load-program-body .cleanTempFolder,
|
||||
.modal.modal-load-program .modal-add-element-queue-body .cleanTempFolder,
|
||||
|
||||
@@ -74,6 +74,8 @@ export default class ModalLoadProgram extends Vue {
|
||||
offLabel: string = "Off";
|
||||
recentPath: string = ""
|
||||
thereAreFileEliminated: boolean = false
|
||||
askConfirmLayer: boolean = false
|
||||
loadClicked: boolean = false
|
||||
|
||||
get machineInfo() {
|
||||
return this.$store.state.machineInfo;
|
||||
@@ -88,6 +90,8 @@ export default class ModalLoadProgram extends Vue {
|
||||
this.driveList = JSON.parse(cmsClient.getOSdriveList());
|
||||
this.recentPath = cmsClient.RECENT_FOLDER_KEY
|
||||
}
|
||||
|
||||
this.loadClicked = false
|
||||
}
|
||||
|
||||
async navigateTo(path: string, absolutePath: string, local: boolean, todepth: number, fromdepth: number) {
|
||||
@@ -141,7 +145,6 @@ export default class ModalLoadProgram extends Vue {
|
||||
this.thereAreFileEliminated = false;
|
||||
}
|
||||
|
||||
console.log(this.thereAreFileEliminated)
|
||||
this.calcBreadCrumb(absolutePath);
|
||||
this.cleanFileWatcher();
|
||||
}
|
||||
@@ -310,10 +313,19 @@ export default class ModalLoadProgram extends Vue {
|
||||
}
|
||||
|
||||
async load(item: FileInfo) {
|
||||
if (item.IsJob)
|
||||
this.loadJob(item.AbsolutePath);
|
||||
else
|
||||
this.loadProgram(item.AbsolutePath);
|
||||
if(!this.thereAreFileEliminated || this.askConfirmLayer) {
|
||||
this.loadClicked = true
|
||||
|
||||
if (item.IsJob)
|
||||
this.loadJob(item.AbsolutePath);
|
||||
else
|
||||
this.loadProgram(item.AbsolutePath);
|
||||
|
||||
this.askConfirmLayer = false
|
||||
}
|
||||
else {
|
||||
this.askConfirmLayer = true
|
||||
}
|
||||
}
|
||||
|
||||
async loadProgram (path: string) {
|
||||
@@ -401,4 +413,12 @@ export default class ModalLoadProgram extends Vue {
|
||||
this.fileIsChanged = false;
|
||||
cmsClient.cleanFileWatcher()
|
||||
}
|
||||
|
||||
askConfirmOkClick(){
|
||||
this.load(this.selectedFile)
|
||||
}
|
||||
|
||||
askConfirmCancelClick(){
|
||||
this.askConfirmLayer = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,7 +216,24 @@
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ask-confirm" v-if="askConfirmLayer">
|
||||
{{'modal_load_program_lbl_ask_confirm' | localize('Ci sono dei file che sono stati spostati o eliminati, caricare comunque?')}}
|
||||
<div>
|
||||
<button
|
||||
class="btn"
|
||||
@click="askConfirmCancelClick()"
|
||||
>{{'userinfo_btn_cancel' | localize('Annulla')}}
|
||||
</button>
|
||||
<button
|
||||
class="btn"
|
||||
@click="askConfirmOkClick()"
|
||||
>{{'modal_load_program_btn_upload_program' | localize('Carica e attiva programma')}}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal-load-program-footer">
|
||||
<div class="togglebutton" v-if="this.isLocalNavigation">
|
||||
<label>
|
||||
@@ -232,13 +249,13 @@
|
||||
|
||||
<button
|
||||
class="btn btn-success"
|
||||
:disabled="!selectedFile || !isCnReady()"
|
||||
:disabled="!selectedFile || !isCnReady() || loadClicked"
|
||||
v-if="!this.isLocalNavigation"
|
||||
@click="load(selectedFile)"
|
||||
>{{'modal_load_program_btn_load_program' | localize('Attiva programma')}}</button>
|
||||
<button
|
||||
class="btn btn-success"
|
||||
:disabled="!selectedFile || !isCnReady() || fileIsChanged || !canLoadProgram"
|
||||
:disabled="!selectedFile || !isCnReady() || fileIsChanged || !canLoadProgram || loadClicked"
|
||||
v-if="this.isLocalNavigation"
|
||||
@click="load(selectedFile)"
|
||||
>{{'modal_load_program_btn_upload_program' | localize('Carica e attiva programma')}}</button>
|
||||
|
||||
Reference in New Issue
Block a user