PhlexPlexico / get5-web

[END OF LIFE] Webpanel for servers using the get5 CS:GO server plugin
GNU General Public License v3.0
21 stars 10 forks source link

Add Team Logo upload feature #51

Closed TandelK closed 5 years ago

TandelK commented 5 years ago

Allow admins to easily add logos of teams while creating a team. Uploading logos and saving them to static/img/logos folder

TandelK commented 5 years ago

Also make sure to check for logo format and only allow .jpg and .png in 64x64 dimension with less than 10 kb size

PhlexPlexico commented 5 years ago

http://flask.pocoo.org/docs/1.0/patterns/fileuploads/ reference for later.

TandelK commented 5 years ago

Also need to make sure logo names are less than 5 characters

mrc4tt commented 5 years ago

But, will it "display" logo on the server or for get5-web?

I remember VALVe did disabled sv_allowupload 1 on the client. so it's not possible to download. or am I wrong on this scale

PhlexPlexico commented 5 years ago

From the testing I've done, you would need to have the logos pre-existing in your installation. I have not found a way to allow them otherwise, because if you enable sv_allowupload 1 on the server side, the connect will just hang.

My use case for this would be that I have specific spectator machines that stream to twitch, and those would already have the resources pre-existing under whatever the directory is.... csgo/resources/flash/econ/tournaments/teams/ I think?

mrc4tt commented 5 years ago

So the sv_allowupload 1 does not need to be "enable" on the server-side? (as for example server.cfg)

Yeah, I mean they should be on: csgo/resources/flash/econ/tournaments/teams/ OR materials/panorama/images/tournaments/teams

PhlexPlexico commented 5 years ago

Nope! So long as it exists in those directories, the server will not need that sv option at all. There are a few bugs to work out, but I think it's mainly an actual get5 problem, and not the webpanel. At least, I don't think. There was a reported issue awhile back of team logos only showing up if you cancel and restart the match. Regardless, this one will probably be put on hold until I make this application more efficient, hence the 2,0 tag

mrc4tt commented 5 years ago

Hmm.

But there will still be a small problem. because if you have the opportunity to see the "logo" ingame. then it requires that player's "client" has sv_allowupload 1 enabled. otherwise, is it not entirely impossible?

PhlexPlexico commented 5 years ago

From the testing I've done, you would need to have the logos pre-existing in your installation

The only reason I would personally want to have this is because I have 2 or 3 machines that are dedicated spectator/observer machines, that I have complete access to, so I can just move the files by myself. I've only ran into problems with adjusting sv_allowupload and having players not be able to connect. I'll need to find out why the download just hangs, and gives an error in console, but that's more of a server problem than a webpanel issue :)

mrc4tt commented 5 years ago

Let me know if you figure a fix! ;)

TandelK commented 5 years ago

BTW if you guys read before in splewis repo , the Web API automatically downloads logos in resource/econ/tournaments/teams folder only in Linux Server, for Windows due to file permissions issues they are not able to download and store in that folders. Now as this does not require any kind of special permission of sv_allowupload permission. BTW the logos are not displayed if they are downloaded during the match but if you make sure to download before the tournament and keep them ready they can be seen in every match. I did 3-4 experiments about this and found the working solution with addition of Team Logo Manager plugin with the server. The only issue with Splewis get5 is that it doesnt display logo for the first match and if its the only match it wont work at all. But for GOTV users it will work perfectly because of the fastdl setup used by Team Logo Manager.

https://forums.alliedmods.net/showthread.php?t=258206

TandelK commented 5 years ago

Also it will require sv_allowdownload and sv_download_url settings for Team Logo Manager.

PhlexPlexico commented 5 years ago

See, I tried using that work around before, and it proved to be not useful. It didn't end up working for me as my users couldn't enter the game once these settings and plugins were applied. I saw that it does move it omto the server which is fine, but it's the clients receiving the files from the game servers that I ran into issues with.

As for the first upload and match, I'm not sure if it's a get5 issue or a webpanel issue.

mrc4tt commented 5 years ago

A little update from me:

I got it to work to downloading (without sv_allowupload 1 as a client!)

I did upload (SVG + PNG) (incl FastDL with .bz2).

But, the problem I have now: I can't see the "logo" about it's from: csgo/resources/flash/econ/tournaments/teams/ (png) OR materials/panorama/images/tournaments/teams (svg)

TandelK commented 5 years ago

I fixed a issue of this with one of my friend i am helping for setting up his tournament requirements. We had issue first but after additions of Team Logo manager and 2 major cvars of them added everything worked smoothly. Just need to make sure the Game Server is linux.

mrc4tt commented 5 years ago

I fixed a issue of this with one of my friend i am helping for setting up his tournament requirements. We had issue first but after additions of Team Logo manager and 2 major cvars of them added everything worked smoothly. Just need to make sure the Game Server is linux.

Did you found out, with how the "logo" works? my gameservers is Linux! ;) @TandelK ^^

// As an example a custom logo in svg or png. (not the original logos of teams like NiP/Astralis)

TandelK commented 5 years ago

You mean with or without Team Logo Manager plugin installed ?

If Team Logo Manager are installed i would recommend using this 2 cvars in server.cfg teamlogo_teamnames 0 teamlogo_autologos 0

The Get5 plugin just sends to CSGO Server the Team Logo name nothing else in json . If you already have logo in it , it should always pick it up. The panel will always send a match first and after that clients are allowed to connect. Because of this function i would say the server after getting match will download logos from get5 panel and than add it .

We did 2 things , first we setup logos using static/img/logos section and than with FastDL setup. Make sure your fastdl permissions are 755 for files otherwise it wont allow people to download as it wont get executed.

TandelK commented 5 years ago

@PhlexPlexico and @MikkelDK lets add each other in Discord and chat there. this will go long chat here on Github. Add me at Tandelk#7676

mrc4tt commented 5 years ago

With Team Logo Manager plugin installed.

I have to try to set it with .png & .svg of this logo: https://lh3.googleusercontent.com/TSzI0qFvDl6Hi66VsjniPc_X-vXVRE9Fohg5gW8F8XgLzI7F_rV9Whhs_K_iI2iv5tSOsw=s64 (and called it vind.png) did too try converted the png to svg. (incl .bz2 both file to FastDL)

As example. but without it did "display" the logo in-game (on the scoreboard) maybe I have forgotten something?

// I will do adding! I'm mrc4t#2090 on discord. // Edit2: Seems we can't add you TandelK. ;/

TandelK commented 5 years ago

It should display only to people having same logos in their folders. It needs to get downloaded by every clients including spectator and GOTV. Even when i tried joining my server of GOTV it basically downloaded logos from my FastDL and than it was showing it. For fist match always remember it wont work as the logos are sent after the clients have joined and before that logos are not yet downloaded. But after VETO the logos should start working as the map reloads and automatically should be added to the Download Cache.

PhlexPlexico commented 5 years ago

For fist match always remember it wont work as the logos are sent after the clients have joined and before that logos are not yet downloaded.

Any chance you can find that logic on the MatchCreate? It's possibly under match.py. I want to look into that, because the users should be seeing it as soon as the match is created. Or is it within get5 itself?

As for the logos and allowing sv_allowdownload and those. As I've said, I'll just have to look into it, but that's still more of a backlog thing, since I have other stuff I wish to take care of first.

TandelK commented 5 years ago

If the logos are directly inside the server folders it will work directly but if it not on the server and want to use panel download thing , it wont work as the server starts without any match config so at that time server cvar is mp_teamlogo_1 and mp_teamlogo_2 as nothing but as soon as we send a match config , for the first time the panel will download the logos in teams folder and than people are joining and that download is not yet cached for upload to clients in middle of the server. But as per information the server should add the logo to download for clients after map veto which is also not doing it. So in order it to work , we have to use a working plugin Team Logo Manager

PhlexPlexico commented 5 years ago

So it could also just be a limitation on how the game server handles logos/etc then, correct? I wonder what the effect would be if we loaded the game config, then changed maps immediately after, so after veto and a second map change, the clients would have the logos downloaded... A bit of a hack workaround if it does work, but something that could possibly just work? Has that been tested? I.e.

Load gameconfig from URL
After load complete, immediately send rcon to change map  - update mp_teamlogo_1 and 2
Let people join
Do vetoes, etc.
Map changes to pick
???
Logos
TandelK commented 5 years ago

Yeah i think that should work .

PhlexPlexico commented 5 years ago

Alright, I made the change in my dev build, as well as my master branch. Going to be testing this on Wed and will get back to you if this works or not :)

EDIT; And found someone to test, it seems the logos do appear on the spectator side. However, these logos already exist on the server. If you'd like to test you can adjust line 222 in match.py to test:

if server_available and not mock:
                    server.send_rcon_command('get5_check_auths 1', num_retries=2, timeout=0.75)
                    # Get icon IDs from match, update mp_teamlogo_1 and mp_teamlogo_2 to fix icons not loading?
                    team1 = Team.query.get_or_404(match.team1_id)
                    team2 = Team.query.get_or_404(match.team2_id)
                    strUpdateLogo1 = 'mp_teamlogo_1 ' + team1.logo
                    strUpdateLogo2 = 'mp_teamlogo_2 ' + team2.logo
                    server.send_rcon_command(strUpdateLogo1, num_retries=2, timeout=0.75)
                    server.send_rcon_command(strUpdateLogo2, num_retries=2, timeout=0.75)
                    server.send_rcon_command('map de_mirage', num_retries=2, timeout=0.75)

It ain't pretty and adds overhead to the match creation by quite a bit, but it does load the logos by the looks of it.

PhlexPlexico commented 5 years ago

Also @TandelK I'm having trouble finding it but you have the original issue where it was shown that cancelling + recreating the match? I wonder if this is just a limitation of the server, and would just require the logos to be on the server prior to? This would avoid having to swap maps, correct?

TandelK commented 5 years ago

Yes the logos have to be on the server before the match creation than only they will be added to server upload cache after match is created. Yeah if the logos are there already we will not require to swap maps.

PhlexPlexico commented 5 years ago

Alright! Thanks.

I'm trying to think of different ways of allowing this. I don't like the solution I've provided above, as it does add like 10 seconds of overhead to match creation. I wonder if there's a way to send these images via ftp or something to all the servers that you own when the team is created/updated. I'm surprised it doesn't cache the files once they change maps after the vetoes, honestly.

Also, I've been chipping away at this issue and I think I have file validation about halfway done. So far:

WTForms doesn't offer it's own FileField that uploads automatically, so I need to write all the functionality for it, which is proving to be a huge pain :) but at least I made some headway on it last night.

PhlexPlexico commented 5 years ago

Currently running unit tests and getting the good ol' 200 response code. Need to figure out how to get a response code that redirects again.

PhlexPlexico commented 5 years ago

Turns out we needed to remove CSRF checsk from tests, as there was some issues behind that. Currently on the development branch and has been tested by me. Looking for others to test now, as it would make things easier.

So far I've tested:

We also made a fix to the logo set, since .insert or whatever was there before was not proper, and it did not work. We've fixed this and added logo_choices within the loading of the webpage instead, so it can dynamically add itself to the form now.

If there's anything else, please tell me.

PhlexPlexico commented 5 years ago

Logos are currently working and being uploaded. A small fix for the issue of not having the logos setup on the match would be to set the FastDL server of your game server to point to http://your-web-panel.lol/static/resources where you have your FastDL things setup. However, this may need some change in the logic, to make sure our logos point to the same area when loading them.

PhlexPlexico commented 5 years ago

Now points to FastDL. Going to close this ticket for now. If there's any bugs, please re-open.

PhlexPlexico commented 5 years ago

Reopening as I seem to have a small issue with uploading and adding to the logos object, as it does exist in the directory now, but it seems to be spotty at loading the logo, and it randomly disappears.

TandelK commented 5 years ago

The logos doesnt get downloaded from the webpanel to the game server as the plugin get5_apistats has hard coded location of the logos to be in default given directory.

// Try to fetch the file if we don't have it. if (!FileExists(logoPath)) { LogDebug("Fetching logo for %s", logo); Handle req = CreateRequest(k_EHTTPMethodGET, "/static/img/logos/%s.png", logo); if (req == INVALID_HANDLE) { return; }

PhlexPlexico commented 5 years ago

Commit 32ed4cc fixes this in the plugin. You will have to rebuild the api_stats plugin from dev. It's untested as of right now but if you'd like to try to compile and test, please write back here to say whether it's working or not!

PhlexPlexico commented 5 years ago

Also that being said, please continue discussion for future improvements in issue #64. I may chalk my small error up to my installation bugging out again, as it did with filling out forms and fields. I'll leave open for a few days, but by the looks of it the set was successfully added to, and the database values were updated for the list selection of values within the edit team area.

PhlexPlexico commented 5 years ago

Closing this again, as I haven't ran into the issue any longer...